Subversion Repositories Kolibri OS

Rev

Rev 584 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
580 mario79 1
;cache_ide0_pointer          dd 0
2
;cache_ide0_size             dd 0   ; not use
3
;cache_ide0_data_pointer     dd 0
4
;cache_ide0_system_data_size dd 0   ; not use
5
;cache_ide0_appl_data_size   dd 0   ; not use
6
;cache_ide0_system_data      dd 0
7
;cache_ide0_appl_data        dd 0
8
;cache_ide0_system_sad_size  dd 0
9
;cache_ide0_appl_sad_size    dd 0
10
 
11
    pusha
12
 
13
    mov  eax,[pg_data.pages_free]
14
;   1/32
15
    shr eax,5
16
;   round off up to 8 pages
17
    shr eax,3
18
    shl eax,3
19
;   translate pages in butes *4096
20
    shl eax,12
21
;	check a upper size of the cache, no more than 1 Mb on the physical device
22
    cmp  eax,1024*1024
23
    jbe  @f
24
    mov  eax,1024*1024
25
    jmp  .continue
26
@@:
27
;	check a lower size of the cache, not less than 128 Kb on the physical device
28
    cmp  eax,128*1024
29
    jae  @f
30
    mov  eax,128*1024
31
@@:
32
.continue:
33
    mov  [cache_ide0_size],eax
34
    mov  [cache_ide1_size],eax
35
    mov  [cache_ide2_size],eax
36
    mov  [cache_ide3_size],eax
37
    xor  eax,eax
38
    mov  [cache_ide0_search_start],eax
39
    mov  [cache_ide0_appl_search_start],eax
40
    mov  [cache_ide1_search_start],eax
41
    mov  [cache_ide1_appl_search_start],eax
42
    mov  [cache_ide2_search_start],eax
43
    mov  [cache_ide2_appl_search_start],eax
44
    mov  [cache_ide3_search_start],eax
45
    mov  [cache_ide3_appl_search_start],eax
46
    mov  [hdd_appl_data],1  ;al
47
 
48
    mov  cl,[DRIVE_DATA+1]
49
    mov  ch,cl
50
    and  cl,11b
51
    cmp cl,0
52
    je  .ide2
53
    call get_cache_ide3
54
.ide2:
55
    mov  cl,ch
56
    and  cl,1100b
57
    cmp cl,0
58
    je  .ide1
59
    call get_cache_ide2
60
.ide1:
61
    mov  cl,ch
62
    and  cl,110000b
63
    cmp cl,0
64
    je  .ide0
65
    call get_cache_ide1
66
.ide0:
67
    mov  cl,ch
68
    and  cl,11000000b
69
    cmp cl,0
70
    je  end_get_cache
71
    call get_cache_ide0
72
    jmp  end_get_cache
73
 
74
get_cache_ide0:
75
    push  ecx
76
    stdcall kernel_alloc,[cache_ide0_size]
77
    mov [cache_ide0_pointer],eax
78
    pop   ecx
79
    mov  edx,eax
80
    mov  eax,[cache_ide0_size]
81
    shr  eax,3
82
    mov  [cache_ide0_system_data_size],eax
83
    mov  ebx,eax
84
    imul eax,7
85
    mov  [cache_ide0_appl_data_size],eax
86
    add  ebx,edx
87
    mov  [cache_ide0_data_pointer],ebx
88
 
89
    cmp cl,10000000b
90
    je  .cd
91
    push ecx
92
    mov  eax,[cache_ide0_system_data_size]
93
    call calculate_for_hd
94
    add  eax,[cache_ide0_pointer]
95
    mov  [cache_ide0_system_data],eax
96
    mov  [cache_ide0_system_sad_size],ecx
97
 
98
    push  edi
99
    mov   edi,[cache_ide0_pointer]
100
    call  clear_ide_cache
101
    pop   edi
102
 
103
    mov  eax,[cache_ide0_appl_data_size]
104
    call calculate_for_hd
105
    add  eax,[cache_ide0_data_pointer]
106
    mov  [cache_ide0_appl_data],eax
107
    mov  [cache_ide0_appl_sad_size],ecx
108
 
109
    push  edi
110
    mov   edi,[cache_ide0_data_pointer]
111
    call  clear_ide_cache
112
    pop   edi
113
 
114
    pop  ecx
115
    ret
116
.cd:
117
    push ecx
118
    mov  eax,[cache_ide0_system_data_size]
119
    call calculate_for_cd
120
    add  eax,[cache_ide0_pointer]
121
    mov  [cache_ide0_system_data],eax
122
    mov  [cache_ide0_system_sad_size],ecx
