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