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, [bx+ATA1.bBlockSel] ; ATA2+ has flag on high word |
---|
178 | cwd |
---|
179 | mov dl, [bx+ATA1.bBlckSize] |
---|
180 | mov si, g_szBlockMode |
---|
181 | jmp Print_FormatStringFromSIwithParametersInAXDX |
---|
182 | |
---|
183 | |
---|
184 | ;-------------------------------------------------------------------- |
---|
185 | ; DisplayPioModeInformationUsingAtaInfoFromDSBX |
---|
186 | ; Parameters: |
---|
187 | ; BX: Offset to ATA Information |
---|
188 | ; Returns: |
---|
189 | ; Nothing |
---|
190 | ; Corrupts registers: |
---|
191 | ; AX, CX, DX, BP, SI, DI |
---|
192 | ;-------------------------------------------------------------------- |
---|
193 | DisplayPioModeInformationUsingAtaInfoFromDSBX: |
---|
194 | ; Load standard timings (up to PIO-2) |
---|
195 | mov ax, [bx+ATA1.bPioMode] |
---|
196 | mov si, ax |
---|
197 | shl si, 1 ; Shift for WORD lookup |
---|
198 | mov dx, [si+.rgwStandardPioTimings] ; Load min cycle time |
---|
199 | mov cx, -1 ; IORDY not supported |
---|
200 | |
---|
201 | ; Replace with advanced mode timings (PIO-3 and up) |
---|
202 | test BYTE [bx+ATA2.wFields], A2_wFields_64to70 |
---|
203 | jz SHORT .NoAdvancedPioModesSupported |
---|
204 | |
---|
205 | mov si, [bx+ATA2.bPIOSupp] ; Advanced mode flags |
---|
206 | .IncrementPioMode: |
---|
207 | inc ax |
---|
208 | shr si, 1 |
---|
209 | jnz SHORT .IncrementPioMode |
---|
210 | mov dx, [bx+ATA2.wPIOMinCy] |
---|
211 | mov cx, [bx+ATA2.wPIOMinCyF] |
---|
212 | |
---|
213 | .NoAdvancedPioModesSupported: |
---|
214 | mov si, g_szPIO |
---|
215 | jmp Print_FormatStringFromSIwithParametersInAXDXCX |
---|
216 | |
---|
217 | .rgwStandardPioTimings: |
---|
218 | dw PIO_0_MIN_CYCLE_TIME_NS |
---|
219 | dw PIO_1_MIN_CYCLE_TIME_NS |
---|
220 | dw PIO_2_MIN_CYCLE_TIME_NS |
---|
221 | |
---|
222 | |
---|
223 | ;-------------------------------------------------------------------- |
---|
224 | ; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX |
---|
225 | ; Parameters: |
---|
226 | ; BX: Offset to ATA Information |
---|
227 | ; Returns: |
---|
228 | ; Nothing |
---|
229 | ; Corrupts registers: |
---|
230 | ; AX, BX, CX, DX, BP, SI, DI |
---|
231 | ;-------------------------------------------------------------------- |
---|
232 | DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX: |
---|
233 | ; Display header |
---|
234 | mov ax, g_szXTUBversion |
---|
235 | mov si, g_szXTUB |
---|
236 | call Print_FormatStringFromSIwithParameterInAX |
---|
237 | |
---|
238 | ; Display translation mode and L-CHS |
---|
239 | mov si, bx ; DS == ES |
---|
240 | mov dx, TRANSLATEMODE_AUTO |
---|
241 | call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX |
---|
242 | dec ax ; Reserve diagnostics cylinder |
---|
243 | MIN_U ax, MAX_LCHS_CYLINDERS |
---|
244 | jmp Print_ModeFromDLandCHSfromAXLBH |
---|