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

Last change on this file since 240 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
RevLine 
[150]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
[238]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
[150]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
[160]31; CS:BP: Ptr to IDEVARS for the controller
[150]32; Returns:
33; Nothing
34; Corrupts registers:
35; AX, BX, CX, DX
36;--------------------------------------------------------------------
[181]37%ifdef MODULE_SERIAL
[150]38Device_FinalizeDPT:
[238]39 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE .FinalizeDptForSerialPortDevice
[150]40 jmp IdeDPT_Finalize
[175]41.FinalizeDptForSerialPortDevice:
[181]42 jmp SerialDPT_Finalize
[238]43
44%else ; IDE or JR-IDE/ISA
[181]45 Device_FinalizeDPT EQU IdeDPT_Finalize
[175]46%endif
[150]47
[181]48
[150]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;--------------------------------------------------------------------
[238]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
[150]73Device_ResetMasterAndSlaveController:
[238]74 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
[181]75 jmp IdeCommand_ResetMasterAndSlaveController
[238]76
77%else ; IDE
[181]78 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
[175]79%endif
[150]80
[238]81%ifdef MODULE_JRIDE
82.ResetJrIDE:
83 jmp MemIdeCommand_ResetMasterAndSlaveController
84%endif
[150]85
[238]86
[150]87;--------------------------------------------------------------------
88; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
89; Parameters:
90; BH: Drive Select byte for Drive and Head Select Register
91; DS: Segment to RAMVARS
[218]92; ES:SI: Ptr to normalized buffer to receive 512-byte IDE Information
[150]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;--------------------------------------------------------------------
[238]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
[150]114Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
[238]115 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
[150]116 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[181]117
[238]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
[150]128.IdentifyDriveFromSerialPort:
129 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[175]130%endif
[150]131
[181]132
[150]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
[218]138; ES:SI: Ptr to normalized buffer (for data transfer commands)
[150]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;--------------------------------------------------------------------
[238]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
[150]161Device_OutputCommandWithParameters:
[238]162 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
[150]163 jmp IdeCommand_OutputWithParameters
[181]164
[238]165%else ; IDE
166 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
167%endif
168
169%ifdef MODULE_JRIDE
[150]170ALIGN JUMP_ALIGN
[238]171.OutputCommandToJrIDE:
172 jmp MemIdeCommand_OutputWithParameters
173%endif
174
175%ifdef MODULE_SERIAL
176ALIGN JUMP_ALIGN
[150]177.OutputCommandToSerialPort:
178 jmp SerialCommand_OutputWithParameters
[175]179%endif
[150]180
[181]181
[150]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;--------------------------------------------------------------------
[238]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
[150]207Device_SelectDrive:
[238]208 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE ReturnSuccessForSerialPort
[150]209 jmp IdeCommand_SelectDrive
[181]210
[238]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
[150]223ReturnSuccessForSerialPort:
224 xor ax, ax
225 ret
[175]226%endif
Note: See TracBrowser for help on using the repository browser.