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

Last change on this file since 153 was 152, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • XTIDE mod should now be supported (untested).
  • Interrupt Service Routine no longer requires variable from RAMVARS.
  • Some small improvements.
File size: 6.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
7;--------------------------------------------------------------------
8; Device_FinalizeDPT
9; Parameters:
10; DS:DI: Ptr to Disk Parameter Table
11; ES:SI: Ptr to 512-byte ATA information read from the drive
12; Returns:
13; Nothing
14; Corrupts registers:
15; AX, BX, CX, DX
16;--------------------------------------------------------------------
17Device_FinalizeDPT:
18 test WORD [di+DPT.wFlags], FLG_DPT_SERIAL_DEVICE
19 jnz SHORT ReturnSuccessForSerialPort
20 jmp IdeDPT_Finalize
21.FinalizeDptForSerialPortDevice:
22 jmp SerialDPT_Finalize
23
24
25;--------------------------------------------------------------------
26; Device_ResetMasterAndSlaveController
27; Parameters:
28; DS:DI: Ptr to DPT (in RAMVARS segment)
29; Returns:
30; AH: INT 13h Error Code
31; CF: Cleared if success, Set if error
32; Corrupts registers:
33; AL, BX, CX, DX
34;--------------------------------------------------------------------
35Device_ResetMasterAndSlaveController:
36 test WORD [di+DPT.wFlags], FLG_DPT_SERIAL_DEVICE
37 jnz SHORT ReturnSuccessForSerialPort
38 jmp IdeCommand_ResetMasterAndSlaveController
39
40
41;--------------------------------------------------------------------
42; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
43; Parameters:
44; BH: Drive Select byte for Drive and Head Select Register
45; DS: Segment to RAMVARS
46; ES:SI: Ptr to buffer to receive 512-byte IDE Information
47; CS:BP: Ptr to IDEVARS
48; Returns:
49; AH: INT 13h Error Code
50; CF: Cleared if success, Set if error
51; Corrupts registers:
52; AL, BL, CX, DX, SI, DI, ES
53;--------------------------------------------------------------------
54Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
55 cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
56 je SHORT .IdentifyDriveFromSerialPort
57 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
58.IdentifyDriveFromSerialPort:
59 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
60
61
62;--------------------------------------------------------------------
63; Device_OutputCommandWithParameters
64; Parameters:
65; BH: Default system timer ticks for timeout (can be ignored)
66; BL: IDE Status Register bit to poll after command
67; ES:SI: Ptr to buffer (for data transfer commands)
68; DS:DI: Ptr to DPT (in RAMVARS segment)
69; SS:BP: Ptr to IDEPACK
70; Returns:
71; AH: INT 13h Error Code
72; CF: Cleared if success, Set if error
73; Corrupts registers:
74; AL, BX, CX, DX, (ES:SI for data transfer commands)
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
77Device_OutputCommandWithParameters:
78 test WORD [di+DPT.wFlags], FLG_DPT_SERIAL_DEVICE
79 jnz SHORT .OutputCommandToSerialPort
80 jmp IdeCommand_OutputWithParameters
81ALIGN JUMP_ALIGN
82.OutputCommandToSerialPort:
83 jmp SerialCommand_OutputWithParameters
84
85
86;--------------------------------------------------------------------
87; Device_SelectDrive
88; Parameters:
89; DS:DI: Ptr to DPT (in RAMVARS segment)
90; SS:BP: Ptr to IDEPACK
91; Returns:
92; AH: INT 13h Error Code
93; CF: Cleared if success, Set if error
94; Corrupts registers:
95; AL, BX, CX, DX
96;--------------------------------------------------------------------
97ALIGN JUMP_ALIGN
98Device_SelectDrive:
99 test WORD [di+DPT.wFlags], FLG_DPT_SERIAL_DEVICE
100 jnz SHORT ReturnSuccessForSerialPort
101 jmp IdeCommand_SelectDrive
102ReturnSuccessForSerialPort:
103 xor ax, ax
104 ret
105
106
107;--------------------------------------------------------------------
108; Device_OutputALtoIdeRegisterInDL
109; Parameters:
110; AL: Byte to output
111; DL: IDE Register
112; DS:DI: Ptr to DPT (in RAMVARS segment)
113; Returns:
114; Nothing
115; Corrupts registers:
116; BX, DX
117;--------------------------------------------------------------------
118ALIGN JUMP_ALIGN
119Device_OutputALtoIdeRegisterInDL:
120 mov bx, IdeIO_OutputALtoIdeRegisterInDX
121 jmp SHORT TranslateRegisterAddressInDLifNecessaryThenJumpToBX
122
123
124;--------------------------------------------------------------------
125; Device_OutputALtoIdeControlBlockRegisterInDL
126; Parameters:
127; AL: Byte to output
128; DL: IDE Control Block Register
129; DS:DI: Ptr to DPT (in RAMVARS segment)
130; Returns:
131; Nothing
132; Corrupts registers:
133; BX, DX
134;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
136Device_OutputALtoIdeControlBlockRegisterInDL:
137 mov bx, IdeIO_OutputALtoIdeControlBlockRegisterInDX
138 jmp SHORT TranslateRegisterAddressInDLifNecessaryThenJumpToBX
139
140
141;--------------------------------------------------------------------
142; Device_InputToALfromIdeRegisterInDL
143; Parameters:
144; DL: IDE Register
145; DS:DI: Ptr to DPT (in RAMVARS segment)
146; Returns:
147; AL: Inputted byte
148; Corrupts registers:
149; BX, DX
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152Device_InputToALfromIdeRegisterInDL:
153 mov bx, IdeIO_InputToALfromIdeRegisterInDX
154 ; Fall to TranslateRegisterAddressInDLifNecessaryThenJumpToBX
155
156
157;--------------------------------------------------------------------
158; TranslateRegisterAddressInDLifNecessaryThenJumpToBX
159; Parameters:
160; AL: Byte to output (if output function in BX)
161; DL: IDE Register
162; BX: I/O function to jump to
163; DS:DI: Ptr to DPT (in RAMVARS segment)
164; Returns:
165; AL: Inputted byte (if input function in BX)
166; Corrupts registers:
167; BX, DX
168;--------------------------------------------------------------------
169TranslateRegisterAddressInDLifNecessaryThenJumpToBX:
170 test WORD [di+DPT.wFlags], FLG_DPT_REVERSED_A0_AND_A3
171 jz SHORT .JumpToIoFunctionInSI
172
173 ; Exchange address lines A0 and A3 from DL
174 mov dh, MASK_A3_AND_A0_ADDRESS_LINES
175 and dh, dl ; DH = 0, 1, 8 or 9, we can ignore 0 and 9
176 jz SHORT .JumpToIoFunctionInSI ; Jump out since DH is 0
177 xor dh, MASK_A3_AND_A0_ADDRESS_LINES
178 jz SHORT .JumpToIoFunctionInSI ; Jump out since DH was 9
179 and dl, ~MASK_A3_AND_A0_ADDRESS_LINES
180 or dl, dh ; Address lines now reversed
181
182ALIGN JUMP_ALIGN
183.JumpToIoFunctionInSI:
184 push bx
185 xor dh, dh
186 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset]; CS:BX now points to IDEVARS
187 ret
Note: See TracBrowser for help on using the repository browser.