source: xtideuniversalbios/trunk/BIOS_Drive_Information_Tool/Src/AtaInfo.asm@ 424

Last change on this file since 424 was 424, checked in by Tomi Tilli, 12 years ago

Changes to BIOS Drive Information Tool:

  • Up to date with recent CHS translation changes.
  • Block mode and PIO capabilities are now displayed.
File size: 7.0 KB
Line 
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
21SECTION .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;--------------------------------------------------------------------
33AtaInfo_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 L-CHS generated by XTIDE Universal BIOS
67 call DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
68
69 ; Print block mode information
70 call DisplayBlockModeInformationUsingAtaInfoFromDSBX
71
72 ; Print PIO mode information
73 call DisplayPioModeInformationUsingAtaInfoFromDSBX
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;--------------------------------------------------------------------
90DisplayPCHSusingAtaInfoFromDSBX:
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;--------------------------------------------------------------------
110DisplayPCHSsectorCountUsingAtaInfoFromDXBX:
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;--------------------------------------------------------------------
132DisplayLBA28sectorCountUsingAtaInfoFromDSBX:
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;--------------------------------------------------------------------
154DisplayLBA48sectorCountUsingAtaInfoFromDSBX:
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; DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX
169; Parameters:
170; BX: Offset to ATA Information
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, CX, DX, BP, SI, DI
175;--------------------------------------------------------------------
176DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX:
177 push bx
178
179 ; Display header
180 mov ax, g_szXTUBversion
181 mov si, g_szXTUB
182 call Print_FormatStringFromSIwithParameterInAX
183
184 ; Display translation mode and L-CHS
185 mov si, bx ; DS == ES
186 mov dx, TRANSLATEMODE_AUTO
187 call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIandTranslateModeInDX
188 dec ax ; Reserve diagnostics cylinder
189 MIN_U ax, MAX_LCHS_CYLINDERS
190 call Print_ModeFromDLandCHSfromAXLBH
191
192 pop bx
193 ret
194
195
196;--------------------------------------------------------------------
197; DisplayBlockModeInformationUsingAtaInfoFromDSBX
198; Parameters:
199; BX: Offset to ATA Information
200; Returns:
201; Nothing
202; Corrupts registers:
203; AX, DX, BP, SI, DI
204;--------------------------------------------------------------------
205DisplayBlockModeInformationUsingAtaInfoFromDSBX:
206 eMOVZX ax, BYTE [bx+ATA1.bBlockSel] ; ATA2+ has flag on high word
207 mov dx, [bx+ATA1.bBlckSize]
208 mov si, g_szBlockMode
209 jmp Print_FormatStringFromSIwithParametersInAXDX
210
211
212;--------------------------------------------------------------------
213; DisplayPioModeInformationUsingAtaInfoFromDSBX
214; Parameters:
215; BX: Offset to ATA Information
216; Returns:
217; Nothing
218; Corrupts registers:
219; AX, CX, DX, BP, SI, DI
220;--------------------------------------------------------------------
221DisplayPioModeInformationUsingAtaInfoFromDSBX:
222 ; Load standard timings (up to PIO-2)
223 mov ax, [bx+ATA1.bPioMode]
224 mov si, ax
225 shl si, 1 ; Shift for WORD lookup
226 mov dx, [si+.rgwStandardPioTimings] ; Load min cycle time
227 mov cx, -1 ; IORDY not supported
228
229 ; Replace with advanced mode timings (PIO-3 and up)
230 test BYTE [bx+ATA2.wFields], A2_wFields_64to70
231 jz SHORT .NoAdvancedPioModesSupported
232
233 mov si, [bx+ATA2.bPIOSupp] ; Advanced mode flags
234.IncrementPioMode:
235 inc ax
236 shr si, 1
237 jnz SHORT .IncrementPioMode
238 mov dx, [bx+ATA2.wPIOMinCy]
239 mov cx, [bx+ATA2.wPIOMinCyF]
240
241.NoAdvancedPioModesSupported:
242 mov si, g_szPIO
243 jmp Print_FormatStringFromSIwithParametersInAXDXCX
244
245.rgwStandardPioTimings:
246 dw PIO_0_MIN_CYCLE_TIME_NS
247 dw PIO_1_MIN_CYCLE_TIME_NS
248 dw PIO_2_MIN_CYCLE_TIME_NS
Note: See TracBrowser for help on using the repository browser.