source: xtideuniversalbios/trunk/BIOS_Drive_Information_Tool/Src/Main.asm@ 354

Last change on this file since 354 was 332, checked in by krille_n_@…, 13 years ago

Changes:

  • Fixed a bug in the new BIOS Drive Information Tool.
  • Very small changes to improve speed (I hope).
  • Changed AH48h_GetExtendedDriveParameters.asm to allow AT builds with USE_386 (won't affect any other builds).
  • Verified that most define combinations can be built and changed Strings.asm accordingly. "Most" meaning with or without any combination of EBIOS and/or Serial code defines.
File size: 4.9 KB
RevLine 
[327]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 "ATA_ID.inc"
10%include "Int13h.inc"
11%include "EBIOS.inc"
12
13
14; Section containing code
15SECTION .text
16
17; Program first instruction.
18ORG 100h ; Code starts at offset 100h (DOS .COM)
19Start:
20 jmp StartBiosDriveInformationTool
21
22; Include library and other sources
23%include "AssemblyLibrary.asm"
24%include "Strings.asm"
25%include "Bios.asm"
26%include "Print.asm"
27
28
29;--------------------------------------------------------------------
30; Program start
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33StartBiosDriveInformationTool:
34 CALL_DISPLAY_LIBRARY InitializeDisplayContext
35 mov bl, ATTRIBUTES_NOT_USED
36 mov ax, Print_DosCharOut
37 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
38
39 mov si, g_szProgramName
40 call Print_NullTerminatedStringFromSI
41
42 call ReadAndDisplayAllHardDrives
43
44 ; Exit to DOS
45 mov ax, 4C00h ; Exit to DOS
46 int 21h
47
48
49
50ReadAndDisplayAllHardDrives:
51 call Bios_GetNumberOfHardDrivesToDX
52 jc SHORT .NoDrivesAvailable
53 mov cx, dx
54 mov dl, 80h ; First hard drive
55 jmp SHORT .DisplayFirstDrive
56
57ALIGN JUMP_ALIGN
58.DisplayNextDriveFromDL:
59 mov si, g_szPressAnyKey
60 call Print_NullTerminatedStringFromSI
61 call Keyboard_GetKeystrokeToAXandWaitIfNecessary
62.DisplayFirstDrive:
63 mov si, g_szHeaderDrive
64 call Print_DriveNumberFromDLusingFormatStringInSI
65
66 mov si, g_szAtaInfoHeader
67 call Print_NullTerminatedStringFromSI
68 call DisplayAtaInformationForDriveDL
69
70 mov si, g_szOldInfoHeader
71 call Print_NullTerminatedStringFromSI
72 call DisplayOldInt13hInformationForDriveDL
73
74 mov si, g_szNewInfoHeader
75 call Print_NullTerminatedStringFromSI
76 call DisplayNewInt13hInformationFromDriveDL
77
78 inc dx
79 loop .DisplayNextDriveFromDL
80.NoDrivesAvailable:
81 ret
82
83
84ALIGN JUMP_ALIGN
85DisplayAtaInformationForDriveDL:
86 push cx
87 push dx
88
89 call Bios_ReadAtaInfoFromDriveDLtoBX
90 call Print_ErrorMessageFromAHifError
91 jc SHORT .SkipAtaInfoSinceError
92
93 call Print_NameFromAtaInfoInBX
94
95 mov cx, [bx+ATA1.wCylCnt]
96 mov dx, [bx+ATA1.wHeadCnt]
97 mov ax, [bx+ATA1.wSPT]
98 call Print_CHSfromCXDXAX
99
100 test WORD [bx+ATA1.wFields], A1_wFields_54to58
101 jz SHORT .SkipChsSectors
102 mov si, g_szChsSectors
103 call Print_NullTerminatedStringFromSI
104 mov si, bx
105 mov ax, [si+ATA1.dwCurSCnt]
106 mov dx, [si+ATA1.dwCurSCnt+2]
107 xor bx, bx
108 call Print_TotalSectorsFromBXDXAX
109 mov bx, si
110.SkipChsSectors:
111
112 test WORD [bx+ATA1.wCaps], A1_wCaps_LBA
113 jz SHORT .SkipLBA28
114 mov si, g_szLBA28
115 call Print_NullTerminatedStringFromSI
116 mov si, bx
117 mov ax, [si+ATA1.dwLBACnt]
118 mov dx, [si+ATA1.dwLBACnt+2]
119 xor bx, bx
120 call Print_TotalSectorsFromBXDXAX
121 mov bx, si
122.SkipLBA28:
123
124 test WORD [bx+ATA6.wSetSup83], A6_wSetSup83_LBA48
125 jz SHORT .SkipLBA48
126 mov si, g_szLBA48
127 call Print_NullTerminatedStringFromSI
128 mov ax, [bx+ATA6.qwLBACnt]
129 mov dx, [bx+ATA6.qwLBACnt+2]
130 mov bx, [bx+ATA6.qwLBACnt+4]
131 call Print_TotalSectorsFromBXDXAX
132.SkipLBA48:
133.SkipAtaInfoSinceError:
134 pop dx
135 pop cx
136 ret
137
138
139ALIGN JUMP_ALIGN
140DisplayOldInt13hInformationForDriveDL:
141 push cx
142 push dx
143
144 call Bios_ReadOldInt13hParametersFromDriveDL
145 call Print_ErrorMessageFromAHifError
146 jc SHORT .SkipOldInt13hSinceError
147 call Print_CHSfromCXDXAX
148
149 mov si, g_szSectors
150 call Print_NullTerminatedStringFromSI
151 pop dx
[332]152 push dx
[327]153 call Bios_ReadOldInt13hCapacityFromDriveDL
154 call Print_ErrorMessageFromAHifError
155 jc SHORT .SkipOldInt13hSinceError
156 xchg ax, dx
157 mov dx, cx
158 xor bx, bx
159 call Print_TotalSectorsFromBXDXAX
160.SkipOldInt13hSinceError:
161 pop dx
162 pop cx
163 ret
164
[332]165
[327]166ALIGN JUMP_ALIGN
167DisplayNewInt13hInformationFromDriveDL:
168 push cx
169 push dx
170
171 call Bios_ReadEbiosVersionFromDriveDL
172 call Print_ErrorMessageFromAHifError
173 jc SHORT .SkipNewInt13hSinceError
174 call Print_EbiosVersionFromBXandExtensionsFromCX
175
176 call Bios_ReadEbiosInfoFromDriveDLtoDSSI
177 call Print_ErrorMessageFromAHifError
178 jc SHORT .SkipNewInt13hSinceError
179
180 test WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
181 jz SHORT .SkipEbiosCHS
182 mov ax, [si+EDRIVE_INFO.dwCylinders]
183 mov dx, [si+EDRIVE_INFO.dwHeads]
184 mov cx, [si+EDRIVE_INFO.dwSectorsPerTrack]
185 call Print_CHSfromCXDXAX
186.SkipEbiosCHS:
187
188 push si
189 mov si, g_szSectors
190 call Print_NullTerminatedStringFromSI
191 pop si
192 mov ax, [si+EDRIVE_INFO.qwTotalSectors]
193 mov dx, [si+EDRIVE_INFO.qwTotalSectors+2]
194 mov bx, [si+EDRIVE_INFO.qwTotalSectors+4]
195 call Print_TotalSectorsFromBXDXAX
196
197 mov ax, [si+EDRIVE_INFO.wSectorSize]
198 mov si, g_szNewSectorSize
199 call Print_SectorSizeFromAXusingFormatStringInSI
200
201.SkipNewInt13hSinceError:
202 pop dx
203 pop cx
204 ret
Note: See TracBrowser for help on using the repository browser.