[88] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for printing drive detection strings.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
| 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.
|
---|
| 12 | ;
|
---|
| 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
|
---|
| 16 | ; GNU General Public License for more details.
|
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
| 19 |
|
---|
[3] | 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
[392] | 24 | ; DetectPrint_InitializeDisplayContext
|
---|
[386] | 25 | ; Parameters:
|
---|
| 26 | ; Nothing
|
---|
| 27 | ; Returns:
|
---|
| 28 | ; Nothing
|
---|
| 29 | ; Corrupts registers:
|
---|
| 30 | ; AX, DI
|
---|
| 31 | ;--------------------------------------------------------------------
|
---|
[392] | 32 | DetectPrint_InitializeDisplayContext:
|
---|
| 33 | CALL_DISPLAY_LIBRARY InitializeDisplayContext
|
---|
[386] | 34 | ret
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | ;--------------------------------------------------------------------
|
---|
[392] | 38 | ; DetectPrint_GetSoftwareCoordinatesToAX
|
---|
| 39 | ; Parameters:
|
---|
| 40 | ; Nothing
|
---|
| 41 | ; Returns:
|
---|
| 42 | ; Nothing
|
---|
| 43 | ; Corrupts registers:
|
---|
| 44 | ; AX, DI
|
---|
| 45 | ;--------------------------------------------------------------------
|
---|
| 46 | DetectPrint_GetSoftwareCoordinatesToAX:
|
---|
| 47 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
|
---|
| 48 | ret
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | ;--------------------------------------------------------------------
|
---|
[3] | 52 | ; Prints BIOS name and segment address where it is found.
|
---|
| 53 | ;
|
---|
| 54 | ; DetectPrint_RomFoundAtSegment
|
---|
| 55 | ; Parameters:
|
---|
| 56 | ; Nothing
|
---|
| 57 | ; Returns:
|
---|
| 58 | ; Nothing
|
---|
| 59 | ; Corrupts registers:
|
---|
[120] | 60 | ; AX, SI, DI
|
---|
[3] | 61 | ;--------------------------------------------------------------------
|
---|
| 62 | DetectPrint_RomFoundAtSegment:
|
---|
[88] | 63 | push bp
|
---|
[97] | 64 | mov bp, sp
|
---|
[3] | 65 | mov si, g_szRomAt
|
---|
[88] | 66 | ePUSH_T ax, ROMVARS.szTitle ; Bios title string
|
---|
| 67 | push cs ; BIOS segment
|
---|
[242] | 68 |
|
---|
[386] | 69 | jmp DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
[3] | 70 |
|
---|
| 71 |
|
---|
| 72 | ;--------------------------------------------------------------------
|
---|
[294] | 73 | ; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
|
---|
[3] | 74 | ; Parameters:
|
---|
[233] | 75 | ; CS:CX: Ptr to "Master" or "Slave" string
|
---|
[3] | 76 | ; CS:BP: Ptr to IDEVARS
|
---|
[242] | 77 | ; SI: Ptr to template string
|
---|
[3] | 78 | ; Returns:
|
---|
| 79 | ; Nothing
|
---|
| 80 | ; Corrupts registers:
|
---|
[196] | 81 | ; AX, SI, DI, CX
|
---|
[3] | 82 | ;--------------------------------------------------------------------
|
---|
[294] | 83 | DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
|
---|
[233] | 84 | mov ax, [cs:bp+IDEVARS.wPort] ; for IDE: AX=port address, DH=.bDevice
|
---|
| 85 | mov dx, [cs:bp+IDEVARS.bDevice-1] ; for Serial: AL=port address>>2, AH=baud rate
|
---|
| 86 | ; DL=COM number character, DH=.bDevice
|
---|
[285] | 87 | %ifdef MODULE_JRIDE
|
---|
[400] | 88 | cmp dh, DEVICE_8BIT_JRIDE_ISA
|
---|
[285] | 89 | eCMOVE ax, cs ; Use segment address for JR-IDE/ISA
|
---|
| 90 | %endif
|
---|
| 91 |
|
---|
[242] | 92 | push bp ; setup stack for call to
|
---|
[233] | 93 | mov bp, sp ; BootMenuPrint_FormatCSSIfromParamsInSSBP
|
---|
| 94 |
|
---|
| 95 | push cx ; Push "Master" or "Slave"
|
---|
[242] | 96 |
|
---|
[233] | 97 | mov cl, (g_szDetectPort-$$) & 0xff ; Setup print string for standard IDE
|
---|
| 98 | ; Note that we modify only the low order bits of CX a lot here,
|
---|
| 99 | ; saving code space rather than reloading CX completely.
|
---|
| 100 | ; This optimization requires that all the g_szDetect* strings are
|
---|
| 101 | ; on the same 256 byte page, which is checked in strings.asm.
|
---|
[3] | 102 |
|
---|
[277] | 103 | %ifdef MODULE_SERIAL
|
---|
[244] | 104 | cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
|
---|
[233] | 105 |
|
---|
[244] | 106 | jnz .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
|
---|
[233] | 107 |
|
---|
| 108 | mov cl, (g_szDetectCOM-$$) & 0xff ; Setup print string for COM ports
|
---|
| 109 | push cx ; And push now. We use the fact that format strings can contain
|
---|
| 110 | ; themselves format strings.
|
---|
| 111 |
|
---|
| 112 | push dx ; Push COM number character
|
---|
[242] | 113 | ; If the string is going to be "Auto", we will push a NULL (zero)
|
---|
| 114 | ; here for the COM port number, which will be eaten by the
|
---|
| 115 | ; print routine (DisplayPrint_CharacterFromAL), resulting in
|
---|
[235] | 116 | ; just "COM" being printed without a character after it.
|
---|
[242] | 117 |
|
---|
[233] | 118 | mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
|
---|
[242] | 119 |
|
---|
[244] | 120 | test dl, dl ; Check if serial port "Auto"
|
---|
[262] | 121 | jz .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
|
---|
[242] | 122 |
|
---|
[233] | 123 | mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
|
---|
[3] | 124 |
|
---|
[233] | 125 | mov al,ah ; baud rate divisor to AL
|
---|
| 126 | cbw ; clear AH, AL will always be less than 128
|
---|
| 127 | xchg si,ax ; move AX to SI for divide
|
---|
[242] | 128 | mov ax,1152 ; baud rate to display is 115200/divisor, the "00" is handled
|
---|
[233] | 129 | ; in the print strings
|
---|
[242] | 130 | cwd ; clear top 16-bits of dividend
|
---|
[233] | 131 | div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
|
---|
[242] | 132 |
|
---|
[233] | 133 | mov si,10 ; Now separate the whole portion from the fractional for "K" display
|
---|
| 134 | div si ; and divide... Now AX = baud rate/1000, DX = low order digit
|
---|
[242] | 135 |
|
---|
| 136 | cmp ax,si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
|
---|
[262] | 137 | jae .pushAndPrintSerial
|
---|
[196] | 138 |
|
---|
[233] | 139 | mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
|
---|
[242] | 140 |
|
---|
[294] | 141 | .pushAndPrintSerial:
|
---|
[242] | 142 | .pushAndPrint:
|
---|
[277] | 143 | %endif
|
---|
[294] | 144 |
|
---|
[233] | 145 | push cx ; Push print string
|
---|
| 146 | push ax ; Push high order digits, or port address, or N/A
|
---|
| 147 | push dx ; Push low order digit, or N/A
|
---|
| 148 |
|
---|
[334] | 149 | mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
|
---|
| 150 |
|
---|
[386] | 151 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
[196] | 152 |
|
---|
| 153 |
|
---|
[3] | 154 | ;--------------------------------------------------------------------
|
---|
[397] | 155 | ; DetectPrint_DriveNameFromDrvDetectInfoInESBX
|
---|
[3] | 156 | ; Parameters:
|
---|
[397] | 157 | ; ES:BX: Ptr to DRVDETECTINFO (if drive found)
|
---|
[3] | 158 | ; Returns:
|
---|
| 159 | ; Nothing
|
---|
| 160 | ; Corrupts registers:
|
---|
[88] | 161 | ; AX, SI
|
---|
[3] | 162 | ;--------------------------------------------------------------------
|
---|
[397] | 163 | DetectPrint_DriveNameFromDrvDetectInfoInESBX:
|
---|
[88] | 164 | push di
|
---|
| 165 | push bx
|
---|
| 166 |
|
---|
[397] | 167 | lea si, [bx+DRVDETECTINFO.szDrvName]
|
---|
[88] | 168 | mov bx, es
|
---|
| 169 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
|
---|
| 170 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
| 171 |
|
---|
| 172 | pop bx
|
---|
| 173 | pop di
|
---|
| 174 | ret
|
---|
[386] | 175 |
|
---|
| 176 | ;--------------------------------------------------------------------
|
---|
| 177 | ; DetectPrint_FailedToLoadFirstSector
|
---|
| 178 | ; Parameters:
|
---|
| 179 | ; AH: INT 13h error code
|
---|
| 180 | ; Returns:
|
---|
| 181 | ; Nothing
|
---|
| 182 | ; Corrupts registers:
|
---|
| 183 | ; AX, CX, SI, DI
|
---|
| 184 | ;--------------------------------------------------------------------
|
---|
| 185 | DetectPrint_FailedToLoadFirstSector:
|
---|
| 186 | push bp
|
---|
| 187 | mov bp, sp
|
---|
| 188 | eMOVZX cx, ah
|
---|
| 189 | push cx ; Push INT 13h error code
|
---|
| 190 | mov si, g_szReadError
|
---|
| 191 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
| 192 |
|
---|
| 193 |
|
---|
| 194 | ;--------------------------------------------------------------------
|
---|
| 195 | ; DetectPrint_TryToBootFromDL
|
---|
| 196 | ; Parameters:
|
---|
| 197 | ; DL: Drive to boot from (translated, 00h or 80h)
|
---|
| 198 | ; DS: RAMVARS segment
|
---|
| 199 | ; Returns:
|
---|
| 200 | ; Nothing
|
---|
| 201 | ; Corrupts registers:
|
---|
[392] | 202 | ; AX, DH, SI, DI
|
---|
[386] | 203 | ;--------------------------------------------------------------------
|
---|
| 204 | DetectPrint_TryToBootFromDL:
|
---|
| 205 | push bp
|
---|
| 206 | mov bp, sp
|
---|
| 207 |
|
---|
[395] | 208 | %ifdef MODULE_HOTKEYS
|
---|
| 209 |
|
---|
[392] | 210 | call DriveXlate_ToOrBack ; DL = Untranslated Drive number
|
---|
| 211 | mov dh, dl
|
---|
| 212 | call DriveXlate_ToOrBack ; DL = Translated Drive number
|
---|
[386] | 213 |
|
---|
[392] | 214 | call HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
|
---|
| 215 | xchg dl, dh
|
---|
| 216 | call HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
|
---|
| 217 | push dx
|
---|
| 218 | xchg dl, dh
|
---|
| 219 | push dx
|
---|
[386] | 220 |
|
---|
[395] | 221 | call HotkeyBar_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
|
---|
[392] | 222 |
|
---|
[395] | 223 | %else
|
---|
| 224 | ePUSH_T ax, ' ' ; No drive translation so print space
|
---|
| 225 |
|
---|
| 226 | ; Get boot drive letters
|
---|
| 227 | call FloppyDrive_GetCountToAX
|
---|
| 228 | mov ah, 'A' ; AH = First Floppy Drive letter (always 'A')
|
---|
| 229 | add al, ah
|
---|
| 230 | MAX_U al, 'C' ; AL = First Hard Drive letter ('C', 'D', or 'E')
|
---|
| 231 | test dl, dl
|
---|
| 232 | eCMOVNS al, ah
|
---|
| 233 | push ax
|
---|
| 234 |
|
---|
| 235 | %endif ; MODULE_HOTKEYS
|
---|
| 236 |
|
---|
[386] | 237 | mov si, g_szTryToBoot
|
---|
| 238 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 | ;--------------------------------------------------------------------
|
---|
| 242 | ; DetectPrint_NullTerminatedStringFromCSSIandSetCF
|
---|
| 243 | ; Parameters:
|
---|
| 244 | ; CS:SI: Ptr to NULL terminated string to print
|
---|
| 245 | ; Returns:
|
---|
| 246 | ; CF: Set since menu event was handled successfully
|
---|
| 247 | ; Corrupts registers:
|
---|
| 248 | ; AX, DI
|
---|
| 249 | ;--------------------------------------------------------------------
|
---|
| 250 | DetectPrint_NullTerminatedStringFromCSSIandSetCF:
|
---|
| 251 | ;
|
---|
| 252 | ; We send all CSSI strings through the Format routine for the case of
|
---|
| 253 | ; compressed strings, but this doesn't hurt in the non-compressed case either
|
---|
| 254 | ; (perhaps a little slower, but shouldn't be noticeable to the user)
|
---|
| 255 | ; and results in smaller code size.
|
---|
| 256 | ;
|
---|
| 257 | push bp
|
---|
| 258 | mov bp,sp
|
---|
[392] | 259 | ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
[386] | 260 |
|
---|
| 261 | ;--------------------------------------------------------------------
|
---|
| 262 | ; DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
| 263 | ; Parameters:
|
---|
| 264 | ; CS:SI: Ptr to string to format
|
---|
| 265 | ; BP: SP before pushing parameters
|
---|
| 266 | ; Returns:
|
---|
| 267 | ; BP: Popped from stack
|
---|
| 268 | ; CF: Set since menu event was handled successfully
|
---|
| 269 | ; Corrupts registers:
|
---|
| 270 | ; AX, DI
|
---|
| 271 | ;--------------------------------------------------------------------
|
---|
| 272 | DetectPrint_FormatCSSIfromParamsInSSBP:
|
---|
| 273 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 274 | stc ; Successful return from menu event
|
---|
| 275 | pop bp
|
---|
| 276 | ret
|
---|