source: xtideuniversalbios/trunk/Assembly_Library/Src/Serial/SerialServerScan.asm@ 576

Last change on this file since 576 was 567, checked in by krille_n_@…, 11 years ago

Changes:

  • Renamed MODULE_FEATURE_SETS to MODULE_POWER_MANAGEMENT.
  • Renamed MODULE_VERY_LATE_INITIALIZATION to MODULE_VERY_LATE_INIT and removed it from the official builds.
  • Removed the code that skips detection of slave drives on XT-CF controllers since slave drives can be used with Lo-tech ISA CompactFlash boards.
  • Added autodetection of the SVC ADP50L controller to XTIDECFG.
  • The autodetection of XT-CF controllers now requires MODULE_8BIT_IDE_ADVANCED in the loaded BIOS.
  • Fixed a bug in XTIDECFG from r502 where the "Base (cmd block) address" menu option would be displayed when a serial device was selected as the IDE controller.
  • XTIDECFG would display the "Enable interrupt" menu option for the XTIDE r1 but not for the XTIDE r2. It's now displayed for both controller types.
  • Disabled the "Internal Write Cache" menu option in the Master/Slave Drive menus for serial device type drives.
  • Optimizations and other fixes.
File size: 4.8 KB
RevLine 
[277]1; Project name : Assembly Library
2; Description : Serial Server Support, Scan for Server
3;
4; This functionality is broken out from SerialServer as it may only be needed during
5; initialization to find a server, and then could be discarded, (for example the case
6; of a TSR).
7
[376]8;
[526]9; XTIDE Universal BIOS and Associated Tools
10; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]11;
12; This program is free software; you can redistribute it and/or modify
13; it under the terms of the GNU General Public License as published by
14; the Free Software Foundation; either version 2 of the License, or
15; (at your option) any later version.
[526]16;
[376]17; This program is distributed in the hope that it will be useful,
18; but WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[526]20; GNU General Public License for more details.
[376]21; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22;
23
[526]24
[277]25%include "SerialServer.inc"
[526]26
[277]27; Section containing code
28SECTION .text
[526]29
[277]30;--------------------------------------------------------------------
[526]31; SerialServerScan_ScanForServer:
[277]32; Parameters:
[567]33; BH: Drive Select byte for Drive and Head Select Register
34; 0xAx: Scan for drive, low nibble indicates drive
35; 0x0: Scan for Server, independent of drives
[277]36; DX: Port and Baud to Scan for
37; 0: Scan a known set of ports and bauds
38; ES:SI: Ptr to buffer for return
39; Returns:
40; CF: Cleared if success, Set if error
41; Corrupts registers:
42; AL, BX, CX, DX, DI
43;--------------------------------------------------------------------
[526]44SerialServerScan_ScanForServer:
[277]45 mov cx, 1 ; one sector, not scanning (default)
46
47 test dx, dx
48 jnz short SerialServerScan_CheckForServer_PortAndBaudInDX
49
50 mov di,.scanPortAddresses-1
51 mov ch,1 ; tell server that we are scanning
52
53.nextPort:
54 inc di ; load next port address
55 xor dh, dh
56 mov dl,[cs:di]
57 eSHL_IM dx, 2 ; shift from one byte to two
58 stc ; setup error code for exit
59 jz .error
60
61;
62; Test for COM port presence, write to and read from registers
63;
64 push dx
65 add dl,Serial_UART_lineControl
66 mov al, 09ah
67 out dx, al
68 in al, dx
69 pop dx
70 cmp al, 09ah
71 jnz .nextPort
72
73 mov al, 0ch
74 out dx, al
75 in al, dx
76 cmp al, 0ch
77 jnz .nextPort
78
79;
80; Begin baud rate scan on this port...
81;
82; On a scan, we support 6 baud rates, starting here and going higher by a factor of two each step, with a
83; small jump between 9600 and 38800. These 6 were selected since we wanted to support 9600 baud and 115200,
84; *on the server side* if the client side had a 4x clock multiplier, a 2x clock multiplier, or no clock multiplier.
85;
86; Starting with 30h, that means 30h (2400 baud), 18h (4800 baud), 0ch (9600 baud), and
87; 04h (28800 baud), 02h (57600 baud), 01h (115200 baud)
88;
89; Note: hardware baud multipliers (2x, 4x) will impact the final baud rate and are not known at this level
90;
[567]91 mov dh,030h * 2 ; multiply by 2 since we are about to divide by 2
[277]92 mov dl,[cs:di] ; restore single byte port address for scan
93
94.nextBaud:
95 shr dh,1
96 jz .nextPort
97 cmp dh,6 ; skip from 6 to 4, to move from the top of the 9600 baud range
98 jnz .testBaud ; to the bottom of the 115200 baud range
99 mov dh,4
100
101.testBaud:
102 call SerialServerScan_CheckForServer_PortAndBaudInDX
103 jc .nextBaud
104
[526]105.error:
[277]106 ret
107
108.scanPortAddresses: db SERIAL_COM7_IOADDRESS >> 2
109 db SERIAL_COM6_IOADDRESS >> 2
110 db SERIAL_COM5_IOADDRESS >> 2
111 db SERIAL_COM4_IOADDRESS >> 2
112 db SERIAL_COM3_IOADDRESS >> 2
113 db SERIAL_COM2_IOADDRESS >> 2
114 db SERIAL_COM1_IOADDRESS >> 2
115 db 0
116
[526]117
[277]118;--------------------------------------------------------------------
119; SerialServer_CheckForServer_PortAndBaudInDX:
120; Parameters:
[567]121; BH: Drive Select byte for Drive and Head Select Register
122; 0xAx: Scan for drive, low nibble indicates drive
123; 0x0: Scan for Server, independent of drives
[277]124; DX: Baud and Port
125; CH: 1: We are doing a scan for the serial server
[567]126; 0: We are working off a specific port given by the user
[277]127; CL: 1, for one sector to read
128; ES:SI: Ptr to buffer for return
129; Returns:
130; AH: INT 13h Error Code
131; CF: Cleared if success, Set if error
132; Corrupts registers:
133; AL, BX
134;--------------------------------------------------------------------
135SerialServerScan_CheckForServer_PortAndBaudInDX:
136 push bp ; setup fake SerialServer_Command
137
138 push dx ; send port baud and rate, returned in inquire packet
139 ; (and possibly returned in the drive identification string)
140
141 push cx ; send number of sectors, and if it is on a scan or not
142
143 mov bl,SerialServer_Command_Inquire ; protocol command onto stack with bh
144 push bx
145
146 mov bp,sp
[526]147
[277]148 call SerialServer_SendReceive
149
150 pop bx
151 pop cx
152 pop dx
153 pop bp
154
155 ret
156
Note: See TracBrowser for help on using the repository browser.