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