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

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

Changes to XTIDE Universal BIOS:

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