Subversion Repositories Kolibri OS

Rev

Rev 5201 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5201 Rev 5565
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
;**************************************************************************
8
;**************************************************************************
9
;
9
;
10
;   [cache_ide[X]_pointer]
10
;   [cache_ide[X]_pointer]
11
;   or [cache_ide[X]_data_pointer]  first entry in cache list
11
;   or [cache_ide[X]_data_pointer]  first entry in cache list
12
;
12
;
13
;            +0   - lba sector
13
;            +0   - lba sector
14
;            +4   - state of cache sector
14
;            +4   - state of cache sector
15
;                   0 = empty
15
;                   0 = empty
16
;                   1 = used for read  ( same as in hd )
16
;                   1 = used for read  ( same as in hd )
17
;                   2 = used for write ( differs from hd )
17
;                   2 = used for write ( differs from hd )
18
;
18
;
19
;  [cache_ide[X]_system_data]
19
;  [cache_ide[X]_system_data]
20
;  or [cache_ide[x]_appl_data] - cache entries
20
;  or [cache_ide[x]_appl_data] - cache entries
21
;
21
;
22
;**************************************************************************
22
;**************************************************************************
23
 
23
 
24
$Revision: 5201 $
24
$Revision: 5565 $
25
 
25
 
26
align 4
26
align 4
27
find_empty_slot_CD_cache:
27
find_empty_slot_CD_cache:
28
;-----------------------------------------------------------
28
;-----------------------------------------------------------
29
; find empty or read slot, flush cache if next 10% is used by write
29
; find empty or read slot, flush cache if next 10% is used by write
30
; output : edi = cache slot
30
; output : edi = cache slot
31
;-----------------------------------------------------------
31
;-----------------------------------------------------------
32
.search_again:
32
.search_again:
33
        call    cd_calculate_cache_3
33
        call    cd_calculate_cache_3
34
.search_for_empty:
34
.search_for_empty:
35
        inc     edi
35
        inc     edi
36
        call    cd_calculate_cache_4
36
        call    cd_calculate_cache_4
37
        jbe     .inside_cache
37
        jbe     .inside_cache
38
        mov     edi, 1
38
        mov     edi, 1
39
.inside_cache:
39
.inside_cache:
40
        call    cd_calculate_cache_5
40
        call    cd_calculate_cache_5
41
        ret
41
        ret
42
;--------------------------------------------------------------------
42
;--------------------------------------------------------------------
43
clear_CD_cache:
43
clear_CD_cache:
44
        DEBUGF  1, 'K : clear_CD_cache\n'
44
        DEBUGF  1, 'K : clear_CD_cache\n'
45
        pusha
45
        pusha
46
 
46
 
47
        mov     esi, [cdpos]
47
        mov     esi, [cdpos]
48
        dec     esi
48
        dec     esi
49
        imul    esi, sizeof.IDE_CACHE
49
        imul    esi, sizeof.IDE_CACHE
50
        add     esi, cache_ide0
50
        add     esi, cache_ide0
51
 
51
 
52
        xor     eax, eax
52
        xor     eax, eax
53
 
53
 
54
        mov     [esi+IDE_CACHE.search_start], eax
54
        mov     [esi+IDE_CACHE.search_start], eax
55
        mov     ecx, [esi+IDE_CACHE.system_sad_size]
55
        mov     ecx, [esi+IDE_CACHE.system_sad_size]
56
        mov     edi, [esi+IDE_CACHE.pointer]
56
        mov     edi, [esi+IDE_CACHE.pointer]
57
        call    .clear
57
        call    .clear
58
 
58
 
59
        mov     [esi+IDE_CACHE.appl_search_start], eax
59
        mov     [esi+IDE_CACHE.appl_search_start], eax
60
        mov     ecx, [esi+IDE_CACHE.appl_sad_size]
60
        mov     ecx, [esi+IDE_CACHE.appl_sad_size]
61
        mov     edi, [esi+IDE_CACHE.data_pointer]
61
        mov     edi, [esi+IDE_CACHE.data_pointer]
62
        call    .clear
62
        call    .clear
63
 
63
 
64
        popa
64
        popa
65
        ret
65
        ret
66
;--------------------------------------
66
;--------------------------------------
67
.clear:
67
.clear:
68
        shl     ecx, 1
68
        shl     ecx, 1
