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

Last change on this file since 595 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: 4.9 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
[589]48 jnz SHORT SerialServerScan_CheckForServer_PortAndBaudInDX
[277]49
[589]50 mov di, .scanPortAddresses-1
51 mov ch, 1 ; tell server that we are scanning
[277]52
53.nextPort:
54 inc di ; load next port address
[589]55 mov dh, 40h ; Clear DH and make sure CF is set if error
56 mov dl, [cs:di]
[277]57 eSHL_IM dx, 2 ; shift from one byte to two
[589]58 jz SHORT .error
[277]59
60;
61; Test for COM port presence, write to and read from registers
62;
63 push dx
[589]64 add dl, Serial_UART_lineControl
65 mov al, 9Ah
[277]66 out dx, al
67 in al, dx
68 pop dx
[589]69 cmp al, 9Ah
70 jne SHORT .nextPort
[277]71
[589]72 mov al, 0Ch
[277]73 out dx, al
74 in al, dx
[589]75 cmp al, 0Ch
76 jne SHORT .nextPort
[277]77
78;
79; Begin baud rate scan on this port...
80;
81; On a scan, we support 6 baud rates, starting here and going higher by a factor of two each step, with a
82; small jump between 9600 and 38800. These 6 were selected since we wanted to support 9600 baud and 115200,
83; *on the server side* if the client side had a 4x clock multiplier, a 2x clock multiplier, or no clock multiplier.
84;
[589]85; Starting with 30h, that means 30h (2400 baud), 18h (4800 baud), 0Ch (9600 baud), and
[277]86; 04h (28800 baud), 02h (57600 baud), 01h (115200 baud)
87;
[589]88; Note: hardware baud multipliers (2x, 4x, 8x) will impact the final baud rate and are not known at this level
[277]89;
[589]90 mov dh, 30h * 2 ; multiply by 2 since we are about to divide by 2
91 mov dl, [cs:di] ; restore single byte port address for scan
[277]92
93.nextBaud:
[589]94 shr dh, 1
95 jz SHORT .nextPort
96 cmp dh, 6 ; skip from 6 to 4, to move from the top of the 9600 baud range
97 jne SHORT .testBaud ; to the bottom of the 115200 baud range
98 mov dh, 4
[277]99
100.testBaud:
101 call SerialServerScan_CheckForServer_PortAndBaudInDX
[589]102 jc SHORT .nextBaud
[277]103
[526]104.error:
[277]105 ret
106
107.scanPortAddresses: db SERIAL_COM7_IOADDRESS >> 2
108 db SERIAL_COM6_IOADDRESS >> 2
109 db SERIAL_COM5_IOADDRESS >> 2
110 db SERIAL_COM4_IOADDRESS >> 2
111 db SERIAL_COM3_IOADDRESS >> 2
112 db SERIAL_COM2_IOADDRESS >> 2
113 db SERIAL_COM1_IOADDRESS >> 2
114 db 0
115
[526]116
[277]117;--------------------------------------------------------------------
118; SerialServer_CheckForServer_PortAndBaudInDX:
119; Parameters:
[567]120; BH: Drive Select byte for Drive and Head Select Register
121; 0xAx: Scan for drive, low nibble indicates drive
122; 0x0: Scan for Server, independent of drives
[277]123; DX: Baud and Port
124; CH: 1: We are doing a scan for the serial server
[567]125; 0: We are working off a specific port given by the user
[277]126; CL: 1, for one sector to read
127; ES:SI: Ptr to buffer for return
128; Returns:
129; AH: INT 13h Error Code
130; CF: Cleared if success, Set if error
131; Corrupts registers:
132; AL, BX
133;--------------------------------------------------------------------
134SerialServerScan_CheckForServer_PortAndBaudInDX:
135 push bp ; setup fake SerialServer_Command
136 push dx ; send port baud and rate, returned in inquire packet
137 ; (and possibly returned in the drive identification string)
138 push cx ; send number of sectors, and if it is on a scan or not
[589]139 mov bl, SerialServer_Command_Inquire ; protocol command onto stack with bh
[277]140 push bx
141
[589]142 mov bp, sp
[277]143 call SerialServer_SendReceive
144
145 pop bx
146 pop cx
147 pop dx
148 pop bp
149
150 ret
151
Note: See TracBrowser for help on using the repository browser.