source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm@ 612

Last change on this file since 612 was 601, checked in by Krister Nordvall, 6 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: 8.2 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Serial Device Command functions.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
20; Section containing code
21SECTION .text
22
23%define SERIALSERVER_AH_ALREADY_HAS_COMMAND_BYTE
24%define SERIALSERVER_NO_ZERO_SECTOR_COUNTS
25
26;--------------------------------------------------------------------
27; SerialCommand_OutputWithParameters
28; Parameters:
29; BH: Non-zero if 48-bit addressing used
30; (ignored at present as 48-bit addressing is not supported)
31; BL: IDE Status Register bit to poll after command
32; (ignored at present, since there is no IDE status register to poll)
33; ES:SI: Ptr to buffer (for data transfer commands)
34; DS:DI: Ptr to DPT (in RAMVARS segment)
35; SS:BP: Ptr to IDEREGS_AND_INTPACK
36; Returns:
37; AH: INT 13h Error Code
38; CX: Number of successfully transferred sectors (for transfer commands)
39; CF: Cleared if success, Set if error
40; Corrupts registers:
41; AL, BX, CX, DX, (ES:SI for data transfer commands)
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44SerialCommand_OutputWithParameters:
45 mov ah, SerialServer_Command_Read
46 mov al, [bp+IDEPACK.bCommand]
47
48 cmp al, 20h ; Read Sectors IDE command
49 je SHORT .readOrWrite
50 inc ah ; now SerialServer_Protocol_Write
51 cmp al, 30h ; Write Sectors IDE command
52 je SHORT .readOrWrite
53
54; all other commands return success
55; including function 0ech which should return drive information, this is handled with the identify functions
56;
57 xor ah, ah ; also clears carry
58 ret
59
60.readOrWrite:
61 mov [bp+IDEPACK.bFeatures], ah ; store protocol command
62%ifdef USE_AT
63 mov dh, [bp+IDEPACK.bSectorCount]
64%endif
65 call IdeTransfer_NormalizePointerInESSI
66%ifdef USE_AT
67 jnc SHORT .PointerNormalizationWasSuccessful
68 xor cx, cx ; Nothing transferred
69 stc
70 ret
71.PointerNormalizationWasSuccessful:
72%endif
73
74 mov dx, [di+DPT_SERIAL.wSerialPortAndBaud]
75; fall through to SerialCommand_FallThroughToSerialServer_SendReceive
76
77ALIGN JUMP_ALIGN
78SerialCommand_FallThroughToSerialServer_SendReceive:
79; fall through to SerialServer_SendReceive
80%include "SerialServer.asm"
81
82%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
83 %if SerialCommand_FallThroughToSerialServer_SendReceive <> SerialServer_SendReceive
84 %error "SerialServer_SendReceive must be the first routine at the top of SerialServer.asm in the Assembly_Library"
85 %endif
86%endif
87
88ALIGN JUMP_ALIGN
89SerialCommand_ReturnError:
90 stc
91 ret
92
93;--------------------------------------------------------------------
94; SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
95; Parameters:
96; BH: Drive Select byte for Drive and Head Select Register
97; DS: Segment to RAMVARS
98; ES:SI: Ptr to buffer to receive 512-byte IDE Information
99; CS:BP: Ptr to IDEVARS
100; Returns:
101; CF: Cleared if success, Set if error
102; Corrupts registers:
103; AL, BL, CX, DX, SI, DI, ES
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
107;
108; To improve boot time, we do our best to avoid looking for slave serial drives when we already know the results
109; from the looking for a master. This is particularly true when doing a COM port scan, as we will end up running
110; through all the COM ports and baud rates a second time.
111;
112; But drive detection isn't the only case - we also need to get the right drive when called on int13h/25h.
113;
114; The decision tree:
115;
116; Master:
117; wSerialPortAndBaud Non-Zero: -> Continue with wSerialPortAndBaud (1)
118; wSerialPortAndBaud Zero:
119; previous serial drive not found: -> Scan (2)
120; previous serial drive found: -> Continue with previous serial drive info (3)
121;
122; Slave:
123; wSerialPortAndBaud Non-Zero:
124; previous serial drive not found: -> Error - Not Found (4)
125; previous serial drive found: -> Continue with wSerialPackedAndBaud (5)
126; wSerialPortAndBaud Zero:
127; previous serial drive not found: -> Error - Not Found (4)
128; previous serial drive found: -> Continue with previous serial drive info (6)
129;
130; (1) This was a port/baud that was explicitly set with the configurator. In the drive detection case, as this
131; is the Master, we are checking out a new controller, and so don't care if we already have a serial drive.
132; And as with the int13h/25h case, we just go off and get the needed information using the user's setting.
133; (2) We are using the special .ideVarsSerialAuto structure. During drive detection, we would only be here
134; if we hadn't already seen a serial drive (since we only scan if no explicit drives are set),
135; so we go off to scan.
136; (3) We are using the special .ideVarsSerialAuto structure. We won't get here during drive detection, but
137; we might get here on an int13h/25h call. If we have scanned COM drives, they are the ONLY serial drives
138; in use, and so we use the values from the previously seen serial drive DPT.
139; (4) No master has been found yet, therefore no slave should be found. Avoiding the slave reduces boot time,
140; especially in the full COM port scan case. Note that this is different from the hardware IDE, where we
141; will scan for a slave even if a master is not present. Note that if ANY master had been previously found,
142; we will do the slave scan, which isn't harmful, it just wastes time. But the most common case (by a wide
143; margin) will be just one serial controller.
144; (5) A COM port scan for a master had been previously completed, and a drive was found. In a multiple serial
145; controller scenario being called with int13h/25h, we need to use the value in bSerialPackedPortAndBaud
146; to make sure we get the proper drive.
147; (6) A COM port scan for a master had been previously completed, and a drive was found. We would only get here
148; if no serial drive was explicitly set by the user in the configurator or that drive had not been found.
149; Instead of performing the full COM port scan for the slave, use the port/baud value stored during the
150; master scan.
151;
152 mov dx, [cs:bp+IDEVARS.wSerialPortAndBaud]
153 xor ax, ax
154
155 push si
156 call FindDPT_ToDSDIforSerialDevice
157 pop si
158%ifdef MODULE_SERIAL_FLOPPY
159 jnc SHORT .founddpt
160;
161; If not found above with FindDPT_ToDSDIforSerialDevice, DI will point to the DPT after the last hard disk DPT
162; So, if there was a previously found floppy disk, DI will point to that DPT and we use that value for the slave.
163;
164 cmp BYTE [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], 0
165 je SHORT .notfounddpt
166.founddpt:
167%else
168 jc SHORT .notfounddpt
169%endif
170 mov ax, [di+DPT_SERIAL.wSerialPortAndBaud]
171.notfounddpt:
172 test bh, FLG_DRVNHEAD_DRV
173 jz SHORT .master
174
175 test ax, ax ; Take care of the case that is different between master and slave.
176 jz SHORT SerialCommand_ReturnError
177
178; fall-through
179.master:
180 test dx, dx
181 jnz SHORT .identifyDeviceInDX
182
183 xchg dx, ax ; move ax to dx (move previously found serial drive to dx, could be zero)
184
185.identifyDeviceInDX:
186; fall through to SerialCommand_FallThroughToSerialServerScan_ScanForServer
187
188ALIGN JUMP_ALIGN
189SerialCommand_FallThroughToSerialServerScan_ScanForServer:
190; fall through to SerialServerScan_ScanForServer
191%include "SerialServerScan.asm"
192
193%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
194 %if SerialCommand_FallThroughToSerialServerScan_ScanForServer <> SerialServerScan_ScanForServer
195 %error "SerialServerScan_ScanForServer must be the first routine at the top of SerialServerScan.asm in the Assembly_Library"
196 %endif
197%endif
198
Note: See TracBrowser for help on using the repository browser.