Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
750 victor 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
593 mikedld 7
 
750 victor 8
$Revision: 859 $
593 mikedld 9
 
580 mario79 10
    pusha
11
 
859 serge 12
    call _get_free_mem
13
 
580 mario79 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
585 mario79 21
;       check a upper size of the cache, no more than 1 Mb on the physical device
580 mario79 22
    cmp  eax,1024*1024
23
    jbe  @f
24
    mov  eax,1024*1024
25
    jmp  .continue
26
@@:
585 mario79 27
;       check a lower size of the cache, not less than 128 Kb on the physical device
580 mario79 28
    cmp  eax,128*1024
29
    jae  @f
30
    mov  eax,128*1024
31
@@:
32
.continue:
33
    mov  [cache_ide0_size],eax
34
    mov  [cache_ide1_size],eax
35
    mov  [cache_ide2_size],eax
36
    mov  [cache_ide3_size],eax
37
    xor  eax,eax
38
    mov  [hdd_appl_data],1  ;al
585 mario79 39
    mov  [cd_appl_data],1
859 serge 40
 
709 diamond 41
    mov  ch,[DRIVE_DATA+1]
42
    mov  cl,ch
580 mario79 43
    and  cl,11b
585 mario79 44
    je	.ide2
709 diamond 45
    mov  esi,cache_ide3
46
    call get_cache_ide
580 mario79 47
.ide2:
48
    mov  cl,ch
709 diamond 49
    shr  cl,2
50
    and  cl,11b
585 mario79 51
    je	.ide1
709 diamond 52
    mov  esi,cache_ide2
53
    call get_cache_ide
580 mario79 54
.ide1:
55
    mov  cl,ch
709 diamond 56
    shr  cl,4
57
    and  cl,11b
585 mario79 58
    je	.ide0
709 diamond 59
    mov  esi,cache_ide1
60
    call get_cache_ide
580 mario79 61
.ide0:
62
    mov  cl,ch
709 diamond 63
    shr  cl,6
64
    and  cl,11b
65
    je	@f
66
    mov  esi,cache_ide0
67
    call get_cache_ide
68
@@:
69
    xor ecx,ecx
70
    cmp [NumBiosDisks],ecx
71
    jz  .endbd
72
    mov esi,BiosDiskCaches
73
.loopbd:
74
    cmp byte [BiosDisksData+ecx*4+2],-1
75
    jnz .contbd
76
    mov eax,[cache_ide0_size]
77
    mov [esi+cache_ide0_size-cache_ide0],eax
580 mario79 78
    push ecx
709 diamond 79
    mov  cl,1
80
    call get_cache_ide
580 mario79 81
    pop  ecx
709 diamond 82
.contbd:
83
    add  esi,cache_ide1-cache_ide0
84
    inc  ecx
85
    cmp  ecx,[NumBiosDisks]
86
    jb   .loopbd
87
.endbd:
88
    jmp  end_get_cache
580 mario79 89
 
709 diamond 90
get_cache_ide:
91
    and  [esi+cache_ide0_search_start-cache_ide0],0
92
    and  [esi+cache_ide0_appl_search_start-cache_ide0],0
580 mario79 93
    push  ecx
709 diamond 94
    stdcall kernel_alloc,[esi+cache_ide0_size-cache_ide0]
95
    mov [esi+cache_ide0_pointer-cache_ide0],eax
580 mario79 96
    pop   ecx
97
    mov  edx,eax
709 diamond 98
    mov  eax,[esi+cache_ide0_size-cache_ide0]
580 mario79 99
    shr  eax,3
709 diamond 100
    mov  [esi+cache_ide0_system_data_size-cache_ide0],eax
580 mario79 101
    mov  ebx,eax
102
    imul eax,7
709 diamond 103
    mov  [esi+cache_ide0_appl_data_size-cache_ide0],eax
580 mario79 104
    add  ebx,edx
709 diamond 105
    mov  [esi+cache_ide0_data_pointer-cache_ide0],ebx
585 mario79 106
 
580 mario79 107
    cmp cl,10b
