Subversion Repositories Kolibri OS

Rev

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