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

Last change on this file since 601 was 601, checked in by krille_n_, 5 years ago

Changes:

  • Building the BIOS now works again.
  • Added a new IDE device type/transfer mode for use only with XT-IDE rev 2+ (or Chuck(G)-modded rev 1) cards installed in any of the following machines: Olivetti M24, AT&T PC6300, Xerox 6060 and Logabax Persona 1600. This new transfer mode is slightly faster than the regular XT-IDE rev 1 device type and requires that the card is configured for High Speed mode (or, in case of the card being a rev 1 card, has the Chuck(G) mod done). The new device type is called "XTIDE rev 2 (Olivetti M24)" in XTIDECFG.
  • Made some minor improvements to the library code that handles 'Drive Not Ready' errors in XTIDECFG.
  • Optimizations.
File size: 4.8 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   Serial Server Support, Scan for Server
3
4;
5; This functionality is broken out from SerialServer as it may only be needed during
6; initialization to find a server, and then could be discarded, (for example the case
7; of a TSR).
8
9;
10; XTIDE Universal BIOS and Associated Tools
11; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
12;
13; This program is free software; you can redistribute it and/or modify
14; it under the terms of the GNU General Public License as published by
15; the Free Software Foundation; either version 2 of the License, or
16; (at your option) any later version.
17;
18; This program is distributed in the hope that it will be useful,
19; but WITHOUT ANY WARRANTY; without even the implied warranty of
20; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21; GNU General Public License for more details.
22; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23;
24
25
26%include "SerialServer.inc"
27
28; Section containing code
29SECTION .text
30
31;--------------------------------------------------------------------
32; SerialServerScan_ScanForServer:
33;   Parameters:
34;       BH:     Drive Select byte for Drive and Head Select Register
35;               0xAx: Scan for drive, low nibble indicates drive
36;               0x0:  Scan for Server, independent of drives
37;       DX:     Port and Baud to Scan for
38;               0: Scan a known set of ports and bauds
39;       ES:SI:  Ptr to buffer for return
40;   Returns:
41;       CF:     Cleared if success, Set if error
42;   Corrupts registers:
43;       AL, BX, CX, DX, DI
44;--------------------------------------------------------------------
45SerialServerScan_ScanForServer:
46    mov     cx, 1           ; one sector, not scanning (default)
47
48    test    dx, dx
49    jnz     SHORT SerialServerScan_CheckForServer_PortAndBaudInDX
50
51    mov     di, .scanPortAddresses-1
52    mov     ch, 1           ;  tell server that we are scanning
53
54.nextPort:
55    inc     di              ; load next port address
56    mov     dh, 40h         ; Clear DH and make sure CF is set if error
57    mov     dl, [cs:di]
58    eSHL_IM dx, 2           ; shift from one byte to two
59    jz      SHORT .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, 9Ah
67    out     dx, al
68    in      al, dx
69    pop     dx
70    cmp     al, 9Ah
71    jne     SHORT .nextPort
72
73    mov     al, 0Ch
74    out     dx, al
75    in      al, dx
76    cmp     al, 0Ch
77    jne     SHORT .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, 8x) will impact the final baud rate and are not known at this level
90;
91    mov     dh, 30h * 2     ; multiply by 2 since we are about to divide by 2
92    mov     dl, [cs:di]     ; restore single byte port address for scan
93
94.nextBaud:
95    shr     dh, 1
96    jz      SHORT .nextPort
97    cmp     dh, 6           ; skip from 6 to 4, to move from the top of the 9600 baud range
98    jne     SHORT .testBaud ; to the bottom of the 115200 baud range
99    mov     dh, 4
100
101.testBaud:
102    call    SerialServerScan_CheckForServer_PortAndBaudInDX
103    jc      SHORT .nextBaud
104
105.error:
106    ret
107
108.scanPortAddresses:
109    db  SERIAL_COM7_IOADDRESS >> 2
110    db  SERIAL_COM6_IOADDRESS >> 2
111    db  SERIAL_COM5_IOADDRESS >> 2
112    db  SERIAL_COM4_IOADDRESS >> 2
113    db  SERIAL_COM3_IOADDRESS >> 2
114    db  SERIAL_COM2_IOADDRESS >> 2
115    db  SERIAL_COM1_IOADDRESS >> 2
116    db  0
117
118
119;--------------------------------------------------------------------
120; SerialServer_CheckForServer_PortAndBaudInDX:
121;   Parameters:
122;       BH:     Drive Select byte for Drive and Head Select Register
123;               0xAx: Scan for drive, low nibble indicates drive
124;               0x0:  Scan for Server, independent of drives
125;       DX:     Baud and Port
126;       CH:     1: We are doing a scan for the serial server
127;               0: We are working off a specific port given by the user
128;       CL:     1, for one sector to read
129;       ES:SI:  Ptr to buffer for return
130;   Returns:
131;       AH:     INT 13h Error Code
132;       CF:     Cleared if success, Set if error
133;   Corrupts registers:
134;       AL, BX
135;--------------------------------------------------------------------
136SerialServerScan_CheckForServer_PortAndBaudInDX:
137    push    bp              ; setup fake SerialServer_Command
138    push    dx              ; send port baud and rate, returned in inquire packet
139                            ; (and possibly returned in the drive identification string)
140    push    cx              ; send number of sectors, and if it is on a scan or not
141    mov     bl, SerialServer_Command_Inquire        ; protocol command onto stack with bh
142    push    bx
143
144    mov     bp, sp
145    call    SerialServer_SendReceive
146
147    pop     bx
148    pop     cx
149    pop     dx
150    pop     bp
151
152    ret
153
Note: See TracBrowser for help on using the repository browser.