source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm@ 272

Last change on this file since 272 was 268, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • JR-IDE/ISA support now works!
File size: 7.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Command and port direction functions for different device types.
3
4; Section containing code
5SECTION .text
6
7
8%macro TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE 1
9 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
10 jnz SHORT %1
11%endmacro
12
13%macro CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE 1
14 xchg ax, bx
15 eMOVZX bx, [di+DPT.bIdevarsOffset]
16 cmp BYTE [cs:bx+IDEVARS.bDevice], DEVICE_JRIDE_ISA
17 xchg bx, ax ; Restore BX
18 je SHORT %1
19%endmacro
20
21%macro CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF 2
22 cmp BYTE [cs:bp+IDEVARS.bDevice], %1
23 je SHORT %2
24%endmacro
25
26
27
28;--------------------------------------------------------------------
29; Device_FinalizeDPT
30; Parameters:
31; DS:DI: Ptr to Disk Parameter Table
32; ES:SI: Ptr to 512-byte ATA information read from the drive
33; CS:BP: Ptr to IDEVARS for the controller
34; Returns:
35; Nothing
36; Corrupts registers:
37; AX, BX, CX, DX
38;--------------------------------------------------------------------
39%ifdef MODULE_SERIAL
40Device_FinalizeDPT:
41 ; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine
42 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice
43 jmp IdeDPT_Finalize
44.FinalizeDptForSerialPortDevice:
45 jmp SerialDPT_Finalize
46
47%else ; IDE or JR-IDE/ISA
48 Device_FinalizeDPT EQU IdeDPT_Finalize
49%endif
50
51
52;--------------------------------------------------------------------
53; Device_ResetMasterAndSlaveController
54; Parameters:
55; DS:DI: Ptr to DPT (in RAMVARS segment)
56; Returns:
57; AH: INT 13h Error Code
58; CF: Cleared if success, Set if error
59; Corrupts registers:
60; AL, BX, CX, DX
61;--------------------------------------------------------------------
62%ifdef MODULE_JRIDE
63 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial
64 Device_ResetMasterAndSlaveController:
65 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
66 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .ResetJrIDE
67 jmp IdeCommand_ResetMasterAndSlaveController
68
69 %else ; IDE + JR-IDE/ISA
70 Device_ResetMasterAndSlaveController:
71 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .ResetJrIDE
72 jmp IdeCommand_ResetMasterAndSlaveController
73 %endif
74
75%elifdef MODULE_SERIAL ; IDE + Serial
76Device_ResetMasterAndSlaveController:
77 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
78 jmp IdeCommand_ResetMasterAndSlaveController
79
80%else ; IDE
81 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
82%endif
83
84%ifdef MODULE_JRIDE
85.ResetJrIDE:
86 jmp MemIdeCommand_ResetMasterAndSlaveController
87%endif
88
89
90;--------------------------------------------------------------------
91; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
92; Parameters:
93; BH: Drive Select byte for Drive and Head Select Register
94; DS: Segment to RAMVARS
95; ES:SI: Ptr to normalized buffer to receive 512-byte IDE Information
96; CS:BP: Ptr to IDEVARS
97; Returns:
98; AH: INT 13h Error Code
99; CF: Cleared if success, Set if error
100; Corrupts registers:
101; AL, BL, CX, DX, SI, DI, ES
102;--------------------------------------------------------------------
103%ifdef MODULE_JRIDE
104 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial
105 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
106 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
107 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_JRIDE_ISA, .IdentifyDriveFromJrIde
108 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
109
110 %else ; IDE + JR-IDE/ISA
111 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
112 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_JRIDE_ISA, .IdentifyDriveFromJrIde
113 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
114 %endif
115
116%elifdef MODULE_SERIAL ; IDE + Serial
117Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
118 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
119 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
120
121%else ; IDE
122 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
123%endif
124
125%ifdef MODULE_JRIDE
126.IdentifyDriveFromJrIde:
127 jmp MemIdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
128%endif
129
130%ifdef MODULE_SERIAL
131.IdentifyDriveFromSerialPort:
132 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
133%endif
134
135
136;--------------------------------------------------------------------
137; Device_OutputCommandWithParameters
138; Parameters:
139; BH: Default system timer ticks for timeout (can be ignored)
140; BL: IDE Status Register bit to poll after command
141; ES:SI: Ptr to normalized buffer (for data transfer commands)
142; DS:DI: Ptr to DPT (in RAMVARS segment)
143; SS:BP: Ptr to IDEPACK
144; Returns:
145; AH: INT 13h Error Code
146; CX: Number of successfully transferred sectors (for transfer commands)
147; CF: Cleared if success, Set if error
148; Corrupts registers:
149; AL, BX, (CX), DX, (ES:SI for data transfer commands)
150;--------------------------------------------------------------------
151%ifdef MODULE_JRIDE
152 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial
153 Device_OutputCommandWithParameters:
154 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
155 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .OutputCommandToJrIDE
156 jmp IdeCommand_OutputWithParameters
157
158 %else ; IDE + JR-IDE/ISA
159 Device_OutputCommandWithParameters:
160 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .OutputCommandToJrIDE
161 jmp IdeCommand_OutputWithParameters
162 %endif
163
164%elifdef MODULE_SERIAL ; IDE + Serial
165Device_OutputCommandWithParameters:
166 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
167 jmp IdeCommand_OutputWithParameters
168
169%else ; IDE
170 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
171%endif
172
173%ifdef MODULE_JRIDE
174ALIGN JUMP_ALIGN
175.OutputCommandToJrIDE:
176 jmp MemIdeCommand_OutputWithParameters
177%endif
178
179%ifdef MODULE_SERIAL
180ALIGN JUMP_ALIGN
181.OutputCommandToSerialPort:
182 jmp SerialCommand_OutputWithParameters
183%endif
184
185
186;--------------------------------------------------------------------
187; Device_SelectDrive
188; Parameters:
189; DS:DI: Ptr to DPT (in RAMVARS segment)
190; SS:BP: Ptr to IDEPACK
191; Returns:
192; AH: INT 13h Error Code
193; CF: Cleared if success, Set if error
194; Corrupts registers:
195; AL, BX, CX, DX
196;--------------------------------------------------------------------
197%ifdef MODULE_JRIDE
198 %ifdef MODULE_SERIAL ; IDE + JR-IDE/ISA + Serial
199 Device_SelectDrive:
200 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
201 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .SelectJrIdeDrive
202 jmp IdeCommand_SelectDrive
203
204 %else ; IDE + JR-IDE/ISA
205 Device_SelectDrive:
206 CMP_USING_DPT_AND_JUMP_IF_JRIDE_DEVICE .SelectJrIdeDrive
207 jmp IdeCommand_SelectDrive
208 %endif
209
210%elifdef MODULE_SERIAL ; IDE + Serial
211Device_SelectDrive:
212 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
213 jmp IdeCommand_SelectDrive
214
215%else ; IDE
216 Device_SelectDrive EQU IdeCommand_SelectDrive
217%endif
218
219%ifdef MODULE_JRIDE
220ALIGN JUMP_ALIGN
221.SelectJrIdeDrive:
222 jmp MemIdeCommand_SelectDrive
223%endif
224
225%ifdef MODULE_SERIAL
226ALIGN JUMP_ALIGN
227ReturnSuccessForSerialPort:
228 xor ax, ax
229 ret
230%endif
Note: See TracBrowser for help on using the repository browser.