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