Subversion Repositories Kolibri OS

Rev

Rev 4429 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4429 Serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 3742 $
9
 
4923 Serge 10
;-----------------------------------------------------------------------------
4429 Serge 11
        pusha
12
 
13
        mov     eax, [pg_data.pages_free]
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
21
;       check a upper size of the cache, no more than 1 Mb on the physical device
22
        cmp     eax, 1024*1024
23
        jbe     @f
4923 Serge 24
 
4429 Serge 25
        mov     eax, 1024*1024
26
        jmp     .continue
4923 Serge 27
;--------------------------------------
4429 Serge 28
@@:
29
;       check a lower size of the cache, not less than 128 Kb on the physical device
30
        cmp     eax, 128*1024
4923 Serge 31
        jae     .continue
32
 
4429 Serge 33
        mov     eax, 128*1024
4923 Serge 34
;--------------------------------------
35
.continue:
36
        push    ecx
37
        mov     ecx, 12
38
        mov     esi, cache_ide0+IDE_CACHE.size
39
        cld
4429 Serge 40
@@:
4923 Serge 41
        mov     [esi], eax
42
        add     esi, sizeof.IDE_CACHE
43
        loop    @b
44
 
45
        pop     ecx
46
 
4429 Serge 47
        xor     eax, eax
4923 Serge 48
        mov     [hdd_appl_data], 1 ;al
4429 Serge 49
        mov     [cd_appl_data], 1
4923 Serge 50
;--------------------------------------
51
        test    byte [DRIVE_DATA+1], 0x80
52
        je      @f
4429 Serge 53
 
4923 Serge 54
        mov     esi, cache_ide0
4429 Serge 55
        call    get_cache_ide
4923 Serge 56
;--------------------------------------
57
@@:
58
        test    byte [DRIVE_DATA+1], 0x20
59
        je      @f
60
 
61
        mov     esi, cache_ide1
62
        call    get_cache_ide
63
;--------------------------------------
64
@@:
4429 Serge 65
        test    byte [DRIVE_DATA+1], 8
4923 Serge 66
        je      @f
67
 
4429 Serge 68
        mov     esi, cache_ide2
69
        call    get_cache_ide
4923 Serge 70
;--------------------------------------
71
@@:
72
        test    byte [DRIVE_DATA+1], 2
73
        je      @f
74
 
75
        mov     esi, cache_ide3
4429 Serge 76
        call    get_cache_ide
4923 Serge 77
;--------------------------------------
78
@@:
79
        test    byte [DRIVE_DATA+6], 0x80
4429 Serge 80
        je      @f
4923 Serge 81
 
82
        mov     esi, cache_ide4
4429 Serge 83
        call    get_cache_ide
4923 Serge 84
;--------------------------------------
4429 Serge 85
@@:
4923 Serge 86
        test    byte [DRIVE_DATA+6], 0x20
87
        je      @f
88
 
89
        mov     esi, cache_ide5
90
        call    get_cache_ide
91
;--------------------------------------
92
@@:
93
        test    byte [DRIVE_DATA+6], 8
94
        je      @f
95
 
96
        mov     esi, cache_ide6
97
        call    get_cache_ide
98
;--------------------------------------
99
@@:
100
        test    byte [DRIVE_DATA+6], 2
101
        je      @f
102
 
103
        mov     esi, cache_ide7
104
        call    get_cache_ide
105
;--------------------------------------
106
@@:
107
        test    byte [DRIVE_DATA+11], 0x80
108
        je      @f
109
 
110
        mov     esi, cache_ide8
111
        call    get_cache_ide
112
;--------------------------------------
113
@@:
114
        test    byte [DRIVE_DATA+11], 0x20
115
        je      @f
116
 
117
        mov     esi, cache_ide9
118
        call    get_cache_ide
119
;--------------------------------------
120
@@:
121
        test    byte [DRIVE_DATA+11], 8
122
        je      @f
123
 
124
        mov     esi, cache_ide10
125
        call    get_cache_ide
126
;--------------------------------------
127
@@:
128
        test    byte [DRIVE_DATA+11], 2
129
        je      end_get_cache
130
 
131
        mov     esi, cache_ide11
132
        call    get_cache_ide
133
 
4429 Serge 134
        jmp     end_get_cache
4923 Serge 135
;-----------------------------------------------------------------------------
136
get_cache_ide:
137
        and     [esi+IDE_CACHE.search_start], 0
138
        and     [esi+IDE_CACHE.appl_search_start], 0
4429 Serge 139
 
140
        push    ecx
4923 Serge 141
;        DEBUGF  1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
142
        stdcall kernel_alloc, [esi+IDE_CACHE.size]
143
        mov     [esi+IDE_CACHE.pointer], eax
4429 Serge 144
        pop     ecx
4923 Serge 145
 
4429 Serge 146
        mov     edx, eax
4923 Serge 147
        mov     eax, [esi+IDE_CACHE.size]
4429 Serge 148
        shr     eax, 3
4923 Serge 149
;        DEBUGF  1, "K : IDE_CACHE.system_data_size %x\n", eax
150
        mov     [esi+IDE_CACHE.system_data_size], eax
4429 Serge 151
        mov     ebx, eax
152
        imul    eax, 7
4923 Serge 153
;        DEBUGF  1, "K : IDE_CACHE.appl_data_size %x\n", eax
154
        mov     [esi+IDE_CACHE.appl_data_size], eax
4429 Serge 155
        add     ebx, edx
4923 Serge 156
        mov     [esi+IDE_CACHE.data_pointer], ebx
4429 Serge 157
 
158
.cd:
159
        push    ecx
4923 Serge 160
        mov     eax, [esi+IDE_CACHE.system_data_size]
4429 Serge 161
        call    calculate_for_cd
4923 Serge 162
        add     eax, [esi+IDE_CACHE.pointer]
163
        mov     [esi+IDE_CACHE.system_data], eax
164
        mov     [esi+IDE_CACHE.system_sad_size], ecx
4429 Serge 165
 
166
        push    edi
4923 Serge 167
        mov     edi, [esi+IDE_CACHE.pointer]
4429 Serge 168
        call    clear_ide_cache
169
        pop     edi
170
 
4923 Serge 171
        mov     eax, [esi+IDE_CACHE.appl_data_size]
4429 Serge 172
        call    calculate_for_cd
4923 Serge 173
        add     eax, [esi+IDE_CACHE.data_pointer]
174
        mov     [esi+IDE_CACHE.appl_data], eax
175
        mov     [esi+IDE_CACHE.appl_sad_size], ecx
4429 Serge 176
 
177
        push    edi
4923 Serge 178
        mov     edi, [esi+IDE_CACHE.data_pointer]
4429 Serge 179
        call    clear_ide_cache
180
        pop     edi
181
 
182
        pop     ecx
183
        ret
4923 Serge 184
;-----------------------------------------------------------------------------
4429 Serge 185
calculate_for_cd:
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
4923 Serge 198
;-----------------------------------------------------------------------------
4429 Serge 199
clear_ide_cache:
200
        push    eax
201
        shl     ecx, 1
202
        xor     eax, eax
203
        cld
204
        rep stosd
205
        pop     eax
206
        ret
4923 Serge 207
;-----------------------------------------------------------------------------
4429 Serge 208
end_get_cache:
209
        popa