Subversion Repositories Kolibri OS

Rev

Rev 467 | Rev 514 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 467 Rev 472
Line 1... Line 1...
1
$Revision: 467 $
1
$Revision: 472 $
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                              ;;
3
;;                                                              ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
6
;;                                                              ;;
Line 31... Line 31...
31
;-----------------------------------------------------------
31
;-----------------------------------------------------------
32
        and     [hd_error], 0
32
        and     [hd_error], 0
33
    push  ecx esi edi           ; scan cache
33
    push  ecx esi edi           ; scan cache
Line 34... Line 34...
34
 
34
 
35
    mov   ecx,cache_max         ; entries in cache
35
    mov   ecx,cache_max         ; entries in cache
36
    mov   esi,OS_BASE+0x600000+8
36
    mov   esi,HD_CACHE+8
Line 37... Line 37...
37
    mov   edi,1
37
    mov   edi,1
Line 38... Line 38...
38
 
38
 
Line 60... Line 60...
60
        jmp     @f
60
        jmp     @f
61
.nodma:
61
.nodma:
62
        call    hd_read_pio
62
        call    hd_read_pio
63
@@:
63
@@:
Line 64... Line 64...
64
 
64
 
65
    lea   esi,[edi*8+OS_BASE+0x600000]
65
    lea   esi,[edi*8+HD_CACHE]
66
    mov   [esi],eax             ; sector number
66
    mov   [esi],eax             ; sector number
Line 67... Line 67...
67
    mov   dword [esi+4],1       ; hd read - mark as same as in hd
67
    mov   dword [esi+4],1       ; hd read - mark as same as in hd
Line 68... Line 68...
68
 
68
 
69
  yeshdcache:
69
  yeshdcache:
70
 
70
 
71
    mov   esi,edi
71
    mov   esi,edi
72
    shl   esi,9
72
    shl   esi,9
73
    add   esi,OS_BASE+0x600000+65536
73
    add   esi,HD_CACHE+65536
74
    mov   edi,ebx
74
    mov   edi,ebx
75
    mov   ecx,512/4
75
    mov   ecx,512/4
Line 121... Line 121...
121
    jne   hd_read_error
121
    jne   hd_read_error
Line 122... Line 122...
122
 
122
 
123
    cli
123
    cli
124
    push  edi
124
    push  edi
125
    shl   edi,9
125
    shl   edi,9
126
    add   edi,OS_BASE+0x600000+65536
126
    add   edi,HD_CACHE+65536
127
    mov   ecx,256
127
    mov   ecx,256
128
    mov   edx,[hdbase]
128
    mov   edx,[hdbase]
129
    cld
129
    cld
130
    rep   insw
130
    rep   insw
Line 159... Line 159...
159
    push  ecx esi edi
159
    push  ecx esi edi
Line 160... Line 160...
160
 
160
 
Line 161... Line 161...
161
    ; check if the cache already has the sector and overwrite it
161
    ; check if the cache already has the sector and overwrite it
162
 
162
 
163
    mov   ecx,cache_max
163
    mov   ecx,cache_max
Line 164... Line 164...
164
    mov   esi,OS_BASE+0x600000+8
164
    mov   esi,HD_CACHE+8
Line 165... Line 165...
165
    mov   edi,1
165
    mov   edi,1
Line 184... Line 184...
184
 
184
 
185
    call  find_empty_slot       ; ret in edi
185
    call  find_empty_slot       ; ret in edi
186
    cmp   [hd_error],0
186
    cmp   [hd_error],0
Line 187... Line 187...
187
    jne   hd_write_access_denied
187
    jne   hd_write_access_denied
188
 
188
 
Line 189... Line 189...
189
    lea   esi,[edi*8+OS_BASE+0x600000]
189
    lea   esi,[edi*8+HD_CACHE]
Line 190... Line 190...
190
    mov   [esi],eax             ; sector number
190
    mov   [esi],eax             ; sector number
Line 191... Line 191...
191
 
191
 
192
  yes_in_cache_write:
192
  yes_in_cache_write:
193
 
193
 
194
    mov   dword [esi+4],2       ; write - differs from hd
194
    mov   dword [esi+4],2       ; write - differs from hd
195
 
195
 
196
    shl   edi,9
196
    shl   edi,9
197
    add   edi,OS_BASE+0x600000+65536
197
    add   edi,HD_CACHE+65536
Line 211... Line 211...
211
    push  eax ecx edx esi edi
211
    push  eax ecx edx esi edi
Line 212... Line 212...
212
 
212
 
Line 213... Line 213...
213
    ; write difference ( 2 ) from cache to hd
