Rev 3712 | Rev 4711 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
2455 | mario79 | 3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 3742 $ |
||
9 | |||
10 | pusha |
||
11 | |||
12 | mov eax, [pg_data.pages_free] |
||
13 | ; 1/32 |
||
14 | shr eax, 5 |
||
15 | ; round off up to 8 pages |
||
16 | shr eax, 3 |
||
17 | shl eax, 3 |
||
18 | ; translate pages in butes *4096 |
||
19 | shl eax, 12 |
||
20 | ; check a upper size of the cache, no more than 1 Mb on the physical device |
||
21 | cmp eax, 1024*1024 |
||
22 | jbe @f |
||
23 | mov eax, 1024*1024 |
||
24 | jmp .continue |
||
25 | @@: |
||
26 | ; check a lower size of the cache, not less than 128 Kb on the physical device |
||
27 | cmp eax, 128*1024 |
||
28 | jae @f |
||
29 | mov eax, 128*1024 |
||
30 | @@: |
||
31 | .continue: |
||
32 | mov [cache_ide0_size], eax |
||
33 | mov [cache_ide1_size], eax |
||
34 | mov [cache_ide2_size], eax |
||
35 | mov [cache_ide3_size], eax |
||
36 | xor eax, eax |
||
37 | mov [hdd_appl_data], 1;al |
||
38 | mov [cd_appl_data], 1 |
||
3742 | clevermous | 39 | |
40 | test byte [DRIVE_DATA+1], 2 |
||
41 | je .ide2 |
||
2288 | clevermous | 42 | mov esi, cache_ide3 |
43 | call get_cache_ide |
||
44 | .ide2: |
||
3742 | clevermous | 45 | test byte [DRIVE_DATA+1], 8 |
2288 | clevermous | 46 | je .ide1 |
47 | mov esi, cache_ide2 |
||
48 | call get_cache_ide |
||
49 | .ide1: |
||
3742 | clevermous | 50 | test byte [DRIVE_DATA+1], 0x20 |
2288 | clevermous | 51 | je .ide0 |
52 | mov esi, cache_ide1 |
||
53 | call get_cache_ide |
||
54 | .ide0: |
||
3742 | clevermous | 55 | test byte [DRIVE_DATA+1], 0x80 |
2288 | clevermous | 56 | je @f |
57 | mov esi, cache_ide0 |
||
58 | call get_cache_ide |
||
59 | @@: |
||
60 | jmp end_get_cache |
||
61 | |||
62 | get_cache_ide: |
||
63 | and [esi+cache_ide0_search_start-cache_ide0], 0 |
||
64 | and [esi+cache_ide0_appl_search_start-cache_ide0], 0 |
||
65 | push ecx |
||
66 | stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0] |
||
67 | mov [esi+cache_ide0_pointer-cache_ide0], eax |
||
68 | pop ecx |
||
69 | mov edx, eax |
||
70 | mov eax, [esi+cache_ide0_size-cache_ide0] |
||
71 | shr eax, 3 |
||
72 | mov [esi+cache_ide0_system_data_size-cache_ide0], eax |
||
73 | mov ebx, eax |
||
74 | imul eax, 7 |
||
75 | mov [esi+cache_ide0_appl_data_size-cache_ide0], eax |
||
76 | add ebx, edx |
||
77 | mov [esi+cache_ide0_data_pointer-cache_ide0], ebx |
||
78 | |||
79 | .cd: |
||
80 | push ecx |
||
81 | mov eax, [esi+cache_ide0_system_data_size-cache_ide0] |
||
82 | call calculate_for_cd |
||
83 | add eax, [esi+cache_ide0_pointer-cache_ide0] |
||
84 | mov [esi+cache_ide0_system_data-cache_ide0], eax |
||
85 | mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx |
||
86 | |||
87 | push edi |
||
88 | mov edi, [esi+cache_ide0_pointer-cache_ide0] |
||
89 | call clear_ide_cache |
||
90 | pop edi |
||
91 | |||
92 | mov eax, [esi+cache_ide0_appl_data_size-cache_ide0] |
||
93 | call calculate_for_cd |
||
94 | add eax, [esi+cache_ide0_data_pointer-cache_ide0] |
||
95 | mov [esi+cache_ide0_appl_data-cache_ide0], eax |
||
96 | mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx |
||
97 | |||
98 | push edi |
||
99 | mov edi, [esi+cache_ide0_data_pointer-cache_ide0] |
||
100 | call clear_ide_cache |
||
101 | pop edi |
||
102 | |||
103 | pop ecx |
||
104 | ret |
||
105 | |||
106 | calculate_for_cd: |
||
107 | push eax |
||
108 | mov ebx, eax |
||
109 | shr eax, 11 |
||
110 | shl eax, 3 |
||
111 | sub ebx, eax |
||
112 | shr ebx, 11 |
||
113 | mov ecx, ebx |
||
114 | shl ebx, 11 |
||
115 | pop eax |
||
116 | sub eax, ebx |
||
117 | dec ecx |
||
118 | ret |
||
119 | |||
120 | clear_ide_cache: |
||
121 | push eax |
||
122 | shl ecx, 1 |
||
123 | xor eax, eax |
||
124 | cld |
||
125 | rep stosd |
||
126 | pop eax |
||
127 | ret |
||
128 | |||
129 | end_get_cache: |
||
130 | popa |