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

Last change on this file since 578 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
RevLine 
[327]1; Project name : BIOS Drive Information Tool
2; Description : BIOS Drive Information Tool reads and displays
3; drive information from BIOS.
4
[376]5;
[526]6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[526]13;
[376]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
[526]17; GNU General Public License for more details.
[376]18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[526]19;
[376]20
[327]21; Include .inc files
22%define INCLUDE_DISPLAY_LIBRARY
23%define INCLUDE_KEYBOARD_LIBRARY
24%include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
[359]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
[558]29%include "IdeRegisters.inc" ; From XTIDE Universal BIOS
[424]30%include "Romvars.inc" ; From XTIDE Universal BIOS
[359]31%include "CustomDPT.inc" ; From XTIDE Universal BIOS
[327]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"
[424]44%include "AtaGeometry.asm" ; From XTIDE Universal BIOS
[327]45%include "Strings.asm"
[424]46%include "AtaInfo.asm"
[327]47%include "Bios.asm"
48%include "Print.asm"
49
50
51;--------------------------------------------------------------------
52; Program start
53;--------------------------------------------------------------------
54ALIGN JUMP_ALIGN
55StartBiosDriveInformationTool:
56 CALL_DISPLAY_LIBRARY InitializeDisplayContext
[359]57 call Print_SetCharacterOutputToSTDOUT
[327]58
[424]59 ; Display program name and version
[327]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
[424]70;--------------------------------------------------------------------
71; ReadAndDisplayAllHardDrives
72; Parameters:
73; Nothing
74; Returns:
75; Nothing
76; Corrupts registers:
77; All, except segments
78;--------------------------------------------------------------------
[327]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
[359]90
[327]91.DisplayFirstDrive:
[424]92 ; Display drive number
[327]93 mov si, g_szHeaderDrive
94 call Print_DriveNumberFromDLusingFormatStringInSI
95
[424]96 ; Display ATA information read from drive
[327]97 mov si, g_szAtaInfoHeader
98 call Print_NullTerminatedStringFromSI
[424]99 call AtaInfo_DisplayAtaInformationForDriveDL
[327]100
[424]101 ; Display INT 13h AH=08h and AH=15h information
[327]102 mov si, g_szOldInfoHeader
103 call Print_NullTerminatedStringFromSI
104 call DisplayOldInt13hInformationForDriveDL
105
[424]106 ; Display EBIOS information
[327]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
[424]117;--------------------------------------------------------------------
118; DisplayOldInt13hInformationForDriveDL
119; Parameters:
120; DL: Drive Number
121; Returns:
122; Nothing
123; Corrupts registers:
124; All, except CX and DX
125;--------------------------------------------------------------------
[327]126DisplayOldInt13hInformationForDriveDL:
127 push cx
128 push dx
129
[424]130 ; Print L-CHS from AH=08h
[327]131 call Bios_ReadOldInt13hParametersFromDriveDL
132 call Print_ErrorMessageFromAHifError
133 jc SHORT .SkipOldInt13hSinceError
134 call Print_CHSfromCXDXAX
135
[424]136 ; Print total sector count from AH=15h
[327]137 mov si, g_szSectors
138 call Print_NullTerminatedStringFromSI
139 pop dx
[332]140 push dx
[327]141 call Bios_ReadOldInt13hCapacityFromDriveDL
142 call Print_ErrorMessageFromAHifError
143 jc SHORT .SkipOldInt13hSinceError
[424]144
[327]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
[332]154
[424]155;--------------------------------------------------------------------
156; DisplayNewInt13hInformationFromDriveDL
157; Parameters:
158; DL: Drive Number
159; Returns:
160; Nothing
161; Corrupts registers:
162; All, except CX and DX
163;--------------------------------------------------------------------
[327]164DisplayNewInt13hInformationFromDriveDL:
165 push cx
166 push dx
167
[424]168 ; Display EBIOS version
[327]169 call Bios_ReadEbiosVersionFromDriveDL
170 call Print_ErrorMessageFromAHifError
171 jc SHORT .SkipNewInt13hSinceError
172 call Print_EbiosVersionFromBXandExtensionsFromCX
173
[424]174 ; Display drive info from AH=48h
[327]175 call Bios_ReadEbiosInfoFromDriveDLtoDSSI
176 call Print_ErrorMessageFromAHifError
177 jc SHORT .SkipNewInt13hSinceError
178
[424]179 ; Display CHS
[327]180 test WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
181 jz SHORT .SkipEbiosCHS
[416]182 mov cx, [si+EDRIVE_INFO.dwCylinders]
[327]183 mov dx, [si+EDRIVE_INFO.dwHeads]
[416]184 mov ax, [si+EDRIVE_INFO.dwSectorsPerTrack]
[327]185 call Print_CHSfromCXDXAX
186.SkipEbiosCHS:
187
[424]188 ; Display total sector count
[327]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
[424]198 ; Display sector size
[327]199 mov ax, [si+EDRIVE_INFO.wSectorSize]
200 mov si, g_szNewSectorSize
[424]201 call Print_FormatStringFromSIwithParameterInAX
[327]202
203.SkipNewInt13hSinceError:
204 pop dx
205 pop cx
206 ret
Note: See TracBrowser for help on using the repository browser.