213
    ; write difference ( 2 ) from cache to hd
214
 
214
 
215
    mov   ecx,cache_max
215
    mov   ecx,cache_max
Line 216... Line 216...
216
    mov   esi,OS_BASE+0x600000+8
216
    mov   esi,HD_CACHE+8
Line 217... Line 217...
217
    mov   edi,1
217
    mov   edi,1
Line 329... Line 329...
329
    push  ecx esi
329
    push  ecx esi
Line 330... Line 330...
330
 
330
 
331
;    cli
331
;    cli
332
    mov   esi,edi
332
    mov   esi,edi
333
    shl   esi,9
333
    shl   esi,9
334
    add   esi,OS_BASE+0x600000+65536    ; esi = from memory position
334
    add   esi,HD_CACHE+65536    ; esi = from memory position
335
    mov   ecx,256
335
    mov   ecx,256
336
    mov   edx,[hdbase]
336
    mov   edx,[hdbase]
337
    cld
337
    cld
338
    rep   outsw
338
    rep   outsw
Line 363... Line 363...
363
    jbe   inside_cache
363
    jbe   inside_cache
364
    mov   edi,1
364
    mov   edi,1
Line 365... Line 365...
365
 
365
 
Line 366... Line 366...
366
  inside_cache:
366
  inside_cache:
367
 
367
 
368
    cmp   dword [edi*8+OS_BASE+0x600000+4],2    ; get cache slot info
368
    cmp   dword [edi*8+HD_CACHE+4],2    ; get cache slot info
369
    jb    found_slot                    ; it's empty or read
369
    jb    found_slot                    ; it's empty or read
Line 370... Line 370...
370
    dec   ecx
370
    dec   ecx
Line 384... Line 384...
384
 
384
 
385
align 4
385
align 4
Line 386... Line 386...
386
clear_hd_cache:
386
clear_hd_cache:
387
 
387
 
388
    push  eax ecx edi
388
    push  eax ecx edi
389
    mov   edi,OS_BASE+0x600000
389
    mov   edi, HD_CACHE
390
    mov   ecx,16384
390
    mov   ecx,16384
391
    xor   eax,eax
391
    xor   eax,eax
392
    cld
392
    cld
Line 678... Line 678...
678
        shl     eax, 9
678
        shl     eax, 9
679
        add     eax, OS_BASE+0x284000
679
        add     eax, OS_BASE+0x284000
680
        push    ecx esi edi
680
        push    ecx esi edi
681
        mov     esi, eax
681
        mov     esi, eax
682
        shl     edi, 9
682
        shl     edi, 9
683
        add     edi, OS_BASE+0x610000
683
        add     edi, HD_CACHE+0x10000
684
        mov     ecx, 512/4
684
        mov     ecx, 512/4
685
        cld
685
        cld
686
        rep     movsd
686
        rep     movsd
687
        pop     edi esi ecx
687
        pop     edi esi ecx
688
        pop     edx
688
        pop     edx
Line 773... Line 773...
773
write_cache_chain:
773
write_cache_chain:
774
        push    esi
774
        push    esi
775
        mov     eax, IDE_descriptor_table
775
        mov     eax, IDE_descriptor_table
776
        mov     edx, [cache_chain_pos]
776
        mov     edx, [cache_chain_pos]
777
        shl     edx, 9
777
        shl     edx, 9
778
        add     edx, 0x610000
778
        add     edx, DMA_HD_MEM+0x10000
779
        mov     [eax], edx
779
        mov     [eax], edx
780
        movzx   edx, [cache_chain_size]
780
        movzx   edx, [cache_chain_size]
781
        shl     edx, 9
781
        shl     edx, 9
782
        mov     [eax+4], dx
782
        mov     [eax+4], dx
783
        jmp     do_write_dma
783
        jmp     do_write_dma
784
write_cache_sector:
784
write_cache_sector:
785
        push    esi
785
        push    esi
786
        mov     eax, IDE_descriptor_table
786
        mov     eax, IDE_descriptor_table
787
        mov     edx, edi
787
        mov     edx, edi
788
        shl     edx, 9
788
        shl     edx, 9
789
        add     edx, 0x610000
789
        add     edx, DMA_HD_MEM+0x10000
790
        mov     [eax], edx
790
        mov     [eax], edx
791
        mov     word [eax+4], 0x200
791
        mov     word [eax+4], 0x200
792
do_write_dma:
792
do_write_dma:
793
        sub     eax, OS_BASE
793
        sub     eax, OS_BASE
794
        mov     dx, [IDEContrRegsBaseAddr]
794
        mov     dx, [IDEContrRegsBaseAddr]