[327] | 1 | ; Project name : BIOS Drive Information Tool
|
---|
| 2 | ; Description : Functions to print information read from BIOS.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[505] | 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 7 | ;
|
---|
| 8 | ; This program is free software; you can redistribute it and/or modify
|
---|
| 9 | ; it under the terms of the GNU General Public License as published by
|
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
| 11 | ; (at your option) any later version.
|
---|
[505] | 12 | ;
|
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful,
|
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
[505] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[505] | 18 | ;
|
---|
[327] | 19 |
|
---|
| 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
[359] | 24 | ; Print_SetCharacterOutputToSTDOUT
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; Nothing
|
---|
| 27 | ; Returns:
|
---|
| 28 | ; Nothing
|
---|
| 29 | ; Corrupts registers:
|
---|
| 30 | ; AX, BX, DI
|
---|
| 31 | ;--------------------------------------------------------------------
|
---|
| 32 | Print_SetCharacterOutputToSTDOUT:
|
---|
| 33 | mov bl, ATTRIBUTES_NOT_USED
|
---|
| 34 | mov ax, DosCharOut
|
---|
[505] | 35 | JMP_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
[359] | 36 |
|
---|
[505] | 37 |
|
---|
[359] | 38 | ;--------------------------------------------------------------------
|
---|
[327] | 39 | ; Use DOS standard output so strings can be redirected to a file.
|
---|
| 40 | ;
|
---|
[359] | 41 | ; DosCharOut
|
---|
[327] | 42 | ; Parameters:
|
---|
| 43 | ; AL: Character to output
|
---|
| 44 | ; DS: BDA segment (zero)
|
---|
| 45 | ; ES:DI: Ptr to video memory where to output
|
---|
| 46 | ; Returns:
|
---|
| 47 | ; DI: Incremented for next character
|
---|
| 48 | ; Corrupts registers:
|
---|
| 49 | ; AX, DX
|
---|
| 50 | ;--------------------------------------------------------------------
|
---|
[359] | 51 | DosCharOut:
|
---|
[327] | 52 | xchg dx, ax
|
---|
| 53 | mov ah, 02h ; DOS 1+ - WRITE CHARACTER TO STANDARD OUTPUT
|
---|
| 54 | int 21h ; Call DOS
|
---|
| 55 | ret
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | ;---------------------------------------------------------------------
|
---|
| 59 | ; Print_ErrorMessageFromAHifError
|
---|
| 60 | ; Parameters:
|
---|
| 61 | ; AH: BIOS error code
|
---|
| 62 | ; CF: Set if error, cleared otherwise
|
---|
| 63 | ; Returns:
|
---|
| 64 | ; Nothing
|
---|
| 65 | ; Corrupts registers:
|
---|
| 66 | ; AX, BP, SI, DI (CF remains unchanged)
|
---|
| 67 | ;--------------------------------------------------------------------
|
---|
| 68 | Print_ErrorMessageFromAHifError:
|
---|
| 69 | jnc SHORT .NoErrors
|
---|
| 70 | eMOVZX ax, ah
|
---|
| 71 | mov si, g_szBiosError
|
---|
[424] | 72 | call Print_FormatStringFromSIwithParameterInAX
|
---|
[327] | 73 | stc ; Keep the CF set
|
---|
[505] | 74 | ALIGN JUMP_ALIGN, ret
|
---|
[327] | 75 | .NoErrors:
|
---|
| 76 | ret
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | ;---------------------------------------------------------------------
|
---|
| 80 | ; Print_DriveNumberFromDLusingFormatStringInSI
|
---|
| 81 | ; Parameters:
|
---|
| 82 | ; DL: Drive Number
|
---|
[424] | 83 | ; SI: Offset to format string
|
---|
[327] | 84 | ; Returns:
|
---|
| 85 | ; Nothing
|
---|
| 86 | ; Corrupts registers:
|
---|
| 87 | ; AX, BP, DI
|
---|
| 88 | ;--------------------------------------------------------------------
|
---|
| 89 | Print_DriveNumberFromDLusingFormatStringInSI:
|
---|
| 90 | eMOVZX ax, dl
|
---|
[424] | 91 | ; Fall to Print_FormatStringFromSIwithParameterInAX
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | ;---------------------------------------------------------------------
|
---|
| 95 | ; Print_FormatStringFromSIwithParameterInAX
|
---|
| 96 | ; Print_FormatStringFromSIwithParametersInAXDX
|
---|
| 97 | ; Print_FormatStringFromSIwithParametersInAXDXCX
|
---|
| 98 | ; Parameters:
|
---|
| 99 | ; AX: Format parameter 1
|
---|
| 100 | ; DX: Format parameter 2
|
---|
| 101 | ; CX: Format parameter 3
|
---|
| 102 | ; SI: Offset to format string
|
---|
| 103 | ; Returns:
|
---|
| 104 | ; Nothing
|
---|
| 105 | ; Corrupts registers:
|
---|
| 106 | ; AX, BP, DI
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | Print_FormatStringFromSIwithParameterInAX:
|
---|
[327] | 109 | mov bp, sp
|
---|
| 110 | push ax
|
---|
[424] | 111 | jmp JumpToFormatNullTerminatedStringFromSI
|
---|
| 112 |
|
---|
| 113 | Print_FormatStringFromSIwithParametersInAXDX:
|
---|
| 114 | mov bp, sp
|
---|
| 115 | push ax
|
---|
| 116 | push dx
|
---|
| 117 | jmp JumpToFormatNullTerminatedStringFromSI
|
---|
| 118 |
|
---|
| 119 | Print_FormatStringFromSIwithParametersInAXDXCX:
|
---|
| 120 | mov bp, sp
|
---|
| 121 | push ax
|
---|
| 122 | push dx
|
---|
| 123 | push cx
|
---|
[327] | 124 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | ;---------------------------------------------------------------------
|
---|
[424] | 128 | ; Print_ModeFromDLandCHSfromAXBLBH
|
---|
| 129 | ; Parameters:
|
---|
| 130 | ; AX: Number of L-CHS cylinders (1...1024)
|
---|
| 131 | ; BL: Number of L-CHS heads (1...255)
|
---|
| 132 | ; BH: Number of L-CHS sectors per track (1...63)
|
---|
| 133 | ; DL: CHS Translate Mode
|
---|
| 134 | ; Returns:
|
---|
| 135 | ; Nothing
|
---|
| 136 | ; Corrupts registers:
|
---|
| 137 | ; AX, BP, SI, DI
|
---|
| 138 | ;--------------------------------------------------------------------
|
---|
| 139 | Print_ModeFromDLandCHSfromAXLBH:
|
---|
| 140 | mov bp, sp
|
---|
| 141 |
|
---|
[426] | 142 | ; Push CHS parameters
|
---|
[424] | 143 | ePUSH_T si, g_szFormatCHS
|
---|
| 144 | push ax ; Cylinders
|
---|
| 145 | eMOVZX ax, bl
|
---|
| 146 | push ax ; Heads
|
---|
| 147 | mov al, bh
|
---|
| 148 | push ax ; Sectors per track
|
---|
| 149 |
|
---|
[426] | 150 | ; Push translation mode
|
---|
| 151 | xor dh, dh
|
---|
| 152 | mov si, dx
|
---|
| 153 | shl si, 1 ; Shift for WORD lookup
|
---|
| 154 | push WORD [si+.rgszXlateModeToString]
|
---|
| 155 |
|
---|
| 156 | mov si, g_szChsAndMode
|
---|
[424] | 157 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
| 158 |
|
---|
| 159 | .rgszXlateModeToString:
|
---|
| 160 | dw g_szNormal
|
---|
| 161 | dw g_szLarge
|
---|
| 162 | dw g_szLBA
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | ;---------------------------------------------------------------------
|
---|
[327] | 166 | ; Print_CHSfromCXDXAX
|
---|
| 167 | ; Parameters:
|
---|
| 168 | ; CX: Number of cylinders (1...16383)
|
---|
| 169 | ; DX: Number of heads (1...255)
|
---|
| 170 | ; AX: Sectors per track (1...63)
|
---|
| 171 | ; Returns:
|
---|
| 172 | ; Nothing
|
---|
| 173 | ; Corrupts registers:
|
---|
| 174 | ; AX, BP, DI
|
---|
| 175 | ;--------------------------------------------------------------------
|
---|
| 176 | Print_CHSfromCXDXAX:
|
---|
| 177 | push si
|
---|
| 178 |
|
---|
| 179 | mov bp, sp
|
---|
| 180 | push cx
|
---|
| 181 | push dx
|
---|
| 182 | push ax
|
---|
| 183 | mov si, g_szFormatCHS
|
---|
[505] | 184 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 185 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
[327] | 186 |
|
---|
| 187 | pop si
|
---|
| 188 | ret
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | ;---------------------------------------------------------------------
|
---|
| 192 | ; Print_NameFromAtaInfoInBX
|
---|
| 193 | ; Parameters:
|
---|
| 194 | ; DS:BX: Ptr to ATA information
|
---|
| 195 | ; Returns:
|
---|
| 196 | ; Nothing
|
---|
| 197 | ; Corrupts registers:
|
---|
| 198 | ; AX, CX, BP, SI, DI
|
---|
| 199 | ;--------------------------------------------------------------------
|
---|
| 200 | Print_NameFromAtaInfoInBX:
|
---|
| 201 | cld
|
---|
| 202 | lea si, [bx+ATA1.strModel]
|
---|
| 203 | mov di, si
|
---|
| 204 | mov cx, A1_MODEL_NUMBER_LENGTH/2
|
---|
| 205 | ALIGN JUMP_ALIGN
|
---|
| 206 | .ReverseNextWord:
|
---|
| 207 | lodsw
|
---|
| 208 | xchg al, ah
|
---|
| 209 | stosw
|
---|
| 210 | loop .ReverseNextWord
|
---|
| 211 | dec di
|
---|
[525] | 212 | xchg cx, ax
|
---|
[327] | 213 | stosb ; Terminate with NULL
|
---|
| 214 |
|
---|
| 215 | mov bp, sp
|
---|
| 216 | lea si, [bx+ATA1.strModel]
|
---|
| 217 | push si
|
---|
| 218 | mov si, g_szFormatDrvName
|
---|
| 219 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 | ;---------------------------------------------------------------------
|
---|
| 223 | ; Print_TotalSectorsFromBXDXAX
|
---|
| 224 | ; Parameters:
|
---|
| 225 | ; BX:DX:AX: Total number of sectors
|
---|
| 226 | ; Returns:
|
---|
| 227 | ; Nothing
|
---|
| 228 | ; Corrupts registers:
|
---|
| 229 | ; AX, BX, BP, DI
|
---|
| 230 | ;--------------------------------------------------------------------
|
---|
| 231 | Print_TotalSectorsFromBXDXAX:
|
---|
| 232 | ePUSH_T di, 0
|
---|
| 233 | push bx
|
---|
| 234 | push dx
|
---|
| 235 | push ax
|
---|
| 236 | mov bp, sp
|
---|
| 237 | mov bx, 10
|
---|
| 238 | CALL_DISPLAY_LIBRARY PrintQWordFromSSBPwithBaseInBX
|
---|
| 239 | add sp, BYTE 8
|
---|
| 240 |
|
---|
[371] | 241 | push si
|
---|
| 242 | mov si, g_szNewline
|
---|
| 243 | call Print_NullTerminatedStringFromSI
|
---|
| 244 | pop si
|
---|
[505] | 245 |
|
---|
[327] | 246 | ret
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | ;---------------------------------------------------------------------
|
---|
| 250 | ; Print_EbiosVersionFromBXandExtensionsFromCX
|
---|
| 251 | ; Parameters:
|
---|
| 252 | ; BX: Version of extensions
|
---|
| 253 | ; CX: Interface support bit map
|
---|
| 254 | ; Returns:
|
---|
| 255 | ; Nothing
|
---|
| 256 | ; Corrupts registers:
|
---|
| 257 | ; AX, BP, SI, DI
|
---|
| 258 | ;--------------------------------------------------------------------
|
---|
| 259 | Print_EbiosVersionFromBXandExtensionsFromCX:
|
---|
| 260 | mov bp, sp
|
---|
| 261 | push bx
|
---|
| 262 | push cx
|
---|
| 263 | mov si, g_szNewExtensions
|
---|
[558] | 264 | ; Fall to JumpToFormatNullTerminatedStringFromSI
|
---|
[327] | 265 |
|
---|
| 266 |
|
---|
| 267 | ;---------------------------------------------------------------------
|
---|
| 268 | ; JumpToFormatNullTerminatedStringFromSI
|
---|
| 269 | ; Parameters:
|
---|
| 270 | ; BP: SP before pushing parameters
|
---|
| 271 | ; CS:SI: Ptr to format string
|
---|
| 272 | ; Returns:
|
---|
| 273 | ; Pushed parameters are cleaned from stack
|
---|
| 274 | ; Corrupts registers:
|
---|
| 275 | ; AX, DI
|
---|
| 276 | ;--------------------------------------------------------------------
|
---|
[505] | 277 | JumpToFormatNullTerminatedStringFromSI:
|
---|
| 278 | JMP_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
[327] | 279 |
|
---|
| 280 |
|
---|
| 281 | ;---------------------------------------------------------------------
|
---|
| 282 | ; Print_NullTerminatedStringFromSI
|
---|
| 283 | ; Parameters:
|
---|
| 284 | ; CS:SI: Ptr to string to display
|
---|
| 285 | ; Returns:
|
---|
| 286 | ; Nothing
|
---|
| 287 | ; Corrupts registers:
|
---|
| 288 | ; AX, DI
|
---|
| 289 | ;--------------------------------------------------------------------
|
---|
| 290 | Print_NullTerminatedStringFromSI:
|
---|
[505] | 291 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
| 292 |
|
---|