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

Last change on this file since 503 was 492, checked in by gregli@…, 12 years ago

Removed the dependency between MODULE_BOOT_MENU and MODULE_HOTKEYS. With these changes, 0, 1, or 2 of them can be included in a build. This change also means that the hotkeys don't work while the menu is up. But the most important hotkey there was for Rom Boot, and that has been added to the menu as a choice proper. Lots of changes across the board in the hotkeys code - even if we eventually back this change out (becaue, for example we want hotkeys to work in the menu) we should probably start from this base and add that functionality back in, as these changes results in approximately 120 bytes of savings and includes new functionality, such as the Rom Boot menu item and the Com Detect hotkey.

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