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