Subversion Repositories Kolibri OS

Rev

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

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