[117] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Int 13h function AH=15h, Read Disk Drive Size. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[526] | 12 | ; |
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[526] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[526] | 18 | ; |
---|
[376] | 19 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Int 13h function AH=15h, Read Disk Drive Size. |
---|
| 25 | ; |
---|
[547] | 26 | ; It is unclear what is the total number of sectors to return. |
---|
| 27 | ; Award BIOS from 1997 returns full capacity instead of L-CHS limit |
---|
| 28 | ; like we do. I think it makes more sense if this function returns |
---|
| 29 | ; L-CHS limit. |
---|
| 30 | ; |
---|
[3] | 31 | ; AH15h_HandlerForReadDiskDriveSize |
---|
| 32 | ; Parameters: |
---|
[148] | 33 | ; DL: Translated Drive number |
---|
| 34 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
[150] | 35 | ; SS:BP: Ptr to IDEPACK |
---|
| 36 | ; Returns with INTPACK: |
---|
[294] | 37 | ; If successful: |
---|
[258] | 38 | ; AH: Hard Disk: 3 (Hard disk accessible) |
---|
[567] | 39 | ; Floppy: 1 (Floppy disk, without change detection) |
---|
[3] | 40 | ; CX:DX: Total number of sectors |
---|
| 41 | ; CF: 0 |
---|
| 42 | ; If failed: |
---|
| 43 | ; AH: 0 (Drive not present) |
---|
| 44 | ; CX:DX: 0 |
---|
| 45 | ; CF: 1 |
---|
| 46 | ;-------------------------------------------------------------------- |
---|
| 47 | AH15h_HandlerForReadDiskDriveSize: |
---|
[258] | 48 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 49 | mov cl, 1 ; 1 = floppy disk, no change detection |
---|
[294] | 50 | |
---|
| 51 | test dl,dl ; DO NOT store the sector count if this is a |
---|
| 52 | jns .FloppyDrive ; floppy disk, some OS's depend on this not |
---|
[258] | 53 | ; happening for floppies in order to boot. |
---|
| 54 | %endif |
---|
[294] | 55 | |
---|
[252] | 56 | call AH15h_GetSectorCountToBXDXAX |
---|
[258] | 57 | mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX |
---|
| 58 | xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX, AL gets drive number |
---|
[3] | 59 | |
---|
[294] | 60 | xor ah, ah |
---|
| 61 | %ifdef MODULE_SERIAL_FLOPPY |
---|
[258] | 62 | mov cl, 3 ; 3 = Hard Disk Accessible |
---|
| 63 | .FloppyDrive: |
---|
[294] | 64 | |
---|
| 65 | call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber ; Store success to BDA and CF |
---|
| 66 | mov [bp+IDEPACK.intpack+INTPACK.ah], cl |
---|
[258] | 67 | %else |
---|
[294] | 68 | call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH ; Store success to BDA and CF |
---|
[258] | 69 | mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 |
---|
[294] | 70 | %endif |
---|
| 71 | |
---|
[148] | 72 | jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode |
---|
[150] | 73 | |
---|
| 74 | |
---|
| 75 | ;-------------------------------------------------------------------- |
---|
| 76 | ; AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
[252] | 77 | ; AH15h_GetSectorCountToBXDXAX: |
---|
[150] | 78 | ; Parameters: |
---|
[252] | 79 | ; DL: Drive number (AH15h_GetSectorCountFromForeignDriveToDXAX only) |
---|
[150] | 80 | ; DS: RAMVARS segment |
---|
[252] | 81 | ; DS:DI: Ptr to DPT (AH15h_GetSectorCountToDXAX only) |
---|
[150] | 82 | ; Returns: |
---|
| 83 | ; DX:AX: Total sector count |
---|
| 84 | ; BX: Zero |
---|
| 85 | ; Corrupts registers: |
---|
| 86 | ; CX |
---|
| 87 | ;-------------------------------------------------------------------- |
---|
[392] | 88 | %ifdef MODULE_BOOT_MENU |
---|
[150] | 89 | AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
| 90 | mov ah, GET_DRIVE_PARAMETERS |
---|
| 91 | call Int13h_CallPreviousInt13hHandler |
---|
| 92 | jmp SHORT ConvertAH08hReturnValuesToSectorCount |
---|
[392] | 93 | %endif |
---|
[150] | 94 | |
---|
[252] | 95 | AH15h_GetSectorCountToBXDXAX: |
---|
[150] | 96 | call AH8h_GetDriveParameters |
---|
| 97 | ; Fall to ConvertAH08hReturnValuesToSectorCount |
---|
| 98 | |
---|
| 99 | ConvertAH08hReturnValuesToSectorCount: |
---|
[155] | 100 | call Address_ExtractLCHSparametersFromOldInt13hAddress |
---|
[285] | 101 | mov al, bh ; AL = Max head number |
---|
| 102 | inc cx ; Max cylinder number to cylinder count |
---|
| 103 | inc ax ; Max head number to head count (AH=8h returns max 254 so no overflow to AH) |
---|
| 104 | mul bl ; AX = Head count * Sectors per track |
---|
| 105 | mul cx ; DX:AX = Total sector count for AH=0xh transfer functions |
---|
| 106 | xor bx, bx |
---|
[150] | 107 | ret |
---|