1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : IDE Read/Write functions for transferring block using PIO modes.
|
---|
3 | ; These functions should only be called from IdeTransfer.asm.
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
8 | ;
|
---|
9 | ; This program is free software; you can redistribute it and/or modify
|
---|
10 | ; it under the terms of the GNU General Public License as published by
|
---|
11 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
12 | ; (at your option) any later version.
|
---|
13 | ;
|
---|
14 | ; This program is distributed in the hope that it will be useful,
|
---|
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | ; GNU General Public License for more details.
|
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
19 | ;
|
---|
20 |
|
---|
21 | ; Section containing code
|
---|
22 | SECTION .text
|
---|
23 |
|
---|
24 |
|
---|
25 | ; --------------------------------------------------------------------------------------------------
|
---|
26 | ;
|
---|
27 | ; READ routines follow
|
---|
28 | ;
|
---|
29 | ; --------------------------------------------------------------------------------------------------
|
---|
30 |
|
---|
31 | %ifdef MODULE_8BIT_IDE
|
---|
32 | ;--------------------------------------------------------------------
|
---|
33 | ; IdePioBlock_ReadFromXtideRev1
|
---|
34 | ; Parameters:
|
---|
35 | ; CX: Block size in 512 byte sectors
|
---|
36 | ; DX: IDE Data port address
|
---|
37 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
38 | ; Returns:
|
---|
39 | ; Nothing
|
---|
40 | ; Corrupts registers:
|
---|
41 | ; AX, BX, CX
|
---|
42 | ;--------------------------------------------------------------------
|
---|
43 | ALIGN JUMP_ALIGN
|
---|
44 | IdePioBlock_ReadFromXtideRev1:
|
---|
45 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
46 | mov bl, 8 ; Bit mask for toggling data low/high reg
|
---|
47 | ALIGN JUMP_ALIGN
|
---|
48 | .InswLoop:
|
---|
49 | %rep 8 ; WORDs
|
---|
50 | XTIDE_INSW
|
---|
51 | %endrep
|
---|
52 | loop .InswLoop
|
---|
53 | ret
|
---|
54 |
|
---|
55 |
|
---|
56 | ;--------------------------------------------------------------------
|
---|
57 | ; IdePioBlock_ReadFromXtideRev2_Olivetti
|
---|
58 | ; Parameters:
|
---|
59 | ; CX: Block size in 512 byte sectors
|
---|
60 | ; DX: IDE Data port address
|
---|
61 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
62 | ; Returns:
|
---|
63 | ; Nothing
|
---|
64 | ; Corrupts registers:
|
---|
65 | ; AX, CX
|
---|
66 | ;--------------------------------------------------------------------
|
---|
67 | ALIGN JUMP_ALIGN
|
---|
68 | IdePioBlock_ReadFromXtideRev2_Olivetti:
|
---|
69 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
70 | ALIGN JUMP_ALIGN
|
---|
71 | .InswLoop:
|
---|
72 | %rep 8 ; WORDs
|
---|
73 | XTIDE_MOD_OLIVETTI_INSW
|
---|
74 | %endrep
|
---|
75 | loop .InswLoop
|
---|
76 | ret
|
---|
77 |
|
---|
78 |
|
---|
79 | ;--------------------------------------------------------------------
|
---|
80 | ; 8-bit PIO from a single data port.
|
---|
81 | ;
|
---|
82 | ; IdePioBlock_ReadFrom8bitDataPort
|
---|
83 | ; Parameters:
|
---|
84 | ; CX: Block size in 512 byte sectors
|
---|
85 | ; DX: IDE Data port address
|
---|
86 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
87 | ; Returns:
|
---|
88 | ; Nothing
|
---|
89 | ; Corrupts registers:
|
---|
90 | ; AX, CX
|
---|
91 | ;--------------------------------------------------------------------
|
---|
92 | ALIGN JUMP_ALIGN
|
---|
93 | IdePioBlock_ReadFrom8bitDataPort:
|
---|
94 | %ifdef USE_186
|
---|
95 | shl cx, 9 ; Sectors to BYTEs
|
---|
96 | rep insb
|
---|
97 | ret
|
---|
98 | %else ; 808x
|
---|
99 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
100 | ALIGN JUMP_ALIGN
|
---|
101 | .ReadNextOword:
|
---|
102 | %rep 16 ; BYTEs
|
---|
103 | in al, dx ; Read BYTE
|
---|
104 | stosb ; Store BYTE to [ES:DI]
|
---|
105 | %endrep
|
---|
106 | loop .ReadNextOword
|
---|
107 | ret
|
---|
108 | %endif
|
---|
109 | %endif ; MODULE_8BIT_IDE
|
---|
110 |
|
---|
111 |
|
---|
112 | ;--------------------------------------------------------------------
|
---|
113 | ; 16-bit and 32-bit PIO from a single data port.
|
---|
114 | ;
|
---|
115 | ; IdePioBlock_ReadFrom16bitDataPort
|
---|
116 | ; IdePioBlock_ReadFrom32bitDataPort
|
---|
117 | ; Parameters:
|
---|
118 | ; CX: Block size in 512 byte sectors
|
---|
119 | ; DX: IDE Data port address
|
---|
120 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
121 | ; Returns:
|
---|
122 | ; Nothing
|
---|
123 | ; Corrupts registers:
|
---|
124 | ; AX, CX
|
---|
125 | ;--------------------------------------------------------------------
|
---|
126 | ALIGN JUMP_ALIGN
|
---|
127 | IdePioBlock_ReadFrom16bitDataPort:
|
---|
128 | %ifdef USE_186
|
---|
129 | xchg cl, ch ; Sectors to WORDs
|
---|
130 | rep insw
|
---|
131 | ret
|
---|
132 |
|
---|
133 | %else ; 808x
|
---|
134 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
135 | ALIGN JUMP_ALIGN
|
---|
136 | .ReadNextOword:
|
---|
137 | %rep 8 ; WORDs
|
---|
138 | in ax, dx ; Read WORD
|
---|
139 | stosw ; Store WORD to [ES:DI]
|
---|
140 | %endrep
|
---|
141 | loop .ReadNextOword
|
---|
142 | ret
|
---|
143 | %endif
|
---|
144 |
|
---|
145 |
|
---|
146 | ;--------------------------------------------------------------------
|
---|
147 | %ifdef MODULE_ADVANCED_ATA
|
---|
148 | ALIGN JUMP_ALIGN
|
---|
149 | IdePioBlock_ReadFrom32bitDataPort:
|
---|
150 | shl cx, 7 ; Sectors to DWORDs
|
---|
151 | rep insd
|
---|
152 | ret
|
---|
153 | %endif ; MODULE_ADVANCED_ATA
|
---|
154 |
|
---|
155 |
|
---|
156 | ; --------------------------------------------------------------------------------------------------
|
---|
157 | ;
|
---|
158 | ; WRITE routines follow
|
---|
159 | ;
|
---|
160 | ; --------------------------------------------------------------------------------------------------
|
---|
161 |
|
---|
162 | %ifdef MODULE_8BIT_IDE
|
---|
163 | ;--------------------------------------------------------------------
|
---|
164 | ; IdePioBlock_WriteToXtideRev1
|
---|
165 | ; Parameters:
|
---|
166 | ; CX: Block size in 512-byte sectors
|
---|
167 | ; DX: IDE Data port address
|
---|
168 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
169 | ; Returns:
|
---|
170 | ; Nothing
|
---|
171 | ; Corrupts registers:
|
---|
172 | ; AX, BX, CX
|
---|
173 | ;--------------------------------------------------------------------
|
---|
174 | ALIGN JUMP_ALIGN
|
---|
175 | IdePioBlock_WriteToXtideRev1:
|
---|
176 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
177 | mov bl, 8 ; Bit mask for toggling data low/high reg
|
---|
178 | ALIGN JUMP_ALIGN
|
---|
179 | .OutswLoop:
|
---|
180 | %rep 4 ; WORDs
|
---|
181 | XTIDE_OUTSW
|
---|
182 | %endrep
|
---|
183 | loop .OutswLoop
|
---|
184 | ret
|
---|
185 |
|
---|
186 |
|
---|
187 | ;--------------------------------------------------------------------
|
---|
188 | ; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
|
---|
189 | ; Parameters:
|
---|
190 | ; CX: Block size in 512-byte sectors
|
---|
191 | ; DX: IDE Data port address
|
---|
192 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
193 | ; Returns:
|
---|
194 | ; Nothing
|
---|
195 | ; Corrupts registers:
|
---|
196 | ; AX, CX
|
---|
197 | ;--------------------------------------------------------------------
|
---|
198 | ALIGN JUMP_ALIGN
|
---|
199 | IdePioBlock_WriteToXtideRev2:
|
---|
200 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
201 | ALIGN JUMP_ALIGN
|
---|
202 | .WriteNextQword:
|
---|
203 | %rep 4 ; WORDs
|
---|
204 | XTIDE_MOD_OUTSW
|
---|
205 | %endrep
|
---|
206 | loop .WriteNextQword
|
---|
207 | ret
|
---|
208 |
|
---|
209 |
|
---|
210 | ;--------------------------------------------------------------------
|
---|
211 | ; IdePioBlock_WriteTo8bitDataPort
|
---|
212 | ; Parameters:
|
---|
213 | ; CX: Block size in 512-byte sectors
|
---|
214 | ; DX: IDE Data port address
|
---|
215 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
216 | ; Returns:
|
---|
217 | ; Nothing
|
---|
218 | ; Corrupts registers:
|
---|
219 | ; AX, CX
|
---|
220 | ;--------------------------------------------------------------------
|
---|
221 | ALIGN JUMP_ALIGN
|
---|
222 | IdePioBlock_WriteTo8bitDataPort:
|
---|
223 | %ifdef USE_186
|
---|
224 | shl cx, 9 ; Sectors to BYTEs
|
---|
225 | rep outsb
|
---|
226 | ret
|
---|
227 |
|
---|
228 | %else ; 808x
|
---|
229 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
230 | ALIGN JUMP_ALIGN
|
---|
231 | .WriteNextQword:
|
---|
232 | %rep 8 ; BYTEs
|
---|
233 | lodsb ; Load BYTE from [DS:SI]
|
---|
234 | out dx, al ; Write BYTE
|
---|
235 | %endrep
|
---|
236 | loop .WriteNextQword
|
---|
237 | ret
|
---|
238 | %endif
|
---|
239 | %endif ; MODULE_8BIT_IDE
|
---|
240 |
|
---|
241 |
|
---|
242 | ;--------------------------------------------------------------------
|
---|
243 | ; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
|
---|
244 | ; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
|
---|
245 | ; Parameters:
|
---|
246 | ; CX: Block size in 512-byte sectors
|
---|
247 | ; DX: IDE Data port address
|
---|
248 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
249 | ; Returns:
|
---|
250 | ; Nothing
|
---|
251 | ; Corrupts registers:
|
---|
252 | ; AX, CX
|
---|
253 | ;--------------------------------------------------------------------
|
---|
254 | ALIGN JUMP_ALIGN
|
---|
255 | IdePioBlock_WriteTo16bitDataPort:
|
---|
256 | %ifdef USE_186
|
---|
257 | xchg cl, ch ; Sectors to WORDs
|
---|
258 | rep outsw
|
---|
259 | ret
|
---|
260 |
|
---|
261 | %else ; 808x
|
---|
262 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
263 | ALIGN JUMP_ALIGN
|
---|
264 | .WriteNextQword:
|
---|
265 | %rep 4 ; WORDs
|
---|
266 | lodsw ; Load WORD from [DS:SI]
|
---|
267 | out dx, ax ; Write WORD
|
---|
268 | %endrep
|
---|
269 | loop .WriteNextQword
|
---|
270 | ret
|
---|
271 | %endif
|
---|
272 |
|
---|
273 | ;--------------------------------------------------------------------
|
---|
274 | %ifdef MODULE_ADVANCED_ATA
|
---|
275 | ALIGN JUMP_ALIGN
|
---|
276 | IdePioBlock_WriteTo32bitDataPort:
|
---|
277 | shl cx, 7 ; Sectors to DWORDs
|
---|
278 | rep outsd
|
---|
279 | ret
|
---|
280 | %endif ; MODULE_ADVANCED_ATA
|
---|