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