Subversion Repositories Kolibri OS

Rev

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

Rev 4457 Rev 4587
Line 256... Line 256...
256
        mov     eax, [.sector_lo+.local_vars2_size+8]
256
        mov     eax, [.sector_lo+.local_vars2_size+8]
257
        mov     edx, [.sector_hi+.local_vars2_size+8]
257
        mov     edx, [.sector_hi+.local_vars2_size+8]
258
        call    cache_lookup_write
258
        call    cache_lookup_write
259
        test    eax, eax
259
        test    eax, eax
260
        jnz     .cache_error
260
        jnz     .cache_error
-
 
261
; 12d. If the sector was already present in the cache as modified,
-
 
262
; data that were read at step 10 for this sector are obsolete,
-
 
263
; so rewrite data for the caller from the cache.
-
 
264
        cmp     [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED
-
 
265
        jnz     .not_modified
-
 
266
        mov     esi, ecx
-
 
267
        shl     esi, 9
-
 
268
        add     esi, [ebx+DISKCACHE.data]
-
 
269
        mov     edi, [esp+4]
-
 
270
        mov     ecx, [esp]
-
 
271
        shl     ecx, 9-2
-
 
272
        sub     edi, ecx
-
 
273
        mov     ecx, 512/4
-
 
274
        rep movsd
-
 
275
        add     [.current_buffer+8], 512
-
 
276
        jmp     .sector_done
-
 
277
.not_modified:
-
 
278
; 12e. For each not-modified sector,
261
; 12d. For each sector, copy data, mark the item as not-modified copy of the disk,
279
; copy data, mark the item as not-modified copy of the disk,
262
; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
280
; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
263
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
281
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
264
        mov     esi, [.current_buffer+8]
282
        mov     esi, [.current_buffer+8]
265
        mov     edi, ecx
283
        mov     edi, ecx
266
        shl     edi, 9
284
        shl     edi, 9
267
        add     edi, [ebx+DISKCACHE.data]
285
        add     edi, [ebx+DISKCACHE.data]
268
        mov     ecx, 512/4
286
        mov     ecx, 512/4
269
        rep movsd
287
        rep movsd
270
        mov     [.current_buffer+8], esi
288
        mov     [.current_buffer+8], esi
-
 
289
.sector_done:
271
        add     [.sector_lo+.local_vars2_size+8], 1
290
        add     [.sector_lo+.local_vars2_size+8], 1
272
        adc     [.sector_hi+.local_vars2_size+8], 0
291
        adc     [.sector_hi+.local_vars2_size+8], 0
273
; 12e. Continue the loop 12c-12d until all sectors are read.
292
; 12f. Continue the loop 12c-12e until all sectors are read.
274
        dec     dword [esp]
293
        dec     dword [esp]
275
        jnz     .store_to_cache
294
        jnz     .store_to_cache
276
.cache_error:
295
.cache_error:
277
; 12f. Restore after the loop: pop the local variable and restore edi.
296
; 12g. Restore after the loop: pop the local variable and restore edi.
278
        pop     ecx
297
        pop     ecx
279
        pop     edi
298
        pop     edi
280
; 12g. Release the lock.
299
; 12h. Release the lock.
281
        mov     ecx, [ebp+PARTITION.Disk]
300
        mov     ecx, [ebp+PARTITION.Disk]
282
        add     ecx, DISK.CacheLock
301
        add     ecx, DISK.CacheLock
283
        call    mutex_unlock
302
        call    mutex_unlock
284
.copy_done:
303
.copy_done:
285
; 13. Remove portion of local variables created at step 9.
304
; 13. Remove portion of local variables created at step 9.
Line 649... Line 668...
649
        mov     eax, [.sector_lo+.local_vars2_size]
668
        mov     eax, [.sector_lo+.local_vars2_size]
650
        mov     edx, [.sector_hi+.local_vars2_size]
669
        mov     edx, [.sector_hi+.local_vars2_size]
651
        call    cache_lookup_write
670
        call    cache_lookup_write
652
        test    eax, eax
671
        test    eax, eax
653
        jnz     .cache_error
672
        jnz     .cache_error
-
 
673
; 11c. Ignore sectors marked as modified: for them the cache is more recent that disk data.
-
 
674
        cmp     [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED
-
 
675
        jnz     .not_modified
-
 
676
        add     [.current_buffer], 512
-
 
677
        jmp     .sector_done
-
 
678
.not_modified:
654
; 11c. For each sector, copy data, mark the item as not-modified copy of the disk,
679
; 11d. For each sector, copy data, mark the item as not-modified copy of the disk,
655
; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
680
; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
656
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
681
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
657
        mov     esi, [.current_buffer]
682
        mov     esi, [.current_buffer]
658
        mov     edi, ecx
683
        mov     edi, ecx
659
        shl     edi, 9
684
        shl     edi, 9
660
        add     edi, [ebx+DISKCACHE.data]
685
        add     edi, [ebx+DISKCACHE.data]
661
        mov     ecx, 512/4
686
        mov     ecx, 512/4
662
        rep movsd
687
        rep movsd
663
        mov     [.current_buffer], esi
688
        mov     [.current_buffer], esi
-
 
689
.sector_done:
664
        add     [.sector_lo+.local_vars2_size], 1
690
        add     [.sector_lo+.local_vars2_size], 1
665
        adc     [.sector_hi+.local_vars2_size], 0
691
        adc     [.sector_hi+.local_vars2_size], 0
666
; 11d. Continue the loop at 11b-11c until all sectors are processed.
692
; 11e. Continue the loop at 11b-11d until all sectors are processed.
667
        dec     [.num_sectors]
693
        dec     [.num_sectors]
668
        jnz     .store_to_cache
694
        jnz     .store_to_cache
669
.cache_error:
695
.cache_error:
670
; 11e. Release the lock.
696
; 11f. Release the lock.
671
        mov     ecx, [ebp+PARTITION.Disk]
697
        mov     ecx, [ebp+PARTITION.Disk]
672
        add     ecx, DISK.CacheLock
698
        add     ecx, DISK.CacheLock
673
        call    mutex_unlock
699
        call    mutex_unlock
674
.copy_done:
700
.copy_done:
675
; 12. Remove portion of local variables created at step 8,
701
; 12. Remove portion of local variables created at step 8,
Line 693... Line 719...
693
; We are still holding the lock acquired at step 4a.
719
; We are still holding the lock acquired at step 4a.
694
; 13. Call the lookup function adding sector to the cache.
720
; 13. Call the lookup function adding sector to the cache.
695
        call    cache_lookup_write
721
        call    cache_lookup_write
696
        test    eax, eax
722
        test    eax, eax
697
        jnz     .floppy_cache_error
723
        jnz     .floppy_cache_error
698
; 14. Mark the item as empty for the case of read error.
-
 
699
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_EMPTY
-
 
700
        push    ecx
724
        push    ecx
Line 701... Line 725...
701
 
725
 
702
; 15. Call the driver to read one sector.
726
; 14. Call the driver to read one sector.
703
        push    1
727
        push    1
704
        push    esp
728
        push    esp
705
        push    edx
729
        push    edx
706
        push    [.sector_lo+16]
730
        push    [.sector_lo+16]
Line 711... Line 735...
711
        mov     al, DISKFUNC.read
735
        mov     al, DISKFUNC.read
712
        call    disk_call_driver
736
        call    disk_call_driver
713
        pop     ecx
737
        pop     ecx
714
        dec     ecx
738
        dec     ecx
715
        jnz     .floppy_read_error
739
        jnz     .floppy_read_error
716
; 16. Get the slot and pointer to the cache item,
740
; 15. Get the slot and pointer to the cache item,
717
; change the status to not-modified copy of the disk
741
; change the status to not-modified copy of the disk
718
; and go to 4c.
742
; and go to 4c.
719
        pop     ecx
743
        pop     ecx
720
        lea     esi, [ecx*sizeof.CACHE_ITEM/4]
744
        lea     esi, [ecx*sizeof.CACHE_ITEM/4]
721
        shl     esi, 2
745
        shl     esi, 2
722
        add     esi, [ebx+DISKCACHE.pointer]
746
        add     esi, [ebx+DISKCACHE.pointer]
723
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
747
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
724
        jmp     .found_in_cache
748
        jmp     .found_in_cache
Line 725... Line 749...
725
 
749
 
726
; On error at steps 13-15, release the lock
750
; On error at steps 13-14, release the lock
727
; and pass the error to the caller.
751
; and pass the error to the caller.
728
.floppy_read_error:
752
.floppy_read_error:
729
        pop     ecx
753
        pop     ecx
730
.floppy_cache_error:
754
.floppy_cache_error:
Line 847... Line 871...
847
        jmp     .search_again           ; and start again
871
        jmp     .search_again           ; and start again
848
.found_slot:
872
.found_slot:
849
        mov     [ebx+DISKCACHE.search_start], ecx
873
        mov     [ebx+DISKCACHE.search_start], ecx
850
        popd    [esi+CACHE_ITEM.SectorLo]
874
        popd    [esi+CACHE_ITEM.SectorLo]
851
        popd    [esi+CACHE_ITEM.SectorHi]
875
        popd    [esi+CACHE_ITEM.SectorHi]
-
 
876
        mov     [esi+CACHE_ITEM.Status], CACHE_ITEM_EMPTY
852
.return0:
877
.return0:
853
        xor     eax, eax        ; success
878
        xor     eax, eax        ; success
854
        ret
879
        ret
855
.found_slot_access_denied:
880
.found_slot_access_denied:
856
        add     esp, 8
881
        add     esp, 8