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