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