2014-01-08 05:03:52 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;**************************************************************************
|
|
|
|
;
|
|
|
|
; [cache_ide[X]_pointer]
|
|
|
|
; or [cache_ide[X]_data_pointer] first entry in cache list
|
|
|
|
;
|
|
|
|
; +0 - lba sector
|
|
|
|
; +4 - state of cache sector
|
|
|
|
; 0 = empty
|
|
|
|
; 1 = used for read ( same as in hd )
|
|
|
|
; 2 = used for write ( differs from hd )
|
|
|
|
;
|
|
|
|
; [cache_ide[X]_system_data]
|
|
|
|
; or [cache_ide[x]_appl_data] - cache entries
|
|
|
|
;
|
|
|
|
;**************************************************************************
|
|
|
|
|
2014-07-11 12:47:51 +02:00
|
|
|
$Revision: 4700 $
|
2014-01-08 05:03:52 +01:00
|
|
|
|
|
|
|
align 4
|
|
|
|
find_empty_slot_CD_cache:
|
|
|
|
;-----------------------------------------------------------
|
|
|
|
; find empty or read slot, flush cache if next 10% is used by write
|
|
|
|
; output : edi = cache slot
|
|
|
|
;-----------------------------------------------------------
|
|
|
|
.search_again:
|
|
|
|
call cd_calculate_cache_3
|
|
|
|
.search_for_empty:
|
|
|
|
inc edi
|
|
|
|
call cd_calculate_cache_4
|
|
|
|
jbe .inside_cache
|
|
|
|
mov edi, 1
|
|
|
|
.inside_cache:
|
|
|
|
call cd_calculate_cache_5
|
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
clear_CD_cache:
|
2014-05-12 21:41:55 +02:00
|
|
|
DEBUGF 1, 'K : clear_CD_cache\n'
|
2014-01-08 05:03:52 +01:00
|
|
|
pusha
|
2014-05-12 21:41:55 +02:00
|
|
|
|
|
|
|
mov esi, [cdpos]
|
|
|
|
dec esi
|
|
|
|
imul esi, sizeof.IDE_CACHE
|
|
|
|
add esi, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
xor eax, eax
|
2014-05-12 21:41:55 +02:00
|
|
|
|
|
|
|
mov [esi+IDE_CACHE.search_start], eax
|
|
|
|
mov ecx, [esi+IDE_CACHE.system_sad_size]
|
|
|
|
mov edi, [esi+IDE_CACHE.pointer]
|
2014-01-08 05:03:52 +01:00
|
|
|
call .clear
|
2014-05-12 21:41:55 +02:00
|
|
|
|
|
|
|
mov [esi+IDE_CACHE.appl_search_start], eax
|
|
|
|
mov ecx, [esi+IDE_CACHE.appl_sad_size]
|
|
|
|
mov edi, [esi+IDE_CACHE.data_pointer]
|
2014-01-08 05:03:52 +01:00
|
|
|
call .clear
|
2014-05-12 21:41:55 +02:00
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
popa
|
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
2014-01-08 05:03:52 +01:00
|
|
|
.clear:
|
|
|
|
shl ecx, 1
|
|
|
|
cld
|
|
|
|
rep stosd
|
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
push eax
|
|
|
|
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ecx, [eax+IDE_CACHE.system_sad_size]
|
|
|
|
mov esi, [eax+IDE_CACHE.pointer]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov ecx, [eax+IDE_CACHE.appl_sad_size]
|
|
|
|
mov esi, [eax+IDE_CACHE.data_pointer]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache_1:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
push eax
|
|
|
|
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov esi, [eax+IDE_CACHE.pointer]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov esi, [eax+IDE_CACHE.data_pointer]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache_2:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov eax, [eax+IDE_CACHE.system_data]
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov eax, [eax+IDE_CACHE.appl_data]
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache_3:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
push eax
|
|
|
|
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
2014-01-08 05:03:52 +01:00
|
|
|
|
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov edi, [eax+IDE_CACHE.search_start]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov edi, [eax+IDE_CACHE.appl_search_start]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache_4:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
push eax
|
|
|
|
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
cmp edi, [eax+IDE_CACHE.system_sad_size]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp edi, [eax+IDE_CACHE.appl_sad_size]
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
cd_calculate_cache_5:
|
2014-05-12 21:41:55 +02:00
|
|
|
; 1 - IDE0 ... 12 - IDE11
|
|
|
|
push eax
|
|
|
|
|
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
imul eax, sizeof.IDE_CACHE
|
|
|
|
add eax, cache_ide0
|
|
|
|
|
2014-01-08 05:03:52 +01:00
|
|
|
cmp [cd_appl_data], 0
|
2014-05-12 21:41:55 +02:00
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov [eax+IDE_CACHE.search_start], edi
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
2014-05-12 21:41:55 +02:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov [eax+IDE_CACHE.appl_search_start], edi
|
|
|
|
pop eax
|
2014-01-08 05:03:52 +01:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|