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

Last change on this file since 565 was 558, checked in by krille_n_@…, 11 years ago

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
File size: 5.8 KB
Line 
1; Project name : BIOS Drive Information Tool
2; Description : BIOS Drive Information Tool reads and displays
3; drive information from BIOS.
4
5;
6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
13;
14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17; GNU General Public License for more details.
18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
21; Include .inc files
22%define INCLUDE_DISPLAY_LIBRARY
23%define INCLUDE_KEYBOARD_LIBRARY
24%include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
25%include "Version.inc" ; From XTIDE Universal BIOS
26%include "ATA_ID.inc" ; From XTIDE Universal BIOS
27%include "Int13h.inc" ; From XTIDE Universal BIOS
28%include "EBIOS.inc" ; From XTIDE Universal BIOS
29%include "IdeRegisters.inc" ; From XTIDE Universal BIOS
30%include "Romvars.inc" ; From XTIDE Universal BIOS
31%include "CustomDPT.inc" ; From XTIDE Universal BIOS
32
33
34; Section containing code
35SECTION .text
36
37; Program first instruction.
38ORG 100h ; Code starts at offset 100h (DOS .COM)
39Start:
40 jmp StartBiosDriveInformationTool
41
42; Include library and other sources
43%include "AssemblyLibrary.asm"
44%include "AtaGeometry.asm" ; From XTIDE Universal BIOS
45%include "Strings.asm"
46%include "AtaInfo.asm"
47%include "Bios.asm"
48%include "Print.asm"
49
50
51;--------------------------------------------------------------------
52; Program start
53;--------------------------------------------------------------------
54ALIGN JUMP_ALIGN
55StartBiosDriveInformationTool:
56 CALL_DISPLAY_LIBRARY InitializeDisplayContext
57 call Print_SetCharacterOutputToSTDOUT
58
59 ; Display program name and version
60 mov si, g_szProgramName
61 call Print_NullTerminatedStringFromSI
62
63 call ReadAndDisplayAllHardDrives
64
65 ; Exit to DOS
66 mov ax, 4C00h ; Exit to DOS
67 int 21h
68
69
70;--------------------------------------------------------------------
71; ReadAndDisplayAllHardDrives
72; Parameters:
73; Nothing
74; Returns:
75; Nothing
76; Corrupts registers:
77; All, except segments
78;--------------------------------------------------------------------
79ReadAndDisplayAllHardDrives:
80 call Bios_GetNumberOfHardDrivesToDX
81 jc SHORT .NoDrivesAvailable
82 mov cx, dx
83 mov dl, 80h ; First hard drive
84 jmp SHORT .DisplayFirstDrive
85
86.DisplayNextDriveFromDL:
87 mov si, g_szPressAnyKey
88 call Print_NullTerminatedStringFromSI
89 call Keyboard_GetKeystrokeToAXandWaitIfNecessary
90
91.DisplayFirstDrive:
92 ; Display drive number
93 mov si, g_szHeaderDrive
94 call Print_DriveNumberFromDLusingFormatStringInSI
95
96 ; Display ATA information read from drive
97 mov si, g_szAtaInfoHeader
98 call Print_NullTerminatedStringFromSI
99 call AtaInfo_DisplayAtaInformationForDriveDL
100
101 ; Display INT 13h AH=08h and AH=15h information
102 mov si, g_szOldInfoHeader
103 call Print_NullTerminatedStringFromSI
104 call DisplayOldInt13hInformationForDriveDL
105
106 ; Display EBIOS information
107 mov si, g_szNewInfoHeader
108 call Print_NullTerminatedStringFromSI
109 call DisplayNewInt13hInformationFromDriveDL
110
111 inc dx
112 loop .DisplayNextDriveFromDL
113.NoDrivesAvailable:
114 ret
115
116
117;--------------------------------------------------------------------
118; DisplayOldInt13hInformationForDriveDL
119; Parameters:
120; DL: Drive Number
121; Returns:
122; Nothing
123; Corrupts registers:
124; All, except CX and DX
125;--------------------------------------------------------------------
126DisplayOldInt13hInformationForDriveDL:
127 push cx
128 push dx
129
130 ; Print L-CHS from AH=08h
131 call Bios_ReadOldInt13hParametersFromDriveDL
132 call Print_ErrorMessageFromAHifError
133 jc SHORT .SkipOldInt13hSinceError
134 call Print_CHSfromCXDXAX
135
136 ; Print total sector count from AH=15h
137 mov si, g_szSectors
138 call Print_NullTerminatedStringFromSI
139 pop dx
140 push dx
141 call Bios_ReadOldInt13hCapacityFromDriveDL
142 call Print_ErrorMessageFromAHifError
143 jc SHORT .SkipOldInt13hSinceError
144
145 xchg ax, dx
146 mov dx, cx
147 xor bx, bx
148 call Print_TotalSectorsFromBXDXAX
149.SkipOldInt13hSinceError:
150 pop dx
151 pop cx
152 ret
153
154
155;--------------------------------------------------------------------
156; DisplayNewInt13hInformationFromDriveDL
157; Parameters:
158; DL: Drive Number
159; Returns:
160; Nothing
161; Corrupts registers:
162; All, except CX and DX
163;--------------------------------------------------------------------
164DisplayNewInt13hInformationFromDriveDL:
165 push cx
166 push dx
167
168 ; Display EBIOS version
169 call Bios_ReadEbiosVersionFromDriveDL
170 call Print_ErrorMessageFromAHifError
171 jc SHORT .SkipNewInt13hSinceError
172 call Print_EbiosVersionFromBXandExtensionsFromCX
173
174 ; Display drive info from AH=48h
175 call Bios_ReadEbiosInfoFromDriveDLtoDSSI
176 call Print_ErrorMessageFromAHifError
177 jc SHORT .SkipNewInt13hSinceError
178
179 ; Display CHS
180 test WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
181 jz SHORT .SkipEbiosCHS
182 mov cx, [si+EDRIVE_INFO.dwCylinders]
183 mov dx, [si+EDRIVE_INFO.dwHeads]
184 mov ax, [si+EDRIVE_INFO.dwSectorsPerTrack]
185 call Print_CHSfromCXDXAX
186.SkipEbiosCHS:
187
188 ; Display total sector count
189 push si
190 mov si, g_szSectors
191 call Print_NullTerminatedStringFromSI
192 pop si
193 mov ax, [si+EDRIVE_INFO.qwTotalSectors]
194 mov dx, [si+EDRIVE_INFO.qwTotalSectors+2]
195 mov bx, [si+EDRIVE_INFO.qwTotalSectors+4]
196 call Print_TotalSectorsFromBXDXAX
197
198 ; Display sector size
199 mov ax, [si+EDRIVE_INFO.wSectorSize]
200 mov si, g_szNewSectorSize
201 call Print_FormatStringFromSIwithParameterInAX
202
203.SkipNewInt13hSinceError:
204 pop dx
205 pop cx
206 ret
Note: See TracBrowser for help on using the repository browser.