69
        cld
69
        cld
70
        rep stosd
70
        rep stosd
71
        ret
71
        ret
72
;--------------------------------------------------------------------
72
;--------------------------------------------------------------------
73
align 4
73
align 4
74
cd_calculate_cache:
74
cd_calculate_cache:
75
; 1 - IDE0 ... 12 - IDE11
75
; 1 - IDE0 ... 12 - IDE11
76
        push    eax
76
        push    eax
77
 
77
 
78
        mov     eax, [cdpos]
78
        mov     eax, [cdpos]
79
        dec     eax
79
        dec     eax
80
        imul    eax, sizeof.IDE_CACHE
80
        imul    eax, sizeof.IDE_CACHE
81
        add     eax, cache_ide0
81
        add     eax, cache_ide0
82
 
82
 
83
        cmp     [cd_appl_data], 0
83
        cmp     [cd_appl_data], 0
84
        jne     @f
84
        jne     @f
85
 
85
 
86
        mov     ecx, [eax+IDE_CACHE.system_sad_size]
86
        mov     ecx, [eax+IDE_CACHE.system_sad_size]
87
        mov     esi, [eax+IDE_CACHE.pointer]
87
        mov     esi, [eax+IDE_CACHE.pointer]
88
        pop     eax
88
        pop     eax
89
        ret
89
        ret
90
;--------------------------------------
90
;--------------------------------------
91
@@:
91
@@:
92
        mov     ecx, [eax+IDE_CACHE.appl_sad_size]
92
        mov     ecx, [eax+IDE_CACHE.appl_sad_size]
93
        mov     esi, [eax+IDE_CACHE.data_pointer]
93
        mov     esi, [eax+IDE_CACHE.data_pointer]
94
        pop     eax
94
        pop     eax
95
        ret
95
        ret
96
;--------------------------------------------------------------------
96
;--------------------------------------------------------------------
97
align 4
97
align 4
98
cd_calculate_cache_1:
98
cd_calculate_cache_1:
99
; 1 - IDE0 ... 12 - IDE11
99
; 1 - IDE0 ... 12 - IDE11
100
        push    eax
100
        push    eax
101
 
101
 
102
        mov     eax, [cdpos]
102
        mov     eax, [cdpos]
103
        dec     eax
103
        dec     eax
104
        imul    eax, sizeof.IDE_CACHE
104
        imul    eax, sizeof.IDE_CACHE
105
        add     eax, cache_ide0
105
        add     eax, cache_ide0
106
 
106
 
107
        cmp     [cd_appl_data], 0
107
        cmp     [cd_appl_data], 0
108
        jne     @f
108
        jne     @f
109
 
109
 
110
        mov     esi, [eax+IDE_CACHE.pointer]
110
        mov     esi, [eax+IDE_CACHE.pointer]
111
        pop     eax
111
        pop     eax
112
        ret
112
        ret
113
;--------------------------------------
113
;--------------------------------------
114
@@:
114
@@:
115
        mov     esi, [eax+IDE_CACHE.data_pointer]
115
        mov     esi, [eax+IDE_CACHE.data_pointer]
116
        pop     eax
116
        pop     eax
117
        ret
117
        ret
118
;--------------------------------------------------------------------
118
;--------------------------------------------------------------------
119
align 4
119
align 4
120
cd_calculate_cache_2:
120
cd_calculate_cache_2:
121
; 1 - IDE0 ... 12 - IDE11
121
; 1 - IDE0 ... 12 - IDE11
122
        mov     eax, [cdpos]
122
        mov     eax, [cdpos]
123
        dec     eax
123
        dec     eax
124
        imul    eax, sizeof.IDE_CACHE
124
        imul    eax, sizeof.IDE_CACHE
125
        add     eax, cache_ide0
125
        add     eax, cache_ide0
126
 
126
 
127
        cmp     [cd_appl_data], 0
127
        cmp     [cd_appl_data], 0
128
        jne     @f
128
        jne     @f
129
 
129
 
130
        mov     eax, [eax+IDE_CACHE.system_data]
130
        mov     eax, [eax+IDE_CACHE.system_data]
131
        ret
131
        ret
132
;--------------------------------------
132
;--------------------------------------
133
@@:
133
@@:
134
        mov     eax, [eax+IDE_CACHE.appl_data]
