2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2012-03-13 17:51:57 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
pusha
|
|
|
|
|
|
|
|
mov eax, [pg_data.pages_free]
|
|
|
|
; 1/32
|
|
|
|
shr eax, 5
|
|
|
|
; round off up to 8 pages
|
|
|
|
shr eax, 3
|
|
|
|
shl eax, 3
|
|
|
|
; translate pages in butes *4096
|
|
|
|
shl eax, 12
|
|
|
|
; check a upper size of the cache, no more than 1 Mb on the physical device
|
|
|
|
cmp eax, 1024*1024
|
|
|
|
jbe @f
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, 1024*1024
|
|
|
|
jmp .continue
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
; check a lower size of the cache, not less than 128 Kb on the physical device
|
|
|
|
cmp eax, 128*1024
|
2014-03-27 21:44:32 +01:00
|
|
|
jae .continue
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, 128*1024
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.continue:
|
2014-03-27 21:44:32 +01:00
|
|
|
push ecx
|
|
|
|
mov ecx, 12
|
|
|
|
mov esi, cache_ide0+IDE_CACHE.size
|
|
|
|
cld
|
|
|
|
@@:
|
|
|
|
mov [esi], eax
|
|
|
|
add esi, sizeof.IDE_CACHE
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
pop ecx
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [hdd_appl_data], 1 ;al
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [cd_appl_data], 1
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
test byte [DRIVE_DATA+1], 0x80
|
|
|
|
je @f
|
2013-07-01 18:29:16 +02:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
mov esi, cache_ide0
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+1], 0x20
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide1
|
2011-10-14 23:38:50 +02:00
|
|
|
call get_cache_ide
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
test byte [DRIVE_DATA+1], 8
|
2014-03-27 21:44:32 +01:00
|
|
|
je @f
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov esi, cache_ide2
|
|
|
|
call get_cache_ide
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+1], 2
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide3
|
2011-10-14 23:38:50 +02:00
|
|
|
call get_cache_ide
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+6], 0x80
|
2011-10-14 23:38:50 +02:00
|
|
|
je @f
|
2014-03-27 21:44:32 +01:00
|
|
|
|
|
|
|
mov esi, cache_ide4
|
2011-10-14 23:38:50 +02:00
|
|
|
call get_cache_ide
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
test byte [DRIVE_DATA+6], 0x20
|
|
|
|
je @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
mov esi, cache_ide5
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+6], 8
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide6
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+6], 2
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide7
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+11], 0x80
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide8
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+11], 0x20
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide9
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+11], 8
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov esi, cache_ide10
|
|
|
|
call get_cache_ide
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test byte [DRIVE_DATA+11], 2
|
|
|
|
je end_get_cache
|
|
|
|
|
|
|
|
mov esi, cache_ide11
|
|
|
|
call get_cache_ide
|
|
|
|
|
|
|
|
jmp end_get_cache
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
get_cache_ide:
|
2014-03-27 21:44:32 +01:00
|
|
|
and [esi+IDE_CACHE.search_start], 0
|
|
|
|
and [esi+IDE_CACHE.appl_search_start], 0
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
push ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
|
|
|
|
stdcall kernel_alloc, [esi+IDE_CACHE.size]
|
|
|
|
mov [esi+IDE_CACHE.pointer], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
pop ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, eax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [esi+IDE_CACHE.size]
|
2011-10-14 23:38:50 +02:00
|
|
|
shr eax, 3
|
2014-03-27 21:44:32 +01:00
|
|
|
DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax
|
|
|
|
mov [esi+IDE_CACHE.system_data_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ebx, eax
|
|
|
|
imul eax, 7
|
2014-03-27 21:44:32 +01:00
|
|
|
DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax
|
|
|
|
mov [esi+IDE_CACHE.appl_data_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
add ebx, edx
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [esi+IDE_CACHE.data_pointer], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
.cd:
|
|
|
|
push ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [esi+IDE_CACHE.system_data_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
call calculate_for_cd
|
2014-03-27 21:44:32 +01:00
|
|
|
add eax, [esi+IDE_CACHE.pointer]
|
|
|
|
mov [esi+IDE_CACHE.system_data], eax
|
|
|
|
mov [esi+IDE_CACHE.system_sad_size], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
push edi
|
2014-03-27 21:44:32 +01:00
|
|
|
mov edi, [esi+IDE_CACHE.pointer]
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_ide_cache
|
|
|
|
pop edi
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [esi+IDE_CACHE.appl_data_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
call calculate_for_cd
|
2014-03-27 21:44:32 +01:00
|
|
|
add eax, [esi+IDE_CACHE.data_pointer]
|
|
|
|
mov [esi+IDE_CACHE.appl_data], eax
|
|
|
|
mov [esi+IDE_CACHE.appl_sad_size], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
push edi
|
2014-03-27 21:44:32 +01:00
|
|
|
mov edi, [esi+IDE_CACHE.data_pointer]
|
2011-10-14 23:38:50 +02:00
|
|
|
call clear_ide_cache
|
|
|
|
pop edi
|
|
|
|
|
|
|
|
pop ecx
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
calculate_for_cd:
|
|
|
|
push eax
|
|
|
|
mov ebx, eax
|
|
|
|
shr eax, 11
|
|
|
|
shl eax, 3
|
|
|
|
sub ebx, eax
|
|
|
|
shr ebx, 11
|
|
|
|
mov ecx, ebx
|
|
|
|
shl ebx, 11
|
|
|
|
pop eax
|
|
|
|
sub eax, ebx
|
|
|
|
dec ecx
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
clear_ide_cache:
|
|
|
|
push eax
|
|
|
|
shl ecx, 1
|
|
|
|
xor eax, eax
|
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
pop eax
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
end_get_cache:
|
|
|
|
popa
|