Rev 4700 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
2288 | clevermous | 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 | |||
24 | $Revision: 5363 $ |
||
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: |
||
4700 | mario79 | 44 | DEBUGF 1, 'K : clear_CD_cache\n' |
2288 | clevermous | 45 | pusha |
4700 | mario79 | 46 | |
47 | mov esi, [cdpos] |
||
48 | dec esi |
||
49 | imul esi, sizeof.IDE_CACHE |
||
50 | add esi, cache_ide0 |
||
51 | |||
2288 | clevermous | 52 | xor eax, eax |
4700 | mario79 | 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] |
||
2288 | clevermous | 57 | call .clear |
4700 | mario79 | 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] |
||
2288 | clevermous | 62 | call .clear |
4700 | mario79 | 63 | |
2288 | clevermous | 64 | popa |
65 | ret |
||
4700 | mario79 | 66 | ;-------------------------------------- |
2288 | clevermous | 67 | .clear: |
68 | shl ecx, 1 |
||
69 | cld |
||
70 | rep stosd |
||
71 | ret |
||
72 | ;-------------------------------------------------------------------- |
||
73 | align 4 |
||
74 | cd_calculate_cache: |
||
4700 | mario79 | 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 | |||
2288 | clevermous | 83 | cmp [cd_appl_data], 0 |
4700 | mario79 | 84 | jne @f |
85 | |||
86 | mov ecx, [eax+IDE_CACHE.system_sad_size] |
||
87 | mov esi, [eax+IDE_CACHE.pointer] |
||
88 | pop eax |
||
2288 | clevermous | 89 | ret |
4700 | mario79 | 90 | ;-------------------------------------- |
91 | @@: |
||
92 | mov ecx, [eax+IDE_CACHE.appl_sad_size] |
||
93 | mov esi, [eax+IDE_CACHE.data_pointer] |
||
94 | pop eax |
||
2288 | clevermous | 95 | ret |
96 | ;-------------------------------------------------------------------- |
||
97 | align 4 |
||
98 | cd_calculate_cache_1: |
||
4700 | mario79 | 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 | |||
2288 | clevermous | 107 | cmp [cd_appl_data], 0 |
4700 | mario79 | 108 | jne @f |
109 | |||
110 | mov esi, [eax+IDE_CACHE.pointer] |
||
111 | pop eax |
||
2288 | clevermous | 112 | ret |
4700 | mario79 | 113 | ;-------------------------------------- |
114 | @@: |
||
115 | mov esi, [eax+IDE_CACHE.data_pointer] |
||
116 | pop eax |
||
2288 | clevermous | 117 | ret |
118 | ;-------------------------------------------------------------------- |
||
119 | align 4 |
||
120 | cd_calculate_cache_2: |
||
4700 | mario79 | 121 | ; 1 - IDE0 ... 12 - IDE11 |
122 | mov eax, [cdpos] |
||
123 | dec eax |
||
124 | imul eax, sizeof.IDE_CACHE |
||
125 | add eax, cache_ide0 |
||
126 | |||
2288 | clevermous | 127 | cmp [cd_appl_data], 0 |
4700 | mario79 | 128 | jne @f |
129 | |||
130 | mov eax, [eax+IDE_CACHE.system_data] |
||
2288 | clevermous | 131 | ret |
4700 | mario79 | 132 | ;-------------------------------------- |
133 | @@: |
||
134 | mov eax, [eax+IDE_CACHE.appl_data] |
||
2288 | clevermous | 135 | ret |
136 | ;-------------------------------------------------------------------- |
||
137 | align 4 |
||
138 | cd_calculate_cache_3: |
||
4700 | mario79 | 139 | ; 1 - IDE0 ... 12 - IDE11 |
140 | push eax |
||
2288 | clevermous | 141 | |
4700 | mario79 | 142 | mov eax, [cdpos] |
143 | dec eax |
||
144 | imul eax, sizeof.IDE_CACHE |
||
145 | add eax, cache_ide0 |
||
146 | |||
2288 | clevermous | 147 | cmp [cd_appl_data], 0 |
4700 | mario79 | 148 | jne @f |
149 | |||
150 | mov edi, [eax+IDE_CACHE.search_start] |
||
151 | pop eax |
||
2288 | clevermous | 152 | ret |
4700 | mario79 | 153 | ;-------------------------------------- |
154 | @@: |
||
155 | mov edi, [eax+IDE_CACHE.appl_search_start] |
||
156 | pop eax |
||
2288 | clevermous | 157 | ret |
158 | ;-------------------------------------------------------------------- |
||
159 | align 4 |
||
160 | cd_calculate_cache_4: |
||
4700 | mario79 | 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 | |||
2288 | clevermous | 169 | cmp [cd_appl_data], 0 |
4700 | mario79 | 170 | jne @f |
171 | |||
172 | cmp edi, [eax+IDE_CACHE.system_sad_size] |
||
173 | pop eax |
||
2288 | clevermous | 174 | ret |
4700 | mario79 | 175 | ;-------------------------------------- |
176 | @@: |
||
177 | cmp edi, [eax+IDE_CACHE.appl_sad_size] |
||
178 | pop eax |
||
2288 | clevermous | 179 | ret |
180 | ;-------------------------------------------------------------------- |
||
181 | align 4 |
||
182 | cd_calculate_cache_5: |
||
4700 | mario79 | 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 | |||
2288 | clevermous | 191 | cmp [cd_appl_data], 0 |
4700 | mario79 | 192 | jne @f |
193 | |||
194 | mov [eax+IDE_CACHE.search_start], edi |
||
195 | pop eax |
||
2288 | clevermous | 196 | ret |
4700 | mario79 | 197 | ;-------------------------------------- |
198 | @@: |
||
199 | mov [eax+IDE_CACHE.appl_search_start], edi |
||
200 | pop eax |
||
2288 | clevermous | 201 | ret |
202 | ;-------------------------------------------------------------------- |