1 | ; Project name : BIOS Drive Information Tool
|
---|
2 | ; Description : Reads and prints information from ATA ID.
|
---|
3 |
|
---|
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 |
|
---|
20 | ; Section containing code
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 |
|
---|
24 | ;--------------------------------------------------------------------
|
---|
25 | ; AtaInfo_DisplayAtaInformationForDriveDL
|
---|
26 | ; Parameters:
|
---|
27 | ; DL: Drive Number
|
---|
28 | ; Returns:
|
---|
29 | ; Nothing
|
---|
30 | ; Corrupts registers:
|
---|
31 | ; All, except CX and DX
|
---|
32 | ;--------------------------------------------------------------------
|
---|
33 | AtaInfo_DisplayAtaInformationForDriveDL:
|
---|
34 | push cx
|
---|
35 | push dx
|
---|
36 |
|
---|
37 | ; Read ATA Information from the drive
|
---|
38 | call Bios_ReadAtaInfoFromDriveDLtoBX
|
---|
39 | call Print_ErrorMessageFromAHifError ; AH=25h is not available on many BIOSes
|
---|
40 | jc SHORT .SkipAtaInfoSinceError
|
---|
41 |
|
---|
42 | ; Print Drive Name
|
---|
43 | call Print_NameFromAtaInfoInBX
|
---|
44 |
|
---|
45 | ; Print Drive P-CHS parameters
|
---|
46 | call DisplayPCHSusingAtaInfoFromDSBX
|
---|
47 |
|
---|
48 | ; Print Drive CHS sector count
|
---|
49 | test WORD [bx+ATA1.wFields], A1_wFields_54to58
|
---|
50 | jz SHORT .SkipChsSectors
|
---|
51 | call DisplayPCHSsectorCountUsingAtaInfoFromDXBX
|
---|
52 | .SkipChsSectors:
|
---|
53 |
|
---|
54 | ; Print Drive LBA28 sector count
|
---|
55 | test WORD [bx+ATA1.wCaps], A1_wCaps_LBA
|
---|
56 | jz SHORT .SkipLBA28
|
---|
57 | call DisplayLBA28sectorCountUsingAtaInfoFromDSBX
|
---|
58 | .SkipLBA28:
|
---|
59 |
|
---|
60 | ; Print Drive LBA48 sector count
|
---|
61 | test WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48
|
---|
62 | jz SHORT .SkipLBA48
|
---|
63 | call DisplayLBA48sectorCountUsingAtaInfoFromDSBX
|
---|
64 | .SkipLBA48:
|
---|
65 |
|
---|
66 | ; Print block mode information
|
---|
67 | call DisplayBlockModeInformationUsingAtaInfoFromDSBX
|
---|
68 |
|
---|
69 | ; Print PIO mode information
|
---|
70 | call DisplayPioModeInformationUsingAtaInfoFromDSBX
|
---|
71 |
|
---|
72 | ; Print L-CHS generated by XTIDE Universal BIOS
|
---|
73 | call DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
|
---|
74 |
|
---|
75 | .SkipAtaInfoSinceError:
|
---|
76 | pop dx
|
---|
77 | pop cx
|
---|
78 | ret
|
---|
79 |
|
---|
80 |
|
---|
81 | ;--------------------------------------------------------------------
|
---|
82 | ; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
|
---|
83 | ; Parameters:
|
---|
84 | ; BX: Offset to ATA Information
|
---|
85 | ; Returns:
|
---|
86 | ; Nothing
|
---|
87 | ; Corrupts registers:
|
---|
88 | ; AX, CX, DX, BP, SI, DI
|
---|
89 | ;--------------------------------------------------------------------
|
---|
90 | DisplayPCHSusingAtaInfoFromDSBX:
|
---|
91 | mov si, bx ; DS == ES
|
---|
92 | call AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
|
---|
93 | xchg cx, ax
|
---|
94 | eMOVZX dx, bl
|
---|
95 | eMOVZX ax, bh
|
---|
96 | call Print_CHSfromCXDXAX
|
---|
97 | mov bx, si ; Restore BX
|
---|
98 | ret
|
---|
99 |
|
---|
100 |
|
---|
101 | ;--------------------------------------------------------------------
|
---|
102 | ; DisplayPCHSsectorCountUsingAtaInfoFromDXBX
|
---|
103 | ; Parameters:
|
---|
104 | ; BX: Offset to ATA Information
|
---|
105 | ; Returns:
|
---|
106 | ; Nothing
|
---|
107 | ; Corrupts registers:
|
---|
108 | ; AX, DX, BP, SI, DI
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | DisplayPCHSsectorCountUsingAtaInfoFromDXBX:
|
---|
111 | mov si, g_szChsSectors
|
---|
112 | call Print_NullTerminatedStringFromSI
|
---|
113 |
|
---|
114 | mov si, bx
|
---|
115 | mov ax, [si+ATA1.dwCurSCnt]
|
---|
116 | mov dx, [si+ATA1.dwCurSCnt+2]
|
---|
117 | xor bx, bx
|
---|
118 | call Print_TotalSectorsFromBXDXAX
|
---|
119 | mov bx, si ; Restore BX
|
---|
120 | ret
|
---|
121 |
|
---|
122 |
|
---|
123 | ;--------------------------------------------------------------------
|
---|
124 | ; DisplayLBA28sectorCountUsingAtaInfoFromDSBX
|
---|
125 | ; Parameters:
|
---|
126 | ; BX: Offset to ATA Information
|
---|
127 | ; Returns:
|
---|
128 | ; Nothing
|
---|
129 | ; Corrupts registers:
|
---|
130 | ; AX, DX, BP, SI, DI
|
---|
131 | ;--------------------------------------------------------------------
|
---|
132 | DisplayLBA28sectorCountUsingAtaInfoFromDSBX:
|
---|
133 | mov si, g_szLBA28
|
---|
134 | call Print_NullTerminatedStringFromSI
|
---|
135 |
|
---|
136 | mov si, bx
|
---|
137 | mov ax, [si+ATA1.dwLBACnt]
|
---|
138 | mov dx, [si+ATA1.dwLBACnt+2]
|
---|
139 | xor bx, bx
|
---|
140 | call Print_TotalSectorsFromBXDXAX
|
---|
141 | mov bx, si ; Restore BX
|
---|
142 | ret
|
---|
143 |
|
---|
144 |
|
---|
145 | ;--------------------------------------------------------------------
|
---|
146 | ; DisplayLBA48sectorCountUsingAtaInfoFromDSBX
|
---|
147 | ; Parameters:
|
---|
148 | ; BX: Offset to ATA Information
|
---|
149 | ; Returns:
|
---|
150 | ; Nothing
|
---|
151 | ; Corrupts registers:
|
---|
152 | ; AX, DX, BP, SI, DI
|
---|
153 | ;--------------------------------------------------------------------
|
---|
154 | DisplayLBA48sectorCountUsingAtaInfoFromDSBX:
|
---|
155 | mov si, g_szLBA48
|
---|
156 | call Print_NullTerminatedStringFromSI
|
---|
157 |
|
---|
158 | mov si, bx
|
---|
159 | mov ax, [si+ATA6.qwLBACnt]
|
---|
160 | mov dx, [si+ATA6.qwLBACnt+2]
|
---|
161 | mov bx, [si+ATA6.qwLBACnt+4]
|
---|
162 | call Print_TotalSectorsFromBXDXAX
|
---|
163 | mov bx, si ; Restore BX
|
---|
164 | ret
|
---|
165 |
|
---|
166 |
|
---|
167 | ;--------------------------------------------------------------------
|
---|
168 | ; DisplayBlockModeInformationUsingAtaInfoFromDSBX
|
---|
169 | ; Parameters:
|
---|
170 | ; BX: Offset to ATA Information
|
---|
171 | ; Returns:
|
---|
172 | ; Nothing
|
---|
173 | ; Corrupts registers:
|
---|
174 | ; AX, DX, BP, SI, DI
|
---|
175 | ;--------------------------------------------------------------------
|
---|
176 | DisplayBlockModeInformationUsingAtaInfoFromDSBX:
|
---|
177 | eMOVZX ax, BYTE [bx+ATA1.bBlockSel] ; ATA2+ has flag on high word
|
---|
178 | eMOVZX dx, BYTE [bx+ATA1.bBlckSize]
|
---|
179 | mov si, g_szBlockMode
|
---|
180 | jmp Print_FormatStringFromSIwithParametersInAXDX
|
---|
181 |
|
---|
182 |
|
---|
183 | ;--------------------------------------------------------------------
|
---|
184 | ; DisplayPioModeInformationUsingAtaInfoFromDSBX
|
---|
185 | ; Parameters:
|
---|
186 | ; BX: Offset to ATA Information
|
---|
187 | ; Returns:
|
---|
188 | ; Nothing
|
---|
189 | ; Corrupts registers:
|
---|
190 | ; AX, CX, DX, BP, SI, DI
|
---|
191 | ;--------------------------------------------------------------------
|
---|
192 | DisplayPioModeInformationUsingAtaInfoFromDSBX:
|
---|
193 | ; Load standard timings (up to PIO-2)
|
---|
194 | mov ax, [bx+ATA1.bPioMode]
|
---|
195 | mov si, ax
|
---|
196 | shl si, 1 ; Shift for WORD lookup
|
---|
197 | mov dx, [si+.rgwStandardPioTimings] ; Load min cycle time
|
---|
198 | mov cx, -1 ; IORDY not supported
|
---|
199 |
|
---|
200 | ; Replace with advanced mode timings (PIO-3 and up)
|
---|
201 | test BYTE [bx+ATA2.wFields], A2_wFields_64to70
|
---|
202 | jz SHORT .NoAdvancedPioModesSupported
|
---|
203 |
|
---|
204 | mov si, [bx+ATA2.bPIOSupp] ; Advanced mode flags
|
---|
205 | .IncrementPioMode:
|
---|
206 | inc ax
|
---|
207 | shr si, 1
|
---|
208 | jnz SHORT .IncrementPioMode
|
---|
209 | mov dx, [bx+ATA2.wPIOMinCy]
|
---|
210 | mov cx, [bx+ATA2.wPIOMinCyF]
|
---|
211 |
|
---|
212 | .NoAdvancedPioModesSupported:
|
---|
213 | mov si, g_szPIO
|
---|
214 | jmp Print_FormatStringFromSIwithParametersInAXDXCX
|
---|
215 |
|
---|
216 | .rgwStandardPioTimings:
|
---|
217 | dw PIO_0_MIN_CYCLE_TIME_NS
|
---|
218 | dw PIO_1_MIN_CYCLE_TIME_NS
|
---|
219 | dw PIO_2_MIN_CYCLE_TIME_NS
|
---|
220 |
|
---|
221 |
|
---|
222 | ;--------------------------------------------------------------------
|
---|
223 | ; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
|
---|
224 | ; Parameters:
|
---|
225 | ; BX: Offset to ATA Information
|
---|
226 | ; Returns:
|
---|
227 | ; Nothing
|
---|
228 | ; Corrupts registers:
|
---|
229 | ; AX, BX, CX, DX, BP, SI, DI
|
---|
230 | ;--------------------------------------------------------------------
|
---|
231 | DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX:
|
---|
232 | ; Display header
|
---|
233 | mov ax, g_szXTUBversion
|
---|
234 | mov si, g_szXTUB
|
---|
235 | call Print_FormatStringFromSIwithParameterInAX
|
---|
236 |
|
---|
237 | ; Display translation mode and L-CHS
|
---|
238 | mov si, bx ; DS == ES
|
---|
239 | mov dx, TRANSLATEMODE_AUTO
|
---|
240 | call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
|
---|
241 | dec ax ; Reserve diagnostics cylinder
|
---|
242 | MIN_U ax, MAX_LCHS_CYLINDERS
|
---|
243 | jmp Print_ModeFromDLandCHSfromAXLBH
|
---|