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