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