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

Last change on this file since 380 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 5.4 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;--------------------------------------------------------------------
24; Prints BIOS name and segment address where it is found.
25;
26; DetectPrint_RomFoundAtSegment
27; Parameters:
28; Nothing
29; Returns:
30; Nothing
31; Corrupts registers:
[120]32; AX, SI, DI
[3]33;--------------------------------------------------------------------
34DetectPrint_RomFoundAtSegment:
[88]35 push bp
[97]36 mov bp, sp
[3]37 mov si, g_szRomAt
[88]38 ePUSH_T ax, ROMVARS.szTitle ; Bios title string
39 push cs ; BIOS segment
[242]40
41DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
[88]42 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
[3]43
44
45;--------------------------------------------------------------------
[294]46; DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
[3]47; Parameters:
[233]48; CS:CX: Ptr to "Master" or "Slave" string
[3]49; CS:BP: Ptr to IDEVARS
[242]50; SI: Ptr to template string
[3]51; Returns:
52; Nothing
53; Corrupts registers:
[196]54; AX, SI, DI, CX
[3]55;--------------------------------------------------------------------
[294]56DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP:
[233]57 mov ax, [cs:bp+IDEVARS.wPort] ; for IDE: AX=port address, DH=.bDevice
58 mov dx, [cs:bp+IDEVARS.bDevice-1] ; for Serial: AL=port address>>2, AH=baud rate
59 ; DL=COM number character, DH=.bDevice
[285]60%ifdef MODULE_JRIDE
61 cmp dh, DEVICE_JRIDE_ISA
62 eCMOVE ax, cs ; Use segment address for JR-IDE/ISA
63%endif
64
[242]65 push bp ; setup stack for call to
[233]66 mov bp, sp ; BootMenuPrint_FormatCSSIfromParamsInSSBP
67
68 push cx ; Push "Master" or "Slave"
[242]69
[233]70 mov cl, (g_szDetectPort-$$) & 0xff ; Setup print string for standard IDE
71 ; Note that we modify only the low order bits of CX a lot here,
72 ; saving code space rather than reloading CX completely.
73 ; This optimization requires that all the g_szDetect* strings are
74 ; on the same 256 byte page, which is checked in strings.asm.
[3]75
[277]76%ifdef MODULE_SERIAL
[244]77 cmp dh, DEVICE_SERIAL_PORT ; Check if this is a serial device
[233]78
[244]79 jnz .pushAndPrint ; CX = string to print, AX = port address, DX won't be used
[233]80
81 mov cl, (g_szDetectCOM-$$) & 0xff ; Setup print string for COM ports
82 push cx ; And push now. We use the fact that format strings can contain
83 ; themselves format strings.
84
85 push dx ; Push COM number character
[242]86 ; If the string is going to be "Auto", we will push a NULL (zero)
87 ; here for the COM port number, which will be eaten by the
88 ; print routine (DisplayPrint_CharacterFromAL), resulting in
[235]89 ; just "COM" being printed without a character after it.
[242]90
[233]91 mov cl, (g_szDetectCOMAuto-$$) & 0xff ; Setup secondary print string for "Auto"
[242]92
[244]93 test dl, dl ; Check if serial port "Auto"
[262]94 jz .pushAndPrintSerial ; CX = string to print, AX and DX won't be used
[242]95
[233]96 mov cl, (g_szDetectCOMLarge-$$) & 0xff ; Setup secondary print string for "COMn/xx.yK"
[3]97
[233]98 mov al,ah ; baud rate divisor to AL
99 cbw ; clear AH, AL will always be less than 128
100 xchg si,ax ; move AX to SI for divide
[242]101 mov ax,1152 ; baud rate to display is 115200/divisor, the "00" is handled
[233]102 ; in the print strings
[242]103 cwd ; clear top 16-bits of dividend
[233]104 div si ; and divide... Now AX = baud rate/100, DX = 0 (always a clean divide)
[242]105
[233]106 mov si,10 ; Now separate the whole portion from the fractional for "K" display
107 div si ; and divide... Now AX = baud rate/1000, DX = low order digit
[242]108
109 cmp ax,si ; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
[262]110 jae .pushAndPrintSerial
[196]111
[233]112 mov cl, (g_szDetectCOMSmall-$$) & 0xff ; Setup secondary print string for "COMn/XXy00"
[242]113
[294]114.pushAndPrintSerial:
[242]115.pushAndPrint:
[277]116%endif
[294]117
[233]118 push cx ; Push print string
119 push ax ; Push high order digits, or port address, or N/A
120 push dx ; Push low order digit, or N/A
121
[334]122 mov si, g_szDetectOuter ; Load SI with default wrapper string "IDE %s at %s: "
123
[242]124 jmp short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
[196]125
126
[3]127;--------------------------------------------------------------------
[98]128; DetectPrint_DriveNameFromBootnfoInESBX
[3]129; Parameters:
[254]130; ES:BX: Ptr to BOOTMENUINFO (if drive found)
[3]131; Returns:
132; Nothing
133; Corrupts registers:
[88]134; AX, SI
[3]135;--------------------------------------------------------------------
[98]136DetectPrint_DriveNameFromBootnfoInESBX:
[88]137 push di
138 push bx
139
[254]140 lea si, [bx+BOOTMENUINFO.szDrvName]
[88]141 mov bx, es
142 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
143 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
144
145 pop bx
146 pop di
147 ret
Note: See TracBrowser for help on using the repository browser.