123
 
124
    push  edi
125
    mov   edi,[cache_ide0_pointer]
126
    call  clear_ide_cache
127
    pop   edi
128
 
129
    mov  eax,[cache_ide0_appl_data_size]
130
    call calculate_for_cd
131
    add  eax,[cache_ide0_data_pointer]
132
    mov  [cache_ide0_appl_data],eax
133
    mov  [cache_ide0_appl_sad_size],ecx
134
 
135
    push  edi
136
    mov   edi,[cache_ide0_data_pointer]
137
    call  clear_ide_cache
138
    pop   edi
139
 
140
    pop  ecx
141
    ret
142
 
143
get_cache_ide1:
144
    push  ecx
145
    stdcall kernel_alloc,[cache_ide1_size]
146
    mov [cache_ide1_pointer],eax
147
    pop   ecx
148
    mov  edx,eax
149
    mov  eax,[cache_ide1_size]
150
    shr  eax,3
151
    mov  [cache_ide1_system_data_size],eax
152
    mov  ebx,eax
153
    imul eax,7
154
    mov  [cache_ide1_appl_data_size],eax
155
    add  ebx,edx
156
    mov  [cache_ide1_data_pointer],ebx
157
 
158
    cmp cl,100000b
159
    je  .cd
160
    push ecx
161
    mov  eax,[cache_ide1_system_data_size]
162
    call calculate_for_hd
163
    add  eax,[cache_ide1_pointer]
164
    mov  [cache_ide1_system_data],eax
165
    mov  [cache_ide1_system_sad_size],ecx
166
 
167
    push  edi
168
    mov   edi,[cache_ide1_pointer]
169
    call  clear_ide_cache
170
    pop   edi
171
 
172
    mov  eax,[cache_ide1_appl_data_size]
173
    call calculate_for_hd
174
    add  eax,[cache_ide1_data_pointer]
175
    mov  [cache_ide1_appl_data],eax
176
    mov  [cache_ide1_appl_sad_size],ecx
177
 
178
    push  edi
179
    mov   edi,[cache_ide1_data_pointer]
180
    call  clear_ide_cache
181
    pop   edi
182
 
183
    pop  ecx
184
    ret
185
.cd:
186
    push ecx
187
    mov  eax,[cache_ide1_system_data_size]
188
    call calculate_for_cd
189
    add  eax,[cache_ide1_pointer]
190
    mov  [cache_ide1_system_data],eax
191
    mov  [cache_ide1_system_sad_size],ecx
192
 
193
    push  edi
194
    mov   edi,[cache_ide1_pointer]
195
    call  clear_ide_cache
196
    pop   edi
197
 
198
    mov  eax,[cache_ide1_appl_data_size]
199
    call calculate_for_cd
200
    add  eax,[cache_ide1_data_pointer]
201
    mov  [cache_ide1_appl_data],eax
202
    mov  [cache_ide1_appl_sad_size],ecx
203
 
204
    push  edi
205
    mov   edi,[cache_ide1_data_pointer]
206
    call  clear_ide_cache
207
    pop   edi
208
 
209
    pop  ecx
210
    ret
211
 
212
get_cache_ide2:
213
    push  ecx
214
    stdcall kernel_alloc,[cache_ide2_size]
215
    mov [cache_ide2_pointer],eax
216
    pop   ecx
217
    mov  edx,eax
218
    mov  eax,[cache_ide2_size]
219
    shr  eax,3
220
    mov  [cache_ide2_system_data_size],eax
221
    mov  ebx,eax
222
    imul eax,7
223
    mov  [cache_ide2_appl_data_size],eax
224
    add  ebx,edx
225
    mov  [cache_ide2_data_pointer],ebx
226
 
227
    cmp cl,1000b
228
    je  .cd
229
    push ecx
230
    mov  eax,[cache_ide2_system_data_size]
231
    call calculate_for_hd
232
    add  eax,[cache_ide2_pointer]
233
    mov  [cache_ide2_system_data],eax
234
    mov  [cache_ide2_system_sad_size],ecx
235
 
236
    push  edi
237
    mov   edi,[cache_ide2_pointer]
238
    call  clear_ide_cache
239
    pop   edi
240
 
241
    mov  eax,[cache_ide2_appl_data_size]
242
    call calculate_for_hd
243
    add  eax,[cache_ide2_data_pointer]
244
    mov  [cache_ide2_appl_data],eax
245
    mov  [cache_ide2_appl_sad_size],ecx
246
 
247
    push  edi
248
    mov   edi,[cache_ide2_data_pointer]
249
    call  clear_ide_cache
