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
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; DetectPrint_InitializeDisplayContext
|
---|
25 | ; Parameters:
|
---|
26 | ; Nothing
|
---|
27 | ; Returns:
|
---|
28 | ; Nothing
|
---|
29 | ; Corrupts registers:
|
---|
30 | ; AX, DI
|
---|
31 | ;--------------------------------------------------------------------
|
---|
32 | DetectPrint_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 | ;--------------------------------------------------------------------
|
---|
46 | DetectPrint_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 | ;--------------------------------------------------------------------
|
---|
61 | DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
|
---|
62 | mov ax, [cs:bp+IDEVARS.wBasePort] ; For IDE: AX=port address, DH=.bDevice
|
---|
63 | ; Fall 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 | ;--------------------------------------------------------------------
|
---|
76 | DetectPrint_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 | jne SHORT .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
|
---|
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
|
---|
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
|
---|
102 | ; just "COM" being printed without a character after it.
|
---|
103 |
|
---|
104 | mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
|
---|
105 |
|
---|
106 | test dl, dl ; Check if serial port "Auto"
|
---|
107 | jz SHORT .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
|
---|
108 |
|
---|
109 | mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
|
---|
110 |
|
---|
111 | mov al, ah ; baud rate divisor to AL
|
---|
112 | cbw ; clear AH, AL will always be less than 128
|
---|
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
|
---|
115 | ; in the print strings
|
---|
116 | cwd ; clear top 16-bits of dividend
|
---|
117 | div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
|
---|
118 |
|
---|
119 | mov si, 10 ; Now separate the whole portion from the fractional for "K" display
|
---|
120 | div si ; and divide... Now AX = baud rate/1000, DX = low order digit
|
---|
121 |
|
---|
122 | cmp ax, si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
|
---|
123 | jae SHORT .pushAndPrintSerial
|
---|
124 |
|
---|
125 | mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
|
---|
126 |
|
---|
127 | .pushAndPrintSerial:
|
---|
128 | .pushAndPrint:
|
---|
129 | %endif
|
---|
130 |
|
---|
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 |
|
---|
135 | mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
|
---|
136 |
|
---|
137 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
138 |
|
---|
139 |
|
---|
140 | ;--------------------------------------------------------------------
|
---|
141 | ; DetectPrint_DriveNameFromDrvDetectInfoInESBX
|
---|
142 | ; Parameters:
|
---|
143 | ; ES:BX: Ptr to DRVDETECTINFO (if drive found)
|
---|
144 | ; Returns:
|
---|
145 | ; Nothing
|
---|
146 | ; Corrupts registers:
|
---|
147 | ; AX, SI, DI
|
---|
148 | ;--------------------------------------------------------------------
|
---|
149 | DetectPrint_DriveNameFromDrvDetectInfoInESBX:
|
---|
150 | push bp
|
---|
151 | mov bp, sp
|
---|
152 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
153 | %if DRVDETECTINFO.szDrvName = 0
|
---|
154 | push bx
|
---|
155 | %else
|
---|
156 | lea si, [bx+DRVDETECTINFO.szDrvName]
|
---|
157 | push si
|
---|
158 | %endif
|
---|
159 | %endif
|
---|
160 | mov si, g_szDriveName
|
---|
161 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
162 |
|
---|
163 |
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | ; Prints BIOS name and segment address where it is found.
|
---|
166 | ;
|
---|
167 | ; DetectPrint_RomFoundAtSegment
|
---|
168 | ; Parameters:
|
---|
169 | ; Nothing
|
---|
170 | ; Returns:
|
---|
171 | ; Nothing
|
---|
172 | ; Corrupts registers:
|
---|
173 | ; AX, SI, DI
|
---|
174 | ;--------------------------------------------------------------------
|
---|
175 | DetectPrint_RomFoundAtSegment:
|
---|
176 | mov si, g_szRomAt
|
---|
177 | mov di, cs ; BIOS segment address, for later inclusion in the output, parameterized
|
---|
178 | ; so that it can be a different value when using .BootMenuEntry
|
---|
179 |
|
---|
180 | .BootMenuEntry:
|
---|
181 | push bp
|
---|
182 | mov bp, sp
|
---|
183 |
|
---|
184 | %ifndef USE_186
|
---|
185 | mov ax, ROMVARS.szTitle
|
---|
186 | push ax
|
---|
187 | push di ; BIOS segment
|
---|
188 | mov al, ROMVARS.szVersion & 0FFh
|
---|
189 | push ax
|
---|
190 | %else
|
---|
191 | ; szTitle and szVersion have the high order byte of their addresses zero,
|
---|
192 | ; so these push instructions are only 2 bytes
|
---|
193 | ;
|
---|
194 | push ROMVARS.szTitle
|
---|
195 | push di ; BIOS segment
|
---|
196 | push ROMVARS.szVersion
|
---|
197 | %endif
|
---|
198 |
|
---|
199 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
200 |
|
---|
201 |
|
---|
202 | ;--------------------------------------------------------------------
|
---|
203 | ; DetectPrint_FailedToLoadFirstSector
|
---|
204 | ; Parameters:
|
---|
205 | ; AH: INT 13h error code
|
---|
206 | ; Returns:
|
---|
207 | ; CF: Set
|
---|
208 | ; Corrupts registers:
|
---|
209 | ; AX, CX, SI, DI
|
---|
210 | ;--------------------------------------------------------------------
|
---|
211 | DetectPrint_FailedToLoadFirstSector:
|
---|
212 | push bp
|
---|
213 | mov bp, sp
|
---|
214 | eMOVZX cx, ah
|
---|
215 | push cx ; Push INT 13h error code
|
---|
216 | mov si, g_szReadError
|
---|
217 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP ; Sets CF
|
---|
218 |
|
---|
219 |
|
---|
220 | ;--------------------------------------------------------------------
|
---|
221 | ; DetectPrint_TryToBootFromDL
|
---|
222 | ; Parameters:
|
---|
223 | ; DL: Drive to boot from (translated, 00h or 80h)
|
---|
224 | ; DS: RAMVARS segment
|
---|
225 | ; Returns:
|
---|
226 | ; Nothing
|
---|
227 | ; Corrupts registers:
|
---|
228 | ; AX, DH, SI, DI
|
---|
229 | ;--------------------------------------------------------------------
|
---|
230 | DetectPrint_TryToBootFromDL:
|
---|
231 | push bp
|
---|
232 | mov bp, sp
|
---|
233 |
|
---|
234 | %ifdef MODULE_DRIVEXLATE
|
---|
235 |
|
---|
236 | call DriveXlate_ToOrBack ; DL = Untranslated Drive number
|
---|
237 | mov dh, dl
|
---|
238 | call DriveXlate_ToOrBack ; DL = Translated Drive number
|
---|
239 |
|
---|
240 | call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
|
---|
241 | xchg dl, dh
|
---|
242 | call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
|
---|
243 | push dx
|
---|
244 | xchg dl, dh
|
---|
245 | push dx
|
---|
246 |
|
---|
247 | call DriveXlate_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
|
---|
248 |
|
---|
249 | %else
|
---|
250 | ePUSH_T ax, ' ' ; No drive translation so print space
|
---|
251 |
|
---|
252 | ; Get boot drive letters
|
---|
253 | call BootVars_GetLetterForFirstHardDriveToAX
|
---|
254 | test dl, dl
|
---|
255 | eCMOVNS al, DEFAULT_FLOPPY_DRIVE_LETTER
|
---|
256 | push ax
|
---|
257 |
|
---|
258 | %endif ; MODULE_DRIVEXLATE
|
---|
259 |
|
---|
260 | mov si, g_szTryToBoot
|
---|
261 | jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
262 |
|
---|
263 |
|
---|
264 | ;--------------------------------------------------------------------
|
---|
265 | ; DetectPrint_NullTerminatedStringFromCSSI
|
---|
266 | ; DetectPrint_NullTerminatedStringFromCSSIandSetCF
|
---|
267 | ; Parameters:
|
---|
268 | ; CS:SI: Ptr to NULL terminated string to print
|
---|
269 | ; Returns:
|
---|
270 | ; CF: Set since menu event was handled successfully
|
---|
271 | ; Corrupts registers:
|
---|
272 | ; AX, DI
|
---|
273 | ;--------------------------------------------------------------------
|
---|
274 | DetectPrint_NullTerminatedStringFromCSSI:
|
---|
275 | DetectPrint_NullTerminatedStringFromCSSIandSetCF:
|
---|
276 | ;
|
---|
277 | ; We send all CSSI strings through the Format routine for the case of
|
---|
278 | ; compressed strings, but this doesn't hurt in the non-compressed case either
|
---|
279 | ; (perhaps a little slower, but shouldn't be noticeable to the user)
|
---|
280 | ; and results in smaller code size.
|
---|
281 | ;
|
---|
282 | push bp
|
---|
283 | mov bp, sp
|
---|
284 | ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
285 |
|
---|
286 | ;--------------------------------------------------------------------
|
---|
287 | ; DetectPrint_FormatCSSIfromParamsInSSBP
|
---|
288 | ; Parameters:
|
---|
289 | ; CS:SI: Ptr to string to format
|
---|
290 | ; BP: SP before pushing parameters
|
---|
291 | ; Returns:
|
---|
292 | ; BP: Popped from stack
|
---|
293 | ; CF: Set since menu event was handled successfully
|
---|
294 | ; Corrupts registers:
|
---|
295 | ; AX, DI
|
---|
296 | ;--------------------------------------------------------------------
|
---|
297 | DetectPrint_FormatCSSIfromParamsInSSBP:
|
---|
298 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
299 | stc ; Successful return from menu event
|
---|
300 | pop bp
|
---|
301 | ret
|
---|