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

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

Changes to XTIDE Universal BIOS:

  • Hotkeys were incorrectly initialized to use 'C' as first hard drive letter.
  • All CHS translate modes should again work (incorrectly decremented DX instead of DL, it might or might not have caused problems).
File size: 9.8 KB
RevLine 
[88]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for printing drive detection strings.
3
[376]4;
[505]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[505]12;
[376]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
[505]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[505]18;
[376]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:
[505]33 JMP_DISPLAY_LIBRARY InitializeDisplayContext
[386]34
[505]35
[492]36%ifdef MODULE_HOTKEYS
[386]37;--------------------------------------------------------------------
[392]38; DetectPrint_GetSoftwareCoordinatesToAX
39; Parameters:
40; Nothing
41; Returns:
42; Nothing
43; Corrupts registers:
44; AX, DI
45;--------------------------------------------------------------------
46DetectPrint_GetSoftwareCoordinatesToAX:
[505]47 JMP_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
[492]48%endif
[392]49
[505]50
[392]51;--------------------------------------------------------------------
[294]52; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
[3]53; Parameters:
[233]54; CS:CX: Ptr to "Master" or "Slave" string
[3]55; CS:BP: Ptr to IDEVARS
56; Returns:
57; Nothing
58; Corrupts registers:
[474]59; AX, CX, DX, SI, DI
[3]60;--------------------------------------------------------------------
[294]61DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
[473]62 mov ax, [cs:bp+IDEVARS.wBasePort] ; for IDE: AX=port address, DH=.bDevice
[489]63 ; fall through to DetectPrint_StartDetectWithAutodetectedBasePortInAXandIdeVarsInCSBP
[474]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
[505]75;--------------------------------------------------------------------
[474]76DetectPrint_StartDetectWithAutodetectedBasePortInAXandIdeVarsInCSBP:
[233]77 mov dx, [cs:bp+IDEVARS.bDevice-1] ; for Serial: AL=port address>>2, AH=baud rate
78 ; DL=COM number character, DH=.bDevice
[242]79 push bp ; setup stack for call to
[233]80 mov bp, sp ; BootMenuPrint_FormatCSSIfromParamsInSSBP
81
82 push cx ; Push "Master" or "Slave"
[242]83
[233]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.
[3]89
[277]90%ifdef MODULE_SERIAL
[244]91 cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
[233]92
[244]93 jnz .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
[233]94
95 mov cl, (g_szDetectCOM-$$) & 0xff ; Setup print string for COM ports
96 push cx ; And push now. We use the fact that format strings can contain
97 ; themselves format strings.
98
99 push dx ; Push COM number character
[242]100 ; If the string is going to be "Auto", we will push a NULL (zero)
101 ; here for the COM port number, which will be eaten by the
102 ; print routine (DisplayPrint_CharacterFromAL), resulting in
[235]103 ; just "COM" being printed without a character after it.
[242]104
[233]105 mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
[242]106
[244]107 test dl, dl ; Check if serial port "Auto"
[262]108 jz .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
[242]109
[233]110 mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
[3]111
[233]112 mov al,ah ; baud rate divisor to AL
113 cbw ; clear AH, AL will always be less than 128
114 xchg si,ax ; move AX to SI for divide
[242]115 mov ax,1152 ; baud rate to display is 115200/divisor, the "00" is handled
[233]116 ; in the print strings
[242]117 cwd ; clear top 16-bits of dividend
[233]118 div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
[242]119
[233]120 mov si,10 ; Now separate the whole portion from the fractional for "K" display
121 div si ; and divide... Now AX = baud rate/1000, DX = low order digit
[242]122
123 cmp ax,si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
[262]124 jae .pushAndPrintSerial
[196]125
[233]126 mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
[242]127
[294]128.pushAndPrintSerial:
[242]129.pushAndPrint:
[277]130%endif
[294]131
[233]132 push cx ; Push print string
133 push ax ; Push high order digits, or port address, or N/A
134 push dx ; Push low order digit, or N/A
135
[334]136 mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
137
[386]138 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[196]139
140
[3]141;--------------------------------------------------------------------
[397]142; DetectPrint_DriveNameFromDrvDetectInfoInESBX
[3]143; Parameters:
[397]144; ES:BX: Ptr to DRVDETECTINFO (if drive found)
[3]145; Returns:
146; Nothing
147; Corrupts registers:
[489]148; AX, SI, DI
[3]149;--------------------------------------------------------------------
[397]150DetectPrint_DriveNameFromDrvDetectInfoInESBX:
[489]151 push bp
[505]152 mov bp,sp
[489]153 lea si,[bx+DRVDETECTINFO.szDrvName]
154 push si
155 mov si,g_szDriveName
156 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[88]157
[505]158
[489]159;--------------------------------------------------------------------
160; Prints BIOS name and segment address where it is found.
161;
162; DetectPrint_RomFoundAtSegment
163; Parameters:
164; Nothing
165; Returns:
166; Nothing
167; Corrupts registers:
168; AX, SI, DI
169;--------------------------------------------------------------------
170DetectPrint_RomFoundAtSegment:
171 mov si, g_szRomAt
172 mov di, cs ; BIOS segment address, for later inclusion in the output, parameterized
173 ; so that it can be a different value when using .BootMenuEntry
[88]174
[505]175.BootMenuEntry:
[489]176 push bp
177 mov bp, sp
[386]178
[489]179%ifndef USE_186
180 mov ax, ROMVARS.szTitle
181 push ax
182 push di ; BIOS segment
183 add al, ROMVARS.szVersion - ROMVARS.szTitle
184 push ax
185%else
[505]186 ; szTitle and szVersion have the high order byte of their addresses zero,
[489]187 ; so these push instructions are only 2 bytes
188 ;
189 push ROMVARS.szTitle
190 push di ; BIOS segment
191 push ROMVARS.szVersion
192%endif
193
194 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
195
196
[386]197;--------------------------------------------------------------------
198; DetectPrint_FailedToLoadFirstSector
199; Parameters:
200; AH: INT 13h error code
201; Returns:
[521]202; CF: Set
[386]203; Corrupts registers:
204; AX, CX, SI, DI
205;--------------------------------------------------------------------
206DetectPrint_FailedToLoadFirstSector:
207 push bp
208 mov bp, sp
209 eMOVZX cx, ah
210 push cx ; Push INT 13h error code
211 mov si, g_szReadError
[521]212 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP ; Sets CF
[386]213
214
215;--------------------------------------------------------------------
216; DetectPrint_TryToBootFromDL
217; Parameters:
218; DL: Drive to boot from (translated, 00h or 80h)
219; DS: RAMVARS segment
220; Returns:
221; Nothing
222; Corrupts registers:
[392]223; AX, DH, SI, DI
[386]224;--------------------------------------------------------------------
225DetectPrint_TryToBootFromDL:
226 push bp
227 mov bp, sp
228
[492]229%ifdef MODULE_DRIVEXLATE
[395]230
[392]231 call DriveXlate_ToOrBack ; DL = Untranslated Drive number
232 mov dh, dl
233 call DriveXlate_ToOrBack ; DL = Translated Drive number
[386]234
[492]235 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
[392]236 xchg dl, dh
[492]237 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
[392]238 push dx
239 xchg dl, dh
240 push dx
[386]241
[492]242 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
[392]243
[395]244%else
245 ePUSH_T ax, ' ' ; No drive translation so print space
246
247 ; Get boot drive letters
[547]248 call BootVars_GetLetterForFirstHardDriveToAX
[395]249 test dl, dl
[547]250 eCMOVNS al, DEFAULT_FLOPPY_DRIVE_LETTER
[395]251 push ax
252
[492]253%endif ; MODULE_DRIVEXLATE
[395]254
[386]255 mov si, g_szTryToBoot
[505]256 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[386]257
258
259;--------------------------------------------------------------------
[521]260; DetectPrint_NullTerminatedStringFromCSSI
[386]261; DetectPrint_NullTerminatedStringFromCSSIandSetCF
262; Parameters:
263; CS:SI: Ptr to NULL terminated string to print
264; Returns:
265; CF: Set since menu event was handled successfully
266; Corrupts registers:
267; AX, DI
268;--------------------------------------------------------------------
[521]269DetectPrint_NullTerminatedStringFromCSSI:
[386]270DetectPrint_NullTerminatedStringFromCSSIandSetCF:
271;
272; We send all CSSI strings through the Format routine for the case of
273; compressed strings, but this doesn't hurt in the non-compressed case either
274; (perhaps a little slower, but shouldn't be noticeable to the user)
275; and results in smaller code size.
276;
277 push bp
278 mov bp,sp
[392]279 ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
[386]280
281;--------------------------------------------------------------------
282; DetectPrint_FormatCSSIfromParamsInSSBP
283; Parameters:
284; CS:SI: Ptr to string to format
285; BP: SP before pushing parameters
286; Returns:
287; BP: Popped from stack
288; CF: Set since menu event was handled successfully
289; Corrupts registers:
290; AX, DI
291;--------------------------------------------------------------------
292DetectPrint_FormatCSSIfromParamsInSSBP:
293 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
294 stc ; Successful return from menu event
295 pop bp
296 ret
Note: See TracBrowser for help on using the repository browser.