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

Last change on this file since 612 was 612, checked in by krille_n_, 3 years ago

Changes:

  • BIOSDRVS builds again (broken since r609). Also removed the last remnants of RESERVE_DIAGNOSTIC_CYLINDER from BIOSDRVS that I missed in r606.
  • Put in a limit on the P-CHS cylinder count in an attempt to improve compatibility with some CF cards that violates the ATA specification. The limit applies only to the BIOS. BIOSDRVS will continue to show the true cylinder count since we might want to add code later to warn the user when encountering incompatible drives like these.
  • Optimized the bug fix in r611.
  • Updated the copyright notices in XTIDECFG and BIOSDRVS.
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-2013 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 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    DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
74
75.SkipAtaInfoSinceError:
76    pop     dx
77    pop     cx
78    ret
79
80
81;--------------------------------------------------------------------
82; DisplayPCHSusingAtaInfoFromDSBX
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:
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;--------------------------------------------------------------------
193DisplayPioModeInformationUsingAtaInfoFromDSBX:
194    ; Load standard timings (up to PIO-2)
195    mov     al, [bx+ATA1.bPioMode]
196    cbw
197    mov     si, ax
198    eSHL_IM si, 1       ; Shift for WORD lookup
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
206    mov     si, 0FFh
207    and     si, [bx+ATA2.bPIOSupp]  ; Advanced mode flags
208    jz      SHORT .NoAdvancedPioModesSupported
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
224
225
226;--------------------------------------------------------------------
227; DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX
228;   Parameters:
229;       BX:     Offset to ATA Information
230;   Returns:
231;       Nothing
232;   Corrupts registers:
233;       AX, BX, CX, DX, BP, SI, DI
234;--------------------------------------------------------------------
235DisplayXUBcompatibilityInfoUsingAtaInfoFromDSBX:
236    ; Display header
237    mov     ax, g_szXUBversion
238    mov     si, g_szXUB
239    call    Print_FormatStringFromSIwithParameterInAX
240
241    ; Display translation mode and L-CHS
242    mov     si, bx              ; DS == ES
243    mov     dx, TRANSLATEMODE_AUTO
244    call    AtaGeometry_GetLCHStoAXBLBHfromAtaInfoInESSIwithTranslateModeInDX
245    MIN_U   ax, MAX_LCHS_CYLINDERS
246    jmp     Print_ModeFromDLandCHSfromAXLBH
Note: See TracBrowser for help on using the repository browser.