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

Last change on this file since 623 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
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for printing drive detection strings.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; DetectPrint_InitializeDisplayContext
25; Parameters:
26; Nothing
27; Returns:
28; Nothing
29; Corrupts registers:
30; AX, DI
31;--------------------------------------------------------------------
32DetectPrint_InitializeDisplayContext:
33 JMP_DISPLAY_LIBRARY InitializeDisplayContext
34
35
36;--------------------------------------------------------------------
37; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
38; Parameters:
39; CS:CX: Ptr to "Master" or "Slave" string
40; CS:BP: Ptr to IDEVARS
41; Returns:
42; Nothing
43; Corrupts registers:
44; AX, CX, DX, SI, DI
45;--------------------------------------------------------------------
46DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
47 mov ax, [cs:bp+IDEVARS.wBasePort] ; For IDE: AX=port address, DH=.bDevice
48 ; Fall to DetectPrint_StartDetectWithAutodetectedBasePortInAXandIdeVarsInCSBP
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
60;--------------------------------------------------------------------
61DetectPrint_StartDetectWithAutodetectedBasePortInAXandIdeVarsInCSBP:
62 mov dx, [cs:bp+IDEVARS.bDevice-1] ; For Serial: AL=port address>>2, AH=baud rate
63 ; DL=COM number character, DH=.bDevice
64 push bp ; Setup stack for call to
65 mov bp, sp ; BootMenuPrint_FormatCSSIfromParamsInSSBP
66
67 push cx ; Push "Master" or "Slave"
68
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.
74
75%ifdef MODULE_SERIAL
76 cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
77 jne SHORT .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
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
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
87 ; just "COM" being printed without a character after it.
88
89 mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
90
91 test dl, dl ; Check if serial port "Auto"
92 jz SHORT .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
93
94 mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
95
96 mov al, ah ; baud rate divisor to AL
97 cbw ; clear AH, AL will always be less than 128
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
100 ; in the print strings
101 cwd ; clear top 16-bits of dividend
102 div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
103
104 mov si, 10 ; Now separate the whole portion from the fractional for "K" display
105 div si ; and divide... Now AX = baud rate/1000, DX = low order digit
106
107 cmp ax, si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
108 jae SHORT .pushAndPrintSerial
109
110 mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
111
112.pushAndPrintSerial:
113.pushAndPrint:
114%endif
115
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
120 mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
121
122 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
123
124
125;--------------------------------------------------------------------
126; DetectPrint_DriveNameFromDrvDetectInfoInESBX
127; Parameters:
128; ES:BX: Ptr to DRVDETECTINFO (if drive found)
129; Returns:
130; Nothing
131; Corrupts registers:
132; AX, SI, DI
133;--------------------------------------------------------------------
134DetectPrint_DriveNameFromDrvDetectInfoInESBX:
135 push bp
136 mov bp, sp
137%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
138%if DRVDETECTINFO.szDrvName = 0
139 push bx
140%else
141 lea si, [bx+DRVDETECTINFO.szDrvName]
142 push si
143%endif
144%endif
145 mov si, g_szDriveName
146 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
147
148
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
164
165.BootMenuEntry:
166 push bp
167 mov bp, sp
168
169%ifndef USE_186
170 mov ax, ROMVARS.szTitle
171 push ax
172 push di ; BIOS segment
173 mov al, ROMVARS.szVersion & 0FFh
174 push ax
175%else
176 ; szTitle and szVersion have the high order byte of their addresses zero,
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
187;--------------------------------------------------------------------
188; DetectPrint_FailedToLoadFirstSector
189; Parameters:
190; AH: INT 13h error code
191; Returns:
192; CF: Set
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
202 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP ; Sets CF
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:
213; AX, DH, SI, DI
214;--------------------------------------------------------------------
215DetectPrint_TryToBootFromDL:
216 push bp
217 mov bp, sp
218
219%ifdef MODULE_DRIVEXLATE
220
221 call DriveXlate_ToOrBack ; DL = Untranslated Drive number
222 mov dh, dl
223 call DriveXlate_ToOrBack ; DL = Translated Drive number
224
225 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
226 xchg dl, dh
227 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
228 push dx
229 xchg dl, dh
230 push dx
231
232 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
233
234%else
235 ePUSH_T ax, ' ' ; No drive translation so print space
236
237 ; Get boot drive letters
238 call BootVars_GetLetterForFirstHardDriveToAX
239 test dl, dl
240 eCMOVNS al, DEFAULT_FLOPPY_DRIVE_LETTER
241 push ax
242
243%endif ; MODULE_DRIVEXLATE
244
245 mov si, g_szTryToBoot
246 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
247
248
249;--------------------------------------------------------------------
250; DetectPrint_NullTerminatedStringFromCSSI
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;--------------------------------------------------------------------
259DetectPrint_NullTerminatedStringFromCSSI:
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
268 mov bp, sp
269 ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
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.