Subversion Repositories Kolibri OS

Rev

Rev 4923 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4429 Serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
;**************************************************************************
9
;
10
;   [cache_ide[X]_pointer]
11
;   or [cache_ide[X]_data_pointer]  first entry in cache list
12
;
13
;            +0   - lba sector
14
;            +4   - state of cache sector
15
;                   0 = empty
16
;                   1 = used for read  ( same as in hd )
17
;                   2 = used for write ( differs from hd )
18
;
19
;  [cache_ide[X]_system_data]
20
;  or [cache_ide[x]_appl_data] - cache entries
21
;
22
;**************************************************************************
23
 
4993 Serge 24
$Revision: 4700 $
4429 Serge 25
 
26
align 4
27
find_empty_slot_CD_cache:
28
;-----------------------------------------------------------
29
; find empty or read slot, flush cache if next 10% is used by write
30
; output : edi = cache slot
31
;-----------------------------------------------------------
32
.search_again:
33
        call    cd_calculate_cache_3
34
.search_for_empty:
35
        inc     edi
36
        call    cd_calculate_cache_4
37
        jbe     .inside_cache
38
        mov     edi, 1
39
.inside_cache:
40
        call    cd_calculate_cache_5
41
        ret
42
;--------------------------------------------------------------------
43
clear_CD_cache:
4923 Serge 44
        DEBUGF  1, 'K : clear_CD_cache\n'
4429 Serge 45
        pusha
4923 Serge 46
 
47
        mov     esi, [cdpos]
48
        dec     esi
49
        imul    esi, sizeof.IDE_CACHE
50
        add     esi, cache_ide0
51
 
4429 Serge 52
        xor     eax, eax
4923 Serge 53
 
54
        mov     [esi+IDE_CACHE.search_start], eax
55
        mov     ecx, [esi+IDE_CACHE.system_sad_size]
56
        mov     edi, [esi+IDE_CACHE.pointer]
4429 Serge 57
        call    .clear
4923 Serge 58
 
59
        mov     [esi+IDE_CACHE.appl_search_start], eax
60
        mov     ecx, [esi+IDE_CACHE.appl_sad_size]
61
        mov     edi, [esi+IDE_CACHE.data_pointer]
4429 Serge 62
        call    .clear
4923 Serge 63
 
4429 Serge 64
        popa
65
        ret
4923 Serge 66
;--------------------------------------
4429 Serge 67
.clear:
68
        shl     ecx, 1
69
        cld
70
        rep stosd
71
        ret
72
;--------------------------------------------------------------------
73
align 4
74
cd_calculate_cache:
4923 Serge 75
; 1 - IDE0 ... 12 - IDE11
76
        push    eax
77
 
78
        mov     eax, [cdpos]
79
        dec     eax
80
        imul    eax, sizeof.IDE_CACHE
81
        add     eax, cache_ide0
82
 
4429 Serge 83
        cmp     [cd_appl_data], 0
4923 Serge 84
        jne     @f
85
 
86
        mov     ecx, [eax+IDE_CACHE.system_sad_size]
87
        mov     esi, [eax+IDE_CACHE.pointer]
88
        pop     eax
4429 Serge 89
        ret
4923 Serge 90
;--------------------------------------
91
@@:
92
        mov     ecx, [eax+IDE_CACHE.appl_sad_size]
93
        mov     esi, [eax+IDE_CACHE.data_pointer]
94
        pop     eax
4429 Serge 95
        ret
96
;--------------------------------------------------------------------
97
align 4
98
cd_calculate_cache_1:
4923 Serge 99
; 1 - IDE0 ... 12 - IDE11
100
        push    eax
101
 
102
        mov     eax, [cdpos]
103
        dec     eax
104
        imul    eax, sizeof.IDE_CACHE
105
        add     eax, cache_ide0
106
 
4429 Serge 107
        cmp     [cd_appl_data], 0
4923 Serge 108
        jne     @f
109
 
110
        mov     esi, [eax+IDE_CACHE.pointer]
111
        pop     eax
4429 Serge 112
        ret
4923 Serge 113
;--------------------------------------
114
@@:
115
        mov     esi, [eax+IDE_CACHE.data_pointer]
116
        pop     eax
4429 Serge 117
        ret
118
;--------------------------------------------------------------------
119
align 4
120
cd_calculate_cache_2:
4923 Serge 121
; 1 - IDE0 ... 12 - IDE11
122
        mov     eax, [cdpos]
123
        dec     eax
124
        imul    eax, sizeof.IDE_CACHE
125
        add     eax, cache_ide0
126
 
4429 Serge 127
        cmp     [cd_appl_data], 0
4923 Serge 128
        jne     @f
129
 
130
        mov     eax, [eax+IDE_CACHE.system_data]
4429 Serge 131
        ret
4923 Serge 132
;--------------------------------------
133
@@:
134
        mov     eax, [eax+IDE_CACHE.appl_data]
4429 Serge 135
        ret
136
;--------------------------------------------------------------------
137
align 4
138
cd_calculate_cache_3:
4923 Serge 139
; 1 - IDE0 ... 12 - IDE11
140
        push    eax
4429 Serge 141
 
4923 Serge 142
        mov     eax, [cdpos]
143
        dec     eax
144
        imul    eax, sizeof.IDE_CACHE
145
        add     eax, cache_ide0
146
 
4429 Serge 147
        cmp     [cd_appl_data], 0
4923 Serge 148
        jne     @f
149
 
150
        mov     edi, [eax+IDE_CACHE.search_start]
151
        pop     eax
4429 Serge 152
        ret
4923 Serge 153
;--------------------------------------
154
@@:
155
        mov     edi, [eax+IDE_CACHE.appl_search_start]
156
        pop     eax
4429 Serge 157
        ret
158
;--------------------------------------------------------------------
159
align 4
160
cd_calculate_cache_4:
4923 Serge 161
; 1 - IDE0 ... 12 - IDE11
162
        push    eax
163
 
164
        mov     eax, [cdpos]
165
        dec     eax
166
        imul    eax, sizeof.IDE_CACHE
167
        add     eax, cache_ide0
168
 
4429 Serge 169
        cmp     [cd_appl_data], 0
4923 Serge 170
        jne     @f
171
 
172
        cmp     edi, [eax+IDE_CACHE.system_sad_size]
173
        pop     eax
4429 Serge 174
        ret
4923 Serge 175
;--------------------------------------
176
@@:
177
        cmp     edi, [eax+IDE_CACHE.appl_sad_size]
178
        pop     eax
4429 Serge 179
        ret
180
;--------------------------------------------------------------------
181
align 4
182
cd_calculate_cache_5:
4923 Serge 183
; 1 - IDE0 ... 12 - IDE11
184
        push    eax
185
 
186
        mov     eax, [cdpos]
187
        dec     eax
188
        imul    eax, sizeof.IDE_CACHE
189
        add     eax, cache_ide0
190
 
4429 Serge 191
        cmp     [cd_appl_data], 0
4923 Serge 192
        jne     @f
193
 
194
        mov     [eax+IDE_CACHE.search_start], edi
195
        pop     eax
4429 Serge 196
        ret
4923 Serge 197
;--------------------------------------
198
@@:
199
        mov     [eax+IDE_CACHE.appl_search_start], edi
200
        pop     eax
4429 Serge 201
        ret
202
;--------------------------------------------------------------------