Subversion Repositories Kolibri OS

Rev

Rev 4711 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 5363 $
9
 
4700 mario79 10
;-----------------------------------------------------------------------------
2288 clevermous 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
4700 mario79 24
 
2288 clevermous 25
        mov     eax, 1024*1024
26
        jmp     .continue
4700 mario79 27
;--------------------------------------
2288 clevermous 28
@@:
29
;       check a lower size of the cache, not less than 128 Kb on the physical device
30
        cmp     eax, 128*1024
4700 mario79 31
        jae     .continue
32
 
2288 clevermous 33
        mov     eax, 128*1024
4700 mario79 34
;--------------------------------------
35
.continue:
36
        push    ecx
37
        mov     ecx, 12
38
        mov     esi, cache_ide0+IDE_CACHE.size
39
        cld
2288 clevermous 40
@@:
4700 mario79 41
        mov     [esi], eax
42
        add     esi, sizeof.IDE_CACHE
43
        loop    @b
44
 
45
        pop     ecx
46
 
2288 clevermous 47
        xor     eax, eax
4700 mario79 48
        mov     [hdd_appl_data], 1 ;al
2288 clevermous 49
        mov     [cd_appl_data], 1
4700 mario79 50
;--------------------------------------
51
        test    byte [DRIVE_DATA+1], 0x80
52
        je      @f
3742 clevermous 53
 
4700 mario79 54
        mov     esi, cache_ide0
2288 clevermous 55
        call    get_cache_ide
4700 mario79 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
@@:
3742 clevermous 65
        test    byte [DRIVE_DATA+1], 8
4700 mario79 66
        je      @f
67
 
2288 clevermous 68
        mov     esi, cache_ide2
69
        call    get_cache_ide
4700 mario79 70
;--------------------------------------
71
@@:
72
        test    byte [DRIVE_DATA+1], 2
73
        je      @f
74
 
75
        mov     esi, cache_ide3
2288 clevermous 76
        call    get_cache_ide
4700 mario79 77
;--------------------------------------
78
@@:
79
        test    byte [DRIVE_DATA+6], 0x80
2288 clevermous 80
        je      @f
4700 mario79 81
 
82
        mov     esi, cache_ide4
2288 clevermous 83
        call    get_cache_ide
4700 mario79 84
;--------------------------------------
2288 clevermous 85
@@:
4700 mario79 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
 
2288 clevermous 134
        jmp     end_get_cache
4700 mario79 135
;-----------------------------------------------------------------------------
136
get_cache_ide:
137
        and     [esi+IDE_CACHE.search_start], 0
138
        and     [esi+IDE_CACHE.appl_search_start], 0
2288 clevermous 139
 
140
        push    ecx
4711 mario79 141
;        DEBUGF  1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
4700 mario79 142
        stdcall kernel_alloc, [esi+IDE_CACHE.size]
143
        mov     [esi+IDE_CACHE.pointer], eax
2288 clevermous 144
        pop     ecx
4700 mario79 145
 
2288 clevermous 146
        mov     edx, eax
4700 mario79 147
        mov     eax, [esi+IDE_CACHE.size]
2288 clevermous 148
        shr     eax, 3
4711 mario79 149
;        DEBUGF  1, "K : IDE_CACHE.system_data_size %x\n", eax
4700 mario79 150
        mov     [esi+IDE_CACHE.system_data_size], eax
2288 clevermous 151
        mov     ebx, eax
152
        imul    eax, 7
4711 mario79 153
;        DEBUGF  1, "K : IDE_CACHE.appl_data_size %x\n", eax
4700 mario79 154
        mov     [esi+IDE_CACHE.appl_data_size], eax
2288 clevermous 155
        add     ebx, edx
4700 mario79 156
        mov     [esi+IDE_CACHE.data_pointer], ebx
2288 clevermous 157
 
158
.cd:
159
        push    ecx
4700 mario79 160
        mov     eax, [esi+IDE_CACHE.system_data_size]
2288 clevermous 161
        call    calculate_for_cd
4700 mario79 162
        add     eax, [esi+IDE_CACHE.pointer]
163
        mov     [esi+IDE_CACHE.system_data], eax
164
        mov     [esi+IDE_CACHE.system_sad_size], ecx
2288 clevermous 165
 
166
        push    edi
4700 mario79 167
        mov     edi, [esi+IDE_CACHE.pointer]
2288 clevermous 168
        call    clear_ide_cache
169
        pop     edi
170
 
4700 mario79 171
        mov     eax, [esi+IDE_CACHE.appl_data_size]
2288 clevermous 172
        call    calculate_for_cd
4700 mario79 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
2288 clevermous 176
 
177
        push    edi
4700 mario79 178
        mov     edi, [esi+IDE_CACHE.data_pointer]
2288 clevermous 179
        call    clear_ide_cache
180
        pop     edi
181
 
182
        pop     ecx
183
        ret
4700 mario79 184
;-----------------------------------------------------------------------------
2288 clevermous 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
4700 mario79 198
;-----------------------------------------------------------------------------
2288 clevermous 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
4700 mario79 207
;-----------------------------------------------------------------------------
2288 clevermous 208
end_get_cache:
209
        popa