Rev 4587 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4587 | Rev 4923 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | struct HD_DATA |
15 | struct HD_DATA |
16 | hdbase dd ? |
16 | hdbase dd ? |
17 | hdid dd ? |
17 | hdid dd ? |
18 | hdpos dd ? |
18 | hdpos dd ? |
19 | ends |
19 | ends |
20 | - | ||
- | 20 | ;----------------------------------------------------------------------------- |
|
21 | iglobal |
21 | iglobal |
22 | align 4 |
22 | align 4 |
23 | ide_callbacks: |
23 | ide_callbacks: |
24 | dd ide_callbacks.end - ide_callbacks ; strucsize |
24 | dd ide_callbacks.end - ide_callbacks ; strucsize |
25 | dd 0 ; no close function |
25 | dd 0 ; no close function |
Line 33... | Line 33... | ||
33 | 33 | ||
34 | hd0_data HD_DATA ?, 0, 1 |
34 | hd0_data HD_DATA ?, 0, 1 |
35 | hd1_data HD_DATA ?, 0x10, 2 |
35 | hd1_data HD_DATA ?, 0x10, 2 |
36 | hd2_data HD_DATA ?, 0, 3 |
36 | hd2_data HD_DATA ?, 0, 3 |
- | 37 | hd3_data HD_DATA ?, 0x10, 4 |
|
- | 38 | hd4_data HD_DATA ?, 0, 5 |
|
- | 39 | hd5_data HD_DATA ?, 0x10, 6 |
|
- | 40 | hd6_data HD_DATA ?, 0, 7 |
|
- | 41 | hd7_data HD_DATA ?, 0x10, 8 |
|
- | 42 | hd8_data HD_DATA ?, 0, 9 |
|
- | 43 | hd9_data HD_DATA ?, 0x10, 10 |
|
- | 44 | hd10_data HD_DATA ?, 0, 11 |
|
37 | hd3_data HD_DATA ?, 0x10, 4 |
45 | hd11_data HD_DATA ?, 0x10, 12 |
38 | 46 | ||
39 | hd_address_table: |
47 | ide_mutex_table: |
- | 48 | dd ide_channel1_mutex |
|
- | 49 | dd ide_channel2_mutex |
|
- | 50 | dd ide_channel3_mutex |
|
- | 51 | dd ide_channel4_mutex |
|
40 | dd 0x1f0, 0x00, 0x1f0, 0x10 |
52 | dd ide_channel5_mutex |
41 | dd 0x170, 0x00, 0x170, 0x10 |
53 | dd ide_channel6_mutex |
42 | endg |
- | |
- | 54 | endg |
|
43 | 55 | ;----------------------------------------------------------------------------- |
|
44 | uglobal |
56 | uglobal |
45 | ide_mutex MUTEX |
57 | ide_mutex MUTEX |
46 | ide_channel1_mutex MUTEX |
58 | ide_channel1_mutex MUTEX |
- | 59 | ide_channel2_mutex MUTEX |
|
- | 60 | ide_channel3_mutex MUTEX |
|
- | 61 | ide_channel4_mutex MUTEX |
|
- | 62 | ide_channel5_mutex MUTEX |
|
47 | ide_channel2_mutex MUTEX |
63 | ide_channel6_mutex MUTEX |
48 | endg |
- | |
- | 64 | endg |
|
49 | 65 | ;----------------------------------------------------------------------------- |
|
50 | proc ide_read stdcall uses edi, \ |
66 | proc ide_read stdcall uses edi, \ |
51 | hd_data, buffer, startsector:qword, numsectors |
67 | hd_data, buffer, startsector:qword, numsectors |
52 | ; hd_data = pointer to hd*_data |
68 | ; hd_data = pointer to hd*_data |
53 | ; buffer = pointer to buffer for data |
69 | ; buffer = pointer to buffer for data |
Line 65... | Line 81... | ||
65 | mov dword [ecx], 0 |
81 | mov dword [ecx], 0 |
66 | mov [sectors_todo], eax |
82 | mov [sectors_todo], eax |
67 | ; 2. Acquire the global lock. |
83 | ; 2. Acquire the global lock. |
68 | mov ecx, ide_mutex |
84 | mov ecx, ide_mutex |
69 | call mutex_lock |
85 | call mutex_lock |
- | 86 | ||
70 | mov ecx, ide_channel2_mutex |
87 | mov ecx, [hd_data] |
71 | mov eax, [hd_data] |
88 | mov ecx, [ecx+HD_DATA.hdpos] |
72 | push ecx |
89 | dec ecx |
73 | mov ecx, [hd_address_table] |
- | |
74 | cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 |
- | |
75 | pop ecx |
90 | shr ecx, 1 |
76 | jne .IDE_Channel_2 |
91 | shl ecx, 2 |
77 | mov ecx, ide_channel1_mutex |
92 | mov ecx, [ecx + ide_mutex_table] |
78 | .IDE_Channel_2: |
- | |
79 | mov [channel_lock], ecx |
93 | mov [channel_lock], ecx |
80 | call mutex_lock |
94 | call mutex_lock |
81 | ; 3. Convert parameters to the form suitable for worker procedures. |
95 | ; 3. Convert parameters to the form suitable for worker procedures. |
82 | ; Underlying procedures do not know about 64-bit sectors. |
96 | ; Underlying procedures do not know about 64-bit sectors. |
83 | ; Worker procedures use global variables and edi for [buffer]. |
97 | ; Worker procedures use global variables and edi for [buffer]. |
84 | cmp dword [startsector+4], 0 |
98 | cmp dword [startsector+4], 0 |
85 | jnz .fail |
99 | jnz .fail |
- | 100 | ||
86 | and [hd_error], 0 |
101 | and [hd_error], 0 |
87 | mov ecx, [hd_data] |
102 | mov ecx, [hd_data] |
88 | mov eax, [ecx+HD_DATA.hdbase] |
103 | mov eax, [ecx+HD_DATA.hdbase] |
89 | mov [hdbase], eax |
104 | mov [hdbase], eax |
90 | mov eax, [ecx+HD_DATA.hdid] |
105 | mov eax, [ecx+HD_DATA.hdid] |
Line 96... | Line 111... | ||
96 | ; 4. Worker procedures take one sectors per time, so loop over all sectors to read. |
111 | ; 4. Worker procedures take one sectors per time, so loop over all sectors to read. |
97 | .sectors_loop: |
112 | .sectors_loop: |
98 | ; DMA read is permitted if [allow_dma_access]=1 or 2 |
113 | ; DMA read is permitted if [allow_dma_access]=1 or 2 |
99 | cmp [allow_dma_access], 2 |
114 | cmp [allow_dma_access], 2 |
100 | ja .nodma |
115 | ja .nodma |
101 | cmp [dma_hdd], 1 |
- | |
102 | jnz .nodma |
- | |
103 | ;-------------------------------------- |
- | |
104 | push eax |
- | |
105 | mov eax, [hd_address_table] |
- | |
106 | cmp [hdbase], eax ; 0x1F0 |
- | |
107 | pop eax |
- | |
108 | jnz @f |
- | |
Line -... | Line 116... | ||
- | 116 | ||
109 | 117 | push eax ecx |
|
- | 118 | mov ecx, [hdpos] |
|
110 | test [DRIVE_DATA+1], byte 10100000b |
119 | dec ecx |
- | 120 | shr ecx, 2 |
|
- | 121 | imul ecx, sizeof.IDE_DATA |
|
- | 122 | add ecx, IDE_controller_1 |
|
Line -... | Line 123... | ||
- | 123 | mov [IDE_controller_pointer], ecx |
|
111 | jnz .nodma |
124 | |
- | 125 | mov eax, [hdpos] |
|
112 | 126 | dec eax |
|
- | 127 | and eax, 11b |
|
113 | jmp .dma |
128 | shr eax, 1 |
- | 129 | add eax, ecx |
|
114 | @@: |
130 | cmp [eax+IDE_DATA.dma_hdd_channel_1], 1 |
115 | test [DRIVE_DATA+1], byte 1010b |
131 | pop ecx eax |
116 | jnz .nodma |
- | |
117 | .dma: |
132 | jnz .nodma |
118 | ;-------------------------------------- |
133 | |
- | 134 | call hd_read_dma |
|
119 | call hd_read_dma |
135 | jmp @f |
120 | jmp @f |
136 | ;-------------------------------------- |
- | 137 | .nodma: |
|
121 | .nodma: |
138 | call hd_read_pio |
122 | call hd_read_pio |
139 | ;-------------------------------------- |
123 | @@: |
140 | @@: |
- | 141 | cmp [hd_error], 0 |
|
124 | cmp [hd_error], 0 |
142 | jnz .fail |
125 | jnz .fail |
143 | |
126 | mov ecx, [numsectors] |
144 | mov ecx, [numsectors] |
127 | inc dword [ecx] ; one more sector is read |
145 | inc dword [ecx] ; one more sector is read |
- | 146 | dec [sectors_todo] |
|
128 | dec [sectors_todo] |
147 | jz .done |
129 | jz .done |
148 | |
- | 149 | inc eax |
|
130 | inc eax |
150 | jnz .sectors_loop |
131 | jnz .sectors_loop |
151 | ;-------------------------------------- |
132 | ; 5. Loop is done, either due to error or because everything is done. |
152 | ; 5. Loop is done, either due to error or because everything is done. |
133 | ; Release the global lock and return the corresponding status. |
153 | ; Release the global lock and return the corresponding status. |
134 | .fail: |
154 | .fail: |
- | 155 | mov ecx, [channel_lock] |
|
135 | mov ecx, [channel_lock] |
156 | call mutex_unlock |
136 | call mutex_unlock |
157 | |
- | 158 | mov ecx, ide_mutex |
|
137 | mov ecx, ide_mutex |
159 | call mutex_unlock |
138 | call mutex_unlock |
160 | |
- | 161 | or eax, -1 |
|
139 | or eax, -1 |
162 | ret |
140 | ret |
163 | ;-------------------------------------- |
141 | .done: |
164 | .done: |
- | 165 | mov ecx, [channel_lock] |
|
142 | mov ecx, [channel_lock] |
166 | call mutex_unlock |
143 | call mutex_unlock |
167 | |
- | 168 | mov ecx, ide_mutex |
|
144 | mov ecx, ide_mutex |
169 | call mutex_unlock |
145 | call mutex_unlock |
170 | |
146 | xor eax, eax |
171 | xor eax, eax |
147 | ret |
- | |
- | 172 | ret |
|
148 | endp |
173 | endp |
149 | 174 | ;----------------------------------------------------------------------------- |
|
150 | proc ide_write stdcall uses esi edi, \ |
175 | proc ide_write stdcall uses esi edi, \ |
151 | hd_data, buffer, startsector:qword, numsectors |
176 | hd_data, buffer, startsector:qword, numsectors |
152 | ; hd_data = pointer to hd*_data |
177 | ; hd_data = pointer to hd*_data |
Line 165... | Line 190... | ||
165 | mov dword [ecx], 0 |
190 | mov dword [ecx], 0 |
166 | mov [sectors_todo], eax |
191 | mov [sectors_todo], eax |
167 | ; 2. Acquire the global lock. |
192 | ; 2. Acquire the global lock. |
168 | mov ecx, ide_mutex |
193 | mov ecx, ide_mutex |
169 | call mutex_lock |
194 | call mutex_lock |
- | 195 | ||
170 | mov ecx, ide_channel2_mutex |
196 | mov ecx, [hd_data] |
171 | mov eax, [hd_data] |
197 | mov ecx, [ecx+HD_DATA.hdpos] |
172 | push ecx |
198 | dec ecx |
173 | mov ecx, [hd_address_table] |
- | |
174 | cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 |
- | |
175 | pop ecx |
199 | shr ecx, 1 |
176 | jne .IDE_Channel_2 |
200 | shl ecx, 2 |
177 | mov ecx, ide_channel1_mutex |
201 | mov ecx, [ecx + ide_mutex_table] |
178 | .IDE_Channel_2: |
- | |
179 | mov [channel_lock], ecx |
202 | mov [channel_lock], ecx |
180 | call mutex_lock |
203 | call mutex_lock |
181 | ; 3. Convert parameters to the form suitable for worker procedures. |
204 | ; 3. Convert parameters to the form suitable for worker procedures. |
182 | ; Underlying procedures do not know about 64-bit sectors. |
205 | ; Underlying procedures do not know about 64-bit sectors. |
183 | ; Worker procedures use global variables and esi for [buffer]. |
206 | ; Worker procedures use global variables and esi for [buffer]. |
184 | cmp dword [startsector+4], 0 |
207 | cmp dword [startsector+4], 0 |
185 | jnz .fail |
208 | jnz .fail |
- | 209 | ||
186 | and [hd_error], 0 |
210 | and [hd_error], 0 |
187 | mov ecx, [hd_data] |
211 | mov ecx, [hd_data] |
188 | mov eax, [ecx+HD_DATA.hdbase] |
212 | mov eax, [ecx+HD_DATA.hdbase] |
189 | mov [hdbase], eax |
213 | mov [hdbase], eax |
190 | mov eax, [ecx+HD_DATA.hdid] |
214 | mov eax, [ecx+HD_DATA.hdid] |
Line 198... | Line 222... | ||
198 | ; loop until all sectors will be processed. |
222 | ; loop until all sectors will be processed. |
199 | .sectors_loop: |
223 | .sectors_loop: |
200 | mov ecx, 16 |
224 | mov ecx, 16 |
201 | cmp ecx, [sectors_todo] |
225 | cmp ecx, [sectors_todo] |
202 | jbe @f |
226 | jbe @f |
- | 227 | ||
203 | mov ecx, [sectors_todo] |
228 | mov ecx, [sectors_todo] |
- | 229 | ;-------------------------------------- |
|
204 | @@: |
230 | @@: |
205 | mov [cache_chain_size], cl |
231 | mov [cache_chain_size], cl |
206 | ; DMA write is permitted only if [allow_dma_access]=1 |
232 | ; DMA write is permitted only if [allow_dma_access]=1 |
207 | cmp [allow_dma_access], 2 |
233 | cmp [allow_dma_access], 2 |
208 | jae .nodma |
234 | jae .nodma |
209 | cmp [dma_hdd], 1 |
- | |
210 | jnz .nodma |
- | |
211 | ;-------------------------------------- |
- | |
212 | push eax |
- | |
213 | mov eax, [hd_address_table] |
- | |
214 | cmp [hdbase], eax ; 0x1F0 |
- | |
215 | pop eax |
- | |
216 | jnz @f |
- | |
Line -... | Line 235... | ||
- | 235 | ||
217 | 236 | push eax ecx |
|
- | 237 | mov ecx, [hdpos] |
|
218 | test [DRIVE_DATA+1], byte 10100000b |
238 | dec ecx |
- | 239 | shr ecx, 2 |
|
- | 240 | imul ecx, sizeof.IDE_DATA |
|
- | 241 | add ecx, IDE_controller_1 |
|
Line -... | Line 242... | ||
- | 242 | mov [IDE_controller_pointer], ecx |
|
219 | jnz .nodma |
243 | |
- | 244 | mov eax, [hdpos] |
|
220 | 245 | dec eax |
|
- | 246 | and eax, 11b |
|
221 | jmp .dma |
247 | shr eax, 1 |
- | 248 | add eax, ecx |
|
222 | @@: |
249 | cmp [eax+IDE_DATA.dma_hdd_channel_1], 1 |
223 | test [DRIVE_DATA+1], byte 1010b |
250 | pop ecx eax |
224 | jnz .nodma |
- | |
225 | .dma: |
251 | jnz .nodma |
226 | ;-------------------------------------- |
252 | |
- | 253 | call cache_write_dma |
|
227 | call cache_write_dma |
254 | jmp .common |
228 | jmp .common |
255 | ;-------------------------------------- |
229 | .nodma: |
256 | .nodma: |
- | 257 | mov [cache_chain_size], 1 |
|
230 | mov [cache_chain_size], 1 |
258 | call cache_write_pio |
231 | call cache_write_pio |
259 | ;-------------------------------------- |
232 | .common: |
260 | .common: |
- | 261 | cmp [hd_error], 0 |
|
233 | cmp [hd_error], 0 |
262 | jnz .fail |
234 | jnz .fail |
263 | |
235 | movzx ecx, [cache_chain_size] |
264 | movzx ecx, [cache_chain_size] |
236 | mov eax, [numsectors] |
265 | mov eax, [numsectors] |
237 | add [eax], ecx |
266 | add [eax], ecx |
- | 267 | sub [sectors_todo], ecx |
|
238 | sub [sectors_todo], ecx |
268 | jz .done |
239 | jz .done |
269 | |
- | 270 | add [edi], ecx |
|
240 | add [edi], ecx |
271 | jc .fail |
241 | jc .fail |
272 | |
242 | shl ecx, 9 |
273 | shl ecx, 9 |
- | 274 | add esi, ecx |
|
243 | add esi, ecx |
275 | jmp .sectors_loop |
244 | jmp .sectors_loop |
276 | ;-------------------------------------- |
245 | ; 5. Loop is done, either due to error or because everything is done. |
277 | ; 5. Loop is done, either due to error or because everything is done. |
246 | ; Release the global lock and return the corresponding status. |
278 | ; Release the global lock and return the corresponding status. |
247 | .fail: |
279 | .fail: |
- | 280 | mov ecx, [channel_lock] |
|
248 | mov ecx, [channel_lock] |
281 | call mutex_unlock |
249 | call mutex_unlock |
282 | |
- | 283 | mov ecx, ide_mutex |
|
250 | mov ecx, ide_mutex |
284 | call mutex_unlock |
251 | call mutex_unlock |
285 | |
- | 286 | or eax, -1 |
|
252 | or eax, -1 |
287 | ret |
253 | ret |
288 | ;-------------------------------------- |
254 | .done: |
289 | .done: |
- | 290 | mov ecx, [channel_lock] |
|
255 | mov ecx, [channel_lock] |
291 | call mutex_unlock |
256 | call mutex_unlock |
292 | |
- | 293 | mov ecx, ide_mutex |
|
257 | mov ecx, ide_mutex |
294 | call mutex_unlock |
258 | call mutex_unlock |
295 | |
259 | xor eax, eax |
296 | xor eax, eax |
260 | ret |
- | |
- | 297 | ret |
|
261 | endp |
298 | endp |
262 | 299 | ;----------------------------------------------------------------------------- |
|
263 | ; This is a stub. |
300 | ; This is a stub. |
264 | proc ide_querymedia stdcall, hd_data, mediainfo |
301 | proc ide_querymedia stdcall, hd_data, mediainfo |
265 | mov eax, [mediainfo] |
302 | mov eax, [mediainfo] |
266 | mov [eax+DISKMEDIAINFO.Flags], 0 |
303 | mov [eax+DISKMEDIAINFO.Flags], 0 |
267 | mov [eax+DISKMEDIAINFO.SectorSize], 512 |
304 | mov [eax+DISKMEDIAINFO.SectorSize], 512 |
268 | or dword [eax+DISKMEDIAINFO.Capacity], 0xFFFFFFFF |
305 | or dword [eax+DISKMEDIAINFO.Capacity], 0xFFFFFFFF |
269 | or dword [eax+DISKMEDIAINFO.Capacity+4], 0xFFFFFFFF |
306 | or dword [eax+DISKMEDIAINFO.Capacity+4], 0xFFFFFFFF |
270 | xor eax, eax |
307 | xor eax, eax |
271 | ret |
- | |
272 | endp |
308 | ret |
273 | 309 | endp |
|
274 | ;----------------------------------------------------------------------------- |
310 | ;----------------------------------------------------------------------------- |
275 | align 4 |
311 | align 4 |
276 | ; input: eax = sector, edi -> buffer |
312 | ; input: eax = sector, edi -> buffer |
277 | ; output: edi = edi + 512 |
313 | ; output: edi = edi + 512 |
278 | hd_read_pio: |
- | |
279 | push eax edx |
314 | hd_read_pio: |
280 | 315 | push eax edx |
|
281 | ; Select the desired drive |
316 | ; Select the desired drive |
282 | mov edx, [hdbase] |
317 | mov edx, [hdbase] |
283 | add edx, 6 ;адрес регистра головок |
318 | add edx, 6 ;адрес регистра головок |
284 | mov al, byte [hdid] |
319 | mov al, byte [hdid] |
Line 285... | Line 320... | ||
285 | add al, 128+64+32 |
320 | add al, 128+64+32 |
- | 321 | out dx, al; номер головки/номер диска |
|
286 | out dx, al; номер головки/номер диска |
322 | |
287 | 323 | call wait_for_hd_idle |
|
288 | call wait_for_hd_idle |
- | |
289 | cmp [hd_error], 0 |
324 | |
290 | jne hd_read_error |
325 | cmp [hd_error], 0 |
291 | 326 | jne hd_read_error |
|
292 | ; ATA with 28 or 48 bit for sector number? |
327 | ; ATA with 28 or 48 bit for sector number? |
293 | mov eax, [esp+4] |
328 | mov eax, [esp+4] |
Line 370... | Line 405... | ||
370 | cmp [hd_error], 0 |
405 | cmp [hd_error], 0 |
371 | jne hd_read_error |
406 | jne hd_read_error |
Line 372... | Line 407... | ||
372 | 407 | ||
373 | pushfd |
408 | pushfd |
374 | cli |
- | |
375 | 409 | cli |
|
376 | mov ecx, 256 |
410 | mov ecx, 256 |
377 | mov edx, [hdbase] |
411 | mov edx, [hdbase] |
378 | cld |
412 | cld |
379 | rep insw |
413 | rep insw |
Line 391... | Line 425... | ||
391 | mov al, byte [hdid] |
425 | mov al, byte [hdid] |
392 | add al, 128+64+32 |
426 | add al, 128+64+32 |
393 | out dx, al ; номер головки/номер диска |
427 | out dx, al ; номер головки/номер диска |
Line 394... | Line 428... | ||
394 | 428 | ||
- | 429 | call wait_for_hd_idle |
|
395 | call wait_for_hd_idle |
430 | |
396 | cmp [hd_error], 0 |
431 | cmp [hd_error], 0 |
Line 397... | Line 432... | ||
397 | jne hd_write_error |
432 | jne hd_write_error |
398 | 433 | ||
Line 548... | Line 583... | ||
548 | add edx, 0x7 |
583 | add edx, 0x7 |
549 | ;-------------------------------------- |
584 | ;-------------------------------------- |
550 | align 4 |
585 | align 4 |
551 | wfhil1: |
586 | wfhil1: |
552 | call check_hd_wait_timeout |
587 | call check_hd_wait_timeout |
- | 588 | ||
553 | cmp [hd_error], 0 |
589 | cmp [hd_error], 0 |
554 | jne @f |
590 | jne @f |
Line 555... | Line 591... | ||
555 | 591 | ||
556 | in al, dx |
592 | in al, dx |
557 | test al, 128 |
593 | test al, 128 |
558 | jnz wfhil1 |
- | |
- | 594 | jnz wfhil1 |
|
559 | 595 | ;-------------------------------------- |
|
560 | @@: |
596 | @@: |
561 | pop edx eax |
597 | pop edx eax |
562 | ret |
598 | ret |
563 | ;----------------------------------------------------------------------------- |
599 | ;----------------------------------------------------------------------------- |
Line 571... | Line 607... | ||
571 | call save_hd_wait_timeout |
607 | call save_hd_wait_timeout |
572 | ;-------------------------------------- |
608 | ;-------------------------------------- |
573 | align 4 |
609 | align 4 |
574 | hdwait_sbuf: ; wait for sector buffer to be ready |
610 | hdwait_sbuf: ; wait for sector buffer to be ready |
575 | call check_hd_wait_timeout |
611 | call check_hd_wait_timeout |
- | 612 | ||
576 | cmp [hd_error], 0 |
613 | cmp [hd_error], 0 |
577 | jne @f |
614 | jne @f |
Line 578... | Line 615... | ||
578 | 615 | ||
579 | in al, dx |
616 | in al, dx |
Line 585... | Line 622... | ||
585 | cmp [hd_setup], 1 ; do not mark error for setup request |
622 | cmp [hd_setup], 1 ; do not mark error for setup request |
586 | je buf_wait_ok |
623 | je buf_wait_ok |
Line 587... | Line 624... | ||
587 | 624 | ||
588 | test al, 1 ; previous command ended up with an error |
625 | test al, 1 ; previous command ended up with an error |
- | 626 | jz buf_wait_ok |
|
589 | jz buf_wait_ok |
627 | ;-------------------------------------- |
590 | @@: |
628 | @@: |
591 | mov [hd_error], 1 |
- | |
- | 629 | mov [hd_error], 1 |
|
592 | 630 | ;-------------------------------------- |
|
593 | buf_wait_ok: |
631 | buf_wait_ok: |
594 | pop edx eax |
632 | pop edx eax |
595 | ret |
633 | ret |
596 | ;----------------------------------------------------------------------------- |
634 | ;----------------------------------------------------------------------------- |
Line 604... | Line 642... | ||
604 | call save_hd_wait_timeout |
642 | call save_hd_wait_timeout |
605 | ;-------------------------------------- |
643 | ;-------------------------------------- |
606 | align 4 |
644 | align 4 |
607 | .wait: |
645 | .wait: |
608 | call change_task |
646 | call change_task |
- | 647 | ||
609 | cmp [IDE_common_irq_param], 0 |
648 | cmp [IDE_common_irq_param], 0 |
610 | jz .done |
649 | jz .done |
Line 611... | Line 650... | ||
611 | 650 | ||
- | 651 | call check_hd_wait_timeout |
|
612 | call check_hd_wait_timeout |
652 | |
613 | cmp [hd_error], 0 |
653 | cmp [hd_error], 0 |
614 | jz .wait |
- | |
615 | ; clear Bus Master IDE Command register |
- | |
616 | pushfd |
654 | jz .wait |
617 | cli |
655 | |
618 | mov [IDE_common_irq_param], 0 |
- | |
619 | mov dx, [IDEContrRegsBaseAddr] |
- | |
620 | mov al, 0 |
- | |
621 | out dx, al |
- | |
622 | popfd |
656 | mov [IDE_common_irq_param], 0 |
623 | ;-------------------------------------- |
- | |
624 | align 4 |
657 | ;-------------------------------------- |
625 | .done: |
658 | .done: |
626 | pop edx |
659 | pop edx |
627 | pop eax |
660 | pop eax |
628 | ret |
661 | ret |
Line 634... | Line 667... | ||
634 | call save_hd_wait_timeout |
667 | call save_hd_wait_timeout |
635 | ;-------------------------------------- |
668 | ;-------------------------------------- |
636 | align 4 |
669 | align 4 |
637 | .wait: |
670 | .wait: |
638 | call change_task |
671 | call change_task |
- | 672 | ||
639 | cmp [IDE_common_irq_param], 0 |
673 | cmp [IDE_common_irq_param], 0 |
640 | jz .done |
674 | jz .done |
Line 641... | Line 675... | ||
641 | 675 | ||
- | 676 | call check_hd_wait_timeout |
|
642 | call check_hd_wait_timeout |
677 | |
643 | cmp [hd_error], 0 |
678 | cmp [hd_error], 0 |
644 | jz .wait |
- | |
645 | ; clear Bus Master IDE Command register |
- | |
646 | pushfd |
679 | jz .wait |
647 | cli |
680 | |
648 | mov [IDE_common_irq_param], 0 |
- | |
649 | mov dx, [IDEContrRegsBaseAddr] |
- | |
650 | add dx, 8 |
- | |
651 | mov al, 0 |
- | |
652 | out dx, al |
- | |
653 | popfd |
681 | mov [IDE_common_irq_param], 0 |
654 | ;-------------------------------------- |
- | |
655 | align 4 |
682 | ;-------------------------------------- |
656 | .done: |
683 | .done: |
657 | pop edx |
684 | pop edx |
658 | pop eax |
685 | pop eax |
659 | ret |
686 | ret |
660 | ;----------------------------------------------------------------------------- |
687 | ;----------------------------------------------------------------------------- |
661 | iglobal |
688 | iglobal |
662 | align 4 |
689 | align 4 |
- | 690 | ; note that IDE descriptor table must be 4-byte aligned |
|
663 | ; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary |
691 | ; and do not cross 4K boundary |
664 | IDE_descriptor_table: |
692 | IDE_descriptor_table: |
665 | dd IDE_DMA |
693 | dd IDE_DMA |
666 | dw 0x2000 |
694 | dw 0x2000 |
Line 671... | Line 699... | ||
671 | IDE_common_irq_param db 0 |
699 | IDE_common_irq_param db 0 |
672 | endg |
700 | endg |
673 | ;----------------------------------------------------------------------------- |
701 | ;----------------------------------------------------------------------------- |
674 | uglobal |
702 | uglobal |
675 | ; all uglobals are zeroed at boot |
703 | ; all uglobals are zeroed at boot |
676 | dma_process dd 0 |
- | |
677 | dma_slot_ptr dd 0 |
- | |
678 | cache_chain_pos dd 0 |
- | |
679 | cache_chain_ptr dd 0 |
704 | cache_chain_ptr dd 0 |
680 | cache_chain_size db 0 |
705 | cache_chain_size db 0 |
681 | cache_chain_started db 0 |
- | |
682 | dma_task_switched db 0 |
- | |
683 | dma_hdd db 0 |
- | |
684 | allow_dma_access db 0 |
706 | allow_dma_access db 0 |
685 | endg |
707 | endg |
686 | ;----------------------------------------------------------------------------- |
708 | ;----------------------------------------------------------------------------- |
687 | align 4 |
709 | align 4 |
688 | IDE_irq_14_handler: |
710 | IDE_irq_14_handler: |
- | 711 | ; DEBUGF 1, 'K : IDE_irq_14_handler %x\n', [IDE_common_irq_param]:2 |
|
689 | cmp [IDE_common_irq_param], irq14_num |
712 | cmp [IDE_common_irq_param], irq14_num |
690 | jne .exit |
713 | jne .exit |
Line 691... | Line 714... | ||
691 | 714 | ||
692 | pushfd |
715 | pushfd |
693 | cli |
716 | cli |
694 | pushad |
717 | pushad |
- | 718 | mov [IDE_common_irq_param], 0 |
|
695 | mov [IDE_common_irq_param], 0 |
719 | mov ecx, [IDE_controller_pointer] |
696 | mov dx, [IDEContrRegsBaseAddr] |
720 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
697 | ; test whether it is our interrupt? |
721 | ; test whether it is our interrupt? |
698 | add edx, 2 |
722 | add edx, 2 |
699 | in al, dx |
723 | in al, dx |
700 | test al, 100b |
724 | test al, 100b |
Line 713... | Line 737... | ||
713 | popad |
737 | popad |
714 | popfd |
738 | popfd |
715 | mov al, 1 |
739 | mov al, 1 |
716 | ret |
740 | ret |
717 | ;-------------------------------------- |
741 | ;-------------------------------------- |
718 | align 4 |
- | |
719 | @@: |
742 | @@: |
720 | popad |
743 | popad |
721 | popfd |
744 | popfd |
722 | ;-------------------------------------- |
745 | ;-------------------------------------- |
723 | align 4 |
- | |
724 | .exit: |
746 | .exit: |
725 | mov al, 0 |
747 | mov al, 0 |
726 | ret |
748 | ret |
727 | ;----------------------------------------------------------------------------- |
749 | ;----------------------------------------------------------------------------- |
728 | align 4 |
750 | align 4 |
729 | IDE_irq_15_handler: |
751 | IDE_irq_15_handler: |
- | 752 | ; DEBUGF 1, 'K : IDE_irq_15_handler %x\n', [IDE_common_irq_param]:2 |
|
730 | cmp [IDE_common_irq_param], irq15_num |
753 | cmp [IDE_common_irq_param], irq15_num |
731 | jne .exit |
754 | jne .exit |
Line 732... | Line 755... | ||
732 | 755 | ||
733 | pushfd |
756 | pushfd |
734 | cli |
757 | cli |
735 | pushad |
758 | pushad |
- | 759 | mov [IDE_common_irq_param], 0 |
|
736 | mov [IDE_common_irq_param], 0 |
760 | mov ecx, [IDE_controller_pointer] |
737 | mov dx, [IDEContrRegsBaseAddr] |
761 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
738 | add dx, 8 |
762 | add dx, 8 |
739 | ; test whether it is our interrupt? |
763 | ; test whether it is our interrupt? |
740 | add edx, 2 |
764 | add edx, 2 |
741 | in al, dx |
765 | in al, dx |
Line 755... | Line 779... | ||
755 | popad |
779 | popad |
756 | popfd |
780 | popfd |
757 | mov al, 1 |
781 | mov al, 1 |
758 | ret |
782 | ret |
759 | ;-------------------------------------- |
783 | ;-------------------------------------- |
760 | align 4 |
- | |
761 | @@: |
784 | @@: |
762 | popad |
785 | popad |
763 | popfd |
786 | popfd |
764 | ;-------------------------------------- |
787 | ;-------------------------------------- |
765 | align 4 |
- | |
766 | .exit: |
788 | .exit: |
767 | mov al, 0 |
789 | mov al, 0 |
768 | ret |
790 | ret |
769 | ;----------------------------------------------------------------------------- |
791 | ;----------------------------------------------------------------------------- |
770 | align 4 |
792 | align 4 |
771 | IDE_common_irq_handler: |
793 | IDE_common_irq_handler: |
- | 794 | ; DEBUGF 1, 'K : IDE_common_irq_handler %x\n', [IDE_common_irq_param]:2 |
|
- | 795 | pushfd |
|
- | 796 | cli |
|
772 | cmp [IDE_common_irq_param], 0 |
797 | cmp [IDE_common_irq_param], 0 |
773 | je .exit |
798 | je .exit |
Line 774... | Line -... | ||
774 | - | ||
775 | pushfd |
- | |
776 | cli |
799 | |
777 | pushad |
800 | pushad |
- | 801 | xor ebx, ebx |
|
778 | xor ebx, ebx |
802 | mov ecx, [IDE_controller_pointer] |
779 | mov dx, [IDEContrRegsBaseAddr] |
803 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
780 | mov eax, IDE_common_irq_param |
804 | mov eax, IDE_common_irq_param |
781 | cmp [eax], irq14_num |
805 | cmp [eax], irq14_num |
782 | mov [eax], bl |
806 | mov [eax], bl |
Line 783... | Line 807... | ||
783 | je @f |
807 | je @f |
784 | 808 | ||
785 | add dx, 8 |
- | |
786 | ;-------------------------------------- |
809 | add dx, 8 |
787 | align 4 |
810 | ;-------------------------------------- |
788 | @@: |
811 | @@: |
789 | ; test whether it is our interrupt? |
812 | ; test whether it is our interrupt? |
790 | add edx, 2 |
813 | add edx, 2 |
Line 805... | Line 828... | ||
805 | popad |
828 | popad |
806 | popfd |
829 | popfd |
807 | mov al, 1 |
830 | mov al, 1 |
808 | ret |
831 | ret |
809 | ;-------------------------------------- |
832 | ;-------------------------------------- |
810 | align 4 |
- | |
811 | @@: |
833 | @@: |
812 | popad |
834 | popad |
813 | popfd |
- | |
814 | ;-------------------------------------- |
835 | ;-------------------------------------- |
815 | align 4 |
- | |
816 | .exit: |
836 | .exit: |
- | 837 | popfd |
|
817 | mov al, 0 |
838 | mov al, 0 |
818 | ret |
839 | ret |
819 | ;----------------------------------------------------------------------------- |
840 | ;----------------------------------------------------------------------------- |
820 | align 4 |
841 | align 4 |
821 | hd_read_dma: |
842 | hd_read_dma: |
822 | push eax |
843 | push eax |
823 | push edx |
844 | push edx |
824 | mov edx, [dma_hdpos] |
845 | mov edx, [dma_hdpos] |
825 | cmp edx, [hdpos] |
846 | cmp edx, [hdpos] |
826 | jne .notread |
847 | jne .notread |
- | 848 | ||
827 | mov edx, [dma_cur_sector] |
849 | mov edx, [dma_cur_sector] |
828 | cmp eax, edx |
850 | cmp eax, edx |
829 | jb .notread |
851 | jb .notread |
- | 852 | ||
830 | add edx, 15 |
853 | add edx, 15 |
831 | cmp [esp+4], edx |
854 | cmp [esp+4], edx |
832 | ja .notread |
855 | ja .notread |
- | 856 | ||
833 | mov eax, [esp+4] |
857 | mov eax, [esp+4] |
834 | sub eax, [dma_cur_sector] |
858 | sub eax, [dma_cur_sector] |
835 | shl eax, 9 |
859 | shl eax, 9 |
836 | add eax, (OS_BASE+IDE_DMA) |
860 | add eax, (OS_BASE+IDE_DMA) |
- | 861 | ||
837 | push ecx esi |
862 | push ecx esi |
838 | mov esi, eax |
863 | mov esi, eax |
839 | - | ||
840 | mov ecx, 512/4 |
864 | mov ecx, 512/4 |
841 | cld |
865 | cld |
842 | rep movsd |
866 | rep movsd |
843 | pop esi ecx |
867 | pop esi ecx |
- | 868 | ||
844 | pop edx |
869 | pop edx |
845 | pop eax |
870 | pop eax |
846 | ret |
871 | ret |
- | 872 | ;-------------------------------------- |
|
847 | .notread: |
873 | .notread: |
848 | ; set data for PRD Table |
874 | ; set data for PRD Table |
849 | mov eax, IDE_descriptor_table |
875 | mov eax, IDE_descriptor_table |
850 | mov dword [eax], IDE_DMA |
876 | mov dword [eax], IDE_DMA |
851 | mov word [eax+4], 0x2000 |
877 | mov word [eax+4], 0x2000 |
852 | sub eax, OS_BASE |
878 | sub eax, OS_BASE |
853 | ; select controller Primary or Secondary |
879 | ; select controller Primary or Secondary |
- | 880 | mov ecx, [IDE_controller_pointer] |
|
854 | mov dx, [IDEContrRegsBaseAddr] |
881 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
- | 882 | ||
855 | push eax |
883 | push eax |
856 | mov eax, [hd_address_table] |
884 | mov eax, [hdpos] |
- | 885 | dec eax |
|
857 | cmp [hdbase], eax ; 0x1F0 |
886 | test eax, 10b |
858 | pop eax |
887 | pop eax |
859 | jz @f |
888 | jz @f |
- | 889 | ||
860 | add edx, 8 |
890 | add edx, 8 |
- | 891 | ;-------------------------------------- |
|
861 | @@: |
892 | @@: |
862 | push edx |
893 | push edx |
863 | ; Bus Master IDE PRD Table Address |
894 | ; Bus Master IDE PRD Table Address |
864 | add edx, 4 |
895 | add edx, 4 |
865 | ; save IDE_descriptor_table |
896 | ; save IDE_descriptor_table |
Line 879... | Line 910... | ||
879 | mov al, byte [hdid] |
910 | mov al, byte [hdid] |
880 | add al, 128+64+32 |
911 | add al, 128+64+32 |
881 | out dx, al ; номер головки/номер диска |
912 | out dx, al ; номер головки/номер диска |
Line 882... | Line 913... | ||
882 | 913 | ||
- | 914 | call wait_for_hd_idle |
|
883 | call wait_for_hd_idle |
915 | |
884 | cmp [hd_error], 0 |
916 | cmp [hd_error], 0 |
885 | jnz hd_read_error |
- | |
886 | 917 | jnz hd_read_error |
|
887 | ; ATA with 28 or 48 bit for sector number? |
918 | ; ATA with 28 or 48 bit for sector number? |
888 | mov eax, [esp+4] |
919 | mov eax, [esp+4] |
889 | ; -10h because the PreCache hits the boundary between lba28 and lba48 |
920 | ; -10h because the PreCache hits the boundary between lba28 and lba48 |
890 | ; 10h = 16 - size of PreCache |
921 | ; 10h = 16 - size of PreCache |
Line 959... | Line 990... | ||
959 | mov al, 25h ; READ DMA EXT |
990 | mov al, 25h ; READ DMA EXT |
960 | out dx, al ; ATACommand регистр команд |
991 | out dx, al ; ATACommand регистр команд |
961 | ;-------------------------------------- |
992 | ;-------------------------------------- |
962 | .continue: |
993 | .continue: |
963 | ; select controller Primary or Secondary |
994 | ; select controller Primary or Secondary |
- | 995 | mov ecx, [IDE_controller_pointer] |
|
964 | mov dx, [IDEContrRegsBaseAddr] |
996 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
- | 997 | ||
965 | mov eax, [hd_address_table] |
998 | mov eax, [hdpos] |
- | 999 | dec eax |
|
966 | cmp [hdbase], eax ; 0x1F0 |
1000 | test eax, 10b |
967 | jz @f |
1001 | jz @f |
- | 1002 | ||
968 | add dx, 8 |
1003 | add dx, 8 |
- | 1004 | ;-------------------------------------- |
|
969 | @@: |
1005 | @@: |
970 | ; set write to memory and Start Bus Master |
1006 | ; set write to memory and Start Bus Master |
971 | mov al, 9 |
1007 | mov al, 9 |
972 | out dx, al |
1008 | out dx, al |
Line 973... | Line 1009... | ||
973 | 1009 | ||
974 | mov eax, [CURRENT_TASK] |
1010 | mov eax, [hdpos] |
975 | mov [dma_process], eax |
- | |
976 | 1011 | dec eax |
|
977 | mov eax, [TASK_BASE] |
- | |
978 | mov [dma_slot_ptr], eax |
- | |
979 | - | ||
980 | mov eax, [hd_address_table] |
- | |
981 | cmp [hdbase], eax ; 0x1F0 |
1012 | test eax, 10b |
Line 982... | Line 1013... | ||
982 | jnz .ide1 |
1013 | jnz .ide1 |
983 | 1014 | ||
- | 1015 | mov [IDE_common_irq_param], irq14_num |
|
984 | mov [IDE_common_irq_param], irq14_num |
1016 | jmp @f |
985 | jmp @f |
1017 | ;-------------------------------------- |
- | 1018 | .ide1: |
|
986 | .ide1: |
1019 | mov [IDE_common_irq_param], irq15_num |
987 | mov [IDE_common_irq_param], irq15_num |
1020 | ;-------------------------------------- |
988 | @@: |
1021 | @@: |
989 | popfd |
1022 | popfd |
- | 1023 | ; wait for interrupt |
|
990 | ; wait for interrupt |
1024 | mov eax, [hdpos] |
991 | mov eax, [hd_address_table] |
1025 | dec eax |
- | 1026 | test eax, 10b |
|
992 | cmp [hdbase], eax ; 0x1F0 |
1027 | jnz .wait_ide1 |
993 | jnz .wait_ide1 |
1028 | |
- | 1029 | call wait_for_sector_dma_ide0 |
|
994 | call wait_for_sector_dma_ide0 |
1030 | jmp @f |
995 | jmp @f |
1031 | ;-------------------------------------- |
- | 1032 | .wait_ide1: |
|
996 | .wait_ide1: |
1033 | call wait_for_sector_dma_ide1 |
997 | call wait_for_sector_dma_ide1 |
1034 | ;-------------------------------------- |
998 | @@: |
1035 | @@: |
- | 1036 | cmp [hd_error], 0 |
|
999 | cmp [hd_error], 0 |
1037 | jnz hd_read_error |
1000 | jnz hd_read_error |
1038 | |
1001 | mov eax, [hdpos] |
1039 | mov eax, [hdpos] |
1002 | mov [dma_hdpos], eax |
1040 | mov [dma_hdpos], eax |
- | 1041 | pop edx |
|
1003 | pop edx |
1042 | pop eax |
1004 | pop eax |
1043 | |
1005 | mov [dma_cur_sector], eax |
1044 | mov [dma_cur_sector], eax |
1006 | jmp hd_read_dma |
1045 | jmp hd_read_dma |
1007 | ;----------------------------------------------------------------------------- |
1046 | ;----------------------------------------------------------------------------- |
1008 | cache_write_dma: |
1047 | cache_write_dma: |
1009 | mov eax, [cache_chain_ptr] ; for what? |
1048 | mov eax, [cache_chain_ptr] ; for what? |
1010 | push esi |
1049 | push esi |
1011 | ; set data for PRD Table |
1050 | ; set data for PRD Table |
- | 1051 | mov eax, IDE_descriptor_table |
|
1012 | mov eax, IDE_descriptor_table |
1052 | mov edx, eax |
1013 | mov edx, eax |
1053 | |
1014 | pusha |
1054 | pusha |
1015 | mov edi, (OS_BASE+IDE_DMA) |
1055 | mov edi, (OS_BASE+IDE_DMA) |
1016 | mov dword [edx], IDE_DMA |
1056 | mov dword [edx], IDE_DMA |
1017 | movzx ecx, [cache_chain_size] |
1057 | movzx ecx, [cache_chain_size] |
1018 | shl ecx, 9 |
1058 | shl ecx, 9 |
1019 | mov word [edx+4], cx |
1059 | mov word [edx+4], cx |
1020 | shr ecx, 2 |
1060 | shr ecx, 2 |
1021 | cld |
1061 | cld |
- | 1062 | rep movsd |
|
1022 | rep movsd |
1063 | popa |
1023 | popa |
1064 | |
- | 1065 | sub eax, OS_BASE |
|
1024 | sub eax, OS_BASE |
1066 | ; select controller Primary or Secondary |
- | 1067 | mov ecx, [IDE_controller_pointer] |
|
1025 | ; select controller Primary or Secondary |
1068 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
1026 | mov dx, [IDEContrRegsBaseAddr] |
1069 | |
- | 1070 | push eax |
|
1027 | push eax |
1071 | mov eax, [hdpos] |
1028 | mov eax, [hd_address_table] |
1072 | dec eax |
1029 | cmp [hdbase], eax ; 0x1F0 |
1073 | test eax, 10b |
- | 1074 | pop eax |
|
1030 | pop eax |
1075 | jz @f |
- | 1076 | ||
1031 | jz @f |
1077 | add edx, 8 |
1032 | add edx, 8 |
1078 | ;-------------------------------------- |
1033 | @@: |
1079 | @@: |
1034 | push edx |
1080 | push edx |
1035 | ; Bus Master IDE PRD Table Address |
1081 | ; Bus Master IDE PRD Table Address |
Line 1051... | Line 1097... | ||
1051 | mov al, byte [hdid] |
1097 | mov al, byte [hdid] |
1052 | add al, 128+64+32 |
1098 | add al, 128+64+32 |
1053 | out dx, al ; номер головки/номер диска |
1099 | out dx, al ; номер головки/номер диска |
Line 1054... | Line 1100... | ||
1054 | 1100 | ||
- | 1101 | call wait_for_hd_idle |
|
1055 | call wait_for_hd_idle |
1102 | |
1056 | cmp [hd_error], 0 |
1103 | cmp [hd_error], 0 |
1057 | jnz hd_write_error_dma |
- | |
1058 | 1104 | jnz hd_write_error_dma |
|
1059 | ; ATA with 28 or 48 bit for sector number? |
1105 | ; ATA with 28 or 48 bit for sector number? |
1060 | mov esi, [cache_chain_ptr] |
1106 | mov esi, [cache_chain_ptr] |
1061 | mov eax, [esi] |
1107 | mov eax, [esi] |
1062 | ; -40h because the PreCache hits the boundary between lba28 and lba48 |
1108 | ; -40h because the PreCache hits the boundary between lba28 and lba48 |
Line 1132... | Line 1178... | ||
1132 | mov al, 35h ; WRITE DMA EXT |
1178 | mov al, 35h ; WRITE DMA EXT |
1133 | out dx, al ; ATACommand регистр команд |
1179 | out dx, al ; ATACommand регистр команд |
1134 | ;-------------------------------------- |
1180 | ;-------------------------------------- |
1135 | .continue: |
1181 | .continue: |
1136 | ; select controller Primary or Secondary |
1182 | ; select controller Primary or Secondary |
- | 1183 | mov ecx, [IDE_controller_pointer] |
|
1137 | mov dx, [IDEContrRegsBaseAddr] |
1184 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
- | 1185 | ||
1138 | mov eax, [hd_address_table] |
1186 | mov eax, [hdpos] |
- | 1187 | dec eax |
|
1139 | cmp [hdbase], eax ; 0x1F0 |
1188 | test eax, 10b |
1140 | jz @f |
1189 | jz @f |
- | 1190 | ||
1141 | add dx, 8 |
1191 | add dx, 8 |
- | 1192 | ;-------------------------------------- |
|
1142 | @@: |
1193 | @@: |
1143 | ; set write to device and Start Bus Master |
1194 | ; set write to device and Start Bus Master |
1144 | mov al, 1 |
1195 | mov al, 1 |
1145 | out dx, al |
1196 | out dx, al |
- | 1197 | ||
1146 | mov eax, [CURRENT_TASK] |
1198 | mov eax, [hdpos] |
1147 | mov [dma_process], eax |
1199 | dec eax |
1148 | mov eax, [TASK_BASE] |
1200 | test eax, 10b |
1149 | mov [dma_slot_ptr], eax |
- | |
1150 | mov eax, [hd_address_table] |
- | |
1151 | cmp [hdbase], eax ; 0x1F0 |
- | |
1152 | jnz .ide1 |
1201 | jnz .ide1 |
Line 1153... | Line 1202... | ||
1153 | 1202 | ||
1154 | mov [IDE_common_irq_param], irq14_num |
1203 | mov [IDE_common_irq_param], irq14_num |
- | 1204 | jmp @f |
|
1155 | jmp @f |
1205 | ;-------------------------------------- |
1156 | .ide1: |
1206 | .ide1: |
- | 1207 | mov [IDE_common_irq_param], irq15_num |
|
1157 | mov [IDE_common_irq_param], irq15_num |
1208 | ;-------------------------------------- |
1158 | @@: |
1209 | @@: |
1159 | popfd |
1210 | popfd |
1160 | ; wait for interrupt |
1211 | ; wait for interrupt |
- | 1212 | mov [dma_cur_sector], not 0x40 |
|
1161 | mov [dma_cur_sector], not 0x40 |
1213 | |
- | 1214 | mov eax, [hdpos] |
|
1162 | mov eax, [hd_address_table] |
1215 | dec eax |
1163 | cmp [hdbase], eax ; 0x1F0 |
1216 | test eax, 10b |
- | 1217 | jnz .wait_ide1 |
|
1164 | jnz .wait_ide1 |
1218 | |
- | 1219 | call wait_for_sector_dma_ide0 |
|
1165 | call wait_for_sector_dma_ide0 |
1220 | |
- | 1221 | jmp @f |
|
1166 | jmp @f |
1222 | ;-------------------------------------- |
1167 | .wait_ide1: |
1223 | .wait_ide1: |
- | 1224 | call wait_for_sector_dma_ide1 |
|
1168 | call wait_for_sector_dma_ide1 |
1225 | ;-------------------------------------- |
1169 | @@: |
1226 | @@: |
1170 | cmp [hd_error], 0 |
1227 | cmp [hd_error], 0 |
1171 | jnz hd_write_error_dma |
1228 | jnz hd_write_error_dma |
1172 | pop esi |
1229 | pop esi |
1173 | ret |
1230 | ret |
1174 | ;----------------------------------------------------------------------------- |
- | |
1175 | uglobal |
- | |
1176 | align 4 |
- | |
1177 | IDE_Interrupt dw ? |
- | |
1178 | IDEContrRegsBaseAddr dw ? |
- | |
1179 | IDEContrProgrammingInterface dw ? |
- | |
1180 | IDE_BAR0_val dw ? |
- | |
1181 | IDE_BAR1_val dw ? |
- | |
1182 | IDE_BAR2_val dw ? |
- | |
1183 | IDE_BAR3_val dw ? |
- | |
1184 | endg |
- | |
1185 | ;----------------------------------------------------------------------------- |
- | |
1186 | 1231 | ;----------------------------------------------------------------------------- |
|
1187 | proc clear_pci_ide_interrupts |
1232 | proc clear_pci_ide_interrupts |
- | 1233 | mov esi, pcidev_list |
|
- | 1234 | ;-------------------------------------- |
|
1188 | mov esi, pcidev_list |
1235 | align 4 |
1189 | .loop: |
1236 | .loop: |
1190 | mov esi, [esi+PCIDEV.fd] |
1237 | mov esi, [esi+PCIDEV.fd] |
1191 | cmp esi, pcidev_list |
1238 | cmp esi, pcidev_list |
- | 1239 | jz .done |
|
1192 | jz .done |
1240 | |
- | 1241 | ; cmp [esi+PCIDEV.class], 0x01018F |
|
- | 1242 | mov eax, [esi+PCIDEV.class] |
|
- | 1243 | shr eax, 4 |
|
1193 | cmp [esi+PCIDEV.class], 0x01018F |
1244 | cmp eax, 0x01018 |
- | 1245 | jnz .loop |
|
1194 | jnz .loop |
1246 | |
1195 | mov ah, [esi+PCIDEV.bus] |
1247 | mov ah, [esi+PCIDEV.bus] |
1196 | mov al, 2 |
1248 | mov al, 2 |
1197 | mov bh, [esi+PCIDEV.devfn] |
1249 | mov bh, [esi+PCIDEV.devfn] |
1198 | mov bl, 0x20 |
1250 | mov bl, 0x20 |
- | 1251 | call pci_read_reg |
|
1199 | call pci_read_reg |
1252 | |
1200 | and eax, 0FFFCh |
1253 | and eax, 0FFFCh |
1201 | mov edx, eax |
1254 | mov edx, eax |
1202 | add edx, 2 |
1255 | add edx, 2 |
1203 | in al, dx |
1256 | in al, dx |
Line 1210... | Line 1263... | ||
1210 | DEBUGF 1,'port[%x] = %x ',dx,al |
1263 | DEBUGF 1,'port[%x] = %x ',dx,al |
1211 | out dx, al |
1264 | out dx, al |
1212 | in al, dx |
1265 | in al, dx |
1213 | DEBUGF 1,'-> %x\n',al |
1266 | DEBUGF 1,'-> %x\n',al |
1214 | jmp .loop |
1267 | jmp .loop |
- | 1268 | ;-------------------------------------- |
|
1215 | .done: |
1269 | .done: |
1216 | ret |
1270 | ret |
1217 | endp |
1271 | endp |
- | 1272 | ;----------------------------------------------------------------------------- |