source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm@ 619

Last change on this file since 619 was 603, checked in by Krister Nordvall, 4 years ago

Changes:

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