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

Last change on this file since 617 was 613, checked in by Tomi Tilli, 4 years ago

Added more complex way to limit illegal P-CHS Cylinders. This way more modifications can be easily made later if necessary.
Updated biosdrvs to display unmodified and modified CHS.

File size: 7.4 KB
RevLine 
[424]1; Project name : BIOS Drive Information Tool
2; Description : Reads and prints information from ATA ID.
3
4;
[445]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[424]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.
[445]12;
[424]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
[445]16; GNU General Public License for more details.
[424]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
[613]38 call Bios_ReadAtaInfoFromDriveDLtoBX ; Unaltered ATA information
[424]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
[613]46 call DisplayPCHSusingAtaInfoFromDSBX ; Unaltered
[424]47
[613]48 ; Fix and display values (ATA Info will stay fixed)
49 xor ah, ah ; Successfully read ATA ID
50 push ds
51 pop es
52 mov si, bx
53 call AtaID_FixIllegalValuesFromESSI ; Modify ATA information if necessary
54 mov si, g_szWillBeModified
55 call Print_NullTerminatedStringFromSI
56 call DisplayPCHSusingAtaInfoFromDSBX ; Display fixed values
57
[424]58 ; Print Drive CHS sector count
59 test WORD [bx+ATA1.wFields], A1_wFields_54to58
60 jz SHORT .SkipChsSectors
61 call DisplayPCHSsectorCountUsingAtaInfoFromDXBX
62.SkipChsSectors:
63
64 ; Print Drive LBA28 sector count
65 test WORD [bx+ATA1.wCaps], A1_wCaps_LBA
66 jz SHORT .SkipLBA28
67 call DisplayLBA28sectorCountUsingAtaInfoFromDSBX
68.SkipLBA28:
69
70 ; Print Drive LBA48 sector count
71 test WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48
72 jz SHORT .SkipLBA48
73 call DisplayLBA48sectorCountUsingAtaInfoFromDSBX
74.SkipLBA48:
75
76 ; Print block mode information
77 call DisplayBlockModeInformationUsingAtaInfoFromDSBX
78
79 ; Print PIO mode information
80 call DisplayPioModeInformationUsingAtaInfoFromDSBX
81
[426]82 ; Print L-CHS generated by XTIDE Universal BIOS
[592]83 call DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
[426]84
[424]85.SkipAtaInfoSinceError:
86 pop dx
87 pop cx
88 ret
89
90
91;--------------------------------------------------------------------
[592]92; DisplayPCHSusingAtaInfoFromDSBX
[424]93; Parameters:
94; BX: Offset to ATA Information
95; Returns:
96; Nothing
97; Corrupts registers:
98; AX, CX, DX, BP, SI, DI
99;--------------------------------------------------------------------
100DisplayPCHSusingAtaInfoFromDSBX:
101 mov si, bx ; DS == ES
102 call AtaGeometry_GetPCHStoAXBLBHfromAtaInfoInESSI
103 xchg cx, ax
104 eMOVZX dx, bl
105 eMOVZX ax, bh
106 call Print_CHSfromCXDXAX
107 mov bx, si ; Restore BX
108 ret
109
110
111;--------------------------------------------------------------------
112; DisplayPCHSsectorCountUsingAtaInfoFromDXBX
113; Parameters:
114; BX: Offset to ATA Information
115; Returns:
116; Nothing
117; Corrupts registers:
118; AX, DX, BP, SI, DI
119;--------------------------------------------------------------------
120DisplayPCHSsectorCountUsingAtaInfoFromDXBX:
121 mov si, g_szChsSectors
122 call Print_NullTerminatedStringFromSI
123
124 mov si, bx
125 mov ax, [si+ATA1.dwCurSCnt]
126 mov dx, [si+ATA1.dwCurSCnt+2]
127 xor bx, bx
128 call Print_TotalSectorsFromBXDXAX
129 mov bx, si ; Restore BX
130 ret
131
132
133;--------------------------------------------------------------------
134; DisplayLBA28sectorCountUsingAtaInfoFromDSBX
135; Parameters:
136; BX: Offset to ATA Information
137; Returns:
138; Nothing
139; Corrupts registers:
140; AX, DX, BP, SI, DI
141;--------------------------------------------------------------------
142DisplayLBA28sectorCountUsingAtaInfoFromDSBX:
143 mov si, g_szLBA28
144 call Print_NullTerminatedStringFromSI
145
146 mov si, bx
147 mov ax, [si+ATA1.dwLBACnt]
148 mov dx, [si+ATA1.dwLBACnt+2]
149 xor bx, bx
150 call Print_TotalSectorsFromBXDXAX
151 mov bx, si ; Restore BX
152 ret
153
154
155;--------------------------------------------------------------------
156; DisplayLBA48sectorCountUsingAtaInfoFromDSBX
157; Parameters:
158; BX: Offset to ATA Information
159; Returns:
160; Nothing
161; Corrupts registers:
162; AX, DX, BP, SI, DI
163;--------------------------------------------------------------------
164DisplayLBA48sectorCountUsingAtaInfoFromDSBX:
165 mov si, g_szLBA48
166 call Print_NullTerminatedStringFromSI
167
168 mov si, bx
169 mov ax, [si+ATA6.qwLBACnt]
170 mov dx, [si+ATA6.qwLBACnt+2]
171 mov bx, [si+ATA6.qwLBACnt+4]
172 call Print_TotalSectorsFromBXDXAX
173 mov bx, si ; Restore BX
174 ret
175
176
177;--------------------------------------------------------------------
178; DisplayBlockModeInformationUsingAtaInfoFromDSBX
179; Parameters:
180; BX: Offset to ATA Information
181; Returns:
182; Nothing
183; Corrupts registers:
184; AX, DX, BP, SI, DI
185;--------------------------------------------------------------------
186DisplayBlockModeInformationUsingAtaInfoFromDSBX:
[445]187 eMOVZX ax, [bx+ATA1.bBlockSel] ; ATA2+ has flag on high word
188 cwd
189 mov dl, [bx+ATA1.bBlckSize]
[424]190 mov si, g_szBlockMode
191 jmp Print_FormatStringFromSIwithParametersInAXDX
192
193
194;--------------------------------------------------------------------
195; DisplayPioModeInformationUsingAtaInfoFromDSBX
196; Parameters:
197; BX: Offset to ATA Information
198; Returns:
199; Nothing
200; Corrupts registers:
201; AX, CX, DX, BP, SI, DI
202;--------------------------------------------------------------------
203DisplayPioModeInformationUsingAtaInfoFromDSBX:
204 ; Load standard timings (up to PIO-2)
[592]205 mov al, [bx+ATA1.bPioMode]
206 cbw
[424]207 mov si, ax
[592]208 eSHL_IM si, 1 ; Shift for WORD lookup
[424]209 mov dx, [si+.rgwStandardPioTimings] ; Load min cycle time
210 mov cx, -1 ; IORDY not supported
211
212 ; Replace with advanced mode timings (PIO-3 and up)
213 test BYTE [bx+ATA2.wFields], A2_wFields_64to70
214 jz SHORT .NoAdvancedPioModesSupported
215
[592]216 mov si, 0FFh
217 and si, [bx+ATA2.bPIOSupp] ; Advanced mode flags
218 jz SHORT .NoAdvancedPioModesSupported
[424]219.IncrementPioMode:
220 inc ax
221 shr si, 1
222 jnz SHORT .IncrementPioMode
223 mov dx, [bx+ATA2.wPIOMinCy]
224 mov cx, [bx+ATA2.wPIOMinCyF]
225
226.NoAdvancedPioModesSupported:
227 mov si, g_szPIO
228 jmp Print_FormatStringFromSIwithParametersInAXDXCX
229
230.rgwStandardPioTimings:
231 dw PIO_0_MIN_CYCLE_TIME_NS
232 dw PIO_1_MIN_CYCLE_TIME_NS
233 dw PIO_2_MIN_CYCLE_TIME_NS
[426]234
235
236;--------------------------------------------------------------------
[592]237; DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
[426]238; Parameters:
239; BX: Offset to ATA Information
240; Returns:
241; Nothing
242; Corrupts registers:
243; AX, BX, CX, DX, BP, SI, DI
244;--------------------------------------------------------------------
[592]245DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX:
[426]246 ; Display header
[592]247 mov ax, g_szXUBversion
248 mov si, g_szXUB
[426]249 call Print_FormatStringFromSIwithParameterInAX
250
251 ; Display translation mode and L-CHS
252 mov si, bx ; DS == ES
253 mov dx, TRANSLATEMODE_AUTO
[558]254 call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX
[426]255 MIN_U ax, MAX_LCHS_CYLINDERS
256 jmp Print_ModeFromDLandCHSfromAXLBH
Note: See TracBrowser for help on using the repository browser.