585 mario79 108
    je	.cd
580 mario79 109
    push ecx
709 diamond 110
    mov  eax,[esi+cache_ide0_system_data_size-cache_ide0]
580 mario79 111
    call calculate_for_hd
709 diamond 112
    add  eax,[esi+cache_ide0_pointer-cache_ide0]
113
    mov  [esi+cache_ide0_system_data-cache_ide0],eax
114
    mov  [esi+cache_ide0_system_sad_size-cache_ide0],ecx
580 mario79 115
 
116
    push  edi
709 diamond 117
    mov   edi,[esi+cache_ide0_pointer-cache_ide0]
580 mario79 118
    call  clear_ide_cache
119
    pop   edi
120
 
709 diamond 121
    mov  eax,[esi+cache_ide0_appl_data_size-cache_ide0]
580 mario79 122
    call calculate_for_hd
709 diamond 123
    add  eax,[esi+cache_ide0_data_pointer-cache_ide0]
124
    mov  [esi+cache_ide0_appl_data-cache_ide0],eax
125
    mov  [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
585 mario79 126
 
580 mario79 127
    push  edi
709 diamond 128
    mov   edi,[esi+cache_ide0_data_pointer-cache_ide0]
580 mario79 129
    call  clear_ide_cache
130
    pop   edi
585 mario79 131
 
580 mario79 132
    pop  ecx
133
    ret
134
.cd:
135
    push ecx
709 diamond 136
    mov  eax,[esi+cache_ide0_system_data_size-cache_ide0]
580 mario79 137
    call calculate_for_cd
709 diamond 138
    add  eax,[esi+cache_ide0_pointer-cache_ide0]
139
    mov  [esi+cache_ide0_system_data-cache_ide0],eax
140
    mov  [esi+cache_ide0_system_sad_size-cache_ide0],ecx
580 mario79 141
 
142
    push  edi
709 diamond 143
    mov   edi,[esi+cache_ide0_pointer-cache_ide0]
580 mario79 144
    call  clear_ide_cache
145
    pop   edi
146
 
709 diamond 147
    mov  eax,[esi+cache_ide0_appl_data_size-cache_ide0]
580 mario79 148
    call calculate_for_cd
709 diamond 149
    add  eax,[esi+cache_ide0_data_pointer-cache_ide0]
150
    mov  [esi+cache_ide0_appl_data-cache_ide0],eax
151
    mov  [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
585 mario79 152
 
580 mario79 153
    push  edi
709 diamond 154
    mov   edi,[esi+cache_ide0_data_pointer-cache_ide0]
580 mario79 155
    call  clear_ide_cache
156
    pop   edi
585 mario79 157
 
580 mario79 158
    pop  ecx
159
    ret
160
 
161
calculate_for_hd:
162
    push eax
163
    mov  ebx,eax
164
    shr  eax,9
165
    shl  eax,3
166
    sub  ebx,eax
167
    shr  ebx,9
168
    mov  ecx,ebx
169
    shl  ebx,9
170
    pop  eax
171
    sub  eax,ebx
584 mario79 172
    dec  ecx
580 mario79 173
    ret
174
 
175
calculate_for_cd:
176
    push eax
177
    mov  ebx,eax
178
    shr  eax,11
179
    shl  eax,3
180
    sub  ebx,eax
181
    shr  ebx,11
182
    mov  ecx,ebx
183
    shl  ebx,11
184
    pop  eax
185
    sub  eax,ebx
584 mario79 186
    dec  ecx
580 mario79 187
    ret
585 mario79 188
 
580 mario79 189
clear_ide_cache:
190
    push   eax
191
    shl   ecx,1
192
    xor   eax,eax
193
    cld
194
    rep   stosd
195
    pop   eax
196
    ret
585 mario79 197
 
580 mario79 198
end_get_cache:
199
;    mov  [cache_ide0_pointer],HD_CACHE
200
;    mov  [cache_ide0_system_data],HD_CACHE+65536
201
;    mov  [cache_ide0_system_sad_size],1919
202
    popa