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

Last change on this file since 345 was 334, checked in by gregli@…, 13 years ago

Serial server DPT flag optimization, remove Serial/IDE specific header on drive scan results, added GNU GPL v2 banner at boot.

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