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

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

Changes to XTIDE Universal BIOS:

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