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

Last change on this file since 515 was 505, checked in by krille_n_@…, 12 years ago

Changes:

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