Rev 387 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 387 | Rev 388 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | ;----------------------------------------------------------- |
23 | ;----------------------------------------------------------- |
24 | and [hd_error], 0 |
24 | and [hd_error], 0 |
25 | push ecx esi edi ; scan cache |
25 | push ecx esi edi ; scan cache |
Line 26... | Line 26... | ||
26 | 26 | ||
27 | mov ecx,cache_max ; entries in cache |
27 | mov ecx,cache_max ; entries in cache |
28 | mov esi,0x600000+8 |
28 | mov esi,OS_BASE+0x600000+8 |
Line 29... | Line 29... | ||
29 | mov edi,1 |
29 | mov edi,1 |
Line 30... | Line 30... | ||
30 | 30 | ||
Line 52... | Line 52... | ||
52 | jmp @f |
52 | jmp @f |
53 | .nodma: |
53 | .nodma: |
54 | call hd_read_pio |
54 | call hd_read_pio |
55 | @@: |
55 | @@: |
Line 56... | Line 56... | ||
56 | 56 | ||
57 | lea esi,[edi*8+0x600000] |
57 | lea esi,[edi*8+OS_BASE+0x600000] |
58 | mov [esi],eax ; sector number |
58 | mov [esi],eax ; sector number |
Line 59... | Line 59... | ||
59 | mov dword [esi+4],1 ; hd read - mark as same as in hd |
59 | mov dword [esi+4],1 ; hd read - mark as same as in hd |
Line 60... | Line 60... | ||
60 | 60 | ||
61 | yeshdcache: |
61 | yeshdcache: |
62 | 62 | ||
63 | mov esi,edi |
63 | mov esi,edi |
64 | shl esi,9 |
64 | shl esi,9 |
65 | add esi,0x600000+65536 |
65 | add esi,OS_BASE+0x600000+65536 |
66 | mov edi,ebx |
66 | mov edi,ebx |
67 | mov ecx,512/4 |
67 | mov ecx,512/4 |
Line 113... | Line 113... | ||
113 | jne hd_read_error |
113 | jne hd_read_error |
Line 114... | Line 114... | ||
114 | 114 | ||
115 | cli |
115 | cli |
116 | push edi |
116 | push edi |
117 | shl edi,9 |
117 | shl edi,9 |
118 | add edi,0x600000+65536 |
118 | add edi,OS_BASE+0x600000+65536 |
119 | mov ecx,256 |
119 | mov ecx,256 |
120 | mov edx,[hdbase] |
120 | mov edx,[hdbase] |
121 | cld |
121 | cld |
122 | rep insw |
122 | rep insw |
Line 151... | Line 151... | ||
151 | push ecx esi edi |
151 | push ecx esi edi |
Line 152... | Line 152... | ||
152 | 152 | ||
Line 153... | Line 153... | ||
153 | ; check if the cache already has the sector and overwrite it |
153 | ; check if the cache already has the sector and overwrite it |
154 | 154 | ||
155 | mov ecx,cache_max |
155 | mov ecx,cache_max |
Line 156... | Line 156... | ||
156 | mov esi,0x600000+8 |
156 | mov esi,OS_BASE+0x600000+8 |
Line 157... | Line 157... | ||
157 | mov edi,1 |
157 | mov edi,1 |
Line 176... | Line 176... | ||
176 | 176 | ||
177 | call find_empty_slot ; ret in edi |
177 | call find_empty_slot ; ret in edi |
178 | cmp [hd_error],0 |
178 | cmp [hd_error],0 |
Line 179... | Line 179... | ||
179 | jne hd_write_access_denied |
179 | jne hd_write_access_denied |
180 | 180 | ||
Line 181... | Line 181... | ||
181 | lea esi,[edi*8+0x600000] |
181 | lea esi,[edi*8+OS_BASE+0x600000] |
Line 182... | Line 182... | ||
182 | mov [esi],eax ; sector number |
182 | mov [esi],eax ; sector number |
Line 183... | Line 183... | ||
183 | 183 | ||
184 | yes_in_cache_write: |
184 | yes_in_cache_write: |
185 | 185 | ||
186 | mov dword [esi+4],2 ; write - differs from hd |
186 | mov dword [esi+4],2 ; write - differs from hd |
187 | 187 | ||
188 | shl edi,9 |
188 | shl edi,9 |
189 | add edi,0x600000+65536 |
189 | add edi,OS_BASE+0x600000+65536 |
Line 203... | Line 203... | ||
203 | push eax ecx edx esi edi |
203 | push eax ecx edx esi edi |
Line 204... | Line 204... | ||
204 | 204 | ||
Line 205... | Line 205... | ||
205 | ; write difference ( 2 ) from cache to hd |
205 | ; write difference ( 2 ) from cache to hd |
206 | 206 | ||
207 | mov ecx,cache_max |
207 | mov ecx,cache_max |
Line 208... | Line 208... | ||
208 | mov esi,0x600000+8 |
208 | mov esi,OS_BASE+0x600000+8 |
Line 209... | Line 209... | ||
209 | mov edi,1 |
209 | mov edi,1 |
Line 321... | Line 321... | ||
321 | push ecx esi |
321 | push ecx esi |
Line 322... | Line 322... | ||
322 | 322 | ||
323 | ; cli |
323 | ; cli |
324 | mov esi,edi |
324 | mov esi,edi |
325 | shl esi,9 |
325 | shl esi,9 |
326 | add esi,0x600000+65536 ; esi = from memory position |
326 | add esi,OS_BASE+0x600000+65536 ; esi = from memory position |
327 | mov ecx,256 |
327 | mov ecx,256 |
328 | mov edx,[hdbase] |
328 | mov edx,[hdbase] |
329 | cld |
329 | cld |
330 | rep outsw |
330 | rep outsw |
Line 355... | Line 355... | ||
355 | jbe inside_cache |
355 | jbe inside_cache |
356 | mov edi,1 |
356 | mov edi,1 |
Line 357... | Line 357... | ||
357 | 357 | ||
Line 358... | Line 358... | ||
358 | inside_cache: |
358 | inside_cache: |
359 | 359 | ||
360 | cmp dword [edi*8+0x600000+4],2 ; get cache slot info |
360 | cmp dword [edi*8+OS_BASE+0x600000+4],2 ; get cache slot info |
361 | jb found_slot ; it's empty or read |
361 | jb found_slot ; it's empty or read |
Line 362... | Line 362... | ||
362 | dec ecx |
362 | dec ecx |
Line 376... | Line 376... | ||
376 | 376 | ||
377 | align 4 |
377 | align 4 |
Line 378... | Line 378... | ||
378 | clear_hd_cache: |
378 | clear_hd_cache: |
379 | 379 | ||
380 | push eax ecx edi |
380 | push eax ecx edi |
381 | mov edi,0x600000 |
381 | mov edi,OS_BASE+0x600000 |
382 | mov ecx,16384 |
382 | mov ecx,16384 |
383 | xor eax,eax |
383 | xor eax,eax |
384 | cld |
384 | cld |
Line 572... | Line 572... | ||
572 | 572 | ||
573 | iglobal |
573 | iglobal |
574 | align 4 |
574 | align 4 |
575 | ; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary |
575 | ; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary |
576 | IDE_descriptor_table: |
576 | IDE_descriptor_table: |
577 | dd 284000h |
577 | dd OS_BASE+284000h |
578 | dw 2000h |
578 | dw 2000h |
Line 579... | Line 579... | ||
579 | dw 8000h |
579 | dw 8000h |
580 | 580 | ||
Line 605... | Line 605... | ||
605 | mov dx, [IDEContrRegsBaseAddr] |
605 | mov dx, [IDEContrRegsBaseAddr] |
606 | mov al, 0 |
606 | mov al, 0 |
607 | out dx, al |
607 | out dx, al |
608 | call update_counters |
608 | call update_counters |
609 | mov ebx, [dma_process] |
609 | mov ebx, [dma_process] |
610 | cmp [0x3000], ebx |
610 | cmp [CURRENT_TASK], ebx |
611 | jz .noswitch |
611 | jz .noswitch |
612 | mov [dma_task_switched], 1 |
612 | mov [dma_task_switched], 1 |
613 | mov edi, [dma_slot_ptr] |
613 | mov edi, [dma_slot_ptr] |
614 | mov eax, [0x3000] |
614 | mov eax, [CURRENT_TASK] |
615 | mov [dma_process], eax |
615 | mov [dma_process], eax |
616 | mov eax, [0x3010] |
616 | mov eax, [TASK_BASE] |
617 | mov [dma_slot_ptr], eax |
617 | mov [dma_slot_ptr], eax |
618 | mov [0x3000], ebx |
618 | mov [CURRENT_TASK], ebx |
619 | mov [0x3010], edi |
619 | mov [TASK_BASE], edi |
620 | mov byte [0xFFFF], 1 |
620 | mov byte [0xFFFF], 1 |
621 | call do_change_task |
621 | call do_change_task |
622 | .noswitch: |
622 | .noswitch: |
623 | popad |
623 | popad |
624 | popfd |
624 | popfd |
Line 636... | Line 636... | ||
636 | add dx, 8 |
636 | add dx, 8 |
637 | mov al, 0 |
637 | mov al, 0 |
638 | out dx, al |
638 | out dx, al |
639 | call update_counters |
639 | call update_counters |
640 | mov ebx, [dma_process] |
640 | mov ebx, [dma_process] |
641 | cmp [0x3000], ebx |
641 | cmp [CURRENT_TASK], ebx |
642 | jz .noswitch |
642 | jz .noswitch |
643 | mov [dma_task_switched], 1 |
643 | mov [dma_task_switched], 1 |
644 | mov edi, [dma_slot_ptr] |
644 | mov edi, [dma_slot_ptr] |
645 | mov eax, [0x3000] |
645 | mov eax, [CURRENT_TASK] |
646 | mov [dma_process], eax |
646 | mov [dma_process], eax |
647 | mov eax, [0x3010] |
647 | mov eax, [TASK_BASE] |
648 | mov [dma_slot_ptr], eax |
648 | mov [dma_slot_ptr], eax |
649 | mov [0x3000], ebx |
649 | mov [CURRENT_TASK], ebx |
650 | mov [0x3010], edi |
650 | mov [TASK_BASE], edi |
651 | mov byte [0xFFFF], 1 |
651 | mov byte [0xFFFF], 1 |
652 | call do_change_task |
652 | call do_change_task |
653 | .noswitch: |
653 | .noswitch: |
654 | popad |
654 | popad |
655 | popfd |
655 | popfd |
Line 666... | Line 666... | ||
666 | cmp [esp+4], edx |
666 | cmp [esp+4], edx |
667 | ja .notread |
667 | ja .notread |
668 | mov eax, [esp+4] |
668 | mov eax, [esp+4] |
669 | sub eax, [dma_cur_sector] |
669 | sub eax, [dma_cur_sector] |
670 | shl eax, 9 |
670 | shl eax, 9 |
671 | add eax, 0x284000 |
671 | add eax, OS_BASE+0x284000 |
672 | push ecx esi edi |
672 | push ecx esi edi |
673 | mov esi, eax |
673 | mov esi, eax |
674 | shl edi, 9 |
674 | shl edi, 9 |
675 | add edi, 0x610000 |
675 | add edi, OS_BASE+0x610000 |
676 | mov ecx, 512/4 |
676 | mov ecx, 512/4 |
677 | cld |
677 | cld |
678 | rep movsd |
678 | rep movsd |
679 | pop edi esi ecx |
679 | pop edi esi ecx |
680 | pop edx |
680 | pop edx |
681 | pop eax |
681 | pop eax |
682 | ret |
682 | ret |
683 | .notread: |
683 | .notread: |
684 | mov eax, IDE_descriptor_table |
684 | mov eax, IDE_descriptor_table-OS_BASE |
685 | mov dword [eax], 0x284000 |
685 | mov dword [eax+OS_BASE], 0x284000 |
686 | mov word [eax+4], 0x2000 |
686 | mov word [eax+4+OS_BASE], 0x2000 |
687 | mov dx, [IDEContrRegsBaseAddr] |
687 | mov dx, [IDEContrRegsBaseAddr] |
688 | cmp [hdbase], 0x1F0 |
688 | cmp [hdbase], 0x1F0 |
689 | jz @f |
689 | jz @f |
690 | add edx, 8 |
690 | add edx, 8 |
691 | @@: |
691 | @@: |
Line 732... | Line 732... | ||
732 | jz @f |
732 | jz @f |
733 | add dx, 8 |
733 | add dx, 8 |
734 | @@: |
734 | @@: |
735 | mov al, 9 |
735 | mov al, 9 |
736 | out dx, al |
736 | out dx, al |
737 | mov eax, [0x3000] |
737 | mov eax, [CURRENT_TASK] |
738 | mov [dma_process], eax |
738 | mov [dma_process], eax |
739 | mov eax, [0x3010] |
739 | mov eax, [TASK_BASE] |
740 | mov [dma_slot_ptr], eax |
740 | mov [dma_slot_ptr], eax |
741 | cmp [hdbase], 0x1F0 |
741 | cmp [hdbase], 0x1F0 |
742 | jnz .ide1 |
742 | jnz .ide1 |
743 | mov [irq14_func], hdd_irq14 |
743 | mov [irq14_func], hdd_irq14 |
744 | jmp @f |
744 | jmp @f |
Line 764... | Line 764... | ||
764 | write_cache_chain: |
764 | write_cache_chain: |
765 | push esi |
765 | push esi |
766 | mov eax, IDE_descriptor_table |
766 | mov eax, IDE_descriptor_table |
767 | mov edx, [cache_chain_pos] |
767 | mov edx, [cache_chain_pos] |
768 | shl edx, 9 |
768 | shl edx, 9 |
769 | add edx, 0x610000 |
769 | add edx, OS_BASE+0x610000 |
770 | mov [eax], edx |
770 | mov [eax], edx |
771 | movzx edx, [cache_chain_size] |
771 | movzx edx, [cache_chain_size] |
772 | shl edx, 9 |
772 | shl edx, 9 |
773 | mov [eax+4], dx |
773 | mov [eax+4], dx |
774 | jmp do_write_dma |
774 | jmp do_write_dma |
775 | write_cache_sector: |
775 | write_cache_sector: |
776 | push esi |
776 | push esi |
777 | mov eax, IDE_descriptor_table |
777 | mov eax, IDE_descriptor_table |
778 | mov edx, edi |
778 | mov edx, edi |
779 | shl edx, 9 |
779 | shl edx, 9 |
780 | add edx, 0x610000 |
780 | add edx, OS_BASE+0x610000 |
781 | mov [eax], edx |
781 | mov [eax], edx |
782 | mov word [eax+4], 0x200 |
782 | mov word [eax+4], 0x200 |
783 | do_write_dma: |
783 | do_write_dma: |
784 | mov dx, [IDEContrRegsBaseAddr] |
784 | mov dx, [IDEContrRegsBaseAddr] |
785 | cmp [hdbase], 0x1F0 |
785 | cmp [hdbase], 0x1F0 |
Line 830... | Line 830... | ||
830 | jz @f |
830 | jz @f |
831 | add dx, 8 |
831 | add dx, 8 |
832 | @@: |
832 | @@: |
833 | mov al, 1 |
833 | mov al, 1 |
834 | out dx, al |
834 | out dx, al |
835 | mov eax, [0x3000] |
835 | mov eax, [CURRENT_TASK] |
836 | mov [dma_process], eax |
836 | mov [dma_process], eax |
837 | mov eax, [0x3010] |
837 | mov eax, [TASK_BASE] |
838 | mov [dma_slot_ptr], eax |
838 | mov [dma_slot_ptr], eax |
839 | cmp [hdbase], 0x1F0 |
839 | cmp [hdbase], 0x1F0 |
840 | jnz .ide1 |
840 | jnz .ide1 |
841 | mov [irq14_func], hdd_irq14 |
841 | mov [irq14_func], hdd_irq14 |
842 | jmp @f |
842 | jmp @f |