[93] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Int 13h function AH=8h, Read Disk Drive Parameters.
|
---|
| 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=8h, Read Disk Drive Parameters.
|
---|
| 25 | ;
|
---|
| 26 | ; AH8h_HandlerForReadDiskDriveParameters
|
---|
| 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:
|
---|
[258] | 32 | ; BL: Drive Type (for floppies only)
|
---|
[3] | 33 | ; CH: Maximum cylinder number, bits 7...0
|
---|
| 34 | ; CL: Bits 7...6: Cylinder number bits 9...8
|
---|
| 35 | ; Bits 5...0: Maximum sector number (1...63)
|
---|
[285] | 36 | ; DH: Maximum head number (0...254)
|
---|
[3] | 37 | ; DL: Number of drives
|
---|
[258] | 38 | ; ES:DI: Floppy DPT (for floppies only)
|
---|
[3] | 39 | ; AH: Int 13h/40h floppy return status
|
---|
[294] | 40 | ; CF: 0 if successful, 1 if error
|
---|
[3] | 41 | ;--------------------------------------------------------------------
|
---|
| 42 | AH8h_HandlerForReadDiskDriveParameters:
|
---|
[332] | 43 | test di, di
|
---|
| 44 | jz SHORT .NotOurDrive
|
---|
[258] | 45 |
|
---|
[3] | 46 | call AH8h_GetDriveParameters
|
---|
| 47 |
|
---|
[258] | 48 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 49 | push cs ; setup registers if we are a floppy drive, in all cases
|
---|
| 50 | pop es ; if it is not a floppy drive, these values will not be put in INTPACK
|
---|
| 51 | mov di, AH8h_FloppyDPT
|
---|
| 52 | %endif
|
---|
| 53 | ;; fall-through
|
---|
[294] | 54 |
|
---|
| 55 | .MidGame:
|
---|
[258] | 56 | call RamVars_GetCountOfKnownDrivesToAX ; assume hard disk for now, will discard if for floppies
|
---|
| 57 |
|
---|
| 58 | test byte [bp+IDEPACK.intpack+INTPACK.dl], 080h
|
---|
| 59 | jnz .Done
|
---|
[294] | 60 |
|
---|
[258] | 61 | mov [bp+IDEPACK.intpack+INTPACK.bl], bl
|
---|
| 62 |
|
---|
| 63 | mov [bp+IDEPACK.intpack+INTPACK.es], es
|
---|
[294] | 64 | mov [bp+IDEPACK.intpack+INTPACK.di], di
|
---|
[258] | 65 |
|
---|
| 66 | call FloppyDrive_GetCountToAX
|
---|
| 67 |
|
---|
[294] | 68 | .Done:
|
---|
[258] | 69 | mov ah, dh
|
---|
[294] | 70 |
|
---|
[150] | 71 | mov [bp+IDEPACK.intpack+INTPACK.cx], cx
|
---|
[258] | 72 | xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; recover DL for BDA last status byte determination
|
---|
| 73 |
|
---|
[148] | 74 | xor ah, ah
|
---|
[258] | 75 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
[294] | 76 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber
|
---|
[258] | 77 | %else
|
---|
[148] | 78 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[258] | 79 | %endif
|
---|
[3] | 80 |
|
---|
[332] | 81 | .NotOurDrive:
|
---|
| 82 | call Int13h_CallPreviousInt13hHandler
|
---|
| 83 | jnc SHORT .MidGame
|
---|
| 84 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[32] | 85 |
|
---|
[332] | 86 |
|
---|
[3] | 87 | ;--------------------------------------------------------------------
|
---|
| 88 | ; Returns L-CHS parameters for drive and total hard disk count.
|
---|
| 89 | ;
|
---|
[28] | 90 | ; AH8h_GetDriveParameters
|
---|
[3] | 91 | ; Parameters:
|
---|
[148] | 92 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[3] | 93 | ; Returns:
|
---|
| 94 | ; CH: Maximum cylinder number, bits 7...0
|
---|
| 95 | ; CL: Bits 7...6: Cylinder number bits 9...8
|
---|
| 96 | ; Bits 5...0: Maximum sector number (1...63)
|
---|
[285] | 97 | ; DH: Maximum head number (0...254)
|
---|
[3] | 98 | ; Corrupts registers:
|
---|
[148] | 99 | ; AX, BX
|
---|
[3] | 100 | ;--------------------------------------------------------------------
|
---|
| 101 | AH8h_GetDriveParameters:
|
---|
[227] | 102 | call AccessDPT_GetLCHStoAXBLBH
|
---|
[421] | 103 | %ifdef RESERVE_DIAGNOSTIC_CYLINDER
|
---|
| 104 | dec ax
|
---|
| 105 | %endif
|
---|
| 106 | MIN_U ax, MAX_LCHS_CYLINDERS
|
---|
[148] | 107 | ; Fall to .PackReturnValues
|
---|
[3] | 108 |
|
---|
| 109 | ;--------------------------------------------------------------------
|
---|
| 110 | ; Packs L-CHS values to INT 13h, AH=08h return values.
|
---|
| 111 | ;
|
---|
[148] | 112 | ; .PackReturnValues
|
---|
[3] | 113 | ; Parameters:
|
---|
[227] | 114 | ; AX: Number of L-CHS cylinders available (1...1024)
|
---|
[285] | 115 | ; BL: Number of L-CHS heads (1...255)
|
---|
[227] | 116 | ; BH: Number of L-CHS sectors per track (1...63)
|
---|
[32] | 117 | ; DS: RAMVARS segment
|
---|
[3] | 118 | ; Returns:
|
---|
| 119 | ; CH: Maximum cylinder number, bits 7...0
|
---|
| 120 | ; CL: Bits 7...6: Cylinder number bits 9...8
|
---|
| 121 | ; Bits 5...0: Maximum sector number (1...63)
|
---|
[285] | 122 | ; DH: Maximum head number (0...254)
|
---|
[3] | 123 | ; Corrupts registers:
|
---|
| 124 | ; AX, BX
|
---|
| 125 | ;--------------------------------------------------------------------
|
---|
[148] | 126 | .PackReturnValues:
|
---|
[227] | 127 | dec ax ; AX = Number of last cylinder
|
---|
| 128 | dec bx ; BL = Number of last head
|
---|
| 129 | xchg cx, ax
|
---|
| 130 | xchg cl, ch ; CH = Last cylinder bits 0...7
|
---|
| 131 | eROR_IM cl, 2 ; CL bits 6...7 = Last cylinder bits 8...9
|
---|
| 132 | or cl, bh ; CL bits 0...5 = Sectors per track
|
---|
| 133 | mov dh, bl ; DH = Maximum head number
|
---|
[285] | 134 |
|
---|
[258] | 135 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
[332] | 136 | mov bl, [di+DPT.bFlagsHigh]
|
---|
[261] | 137 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS ; not sure why this is needed for preprocessor-only
|
---|
[332] | 138 | eSHR_IM bl, FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION
|
---|
[261] | 139 | %endif
|
---|
[294] | 140 | %endif
|
---|
[258] | 141 | ret
|
---|
| 142 |
|
---|
| 143 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 144 | ;
|
---|
| 145 | ; Floppy Disk Parameter Table. There is no way to specify more than one of these
|
---|
| 146 | ; for any given system, so no way to make this drive or media specific.
|
---|
[261] | 147 | ; So we return fixed values out of the ROM for callers who might be expecting this information.
|
---|
[258] | 148 | ;
|
---|
[294] | 149 | ; On AT systems, we return the information for a 1.44 MB disk,
|
---|
[258] | 150 | ; and on XT systems, we return the information for a 360 KB disk.
|
---|
| 151 | ;
|
---|
| 152 | AH8h_FloppyDPT:
|
---|
| 153 | %ifdef USE_AT
|
---|
| 154 | db 0ah << 4 | 0fh ; Offset 0: Drive timings, 1.44MB values
|
---|
| 155 | %else
|
---|
| 156 | db 0dh << 4 | 0fh ; Offset 0: Drive timings, 360KB values
|
---|
| 157 | %endif
|
---|
| 158 |
|
---|
| 159 | db 1h << 1 | 0 ; Offset 1: Typical values of 1 for head load time
|
---|
[294] | 160 | ; DMA used (although it actually is not, but is more restrictive)
|
---|
| 161 | db 25h ; Offset 2: Inactivity motor turn-off delay,
|
---|
[258] | 162 | ; Typical value of 25h for 2 second delay
|
---|
| 163 | db 02h ; Offset 3: Sector size, always 512
|
---|
| 164 |
|
---|
| 165 | %ifdef USE_AT
|
---|
| 166 | db 12h ; Offset 4: Sectors per track, 1.44MB value
|
---|
| 167 | db 1bh ; Offset 5: Sector gap, 1.44MB value
|
---|
| 168 | %else
|
---|
| 169 | db 09h ; Offset 4: Sectors per track, 360KB value
|
---|
| 170 | db 2ah ; Offset 5: Sector gap, 360KB value
|
---|
| 171 | %endif
|
---|
| 172 |
|
---|
| 173 | db 0ffh ; Offset 6: Data length
|
---|
| 174 |
|
---|
| 175 | %ifdef USE_AT
|
---|
| 176 | db 6ch ; Offset 7: Format gap length, 1.44MB value
|
---|
| 177 | %else
|
---|
| 178 | db 50h ; Offset 7: Format gap length, 360KB value
|
---|
| 179 | %endif
|
---|
| 180 |
|
---|
| 181 | db 0f6h ; Offset 8: Fill byte for format
|
---|
| 182 | db 0fh ; Offset 9: Head setting time
|
---|
[294] | 183 | db 08h ; Offset A: Wait for motor startup time
|
---|
[258] | 184 |
|
---|
| 185 | %ifdef USE_AT
|
---|
| 186 | db 79 ; Offset B: Maximum track number, 1.44MB value
|
---|
| 187 | db 0 ; Offset C: Data transfer rate, 1.44MB value
|
---|
| 188 | db 4 ; Offset D: Diskette CMOS drive type, 1.44MB value
|
---|
| 189 | %else
|
---|
| 190 | db 39 ; Offset B: Maximum track number, 360KB value
|
---|
| 191 | db 80h ; Offset C: Data transfer rate, 360KB value
|
---|
| 192 | db 1 ; Offset D: Diskette CMOS drive type, 360KB value
|
---|
| 193 | %endif
|
---|
| 194 | %endif
|
---|