Rev 3725 | Rev 5201 | 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: 3908 $ |
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 |
||
3908 | Serge | 39 | |
40 | test byte [DRIVE_DATA+1], 2 |
||
41 | je .ide2 |
||
2434 | Serge | 42 | mov esi, cache_ide3 |
43 | call get_cache_ide |
||
580 | mario79 | 44 | .ide2: |
3908 | Serge | 45 | test byte [DRIVE_DATA+1], 8 |
2434 | Serge | 46 | je .ide1 |
47 | mov esi, cache_ide2 |
||
48 | call get_cache_ide |
||
580 | mario79 | 49 | .ide1: |
3908 | Serge | 50 | test byte [DRIVE_DATA+1], 0x20 |
2434 | Serge | 51 | je .ide0 |
52 | mov esi, cache_ide1 |
||
53 | call get_cache_ide |
||
580 | mario79 | 54 | .ide0: |
3908 | Serge | 55 | test byte [DRIVE_DATA+1], 0x80 |
2434 | Serge | 56 | je @f |
57 | mov esi, cache_ide0 |
||
58 | call get_cache_ide |
||
709 | diamond | 59 | @@: |
2434 | Serge | 60 | jmp end_get_cache |
580 | mario79 | 61 | |
709 | diamond | 62 | get_cache_ide: |
2434 | Serge | 63 | and [esi+cache_ide0_search_start-cache_ide0], 0 |
64 | and [esi+cache_ide0_appl_search_start-cache_ide0], 0 |
||
65 | push ecx |
||
66 | stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0] |
||
67 | mov [esi+cache_ide0_pointer-cache_ide0], eax |
||
68 | pop ecx |
||
69 | mov edx, eax |
||
70 | mov eax, [esi+cache_ide0_size-cache_ide0] |
||
71 | shr eax, 3 |
||
72 | mov [esi+cache_ide0_system_data_size-cache_ide0], eax |
||
73 | mov ebx, eax |
||
74 | imul eax, 7 |
||
75 | mov [esi+cache_ide0_appl_data_size-cache_ide0], eax |
||
76 | add ebx, edx |
||
77 | mov [esi+cache_ide0_data_pointer-cache_ide0], ebx |
||
585 | mario79 | 78 | |
580 | mario79 | 79 | .cd: |
2434 | Serge | 80 | push ecx |
81 | mov eax, [esi+cache_ide0_system_data_size-cache_ide0] |
||
82 | call calculate_for_cd |
||
83 | add eax, [esi+cache_ide0_pointer-cache_ide0] |
||
84 | mov [esi+cache_ide0_system_data-cache_ide0], eax |
||
85 | mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx |
||
580 | mario79 | 86 | |
2434 | Serge | 87 | push edi |
88 | mov edi, [esi+cache_ide0_pointer-cache_ide0] |
||
89 | call clear_ide_cache |
||
90 | pop edi |
||
580 | mario79 | 91 | |
2434 | Serge | 92 | mov eax, [esi+cache_ide0_appl_data_size-cache_ide0] |
93 | call calculate_for_cd |
||
94 | add eax, [esi+cache_ide0_data_pointer-cache_ide0] |
||
95 | mov [esi+cache_ide0_appl_data-cache_ide0], eax |
||
96 | mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx |
||
585 | mario79 | 97 | |
2434 | Serge | 98 | push edi |
99 | mov edi, [esi+cache_ide0_data_pointer-cache_ide0] |
||
100 | call clear_ide_cache |
||
101 | pop edi |
||
585 | mario79 | 102 | |
2434 | Serge | 103 | pop ecx |
104 | ret |
||
580 | mario79 | 105 | |
106 | calculate_for_cd: |
||
2434 | Serge | 107 | push eax |
108 | mov ebx, eax |
||
109 | shr eax, 11 |
||
110 | shl eax, 3 |
||
111 | sub ebx, eax |
||
112 | shr ebx, 11 |
||
113 | mov ecx, ebx |
||
114 | shl ebx, 11 |
||
115 | pop eax |
||
116 | sub eax, ebx |
||
117 | dec ecx |
||
118 | ret |
||
585 | mario79 | 119 | |
580 | mario79 | 120 | clear_ide_cache: |
2434 | Serge | 121 | push eax |
122 | shl ecx, 1 |
||
123 | xor eax, eax |
||
124 | cld |
||
125 | rep stosd |
||
126 | pop eax |
||
127 | ret |
||
585 | mario79 | 128 | |
580 | mario79 | 129 | end_get_cache: |
2434 | Serge | 130 | popa |