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 | ; 8-bit PIO from a single data port.
|
---|
58 | ;
|
---|
59 | ; IdePioBlock_ReadFrom8bitDataPort
|
---|
60 | ; Parameters:
|
---|
61 | ; CX: Block size in 512 byte sectors
|
---|
62 | ; DX: IDE Data port address
|
---|
63 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
64 | ; Returns:
|
---|
65 | ; Nothing
|
---|
66 | ; Corrupts registers:
|
---|
67 | ; AX, CX
|
---|
68 | ;--------------------------------------------------------------------
|
---|
69 | ALIGN JUMP_ALIGN
|
---|
70 | IdePioBlock_ReadFrom8bitDataPort:
|
---|
71 | %ifdef USE_186
|
---|
72 | shl cx, 9 ; Sectors to BYTEs
|
---|
73 | rep insb
|
---|
74 | ret
|
---|
75 | %else ; 808x
|
---|
76 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
77 | ALIGN JUMP_ALIGN
|
---|
78 | .ReadNextOword:
|
---|
79 | %rep 16 ; BYTEs
|
---|
80 | in al, dx ; Read BYTE
|
---|
81 | stosb ; Store BYTE to [ES:DI]
|
---|
82 | %endrep
|
---|
83 | loop .ReadNextOword
|
---|
84 | ret
|
---|
85 | %endif
|
---|
86 | %endif ; MODULE_8BIT_IDE
|
---|
87 |
|
---|
88 |
|
---|
89 | ;--------------------------------------------------------------------
|
---|
90 | ; 16-bit and 32-bit PIO from a single data port.
|
---|
91 | ;
|
---|
92 | ; IdePioBlock_ReadFrom16bitDataPort
|
---|
93 | ; IdePioBlock_ReadFrom32bitDataPort
|
---|
94 | ; Parameters:
|
---|
95 | ; CX: Block size in 512 byte sectors
|
---|
96 | ; DX: IDE Data port address
|
---|
97 | ; ES:DI: Normalized ptr to buffer to receive data
|
---|
98 | ; Returns:
|
---|
99 | ; Nothing
|
---|
100 | ; Corrupts registers:
|
---|
101 | ; AX, CX
|
---|
102 | ;--------------------------------------------------------------------
|
---|
103 | ALIGN JUMP_ALIGN
|
---|
104 | IdePioBlock_ReadFrom16bitDataPort:
|
---|
105 | %ifdef USE_186
|
---|
106 | xchg cl, ch ; Sectors to WORDs
|
---|
107 | rep insw
|
---|
108 | ret
|
---|
109 |
|
---|
110 | %else ; 808x
|
---|
111 | UNROLL_SECTORS_IN_CX_TO_OWORDS
|
---|
112 | ALIGN JUMP_ALIGN
|
---|
113 | .ReadNextOword:
|
---|
114 | %rep 8 ; WORDs
|
---|
115 | in ax, dx ; Read WORD
|
---|
116 | stosw ; Store WORD to [ES:DI]
|
---|
117 | %endrep
|
---|
118 | loop .ReadNextOword
|
---|
119 | ret
|
---|
120 | %endif
|
---|
121 |
|
---|
122 |
|
---|
123 | ;--------------------------------------------------------------------
|
---|
124 | %ifdef MODULE_ADVANCED_ATA
|
---|
125 | ALIGN JUMP_ALIGN
|
---|
126 | IdePioBlock_ReadFrom32bitDataPort:
|
---|
127 | shl cx, 7 ; Sectors to DWORDs
|
---|
128 | rep insd
|
---|
129 | ret
|
---|
130 | %endif ; MODULE_ADVANCED_ATA
|
---|
131 |
|
---|
132 |
|
---|
133 | ; --------------------------------------------------------------------------------------------------
|
---|
134 | ;
|
---|
135 | ; WRITE routines follow
|
---|
136 | ;
|
---|
137 | ; --------------------------------------------------------------------------------------------------
|
---|
138 |
|
---|
139 | %ifdef MODULE_8BIT_IDE
|
---|
140 | ;--------------------------------------------------------------------
|
---|
141 | ; IdePioBlock_WriteToXtideRev1
|
---|
142 | ; Parameters:
|
---|
143 | ; CX: Block size in 512-byte sectors
|
---|
144 | ; DX: IDE Data port address
|
---|
145 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
146 | ; Returns:
|
---|
147 | ; Nothing
|
---|
148 | ; Corrupts registers:
|
---|
149 | ; AX, BX, CX
|
---|
150 | ;--------------------------------------------------------------------
|
---|
151 | ALIGN JUMP_ALIGN
|
---|
152 | IdePioBlock_WriteToXtideRev1:
|
---|
153 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
154 | mov bl, 8 ; Bit mask for toggling data low/high reg
|
---|
155 | ALIGN JUMP_ALIGN
|
---|
156 | .OutswLoop:
|
---|
157 | %rep 4 ; WORDs
|
---|
158 | XTIDE_OUTSW
|
---|
159 | %endrep
|
---|
160 | loop .OutswLoop
|
---|
161 | ret
|
---|
162 |
|
---|
163 |
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | ; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
|
---|
166 | ; Parameters:
|
---|
167 | ; CX: Block size in 512-byte sectors
|
---|
168 | ; DX: IDE Data port address
|
---|
169 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
170 | ; Returns:
|
---|
171 | ; Nothing
|
---|
172 | ; Corrupts registers:
|
---|
173 | ; AX, CX
|
---|
174 | ;--------------------------------------------------------------------
|
---|
175 | ALIGN JUMP_ALIGN
|
---|
176 | IdePioBlock_WriteToXtideRev2:
|
---|
177 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
178 | ALIGN JUMP_ALIGN
|
---|
179 | .WriteNextQword:
|
---|
180 | %rep 4 ; WORDs
|
---|
181 | XTIDE_MOD_OUTSW
|
---|
182 | %endrep
|
---|
183 | loop .WriteNextQword
|
---|
184 | ret
|
---|
185 |
|
---|
186 |
|
---|
187 | ;--------------------------------------------------------------------
|
---|
188 | ; IdePioBlock_WriteTo8bitDataPort
|
---|
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_WriteTo8bitDataPort:
|
---|
200 | %ifdef USE_186
|
---|
201 | shl cx, 9 ; Sectors to BYTEs
|
---|
202 | rep outsb
|
---|
203 | ret
|
---|
204 |
|
---|
205 | %else ; 808x
|
---|
206 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
207 | ALIGN JUMP_ALIGN
|
---|
208 | .WriteNextQword:
|
---|
209 | %rep 8 ; BYTEs
|
---|
210 | lodsb ; Load BYTE from [DS:SI]
|
---|
211 | out dx, al ; Write BYTE
|
---|
212 | %endrep
|
---|
213 | loop .WriteNextQword
|
---|
214 | ret
|
---|
215 | %endif
|
---|
216 | %endif ; MODULE_8BIT_IDE
|
---|
217 |
|
---|
218 |
|
---|
219 | ;--------------------------------------------------------------------
|
---|
220 | ; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
|
---|
221 | ; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
|
---|
222 | ; Parameters:
|
---|
223 | ; CX: Block size in 512-byte sectors
|
---|
224 | ; DX: IDE Data port address
|
---|
225 | ; DS:SI: Normalized ptr to buffer containing data
|
---|
226 | ; Returns:
|
---|
227 | ; Nothing
|
---|
228 | ; Corrupts registers:
|
---|
229 | ; AX, CX
|
---|
230 | ;--------------------------------------------------------------------
|
---|
231 | ALIGN JUMP_ALIGN
|
---|
232 | IdePioBlock_WriteTo16bitDataPort:
|
---|
233 | %ifdef USE_186
|
---|
234 | xchg cl, ch ; Sectors to WORDs
|
---|
235 | rep outsw
|
---|
236 | ret
|
---|
237 |
|
---|
238 | %else ; 808x
|
---|
239 | UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
240 | ALIGN JUMP_ALIGN
|
---|
241 | .WriteNextQword:
|
---|
242 | %rep 4 ; WORDs
|
---|
243 | lodsw ; Load WORD from [DS:SI]
|
---|
244 | out dx, ax ; Write WORD
|
---|
245 | %endrep
|
---|
246 | loop .WriteNextQword
|
---|
247 | ret
|
---|
248 | %endif
|
---|
249 |
|
---|
250 | ;--------------------------------------------------------------------
|
---|
251 | %ifdef MODULE_ADVANCED_ATA
|
---|
252 | ALIGN JUMP_ALIGN
|
---|
253 | IdePioBlock_WriteTo32bitDataPort:
|
---|
254 | shl cx, 7 ; Sectors to DWORDs
|
---|
255 | rep outsd
|
---|
256 | ret
|
---|
257 | %endif ; MODULE_ADVANCED_ATA
|
---|