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

Last change on this file since 609 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 7.1 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
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
[426]72 ; Print L-CHS generated by XTIDE Universal BIOS
[592]73 call DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
[426]74
[424]75.SkipAtaInfoSinceError:
76 pop dx
77 pop cx
78 ret
79
80
81;--------------------------------------------------------------------
[592]82; DisplayPCHSusingAtaInfoFromDSBX
[424]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; DisplayBlockModeInformationUsingAtaInfoFromDSBX
169; Parameters:
170; BX: Offset to ATA Information
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, DX, BP, SI, DI
175;--------------------------------------------------------------------
176DisplayBlockModeInformationUsingAtaInfoFromDSBX:
[445]177 eMOVZX ax, [bx+ATA1.bBlockSel] ; ATA2+ has flag on high word
178 cwd
179 mov dl, [bx+ATA1.bBlckSize]
[424]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;--------------------------------------------------------------------
193DisplayPioModeInformationUsingAtaInfoFromDSBX:
194 ; Load standard timings (up to PIO-2)
[592]195 mov al, [bx+ATA1.bPioMode]
196 cbw
[424]197 mov si, ax
[592]198 eSHL_IM si, 1 ; Shift for WORD lookup
[424]199 mov dx, [si+.rgwStandardPioTimings] ; Load min cycle time
200 mov cx, -1 ; IORDY not supported
201
202 ; Replace with advanced mode timings (PIO-3 and up)
203 test BYTE [bx+ATA2.wFields], A2_wFields_64to70
204 jz SHORT .NoAdvancedPioModesSupported
205
[592]206 mov si, 0FFh
207 and si, [bx+ATA2.bPIOSupp] ; Advanced mode flags
208 jz SHORT .NoAdvancedPioModesSupported
[424]209.IncrementPioMode:
210 inc ax
211 shr si, 1
212 jnz SHORT .IncrementPioMode
213 mov dx, [bx+ATA2.wPIOMinCy]
214 mov cx, [bx+ATA2.wPIOMinCyF]
215
216.NoAdvancedPioModesSupported:
217 mov si, g_szPIO
218 jmp Print_FormatStringFromSIwithParametersInAXDXCX
219
220.rgwStandardPioTimings:
221 dw PIO_0_MIN_CYCLE_TIME_NS
222 dw PIO_1_MIN_CYCLE_TIME_NS
223 dw PIO_2_MIN_CYCLE_TIME_NS
[426]224
225
226;--------------------------------------------------------------------
[592]227; DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
[426]228; Parameters:
229; BX: Offset to ATA Information
230; Returns:
231; Nothing
232; Corrupts registers:
233; AX, BX, CX, DX, BP, SI, DI
234;--------------------------------------------------------------------
[592]235DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX:
[426]236 ; Display header
[592]237 mov ax, g_szXUBversion
238 mov si, g_szXUB
[426]239 call Print_FormatStringFromSIwithParameterInAX
240
241 ; Display translation mode and L-CHS
242 mov si, bx ; DS == ES
243 mov dx, TRANSLATEMODE_AUTO
[558]244 call AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX
[426]245 dec ax ; Reserve diagnostics cylinder
246 MIN_U ax, MAX_LCHS_CYLINDERS
247 jmp Print_ModeFromDLandCHSfromAXLBH
Note: See TracBrowser for help on using the repository browser.