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

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

Changes to XTIDE Universal BIOS:

  • Boot menu is now an optional module (MODULE_BOOT_MENU).
File size: 8.1 KB
RevLine 
[88]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for printing drive detection strings.
3
[376]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
[3]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[386]24; BootMenuPrint_InitializeDisplayContext
25; Parameters:
26; Nothing
27; Returns:
28; Nothing
29; Corrupts registers:
30; AX, DI
31;--------------------------------------------------------------------
32BootMenuPrint_InitializeDisplayContext:
33 CALL_DISPLAY_LIBRARY InitializeDisplayContext
34 ret
35
36
37;--------------------------------------------------------------------
[3]38; Prints BIOS name and segment address where it is found.
39;
40; DetectPrint_RomFoundAtSegment
41; Parameters:
42; Nothing
43; Returns:
44; Nothing
45; Corrupts registers:
[120]46; AX, SI, DI
[3]47;--------------------------------------------------------------------
48DetectPrint_RomFoundAtSegment:
[88]49 push bp
[97]50 mov bp, sp
[3]51 mov si, g_szRomAt
[88]52 ePUSH_T ax, ROMVARS.szTitle ; Bios title string
53 push cs ; BIOS segment
[242]54
[386]55 jmp DetectPrint_FormatCSSIfromParamsInSSBP
[3]56
57
58;--------------------------------------------------------------------
[294]59; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
[3]60; Parameters:
[233]61; CS:CX: Ptr to "Master" or "Slave" string
[3]62; CS:BP: Ptr to IDEVARS
[242]63; SI: Ptr to template string
[3]64; Returns:
65; Nothing
66; Corrupts registers:
[196]67; AX, SI, DI, CX
[3]68;--------------------------------------------------------------------
[294]69DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
[233]70 mov ax, [cs:bp+IDEVARS.wPort] ; for IDE: AX=port address, DH=.bDevice
71 mov dx, [cs:bp+IDEVARS.bDevice-1] ; for Serial: AL=port address>>2, AH=baud rate
72 ; DL=COM number character, DH=.bDevice
[285]73%ifdef MODULE_JRIDE
74 cmp dh, DEVICE_JRIDE_ISA
75 eCMOVE ax, cs ; Use segment address for JR-IDE/ISA
76%endif
77
[242]78 push bp ; setup stack for call to
[233]79 mov bp, sp ; BootMenuPrint_FormatCSSIfromParamsInSSBP
80
81 push cx ; Push "Master" or "Slave"
[242]82
[233]83 mov cl, (g_szDetectPort-$$) & 0xff ; Setup print string for standard IDE
84 ; Note that we modify only the low order bits of CX a lot here,
85 ; saving code space rather than reloading CX completely.
86 ; This optimization requires that all the g_szDetect* strings are
87 ; on the same 256 byte page, which is checked in strings.asm.
[3]88
[277]89%ifdef MODULE_SERIAL
[244]90 cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
[233]91
[244]92 jnz .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
[233]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
[242]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
[235]102 ; just "COM" being printed without a character after it.
[242]103
[233]104 mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
[242]105
[244]106 test dl, dl ; Check if serial port "Auto"
[262]107 jz .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
[242]108
[233]109 mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
[3]110
[233]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
[242]114 mov ax,1152 ; baud rate to display is 115200/divisor, the "00" is handled
[233]115 ; in the print strings
[242]116 cwd ; clear top 16-bits of dividend
[233]117 div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
[242]118
[233]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
[242]121
122 cmp ax,si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
[262]123 jae .pushAndPrintSerial
[196]124
[233]125 mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
[242]126
[294]127.pushAndPrintSerial:
[242]128.pushAndPrint:
[277]129%endif
[294]130
[233]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
[334]135 mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
136
[386]137 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[196]138
139
[3]140;--------------------------------------------------------------------
[98]141; DetectPrint_DriveNameFromBootnfoInESBX
[3]142; Parameters:
[254]143; ES:BX: Ptr to BOOTMENUINFO (if drive found)
[3]144; Returns:
145; Nothing
146; Corrupts registers:
[88]147; AX, SI
[3]148;--------------------------------------------------------------------
[98]149DetectPrint_DriveNameFromBootnfoInESBX:
[88]150 push di
151 push bx
152
[254]153 lea si, [bx+BOOTMENUINFO.szDrvName]
[88]154 mov bx, es
155 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
156 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
157
158 pop bx
159 pop di
160 ret
[386]161
162;--------------------------------------------------------------------
163; DetectPrint_FailedToLoadFirstSector
164; Parameters:
165; AH: INT 13h error code
166; Returns:
167; Nothing
168; Corrupts registers:
169; AX, CX, SI, DI
170;--------------------------------------------------------------------
171DetectPrint_FailedToLoadFirstSector:
172 push bp
173 mov bp, sp
174 eMOVZX cx, ah
175 push cx ; Push INT 13h error code
176 mov si, g_szReadError
177 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
178
179
180;--------------------------------------------------------------------
181; DetectPrint_TryToBootFromDL
182; Parameters:
183; DL: Drive to boot from (translated, 00h or 80h)
184; DS: RAMVARS segment
185; Returns:
186; Nothing
187; Corrupts registers:
188; AX, SI, DI
189;--------------------------------------------------------------------
190DetectPrint_TryToBootFromDL:
191 push bp
192 mov bp, sp
193
194 mov ax, g_szHDD
195 test dl, dl
196 js SHORT .NotFDD
197 mov ax, g_szFDD
198.NotFDD:
199 push ax
200
201 call DriveXlate_ToOrBack
202 push dx ; Push untranslated drive number
203 call DriveXlate_ToOrBack
204 push dx ; Push translated drive number
205
206 mov si, g_szTryToBoot
207 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
208
209
210;--------------------------------------------------------------------
211; DetectPrint_NullTerminatedStringFromCSSIandSetCF
212; Parameters:
213; CS:SI: Ptr to NULL terminated string to print
214; Returns:
215; CF: Set since menu event was handled successfully
216; Corrupts registers:
217; AX, DI
218;--------------------------------------------------------------------
219DetectPrint_NullTerminatedStringFromCSSIandSetCF:
220;
221; We send all CSSI strings through the Format routine for the case of
222; compressed strings, but this doesn't hurt in the non-compressed case either
223; (perhaps a little slower, but shouldn't be noticeable to the user)
224; and results in smaller code size.
225;
226 push bp
227 mov bp,sp
228 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
229
230;--------------------------------------------------------------------
231; DetectPrint_FormatCSSIfromParamsInSSBP
232; Parameters:
233; CS:SI: Ptr to string to format
234; BP: SP before pushing parameters
235; Returns:
236; BP: Popped from stack
237; CF: Set since menu event was handled successfully
238; Corrupts registers:
239; AX, DI
240;--------------------------------------------------------------------
241DetectPrint_FormatCSSIfromParamsInSSBP:
242 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
243 stc ; Successful return from menu event
244 pop bp
245 ret
Note: See TracBrowser for help on using the repository browser.