[117] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Int 13h function AH=15h, Read Disk Drive Size. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 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. |
---|
| 12 | ; |
---|
| 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 |
---|
| 16 | ; GNU General Public License for more details. |
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
| 19 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Int 13h function AH=15h, Read Disk Drive Size. |
---|
| 25 | ; |
---|
| 26 | ; AH15h_HandlerForReadDiskDriveSize |
---|
| 27 | ; Parameters: |
---|
[148] | 28 | ; DL: Translated Drive number |
---|
| 29 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
[150] | 30 | ; SS:BP: Ptr to IDEPACK |
---|
| 31 | ; Returns with INTPACK: |
---|
[294] | 32 | ; If successful: |
---|
[258] | 33 | ; AH: Hard Disk: 3 (Hard disk accessible) |
---|
| 34 | ; Floppy: 1 (Floppy disk, without change detection) |
---|
[3] | 35 | ; CX:DX: Total number of sectors |
---|
| 36 | ; CF: 0 |
---|
| 37 | ; If failed: |
---|
| 38 | ; AH: 0 (Drive not present) |
---|
| 39 | ; CX:DX: 0 |
---|
| 40 | ; CF: 1 |
---|
| 41 | ;-------------------------------------------------------------------- |
---|
| 42 | AH15h_HandlerForReadDiskDriveSize: |
---|
[258] | 43 | %ifdef MODULE_SERIAL_FLOPPY |
---|
| 44 | mov cl, 1 ; 1 = floppy disk, no change detection |
---|
[294] | 45 | |
---|
| 46 | test dl,dl ; DO NOT store the sector count if this is a |
---|
| 47 | jns .FloppyDrive ; floppy disk, some OS's depend on this not |
---|
[258] | 48 | ; happening for floppies in order to boot. |
---|
| 49 | %endif |
---|
[294] | 50 | |
---|
[252] | 51 | call AH15h_GetSectorCountToBXDXAX |
---|
[258] | 52 | mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX |
---|
| 53 | xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX, AL gets drive number |
---|
[3] | 54 | |
---|
[294] | 55 | xor ah, ah |
---|
| 56 | %ifdef MODULE_SERIAL_FLOPPY |
---|
[258] | 57 | mov cl, 3 ; 3 = Hard Disk Accessible |
---|
| 58 | .FloppyDrive: |
---|
[294] | 59 | |
---|
| 60 | call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber ; Store success to BDA and CF |
---|
| 61 | mov [bp+IDEPACK.intpack+INTPACK.ah], cl |
---|
[258] | 62 | %else |
---|
[294] | 63 | call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH ; Store success to BDA and CF |
---|
[258] | 64 | mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 |
---|
[294] | 65 | %endif |
---|
| 66 | |
---|
[148] | 67 | jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode |
---|
[150] | 68 | |
---|
| 69 | |
---|
| 70 | ;-------------------------------------------------------------------- |
---|
| 71 | ; AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
[252] | 72 | ; AH15h_GetSectorCountToBXDXAX: |
---|
[150] | 73 | ; Parameters: |
---|
[252] | 74 | ; DL: Drive number (AH15h_GetSectorCountFromForeignDriveToDXAX only) |
---|
[150] | 75 | ; DS: RAMVARS segment |
---|
[252] | 76 | ; DS:DI: Ptr to DPT (AH15h_GetSectorCountToDXAX only) |
---|
[150] | 77 | ; Returns: |
---|
| 78 | ; DX:AX: Total sector count |
---|
| 79 | ; BX: Zero |
---|
| 80 | ; Corrupts registers: |
---|
| 81 | ; CX |
---|
| 82 | ;-------------------------------------------------------------------- |
---|
| 83 | AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
| 84 | mov ah, GET_DRIVE_PARAMETERS |
---|
| 85 | call Int13h_CallPreviousInt13hHandler |
---|
| 86 | jmp SHORT ConvertAH08hReturnValuesToSectorCount |
---|
| 87 | |
---|
[252] | 88 | AH15h_GetSectorCountToBXDXAX: |
---|
[150] | 89 | call AH8h_GetDriveParameters |
---|
| 90 | ; Fall to ConvertAH08hReturnValuesToSectorCount |
---|
| 91 | |
---|
| 92 | ConvertAH08hReturnValuesToSectorCount: |
---|
[155] | 93 | call Address_ExtractLCHSparametersFromOldInt13hAddress |
---|
[285] | 94 | mov al, bh ; AL = Max head number |
---|
| 95 | inc cx ; Max cylinder number to cylinder count |
---|
| 96 | inc ax ; Max head number to head count (AH=8h returns max 254 so no overflow to AH) |
---|
| 97 | mul bl ; AX = Head count * Sectors per track |
---|
| 98 | mul cx ; DX:AX = Total sector count for AH=0xh transfer functions |
---|
| 99 | xor bx, bx |
---|
[150] | 100 | ret |
---|