134
        mov     eax, [eax+IDE_CACHE.appl_data]
135
        ret
135
        ret
136
;--------------------------------------------------------------------
136
;--------------------------------------------------------------------
137
align 4
137
align 4
138
cd_calculate_cache_3:
138
cd_calculate_cache_3:
139
; 1 - IDE0 ... 12 - IDE11
139
; 1 - IDE0 ... 12 - IDE11
140
        push    eax
140
        push    eax
141
 
141
 
142
        mov     eax, [cdpos]
142
        mov     eax, [cdpos]
143
        dec     eax
143
        dec     eax
144
        imul    eax, sizeof.IDE_CACHE
144
        imul    eax, sizeof.IDE_CACHE
145
        add     eax, cache_ide0
145
        add     eax, cache_ide0
146
 
146
 
147
        cmp     [cd_appl_data], 0
147
        cmp     [cd_appl_data], 0
148
        jne     @f
148
        jne     @f
149
 
149
 
150
        mov     edi, [eax+IDE_CACHE.search_start]
150
        mov     edi, [eax+IDE_CACHE.search_start]
151
        pop     eax
151
        pop     eax
152
        ret
152
        ret
153
;--------------------------------------
153
;--------------------------------------
154
@@:
154
@@:
155
        mov     edi, [eax+IDE_CACHE.appl_search_start]
155
        mov     edi, [eax+IDE_CACHE.appl_search_start]
156
        pop     eax
156
        pop     eax
157
        ret
157
        ret
158
;--------------------------------------------------------------------
158
;--------------------------------------------------------------------
159
align 4
159
align 4
160
cd_calculate_cache_4:
160
cd_calculate_cache_4:
161
; 1 - IDE0 ... 12 - IDE11
161
; 1 - IDE0 ... 12 - IDE11
162
        push    eax
162
        push    eax
163
 
163
 
164
        mov     eax, [cdpos]
164
        mov     eax, [cdpos]
165
        dec     eax
165
        dec     eax
166
        imul    eax, sizeof.IDE_CACHE
166
        imul    eax, sizeof.IDE_CACHE
167
        add     eax, cache_ide0
167
        add     eax, cache_ide0
168
 
168
 
169
        cmp     [cd_appl_data], 0
169
        cmp     [cd_appl_data], 0
170
        jne     @f
170
        jne     @f
171
 
171
 
172
        cmp     edi, [eax+IDE_CACHE.system_sad_size]
172
        cmp     edi, [eax+IDE_CACHE.system_sad_size]
173
        pop     eax
173
        pop     eax
174
        ret
174
        ret
175
;--------------------------------------
175
;--------------------------------------
176
@@:
176
@@:
177
        cmp     edi, [eax+IDE_CACHE.appl_sad_size]
177
        cmp     edi, [eax+IDE_CACHE.appl_sad_size]
178
        pop     eax
178
        pop     eax
179
        ret
179
        ret
180
;--------------------------------------------------------------------
180
;--------------------------------------------------------------------
181
align 4
181
align 4
182
cd_calculate_cache_5:
182
cd_calculate_cache_5:
183
; 1 - IDE0 ... 12 - IDE11
183
; 1 - IDE0 ... 12 - IDE11
184
        push    eax
184
        push    eax
185
 
185
 
186
        mov     eax, [cdpos]
186
        mov     eax, [cdpos]
187
        dec     eax
187
        dec     eax
188
        imul    eax, sizeof.IDE_CACHE
188
        imul    eax, sizeof.IDE_CACHE
189
        add     eax, cache_ide0
189
        add     eax, cache_ide0
190
 
190
 
191
        cmp     [cd_appl_data], 0
191
        cmp     [cd_appl_data], 0
192
        jne     @f
192
        jne     @f
193
 
193
 
194
        mov     [eax+IDE_CACHE.search_start], edi
194
        mov     [eax+IDE_CACHE.search_start], edi
195
        pop     eax
195
        pop     eax
196
        ret
196
        ret
197
;--------------------------------------
197
;--------------------------------------
198
@@:
198
@@:
199
        mov     [eax+IDE_CACHE.appl_search_start], edi
199
        mov     [eax+IDE_CACHE.appl_search_start], edi
200
        pop     eax
200
        pop     eax
201
        ret
201
        ret
202
;--------------------------------------------------------------------
202
;--------------------------------------------------------------------