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