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

Last change on this file since 477 was 474, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

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