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

Last change on this file since 618 was 614, checked in by Krister Nordvall, 3 years ago

Changes:

  • BIOSDRVS should now build again (broke in r613).
  • Removed the NO_ATAID_CORRECTION define from the Tiny build.
  • Added a new configuration option to skip detection of slave drives.
  • Made FLASH_SIGNATURE 2 bytes shorter to free up ROM space.
  • "Auto Configure" in XTIDECFG should now detect if running on an Olivetti M24, AT&T PC6300, Xerox 6060 or Logabax Persona 1600 and automatically select the fastest compatible transfer mode/device type for any IDE controllers found in the system.
  • Cleaned out some duplicate/unused definitions.
File size: 5.9 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 "RamVars.inc" ; From XTIDE Universal BIOS (needed by Int13h.inc)
28%include "Int13h.inc" ; From XTIDE Universal BIOS
29%include "EBIOS.inc" ; From XTIDE Universal BIOS
30%include "IdeRegisters.inc" ; From XTIDE Universal BIOS
31%include "RomVars.inc" ; From XTIDE Universal BIOS
32%include "CustomDPT.inc" ; From XTIDE Universal BIOS
33
34
35; Section containing code
36SECTION .text
37
38; Program first instruction.
39ORG 100h ; Code starts at offset 100h (DOS .COM)
40Start:
41 jmp StartBiosDriveInformationTool
42
43; Include library and other sources
44%include "AssemblyLibrary.asm"
45%include "AtaID.asm" ; From XTIDE Universal BIOS
46%include "AtaGeometry.asm" ; From XTIDE Universal BIOS
47%include "Strings.asm"
48%include "AtaInfo.asm"
49%include "Bios.asm"
50%include "Print.asm"
51
52
53;--------------------------------------------------------------------
54; Program start
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57StartBiosDriveInformationTool:
58 CALL_DISPLAY_LIBRARY InitializeDisplayContext
59 call Print_SetCharacterOutputToSTDOUT
60
61 ; Display program name and version
62 mov si, g_szProgramName
63 call Print_NullTerminatedStringFromSI
64 ; Fall to ReadAndDisplayAllHardDrives
65
66
67;--------------------------------------------------------------------
68; ReadAndDisplayAllHardDrives
69; Parameters:
70; Nothing
71; Returns:
72; Nothing
73; Corrupts registers:
74; All, except segments
75;--------------------------------------------------------------------
76ReadAndDisplayAllHardDrives:
77 call Bios_GetNumberOfHardDrivesToDX
78 jc SHORT .NoDrivesAvailable
79 mov cx, dx
80 mov dl, 80h ; First hard drive
81 jmp SHORT .DisplayFirstDrive
82
83.DisplayNextDriveFromDL:
84 mov si, g_szPressAnyKey
85 call Print_NullTerminatedStringFromSI
86 call Keyboard_GetKeystrokeToAXandWaitIfNecessary
87
88.DisplayFirstDrive:
89 ; Display drive number
90 mov si, g_szHeaderDrive
91 call Print_DriveNumberFromDLusingFormatStringInSI
92
93 ; Display ATA information read from drive
94 mov si, g_szAtaInfoHeader
95 call Print_NullTerminatedStringFromSI
96 call AtaInfo_DisplayAtaInformationForDriveDL
97
98 ; Display INT 13h AH=08h and AH=15h information
99 mov si, g_szOldInfoHeader
100 call Print_NullTerminatedStringFromSI
101 call DisplayOldInt13hInformationForDriveDL
102
103 ; Display EBIOS information
104 mov si, g_szNewInfoHeader
105 call Print_NullTerminatedStringFromSI
106 call DisplayNewInt13hInformationFromDriveDL
107
108 inc dx
109 loop .DisplayNextDriveFromDL
110.NoDrivesAvailable:
111 ret ; Exit to DOS
112
113
114;--------------------------------------------------------------------
115; DisplayOldInt13hInformationForDriveDL
116; Parameters:
117; DL: Drive Number
118; Returns:
119; Nothing
120; Corrupts registers:
121; All, except CX and DX
122;--------------------------------------------------------------------
123DisplayOldInt13hInformationForDriveDL:
124 push cx
125 push dx
126
127 ; Print L-CHS from AH=08h
128 call Bios_ReadOldInt13hParametersFromDriveDL
129 call Print_ErrorMessageFromAHifError
130 jc SHORT .SkipOldInt13hSinceError
131 call Print_CHSfromCXDXAX
132
133 ; Print total sector count from AH=15h
134 mov si, g_szSectors
135 call Print_NullTerminatedStringFromSI
136 pop dx
137 push dx
138 call Bios_ReadOldInt13hCapacityFromDriveDL
139 call Print_ErrorMessageFromAHifError
140 jc SHORT .SkipOldInt13hSinceError
141
142 xchg ax, dx
143 mov dx, cx
144 xor bx, bx
145 call Print_TotalSectorsFromBXDXAX
146.SkipOldInt13hSinceError:
147 pop dx
148 pop cx
149 ret
150
151
152;--------------------------------------------------------------------
153; DisplayNewInt13hInformationFromDriveDL
154; Parameters:
155; DL: Drive Number
156; Returns:
157; Nothing
158; Corrupts registers:
159; All, except CX and DX
160;--------------------------------------------------------------------
161DisplayNewInt13hInformationFromDriveDL:
162 push cx
163 push dx
164
165 ; Display EBIOS version
166 call Bios_ReadEbiosVersionFromDriveDL
167 call Print_ErrorMessageFromAHifError
168 jc SHORT .SkipNewInt13hSinceError
169 call Print_EbiosVersionFromBXandExtensionsFromCX
170
171 ; Display drive info from AH=48h
172 call Bios_ReadEbiosInfoFromDriveDLtoDSSI
173 call Print_ErrorMessageFromAHifError
174 jc SHORT .SkipNewInt13hSinceError
175
176 ; Display CHS
177 test WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
178 jz SHORT .SkipEbiosCHS
179 mov cx, [si+EDRIVE_INFO.dwCylinders]
180 mov dx, [si+EDRIVE_INFO.dwHeads]
181 mov ax, [si+EDRIVE_INFO.dwSectorsPerTrack]
182 call Print_CHSfromCXDXAX
183.SkipEbiosCHS:
184
185 ; Display total sector count
186 push si
187 mov si, g_szSectors
188 call Print_NullTerminatedStringFromSI
189 pop si
190 mov ax, [si+EDRIVE_INFO.qwTotalSectors]
191 mov dx, [si+EDRIVE_INFO.qwTotalSectors+2]
192 mov bx, [si+EDRIVE_INFO.qwTotalSectors+4]
193 call Print_TotalSectorsFromBXDXAX
194
195 ; Display sector size
196 mov ax, [si+EDRIVE_INFO.wSectorSize]
197 mov si, g_szNewSectorSize
198 call Print_FormatStringFromSIwithParameterInAX
199
200.SkipNewInt13hSinceError:
201 pop dx
202 pop cx
203 ret
Note: See TracBrowser for help on using the repository browser.