1 | ; Project name : BIOS Drive Information Tool |
---|
2 | ; Description : BIOS Drive Information Tool reads and displays |
---|
3 | ; drive information from BIOS. |
---|
4 | |
---|
5 | ; Include .inc files |
---|
6 | %define INCLUDE_DISPLAY_LIBRARY |
---|
7 | %define INCLUDE_KEYBOARD_LIBRARY |
---|
8 | %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first! |
---|
9 | %include "Version.inc" ; From XTIDE Universal BIOS |
---|
10 | %include "ATA_ID.inc" ; From XTIDE Universal BIOS |
---|
11 | %include "Int13h.inc" ; From XTIDE Universal BIOS |
---|
12 | %include "EBIOS.inc" ; From XTIDE Universal BIOS |
---|
13 | FLG_DRVNHEAD_DRV EQU (1<<4) ; Required by CustomDPT.inc |
---|
14 | %include "CustomDPT.inc" ; From XTIDE Universal BIOS |
---|
15 | |
---|
16 | |
---|
17 | ; Section containing code |
---|
18 | SECTION .text |
---|
19 | |
---|
20 | ; Program first instruction. |
---|
21 | ORG 100h ; Code starts at offset 100h (DOS .COM) |
---|
22 | Start: |
---|
23 | jmp StartBiosDriveInformationTool |
---|
24 | |
---|
25 | ; Include library and other sources |
---|
26 | %include "AssemblyLibrary.asm" |
---|
27 | %include "LbaAssist.asm" ; From XTIDE Universal BIOS |
---|
28 | %include "Strings.asm" |
---|
29 | %include "Bios.asm" |
---|
30 | %include "Print.asm" |
---|
31 | |
---|
32 | |
---|
33 | ;-------------------------------------------------------------------- |
---|
34 | ; Program start |
---|
35 | ;-------------------------------------------------------------------- |
---|
36 | ALIGN JUMP_ALIGN |
---|
37 | StartBiosDriveInformationTool: |
---|
38 | CALL_DISPLAY_LIBRARY InitializeDisplayContext |
---|
39 | call Print_SetCharacterOutputToSTDOUT |
---|
40 | |
---|
41 | mov si, g_szProgramName |
---|
42 | call Print_NullTerminatedStringFromSI |
---|
43 | |
---|
44 | call ReadAndDisplayAllHardDrives |
---|
45 | |
---|
46 | ; Exit to DOS |
---|
47 | mov ax, 4C00h ; Exit to DOS |
---|
48 | int 21h |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | ReadAndDisplayAllHardDrives: |
---|
53 | call Bios_GetNumberOfHardDrivesToDX |
---|
54 | jc SHORT .NoDrivesAvailable |
---|
55 | mov cx, dx |
---|
56 | mov dl, 80h ; First hard drive |
---|
57 | jmp SHORT .DisplayFirstDrive |
---|
58 | |
---|
59 | ALIGN JUMP_ALIGN |
---|
60 | .DisplayNextDriveFromDL: |
---|
61 | mov si, g_szPressAnyKey |
---|
62 | call Print_NullTerminatedStringFromSI |
---|
63 | call Keyboard_GetKeystrokeToAXandWaitIfNecessary |
---|
64 | |
---|
65 | .DisplayFirstDrive: |
---|
66 | mov si, g_szHeaderDrive |
---|
67 | call Print_DriveNumberFromDLusingFormatStringInSI |
---|
68 | |
---|
69 | mov si, g_szAtaInfoHeader |
---|
70 | call Print_NullTerminatedStringFromSI |
---|
71 | call DisplayAtaInformationForDriveDL |
---|
72 | |
---|
73 | mov si, g_szOldInfoHeader |
---|
74 | call Print_NullTerminatedStringFromSI |
---|
75 | call DisplayOldInt13hInformationForDriveDL |
---|
76 | |
---|
77 | mov si, g_szNewInfoHeader |
---|
78 | call Print_NullTerminatedStringFromSI |
---|
79 | call DisplayNewInt13hInformationFromDriveDL |
---|
80 | |
---|
81 | inc dx |
---|
82 | loop .DisplayNextDriveFromDL |
---|
83 | .NoDrivesAvailable: |
---|
84 | ret |
---|
85 | |
---|
86 | |
---|
87 | ALIGN JUMP_ALIGN |
---|
88 | DisplayAtaInformationForDriveDL: |
---|
89 | push cx |
---|
90 | push dx |
---|
91 | |
---|
92 | call Bios_ReadAtaInfoFromDriveDLtoBX |
---|
93 | call Print_ErrorMessageFromAHifError |
---|
94 | jc SHORT .SkipAtaInfoSinceError |
---|
95 | |
---|
96 | call Print_NameFromAtaInfoInBX |
---|
97 | |
---|
98 | mov cx, [bx+ATA1.wCylCnt] |
---|
99 | mov dx, [bx+ATA1.wHeadCnt] |
---|
100 | mov ax, [bx+ATA1.wSPT] |
---|
101 | call Print_CHSfromCXDXAX |
---|
102 | |
---|
103 | test WORD [bx+ATA1.wFields], A1_wFields_54to58 |
---|
104 | jz SHORT .SkipChsSectors |
---|
105 | mov si, g_szChsSectors |
---|
106 | call Print_NullTerminatedStringFromSI |
---|
107 | mov si, bx |
---|
108 | mov ax, [si+ATA1.dwCurSCnt] |
---|
109 | mov dx, [si+ATA1.dwCurSCnt+2] |
---|
110 | xor bx, bx |
---|
111 | call Print_TotalSectorsFromBXDXAX |
---|
112 | mov bx, si |
---|
113 | .SkipChsSectors: |
---|
114 | |
---|
115 | test WORD [bx+ATA1.wCaps], A1_wCaps_LBA |
---|
116 | jz SHORT .SkipLBA28 |
---|
117 | mov si, g_szLBA28 |
---|
118 | call Print_NullTerminatedStringFromSI |
---|
119 | mov si, bx |
---|
120 | mov ax, [si+ATA1.dwLBACnt] |
---|
121 | mov dx, [si+ATA1.dwLBACnt+2] |
---|
122 | xor bx, bx |
---|
123 | call Print_TotalSectorsFromBXDXAX |
---|
124 | mov bx, si |
---|
125 | .SkipLBA28: |
---|
126 | |
---|
127 | test WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48 |
---|
128 | jz SHORT .SkipLBA48 |
---|
129 | mov si, g_szLBA48 |
---|
130 | call Print_NullTerminatedStringFromSI |
---|
131 | mov si, bx |
---|
132 | mov ax, [bx+ATA6.qwLBACnt] |
---|
133 | mov dx, [bx+ATA6.qwLBACnt+2] |
---|
134 | mov bx, [bx+ATA6.qwLBACnt+4] |
---|
135 | call Print_TotalSectorsFromBXDXAX |
---|
136 | mov bx, si |
---|
137 | .SkipLBA48: |
---|
138 | |
---|
139 | ; Print L-CHS generated by XTIDE Universal BIOS |
---|
140 | mov ax, g_szXTUBversion |
---|
141 | mov si, g_szXTUB |
---|
142 | call Print_VersionStringFromAXusingFormatStringInSI |
---|
143 | call DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX |
---|
144 | |
---|
145 | .SkipAtaInfoSinceError: |
---|
146 | pop dx |
---|
147 | pop cx |
---|
148 | ret |
---|
149 | |
---|
150 | |
---|
151 | ALIGN JUMP_ALIGN |
---|
152 | DisplayXTUBcompatibilityInfoUsingAtaInfoFromDSBX: |
---|
153 | test WORD [bx+ATA1.wCaps], A1_wCaps_LBA |
---|
154 | jz SHORT .LbaNotSupported |
---|
155 | test WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48 |
---|
156 | jz SHORT .LoadLba28SectorCount |
---|
157 | |
---|
158 | ; Load LBA48 Sector Count |
---|
159 | mov ax, [bx+ATA6.qwLBACnt] |
---|
160 | mov dx, [bx+ATA6.qwLBACnt+2] |
---|
161 | mov bx, [bx+ATA6.qwLBACnt+4] |
---|
162 | jmp SHORT .ConvertLbaToLCHS |
---|
163 | .LoadLba28SectorCount: |
---|
164 | mov ax, [bx+ATA1.dwLBACnt] |
---|
165 | mov dx, [bx+ATA1.dwLBACnt+2] |
---|
166 | xor bx, bx |
---|
167 | |
---|
168 | .ConvertLbaToLCHS: |
---|
169 | call LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH |
---|
170 | LIMIT_LBA_CYLINDERS_IN_DXAX_TO_LCHS_CYLINDERS |
---|
171 | xchg cx, ax |
---|
172 | eMOVZX dx, bl |
---|
173 | eMOVZX ax, bh |
---|
174 | call Print_CHSfromCXDXAX |
---|
175 | .LbaNotSupported: |
---|
176 | ret |
---|
177 | |
---|
178 | |
---|
179 | ALIGN JUMP_ALIGN |
---|
180 | DisplayOldInt13hInformationForDriveDL: |
---|
181 | push cx |
---|
182 | push dx |
---|
183 | |
---|
184 | call Bios_ReadOldInt13hParametersFromDriveDL |
---|
185 | call Print_ErrorMessageFromAHifError |
---|
186 | jc SHORT .SkipOldInt13hSinceError |
---|
187 | call Print_CHSfromCXDXAX |
---|
188 | |
---|
189 | mov si, g_szSectors |
---|
190 | call Print_NullTerminatedStringFromSI |
---|
191 | pop dx |
---|
192 | push dx |
---|
193 | call Bios_ReadOldInt13hCapacityFromDriveDL |
---|
194 | call Print_ErrorMessageFromAHifError |
---|
195 | jc SHORT .SkipOldInt13hSinceError |
---|
196 | xchg ax, dx |
---|
197 | mov dx, cx |
---|
198 | xor bx, bx |
---|
199 | call Print_TotalSectorsFromBXDXAX |
---|
200 | .SkipOldInt13hSinceError: |
---|
201 | pop dx |
---|
202 | pop cx |
---|
203 | ret |
---|
204 | |
---|
205 | |
---|
206 | ALIGN JUMP_ALIGN |
---|
207 | DisplayNewInt13hInformationFromDriveDL: |
---|
208 | push cx |
---|
209 | push dx |
---|
210 | |
---|
211 | call Bios_ReadEbiosVersionFromDriveDL |
---|
212 | call Print_ErrorMessageFromAHifError |
---|
213 | jc SHORT .SkipNewInt13hSinceError |
---|
214 | call Print_EbiosVersionFromBXandExtensionsFromCX |
---|
215 | |
---|
216 | call Bios_ReadEbiosInfoFromDriveDLtoDSSI |
---|
217 | call Print_ErrorMessageFromAHifError |
---|
218 | jc SHORT .SkipNewInt13hSinceError |
---|
219 | |
---|
220 | test WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID |
---|
221 | jz SHORT .SkipEbiosCHS |
---|
222 | mov ax, [si+EDRIVE_INFO.dwCylinders] |
---|
223 | mov dx, [si+EDRIVE_INFO.dwHeads] |
---|
224 | mov cx, [si+EDRIVE_INFO.dwSectorsPerTrack] |
---|
225 | call Print_CHSfromCXDXAX |
---|
226 | .SkipEbiosCHS: |
---|
227 | |
---|
228 | push si |
---|
229 | mov si, g_szSectors |
---|
230 | call Print_NullTerminatedStringFromSI |
---|
231 | pop si |
---|
232 | mov ax, [si+EDRIVE_INFO.qwTotalSectors] |
---|
233 | mov dx, [si+EDRIVE_INFO.qwTotalSectors+2] |
---|
234 | mov bx, [si+EDRIVE_INFO.qwTotalSectors+4] |
---|
235 | call Print_TotalSectorsFromBXDXAX |
---|
236 | |
---|
237 | mov ax, [si+EDRIVE_INFO.wSectorSize] |
---|
238 | mov si, g_szNewSectorSize |
---|
239 | call Print_SectorSizeFromAXusingFormatStringInSI |
---|
240 | |
---|
241 | .SkipNewInt13hSinceError: |
---|
242 | pop dx |
---|
243 | pop cx |
---|
244 | ret |
---|