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

Last change on this file since 590 was 589, checked in by Krister Nordvall, 9 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
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:
[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
152 lea si, [bx+DRVDETECTINFO.szDrvName]
[489]153 push si
[589]154 mov si, g_szDriveName
[489]155 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[88]156
[505]157
[489]158;--------------------------------------------------------------------
159; Prints BIOS name and segment address where it is found.
160;
161; DetectPrint_RomFoundAtSegment
162; Parameters:
163; Nothing
164; Returns:
165; Nothing
166; Corrupts registers:
167; AX, SI, DI
168;--------------------------------------------------------------------
169DetectPrint_RomFoundAtSegment:
170 mov si, g_szRomAt
171 mov di, cs ; BIOS segment address, for later inclusion in the output, parameterized
172 ; so that it can be a different value when using .BootMenuEntry
[88]173
[505]174.BootMenuEntry:
[489]175 push bp
176 mov bp, sp
[386]177
[489]178%ifndef USE_186
179 mov ax, ROMVARS.szTitle
180 push ax
181 push di ; BIOS segment
[568]182 mov al, ROMVARS.szVersion & 0FFh
[489]183 push ax
184%else
[505]185 ; szTitle and szVersion have the high order byte of their addresses zero,
[489]186 ; so these push instructions are only 2 bytes
187 ;
188 push ROMVARS.szTitle
189 push di ; BIOS segment
190 push ROMVARS.szVersion
191%endif
192
193 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
194
195
[386]196;--------------------------------------------------------------------
197; DetectPrint_FailedToLoadFirstSector
198; Parameters:
199; AH: INT 13h error code
200; Returns:
[521]201; CF: Set
[386]202; Corrupts registers:
203; AX, CX, SI, DI
204;--------------------------------------------------------------------
205DetectPrint_FailedToLoadFirstSector:
206 push bp
207 mov bp, sp
208 eMOVZX cx, ah
209 push cx ; Push INT 13h error code
210 mov si, g_szReadError
[521]211 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP ; Sets CF
[386]212
213
214;--------------------------------------------------------------------
215; DetectPrint_TryToBootFromDL
216; Parameters:
217; DL: Drive to boot from (translated, 00h or 80h)
218; DS: RAMVARS segment
219; Returns:
220; Nothing
221; Corrupts registers:
[392]222; AX, DH, SI, DI
[386]223;--------------------------------------------------------------------
224DetectPrint_TryToBootFromDL:
225 push bp
226 mov bp, sp
227
[492]228%ifdef MODULE_DRIVEXLATE
[395]229
[392]230 call DriveXlate_ToOrBack ; DL = Untranslated Drive number
231 mov dh, dl
232 call DriveXlate_ToOrBack ; DL = Translated Drive number
[386]233
[492]234 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Translated letter
[392]235 xchg dl, dh
[492]236 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter ; DL = Untranslated letter
[392]237 push dx
238 xchg dl, dh
239 push dx
[386]240
[492]241 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber ; Restore DL
[392]242
[395]243%else
244 ePUSH_T ax, ' ' ; No drive translation so print space
245
246 ; Get boot drive letters
[547]247 call BootVars_GetLetterForFirstHardDriveToAX
[395]248 test dl, dl
[547]249 eCMOVNS al, DEFAULT_FLOPPY_DRIVE_LETTER
[395]250 push ax
251
[492]252%endif ; MODULE_DRIVEXLATE
[395]253
[386]254 mov si, g_szTryToBoot
[505]255 jmp SHORT DetectPrint_FormatCSSIfromParamsInSSBP
[386]256
257
258;--------------------------------------------------------------------
[521]259; DetectPrint_NullTerminatedStringFromCSSI
[386]260; DetectPrint_NullTerminatedStringFromCSSIandSetCF
261; Parameters:
262; CS:SI: Ptr to NULL terminated string to print
263; Returns:
264; CF: Set since menu event was handled successfully
265; Corrupts registers:
266; AX, DI
267;--------------------------------------------------------------------
[521]268DetectPrint_NullTerminatedStringFromCSSI:
[386]269DetectPrint_NullTerminatedStringFromCSSIandSetCF:
270;
271; We send all CSSI strings through the Format routine for the case of
272; compressed strings, but this doesn't hurt in the non-compressed case either
273; (perhaps a little slower, but shouldn't be noticeable to the user)
274; and results in smaller code size.
275;
276 push bp
[589]277 mov bp, sp
[392]278 ; Fall to DetectPrint_FormatCSSIfromParamsInSSBP
[386]279
280;--------------------------------------------------------------------
281; DetectPrint_FormatCSSIfromParamsInSSBP
282; Parameters:
283; CS:SI: Ptr to string to format
284; BP: SP before pushing parameters
285; Returns:
286; BP: Popped from stack
287; CF: Set since menu event was handled successfully
288; Corrupts registers:
289; AX, DI
290;--------------------------------------------------------------------
291DetectPrint_FormatCSSIfromParamsInSSBP:
292 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
293 stc ; Successful return from menu event
294 pop bp
295 ret
Note: See TracBrowser for help on using the repository browser.