Rev 4711 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4711 | Rev 5363 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | $Revision: 4711 $ |
8 | $Revision: 5363 $ |
9 | 9 | ||
10 | ;----------------------------------------------------------------------------- |
10 | ;----------------------------------------------------------------------------- |
11 | pusha |
11 | pusha |
12 | 12 | ||
13 | mov eax, [pg_data.pages_free] |
13 | mov eax, [pg_data.pages_free] |
14 | ; 1/32 |
14 | ; 1/32 |
15 | shr eax, 5 |
15 | shr eax, 5 |
16 | ; round off up to 8 pages |
16 | ; round off up to 8 pages |
17 | shr eax, 3 |
17 | shr eax, 3 |
18 | shl eax, 3 |
18 | shl eax, 3 |
19 | ; translate pages in butes *4096 |
19 | ; translate pages in butes *4096 |
20 | shl eax, 12 |
20 | shl eax, 12 |
21 | ; check a upper size of the cache, no more than 1 Mb on the physical device |
21 | ; check a upper size of the cache, no more than 1 Mb on the physical device |
22 | cmp eax, 1024*1024 |
22 | cmp eax, 1024*1024 |
23 | jbe @f |
23 | jbe @f |
24 | 24 | ||
25 | mov eax, 1024*1024 |
25 | mov eax, 1024*1024 |
26 | jmp .continue |
26 | jmp .continue |
27 | ;-------------------------------------- |
27 | ;-------------------------------------- |
28 | @@: |
28 | @@: |
29 | ; check a lower size of the cache, not less than 128 Kb on the physical device |
29 | ; check a lower size of the cache, not less than 128 Kb on the physical device |
30 | cmp eax, 128*1024 |
30 | cmp eax, 128*1024 |
31 | jae .continue |
31 | jae .continue |
32 | 32 | ||
33 | mov eax, 128*1024 |
33 | mov eax, 128*1024 |
34 | ;-------------------------------------- |
34 | ;-------------------------------------- |
35 | .continue: |
35 | .continue: |
36 | push ecx |
36 | push ecx |
37 | mov ecx, 12 |
37 | mov ecx, 12 |
38 | mov esi, cache_ide0+IDE_CACHE.size |
38 | mov esi, cache_ide0+IDE_CACHE.size |
39 | cld |
39 | cld |
40 | @@: |
40 | @@: |
41 | mov [esi], eax |
41 | mov [esi], eax |
42 | add esi, sizeof.IDE_CACHE |
42 | add esi, sizeof.IDE_CACHE |
43 | loop @b |
43 | loop @b |
44 | 44 | ||
45 | pop ecx |
45 | pop ecx |
46 | 46 | ||
47 | xor eax, eax |
47 | xor eax, eax |
48 | mov [hdd_appl_data], 1 ;al |
48 | mov [hdd_appl_data], 1 ;al |
49 | mov [cd_appl_data], 1 |
49 | mov [cd_appl_data], 1 |
50 | ;-------------------------------------- |
50 | ;-------------------------------------- |
51 | test byte [DRIVE_DATA+1], 0x80 |
51 | test byte [DRIVE_DATA+1], 0x80 |
52 | je @f |
52 | je @f |
53 | 53 | ||
54 | mov esi, cache_ide0 |
54 | mov esi, cache_ide0 |
55 | call get_cache_ide |
55 | call get_cache_ide |
56 | ;-------------------------------------- |
56 | ;-------------------------------------- |
57 | @@: |
57 | @@: |
58 | test byte [DRIVE_DATA+1], 0x20 |
58 | test byte [DRIVE_DATA+1], 0x20 |
59 | je @f |
59 | je @f |
60 | 60 | ||
61 | mov esi, cache_ide1 |
61 | mov esi, cache_ide1 |
62 | call get_cache_ide |
62 | call get_cache_ide |
63 | ;-------------------------------------- |
63 | ;-------------------------------------- |
64 | @@: |
64 | @@: |
65 | test byte [DRIVE_DATA+1], 8 |
65 | test byte [DRIVE_DATA+1], 8 |
66 | je @f |
66 | je @f |
67 | 67 | ||
68 | mov esi, cache_ide2 |
68 | mov esi, cache_ide2 |
69 | call get_cache_ide |
69 | call get_cache_ide |
70 | ;-------------------------------------- |
70 | ;-------------------------------------- |
71 | @@: |
71 | @@: |
72 | test byte [DRIVE_DATA+1], 2 |
72 | test byte [DRIVE_DATA+1], 2 |
73 | je @f |
73 | je @f |
74 | 74 | ||
75 | mov esi, cache_ide3 |
75 | mov esi, cache_ide3 |
76 | call get_cache_ide |
76 | call get_cache_ide |
77 | ;-------------------------------------- |
77 | ;-------------------------------------- |
78 | @@: |
78 | @@: |
79 | test byte [DRIVE_DATA+6], 0x80 |
79 | test byte [DRIVE_DATA+6], 0x80 |
80 | je @f |
80 | je @f |
81 | 81 | ||
82 | mov esi, cache_ide4 |
82 | mov esi, cache_ide4 |
83 | call get_cache_ide |
83 | call get_cache_ide |
84 | ;-------------------------------------- |
84 | ;-------------------------------------- |
85 | @@: |
85 | @@: |
86 | test byte [DRIVE_DATA+6], 0x20 |
86 | test byte [DRIVE_DATA+6], 0x20 |
87 | je @f |
87 | je @f |
88 | 88 | ||
89 | mov esi, cache_ide5 |
89 | mov esi, cache_ide5 |
90 | call get_cache_ide |
90 | call get_cache_ide |
91 | ;-------------------------------------- |
91 | ;-------------------------------------- |
92 | @@: |
92 | @@: |
93 | test byte [DRIVE_DATA+6], 8 |
93 | test byte [DRIVE_DATA+6], 8 |
94 | je @f |
94 | je @f |
95 | 95 | ||
96 | mov esi, cache_ide6 |
96 | mov esi, cache_ide6 |
97 | call get_cache_ide |
97 | call get_cache_ide |
98 | ;-------------------------------------- |
98 | ;-------------------------------------- |
99 | @@: |
99 | @@: |
100 | test byte [DRIVE_DATA+6], 2 |
100 | test byte [DRIVE_DATA+6], 2 |
101 | je @f |
101 | je @f |
102 | 102 | ||
103 | mov esi, cache_ide7 |
103 | mov esi, cache_ide7 |
104 | call get_cache_ide |
104 | call get_cache_ide |
105 | ;-------------------------------------- |
105 | ;-------------------------------------- |
106 | @@: |
106 | @@: |
107 | test byte [DRIVE_DATA+11], 0x80 |
107 | test byte [DRIVE_DATA+11], 0x80 |
108 | je @f |
108 | je @f |
109 | 109 | ||
110 | mov esi, cache_ide8 |
110 | mov esi, cache_ide8 |
111 | call get_cache_ide |
111 | call get_cache_ide |
112 | ;-------------------------------------- |
112 | ;-------------------------------------- |
113 | @@: |
113 | @@: |
114 | test byte [DRIVE_DATA+11], 0x20 |
114 | test byte [DRIVE_DATA+11], 0x20 |
115 | je @f |
115 | je @f |
116 | 116 | ||
117 | mov esi, cache_ide9 |
117 | mov esi, cache_ide9 |
118 | call get_cache_ide |
118 | call get_cache_ide |
119 | ;-------------------------------------- |
119 | ;-------------------------------------- |
120 | @@: |
120 | @@: |
121 | test byte [DRIVE_DATA+11], 8 |
121 | test byte [DRIVE_DATA+11], 8 |
122 | je @f |
122 | je @f |
123 | 123 | ||
124 | mov esi, cache_ide10 |
124 | mov esi, cache_ide10 |
125 | call get_cache_ide |
125 | call get_cache_ide |
126 | ;-------------------------------------- |
126 | ;-------------------------------------- |
127 | @@: |
127 | @@: |
128 | test byte [DRIVE_DATA+11], 2 |
128 | test byte [DRIVE_DATA+11], 2 |
129 | je end_get_cache |
129 | je end_get_cache |
130 | 130 | ||
131 | mov esi, cache_ide11 |
131 | mov esi, cache_ide11 |
132 | call get_cache_ide |
132 | call get_cache_ide |
133 | 133 | ||
134 | jmp end_get_cache |
134 | jmp end_get_cache |
135 | ;----------------------------------------------------------------------------- |
135 | ;----------------------------------------------------------------------------- |
136 | get_cache_ide: |
136 | get_cache_ide: |
137 | and [esi+IDE_CACHE.search_start], 0 |
137 | and [esi+IDE_CACHE.search_start], 0 |
138 | and [esi+IDE_CACHE.appl_search_start], 0 |
138 | and [esi+IDE_CACHE.appl_search_start], 0 |
139 | 139 | ||
140 | push ecx |
140 | push ecx |
141 | ; DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size] |
141 | ; DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size] |
142 | stdcall kernel_alloc, [esi+IDE_CACHE.size] |
142 | stdcall kernel_alloc, [esi+IDE_CACHE.size] |
143 | mov [esi+IDE_CACHE.pointer], eax |
143 | mov [esi+IDE_CACHE.pointer], eax |
144 | pop ecx |
144 | pop ecx |
145 | 145 | ||
146 | mov edx, eax |
146 | mov edx, eax |
147 | mov eax, [esi+IDE_CACHE.size] |
147 | mov eax, [esi+IDE_CACHE.size] |
148 | shr eax, 3 |
148 | shr eax, 3 |
149 | ; DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax |
149 | ; DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax |
150 | mov [esi+IDE_CACHE.system_data_size], eax |
150 | mov [esi+IDE_CACHE.system_data_size], eax |
151 | mov ebx, eax |
151 | mov ebx, eax |
152 | imul eax, 7 |
152 | imul eax, 7 |
153 | ; DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax |
153 | ; DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax |
154 | mov [esi+IDE_CACHE.appl_data_size], eax |
154 | mov [esi+IDE_CACHE.appl_data_size], eax |
155 | add ebx, edx |
155 | add ebx, edx |
156 | mov [esi+IDE_CACHE.data_pointer], ebx |
156 | mov [esi+IDE_CACHE.data_pointer], ebx |
157 | 157 | ||
158 | .cd: |
158 | .cd: |
159 | push ecx |
159 | push ecx |
160 | mov eax, [esi+IDE_CACHE.system_data_size] |
160 | mov eax, [esi+IDE_CACHE.system_data_size] |
161 | call calculate_for_cd |
161 | call calculate_for_cd |
162 | add eax, [esi+IDE_CACHE.pointer] |
162 | add eax, [esi+IDE_CACHE.pointer] |
163 | mov [esi+IDE_CACHE.system_data], eax |
163 | mov [esi+IDE_CACHE.system_data], eax |
164 | mov [esi+IDE_CACHE.system_sad_size], ecx |
164 | mov [esi+IDE_CACHE.system_sad_size], ecx |
165 | 165 | ||
166 | push edi |
166 | push edi |
167 | mov edi, [esi+IDE_CACHE.pointer] |
167 | mov edi, [esi+IDE_CACHE.pointer] |
168 | call clear_ide_cache |
168 | call clear_ide_cache |
169 | pop edi |
169 | pop edi |
170 | 170 | ||
171 | mov eax, [esi+IDE_CACHE.appl_data_size] |
171 | mov eax, [esi+IDE_CACHE.appl_data_size] |
172 | call calculate_for_cd |
172 | call calculate_for_cd |
173 | add eax, [esi+IDE_CACHE.data_pointer] |
173 | add eax, [esi+IDE_CACHE.data_pointer] |
174 | mov [esi+IDE_CACHE.appl_data], eax |
174 | mov [esi+IDE_CACHE.appl_data], eax |
175 | mov [esi+IDE_CACHE.appl_sad_size], ecx |
175 | mov [esi+IDE_CACHE.appl_sad_size], ecx |
176 | 176 | ||
177 | push edi |
177 | push edi |
178 | mov edi, [esi+IDE_CACHE.data_pointer] |
178 | mov edi, [esi+IDE_CACHE.data_pointer] |
179 | call clear_ide_cache |
179 | call clear_ide_cache |
180 | pop edi |
180 | pop edi |
181 | 181 | ||
182 | pop ecx |
182 | pop ecx |
183 | ret |
183 | ret |
184 | ;----------------------------------------------------------------------------- |
184 | ;----------------------------------------------------------------------------- |
185 | calculate_for_cd: |
185 | calculate_for_cd: |
186 | push eax |
186 | push eax |
187 | mov ebx, eax |
187 | mov ebx, eax |
188 | shr eax, 11 |
188 | shr eax, 11 |
189 | shl eax, 3 |
189 | shl eax, 3 |
190 | sub ebx, eax |
190 | sub ebx, eax |
191 | shr ebx, 11 |
191 | shr ebx, 11 |
192 | mov ecx, ebx |
192 | mov ecx, ebx |
193 | shl ebx, 11 |
193 | shl ebx, 11 |
194 | pop eax |
194 | pop eax |
195 | sub eax, ebx |
195 | sub eax, ebx |
196 | dec ecx |
196 | dec ecx |
197 | ret |
197 | ret |
198 | ;----------------------------------------------------------------------------- |
198 | ;----------------------------------------------------------------------------- |
199 | clear_ide_cache: |
199 | clear_ide_cache: |
200 | push eax |
200 | push eax |
201 | shl ecx, 1 |
201 | shl ecx, 1 |
202 | xor eax, eax |
202 | xor eax, eax |
203 | cld |
203 | cld |
204 | rep stosd |
204 | rep stosd |
205 | pop eax |
205 | pop eax |
206 | ret |
206 | ret |
207 | ;----------------------------------------------------------------------------- |
207 | ;----------------------------------------------------------------------------- |
208 | end_get_cache: |
208 | end_get_cache: |
209 | popa |
209 | popa |