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

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