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

Last change on this file since 317 was 294, checked in by krille_n_@…, 12 years ago

Commit 2/2 (BIOS):

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