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

Last change on this file since 602 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
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;
[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:
[567]62 mov ax, [cs:bp+IDEVARS.wBasePort] ; For IDE: AX=port address, DH=.bDevice
63 ; Fall 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:
[567]77 mov dx, [cs:bp+IDEVARS.bDevice-1] ; For Serial: AL=port address>>2, AH=baud rate
[233]78 ; DL=COM number character, DH=.bDevice
[567]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
[567]91 cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
[589]92 jne SHORT .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"
[589]107 jz SHORT .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
[589]111 mov al, ah ; baud rate divisor to AL
[233]112 cbw ; clear AH, AL will always be less than 128
[589]113 xchg si, ax ; move AX to SI for divide
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
[589]119 mov si, 10 ; Now separate the whole portion from the fractional for "K" display
[233]120 div si ; and divide... Now AX = baud rate/1000, DX = low order digit
[242]121
[589]122 cmp ax, si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
123 jae SHORT .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;--------------------------------------------------------------------
[397]141; DetectPrint_DriveNameFromDrvDetectInfoInESBX
[3]142; Parameters:
[397]143; ES:BX: Ptr to DRVDETECTINFO (if drive found)
[3]144; Returns:
145; Nothing
146; Corrupts registers:
[489]147; AX, SI, DI
[3]148;--------------------------------------------------------------------
[397]149DetectPrint_DriveNameFromDrvDetectInfoInESBX:
[489]150 push bp
[589]151 mov bp, sp
[592]152%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
153%if DRVDETECTINFO.szDrvName = 0
154 push bx
155%else
[589]156 lea si, [bx+DRVDETECTINFO.szDrvName]
[489]157 push si
[592]158%endif
159%endif
[589]160 mov si, g_szDriveName
[489]161 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[88]162
[505]163
[489]164;--------------------------------------------------------------------
165; Prints BIOS name and segment address where it is found.
166;
167; DetectPrint_RomFoundAtSegment
168; Parameters:
169; Nothing
170; Returns:
171; Nothing
172; Corrupts registers:
173; AX, SI, DI
174;--------------------------------------------------------------------
175DetectPrint_RomFoundAtSegment:
176 mov si, g_szRomAt
177 mov di, cs ; BIOS segment address, for later inclusion in the output, parameterized
178 ; so that it can be a different value when using .BootMenuEntry
[88]179
[505]180.BootMenuEntry:
[489]181 push bp
182 mov bp, sp
[386]183
[489]184%ifndef USE_186
185 mov ax, ROMVARS.szTitle
186 push ax
187 push di ; BIOS segment
[568]188 mov al, ROMVARS.szVersion & 0FFh
[489]189 push ax
190%else
[505]191 ; szTitle and szVersion have the high order byte of their addresses zero,
[489]192 ; so these push instructions are only 2 bytes
193 ;
194 push ROMVARS.szTitle
195 push di ; BIOS segment
196 push ROMVARS.szVersion
197%endif
198
199 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
200
201
[386]202;--------------------------------------------------------------------
203; DetectPrint_FailedToLoadFirstSector
204; Parameters:
205; AH: INT 13h error code
206; Returns:
[521]207; CF: Set
[386]208; Corrupts registers:
209; AX, CX, SI, DI
210;--------------------------------------------------------------------
211DetectPrint_FailedToLoadFirstSector:
212 push bp
213 mov bp, sp
214 eMOVZX cx, ah
215 push cx ; Push INT 13h error code
216 mov si, g_szReadError
[521]217 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP ; Sets CF
[386]218
219
220;--------------------------------------------------------------------
221; DetectPrint_TryToBootFromDL
222; Parameters:
223; DL: Drive to boot from (translated, 00h or 80h)
224; DS: RAMVARS segment
225; Returns:
226; Nothing
227; Corrupts registers:
[392]228; AX, DH, SI, DI
[386]229;--------------------------------------------------------------------
230DetectPrint_TryToBootFromDL:
231 push bp
232 mov bp, sp
233
[492]234%ifdef MODULE_DRIVEXLATE
[395]235
[392]236 call DriveXlate_ToOrBack ; DL = Untranslated Drive number
237 mov dh, dl
238 call DriveXlate_ToOrBack ; DL = Translated Drive number
[386]239
[492]240 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
[392]241 xchg dl, dh
[492]242 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
[392]243 push dx
244 xchg dl, dh
245 push dx
[386]246
[492]247 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
[392]248
[395]249%else
250 ePUSH_T ax, ' ' ; No drive translation so print space
251
252 ; Get boot drive letters
[547]253 call BootVars_GetLetterForFirstHardDriveToAX
[395]254 test dl, dl
[547]255 eCMOVNS al, DEFAULT_FLOPPY_DRIVE_LETTER
[395]256 push ax
257
[492]258%endif ; MODULE_DRIVEXLATE
[395]259
[386]260 mov si, g_szTryToBoot
[505]261 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[386]262
263
264;--------------------------------------------------------------------
[521]265; DetectPrint_NullTerminatedStringFromCSSI
[386]266; DetectPrint_NullTerminatedStringFromCSSIandSetCF
267; Parameters:
268; CS:SI: Ptr to NULL terminated string to print
269; Returns:
270; CF: Set since menu event was handled successfully
271; Corrupts registers:
272; AX, DI
273;--------------------------------------------------------------------
[521]274DetectPrint_NullTerminatedStringFromCSSI:
[386]275DetectPrint_NullTerminatedStringFromCSSIandSetCF:
276;
277; We send all CSSI strings through the Format routine for the case of
278; compressed strings, but this doesn't hurt in the non-compressed case either
279; (perhaps a little slower, but shouldn't be noticeable to the user)
280; and results in smaller code size.
281;
282 push bp
[589]283 mov bp, sp
[392]284 ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
[386]285
286;--------------------------------------------------------------------
287; DetectPrint_FormatCSSIfromParamsInSSBP
288; Parameters:
289; CS:SI: Ptr to string to format
290; BP: SP before pushing parameters
291; Returns:
292; BP: Popped from stack
293; CF: Set since menu event was handled successfully
294; Corrupts registers:
295; AX, DI
296;--------------------------------------------------------------------
297DetectPrint_FormatCSSIfromParamsInSSBP:
298 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
299 stc ; Successful return from menu event
300 pop bp
301 ret
Note: See TracBrowser for help on using the repository browser.