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

Last change on this file since 492 was 492, checked in by gregli@…, 11 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
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;--------------------------------------------------------------------
[392]24; DetectPrint_InitializeDisplayContext
[386]25;   Parameters:
26;       Nothing
27;   Returns:
28;       Nothing
29;   Corrupts registers:
30;       AX, DI
31;--------------------------------------------------------------------
[392]32DetectPrint_InitializeDisplayContext:
33    CALL_DISPLAY_LIBRARY    InitializeDisplayContext
[386]34    ret
35
[492]36       
37%ifdef MODULE_HOTKEYS
[386]38;--------------------------------------------------------------------
[392]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
[492]50%endif
[392]51
[492]52       
[392]53;--------------------------------------------------------------------
[294]54; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
[3]55;   Parameters:
[233]56;       CS:CX:  Ptr to "Master" or "Slave" string
[3]57;       CS:BP:  Ptr to IDEVARS
58;   Returns:
59;       Nothing
60;   Corrupts registers:
[474]61;       AX, CX, DX, SI, DI
[3]62;--------------------------------------------------------------------
[294]63DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
[473]64    mov     ax, [cs:bp+IDEVARS.wBasePort]   ; for IDE: AX=port address, DH=.bDevice
[489]65    ; fall through to DetectPrint_StartDetectWithAutodetectedBasePortInAXandIdeVarsInCSBP
[474]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:
[233]79    mov     dx, [cs:bp+IDEVARS.bDevice-1]   ; for Serial: AL=port address>>2, AH=baud rate
80                                            ;             DL=COM number character, DH=.bDevice
[242]81    push    bp                              ; setup stack for call to
[233]82    mov     bp, sp                          ; BootMenuPrint_FormatCSSIfromParamsInSSBP
83
84    push    cx                              ; Push "Master" or "Slave"
[242]85
[233]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.
[3]91
[277]92%ifdef MODULE_SERIAL
[244]93    cmp     dh, DEVICE_SERIAL_PORT          ; Check if this is a serial device
[233]94
[244]95    jnz     .pushAndPrint                   ; CX = string to print, AX = port address, DX won't be used
[233]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
[242]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
[235]105                                            ; just "COM" being printed without a character after it.
[242]106
[233]107    mov     cl, (g_szDetectCOMAuto-$$) & 0xff   ; Setup secondary print string for "Auto"
[242]108
[244]109    test    dl, dl                          ; Check if serial port "Auto"
[262]110    jz      .pushAndPrintSerial             ; CX = string to print, AX and DX won't be used
[242]111
[233]112    mov     cl, (g_szDetectCOMLarge-$$) & 0xff  ; Setup secondary print string for "COMn/xx.yK"
[3]113
[233]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
[242]117    mov     ax,1152                         ; baud rate to display is 115200/divisor, the "00" is handled
[233]118                                            ; in the print strings
[242]119    cwd                                     ; clear top 16-bits of dividend
[233]120    div     si                              ; and divide...  Now AX = baud rate/100, DX = 0 (always a clean divide)
[242]121
[233]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
[242]124
125    cmp     ax,si                           ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
[262]126    jae     .pushAndPrintSerial
[196]127
[233]128    mov     cl, (g_szDetectCOMSmall-$$) & 0xff  ; Setup secondary print string for "COMn/XXy00"
[242]129
[294]130.pushAndPrintSerial:
[242]131.pushAndPrint:
[277]132%endif
[294]133
[233]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
[334]138    mov     si, g_szDetectOuter             ; Load SI with default wrapper string "IDE %s at %s: "
139
[386]140    jmp     SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[196]141
142
[3]143;--------------------------------------------------------------------
[397]144; DetectPrint_DriveNameFromDrvDetectInfoInESBX
[3]145;   Parameters:
[397]146;       ES:BX:  Ptr to DRVDETECTINFO (if drive found)
[3]147;   Returns:
148;       Nothing
149;   Corrupts registers:
[489]150;       AX, SI, DI
[3]151;--------------------------------------------------------------------
[397]152DetectPrint_DriveNameFromDrvDetectInfoInESBX:
[489]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
[88]159
[489]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
[88]176
[489]177.BootMenuEntry: 
178    push    bp
179    mov     bp, sp
[386]180
[489]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
[386]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:
[392]225;       AX, DH, SI, DI
[386]226;--------------------------------------------------------------------
227DetectPrint_TryToBootFromDL:
228    push    bp
229    mov     bp, sp
230
[492]231%ifdef MODULE_DRIVEXLATE
[395]232
[392]233    call    DriveXlate_ToOrBack ; DL = Untranslated Drive number
234    mov     dh, dl
235    call    DriveXlate_ToOrBack ; DL = Translated Drive number
[386]236
[492]237    call    DriveXlate_ConvertDriveNumberFromDLtoDriveLetter    ; DL = Translated letter
[392]238    xchg    dl, dh
[492]239    call    DriveXlate_ConvertDriveNumberFromDLtoDriveLetter    ; DL = Untranslated letter
[392]240    push    dx
241    xchg    dl, dh
242    push    dx
[386]243
[492]244    call    DriveXlate_ConvertDriveLetterInDLtoDriveNumber  ; Restore DL
[392]245
[395]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
[492]258%endif ; MODULE_DRIVEXLATE
[395]259
[386]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
[392]282    ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
[386]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.