Rev 6015 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6015 | Rev 6650 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 6015 $ |
8 | $Revision: 6650 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | ; HDD driver |
10 | ; HDD driver |
Line 73... | Line 73... | ||
73 | mov al, 25h ; READ DMA EXT |
73 | mov al, 25h ; READ DMA EXT |
74 | jmp ide_read_write |
74 | jmp ide_read_write |
Line 75... | Line 75... | ||
75 | 75 | ||
76 | ide_write: |
76 | ide_write: |
77 | mov al, 35h ; WRITE DMA EXT |
- | |
78 | 77 | mov al, 35h ; WRITE DMA EXT |
|
79 | proc ide_read_write stdcall uses esi edi ebx, \ |
78 | proc ide_read_write stdcall uses esi edi ebx, \ |
80 | hd_data, buffer, startsector:qword, numsectors |
79 | hd_data, buffer, startsector:qword, numsectors |
81 | ; hd_data = pointer to hd*_data |
80 | ; hd_data = pointer to hd*_data |
82 | ; buffer = pointer to buffer with/for data |
81 | ; buffer = pointer to buffer with/for data |
Line 151... | Line 150... | ||
151 | sub [sectors_todo], ecx |
150 | sub [sectors_todo], ecx |
152 | jz .out |
151 | jz .out |
153 | add [sector], ecx |
152 | add [sector], ecx |
154 | adc word [sector+4], 0 |
153 | adc word [sector+4], 0 |
155 | jmp .next |
154 | jmp .next |
- | 155 | ||
156 | .LBA28: |
156 | .LBA28: |
157 | add eax, [sectors_todo] |
157 | add eax, [sectors_todo] |
158 | add eax, 0xF0000000 |
158 | add eax, 0xF0000000 |
159 | jc .out |
159 | jc .out |
160 | sub bl, 5 ; READ/WRITE SECTOR(S) |
160 | sub bl, 5 ; READ/WRITE SECTOR(S) |
Line 175... | Line 175... | ||
175 | add [eax], ecx |
175 | add [eax], ecx |
176 | sub [sectors_todo], ecx |
176 | sub [sectors_todo], ecx |
177 | jz .out |
177 | jz .out |
178 | add [sector], ecx |
178 | add [sector], ecx |
179 | jmp .next28 |
179 | jmp .next28 |
- | 180 | ||
180 | ; loop is done, either due to error or because everything is done |
181 | ; loop is done, either due to error or because everything is done |
181 | ; release the global lock and return the corresponding status |
182 | ; release the global lock and return the corresponding status |
182 | .out: |
183 | .out: |
183 | sbb eax, eax |
184 | sbb eax, eax |
184 | push eax |
185 | push eax |
Line 312... | Line 313... | ||
312 | add edi, 8 |
313 | add edi, 8 |
313 | sub [blockSize], edx |
314 | sub [blockSize], edx |
314 | jnz .aligned |
315 | jnz .aligned |
315 | sub edi, 8 |
316 | sub edi, 8 |
316 | jmp @f |
317 | jmp @f |
- | 318 | ||
317 | .end: |
319 | .end: |
318 | mov ecx, [blockSize] |
320 | mov ecx, [blockSize] |
319 | mov [edi+4], ecx |
321 | mov [edi+4], ecx |
320 | @@: |
322 | @@: |
321 | mov byte [edi+7], 80h ; list end |
323 | mov byte [edi+7], 80h ; list end |
Line 370... | Line 372... | ||
370 | mov ebx, edx |
372 | mov ebx, edx |
371 | mov ecx, 300 |
373 | mov ecx, 300 |
372 | call wait_event_timeout |
374 | call wait_event_timeout |
373 | test eax, eax |
375 | test eax, eax |
374 | jnz @f |
376 | jnz @f |
- | 377 | dbgstr 'IDE DMA IRQ timeout' |
|
375 | mov [IDE_common_irq_param], 0 |
378 | mov [IDE_common_irq_param], 0 |
376 | mov eax, [eventPointer] |
379 | mov eax, [eventPointer] |
377 | mov ebx, [eventID] |
380 | mov ebx, [eventID] |
378 | call destroy_event |
381 | call destroy_event |
379 | mov [eventPointer], 0 |
382 | mov [eventPointer], 0 |
Line 437... | Line 440... | ||
437 | test al, 8 ; ready for transfer? |
440 | test al, 8 ; ready for transfer? |
438 | jz @b |
441 | jz @b |
439 | cmp [hd_setup], 1 ; do not mark error for setup request |
442 | cmp [hd_setup], 1 ; do not mark error for setup request |
440 | jz @f |
443 | jz @f |
441 | test al, 1 ; previous command ended up with an error |
444 | test al, 1 ; previous command ended up with an error |
442 | jnz .hd_error |
445 | jnz .pio_error |
443 | @@: |
446 | @@: |
444 | pushfd |
447 | pushfd |
445 | cli |
448 | cli |
446 | cld |
449 | cld |
447 | mov ecx, 256 |
450 | mov ecx, 256 |
448 | mov edx, [hdbase] |
451 | mov edx, [hdbase] |
449 | cmp bl, 30h |
452 | cmp bl, 30h |
450 | jnc .write |
453 | jnc .write |
451 | rep insw |
454 | rep insw |
452 | jmp @f |
455 | jmp @f |
- | 456 | ||
453 | .write: |
457 | .write: |
454 | rep outsw |
458 | rep outsw |
455 | @@: |
459 | @@: |
456 | popfd |
460 | popfd |
457 | add edx, 7 |
461 | add edx, 7 |
458 | dec dword [blockSize] |
462 | dec dword [blockSize] |
459 | jnz .sectorTransfer |
463 | jnz .sectorTransfer |
460 | ret |
464 | ret |
- | 465 | ||
- | 466 | .pio_error: |
|
- | 467 | dbgstr 'IDE PIO transfer error' |
|
461 | .hd_error: |
468 | .hd_error: |
462 | cmp bl, 30h |
469 | cmp bl, 30h |
463 | jnc hd_write_error |
470 | jnc hd_write_error |
464 | ;----------------------------------------------------------------- |
471 | ;----------------------------------------------------------------- |
465 | hd_read_error: |
472 | hd_read_error: |
466 | if lang eq sp |
- | |
467 | DEBUGF 1,"K : FS - HD error de lectura\n" |
- | |
468 | else |
- | |
469 | DEBUGF 1,"K : FS - HD read error\n" |
473 | dbgstr 'HD read error' |
470 | end if |
- | |
471 | stc |
474 | stc |
472 | ret |
475 | ret |
473 | ;----------------------------------------------------------------- |
476 | ;----------------------------------------------------------------- |
474 | hd_write_error: |
477 | hd_write_error: |
475 | if lang eq sp |
- | |
476 | DEBUGF 1,"K : FS - HD error de escritura\n" |
- | |
477 | else |
- | |
478 | DEBUGF 1,"K : FS - HD write error\n" |
478 | dbgstr 'HD write error' |
479 | end if |
- | |
480 | stc |
479 | stc |
481 | ret |
480 | ret |
482 | ;----------------------------------------------------------------- |
481 | ;----------------------------------------------------------------- |
483 | save_hd_wait_timeout: |
482 | save_hd_wait_timeout: |
484 | mov eax, [timer_ticks] |
483 | mov eax, [timer_ticks] |
Line 489... | Line 488... | ||
489 | check_hd_wait_timeout: |
488 | check_hd_wait_timeout: |
490 | mov eax, [timer_ticks] |
489 | mov eax, [timer_ticks] |
491 | cmp [hd_wait_timeout], eax |
490 | cmp [hd_wait_timeout], eax |
492 | jc @f |
491 | jc @f |
493 | ret |
492 | ret |
- | 493 | ||
494 | @@: |
494 | @@: |
495 | if lang eq sp |
- | |
496 | DEBUGF 1,"K : FS - HD tiempo de espera agotado\n" |
- | |
497 | else |
- | |
498 | DEBUGF 1,"K : FS - HD timeout\n" |
495 | dbgstr 'IDE device timeout' |
499 | end if |
- | |
500 | stc |
496 | stc |
501 | ret |
497 | ret |
502 | ;----------------------------------------------------------------- |
498 | ;----------------------------------------------------------------- |
503 | align 4 |
499 | align 4 |
504 | IDE_irq_14_handler: |
500 | IDE_irq_14_handler: |
Line 526... | Line 522... | ||
526 | jnz .interrupt_from_primary |
522 | jnz .interrupt_from_primary |
527 | add edx, 8 |
523 | add edx, 8 |
528 | in al, dx |
524 | in al, dx |
529 | test al, 4 |
525 | test al, 4 |
530 | jnz .interrupt_from_secondary |
526 | jnz .interrupt_from_secondary |
531 | .exit_notour: |
- | |
532 | xor eax, eax ; not our interrupt |
527 | xor eax, eax ; not our interrupt |
533 | ret |
528 | ret |
- | 529 | ||
534 | .interrupt_from_primary: |
530 | .interrupt_from_primary: |
535 | out dx, al ; clear Interrupt bit |
531 | out dx, al ; clear Interrupt bit |
536 | sub edx, 2 |
532 | sub edx, 2 |
537 | xor eax, eax |
533 | xor eax, eax |
538 | out dx, al ; clear Bus Master IDE Command register |
534 | out dx, al ; clear Bus Master IDE Command register |
Line 542... | Line 538... | ||
542 | cmp [IDE_common_irq_param], 14 |
538 | cmp [IDE_common_irq_param], 14 |
543 | jz .raise |
539 | jz .raise |
544 | .exit_our: |
540 | .exit_our: |
545 | mov al, 1 |
541 | mov al, 1 |
546 | ret |
542 | ret |
- | 543 | ||
547 | .interrupt_from_secondary: |
544 | .interrupt_from_secondary: |
548 | out dx, al ; clear Interrupt bit |
545 | out dx, al ; clear Interrupt bit |
549 | sub edx, 2 |
546 | sub edx, 2 |
550 | xor eax, eax |
547 | xor eax, eax |
551 | out dx, al ; clear Bus Master IDE Command register |
548 | out dx, al ; clear Bus Master IDE Command register |
Line 564... | Line 561... | ||
564 | xor esi, esi |
561 | xor esi, esi |
565 | call raise_event |
562 | call raise_event |
566 | popad |
563 | popad |
567 | mov al, 1 ; remove the interrupt request |
564 | mov al, 1 ; remove the interrupt request |
568 | ret |
565 | ret |
569 | ;----------------------------------------------------------------- |
- |