250
    pop   edi
251
 
252
    pop  ecx
253
    ret
254
.cd:
255
    push ecx
256
    mov  eax,[cache_ide2_system_data_size]
257
    call calculate_for_cd
258
    add  eax,[cache_ide2_pointer]
259
    mov  [cache_ide2_system_data],eax
260
    mov  [cache_ide2_system_sad_size],ecx
261
 
262
    push  edi
263
    mov   edi,[cache_ide2_pointer]
264
    call  clear_ide_cache
265
    pop   edi
266
 
267
    mov  eax,[cache_ide2_appl_data_size]
268
    call calculate_for_cd
269
    add  eax,[cache_ide2_data_pointer]
270
    mov  [cache_ide2_appl_data],eax
271
    mov  [cache_ide2_appl_sad_size],ecx
272
 
273
    push  edi
274
    mov   edi,[cache_ide2_data_pointer]
275
    call  clear_ide_cache
276
    pop   edi
277
 
278
    pop  ecx
279
    ret
280
 
281
get_cache_ide3:
282
    push  ecx
283
    stdcall kernel_alloc,[cache_ide3_size]
284
    mov [cache_ide3_pointer],eax
285
    pop   ecx
286
    mov  edx,eax
287
    mov  eax,[cache_ide3_size]
288
    shr  eax,3
289
    mov  [cache_ide3_system_data_size],eax
290
    mov  ebx,eax
291
    imul eax,7
292
    mov  [cache_ide3_appl_data_size],eax
293
    add  ebx,edx
294
    mov  [cache_ide3_data_pointer],ebx
295
 
296
    cmp cl,10b
297
    je  .cd
298
    push ecx
299
    mov  eax,[cache_ide3_system_data_size]
300
    call calculate_for_hd
301
    add  eax,[cache_ide3_pointer]
302
    mov  [cache_ide3_system_data],eax
303
    mov  [cache_ide3_system_sad_size],ecx
304
 
305
    push  edi
306
    mov   edi,[cache_ide3_pointer]
307
    call  clear_ide_cache
308
    pop   edi
309
 
310
    mov  eax,[cache_ide3_appl_data_size]
311
    call calculate_for_hd
312
    add  eax,[cache_ide3_data_pointer]
313
    mov  [cache_ide3_appl_data],eax
314
    mov  [cache_ide3_appl_sad_size],ecx
315
 
316
    push  edi
317
    mov   edi,[cache_ide3_data_pointer]
318
    call  clear_ide_cache
319
    pop   edi
320
 
321
    pop  ecx
322
    ret
323
.cd:
324
    push ecx
325
    mov  eax,[cache_ide3_system_data_size]
326
    call calculate_for_cd
327
    add  eax,[cache_ide3_pointer]
328
    mov  [cache_ide3_system_data],eax
329
    mov  [cache_ide3_system_sad_size],ecx
330
 
331
    push  edi
332
    mov   edi,[cache_ide3_pointer]
333
    call  clear_ide_cache
334
    pop   edi
335
 
336
    mov  eax,[cache_ide3_appl_data_size]
337
    call calculate_for_cd
338
    add  eax,[cache_ide3_data_pointer]
339
    mov  [cache_ide3_appl_data],eax
340
    mov  [cache_ide3_appl_sad_size],ecx
341
 
342
    push  edi
343
    mov   edi,[cache_ide3_data_pointer]
344
    call  clear_ide_cache
345
    pop   edi
346
 
347
    pop  ecx
348
    ret
349
 
350
calculate_for_hd:
351
    push eax
352
    mov  ebx,eax
353
    shr  eax,9
354
    shl  eax,3
355
    sub  ebx,eax
356
    shr  ebx,9
357
    mov  ecx,ebx
358
    shl  ebx,9
359
    pop  eax
360
    sub  eax,ebx
361
    ret
362
 
363
calculate_for_cd:
364
    push eax
365
    mov  ebx,eax
366
    shr  eax,11
367
    shl  eax,3
368
    sub  ebx,eax
369
    shr  ebx,11
370
    mov  ecx,ebx
371
    shl  ebx,11
372
    pop  eax
373
    sub  eax,ebx
374
    ret
375
 
376
clear_ide_cache:
377
    push   eax
378
    shl   ecx,1
379
    xor   eax,eax
380
    cld
381
    rep   stosd
382
    pop   eax
383
    ret
384
 
385
end_get_cache:
386
;    mov  [cache_ide0_pointer],HD_CACHE
387
;    mov  [cache_ide0_system_data],HD_CACHE+65536
388
;    mov  [cache_ide0_system_sad_size],1919
389
    popa