mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
キャッシュライブラリ追加。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@132 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
85dd27858e
commit
48bd2a2dc2
@ -117,7 +117,7 @@ asm void STUPi_EnableTCM( void )
|
||||
// プロテクションユニット/キャッシュ/TCM ディセーブル
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
ldr r1, =HW_C1_ICACHE_ENABLE | HW_C1_DCACHE_ENABLE \
|
||||
ldr r1, =HW_C1_IC_ENABLE | HW_C1_DC_ENABLE \
|
||||
| HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \
|
||||
| HW_C1_ITCM_LOAD_MODE | HW_C1_DTCM_LOAD_MODE \
|
||||
| HW_C1_LD_INTERWORK_DISABLE \
|
||||
|
||||
@ -103,7 +103,7 @@ asm void STUPi_InitCP15(void)
|
||||
// プロテクションユニット/キャッシュ/TCM ディセーブル
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
ldr r1, =HW_C1_ICACHE_ENABLE | HW_C1_DCACHE_ENABLE \
|
||||
ldr r1, =HW_C1_IC_ENABLE | HW_C1_DC_ENABLE \
|
||||
| HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \
|
||||
| HW_C1_ITCM_LOAD_MODE | HW_C1_DTCM_LOAD_MODE \
|
||||
| HW_C1_LD_INTERWORK_DISABLE \
|
||||
@ -249,9 +249,9 @@ asm void STUPi_InitCP15(void)
|
||||
// システム制御コプロセッサ マスター設定
|
||||
//
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
ldr r1,=HW_C1_ICACHE_ENABLE | HW_C1_DCACHE_ENABLE | HW_C1_CACHE_ROUND_ROBIN \
|
||||
| HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \
|
||||
| HW_C1_SB1_BITSET | HW_C1_EXCEPT_VEC_UPPER \
|
||||
ldr r1,=HW_C1_IC_ENABLE | HW_C1_DC_ENABLE | HW_C1_CACHE_ROUND_ROBIN \
|
||||
| HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE \
|
||||
| HW_C1_SB1_BITSET | HW_C1_EXCEPT_VEC_UPPER \
|
||||
| HW_C1_PROTECT_UNIT_ENABLE
|
||||
orr r0, r0, r1
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
@ -28,11 +28,12 @@ BROM_CODEGEN_ALL ?= TRUE
|
||||
SRCDIR = . ../common
|
||||
|
||||
SRCS = \
|
||||
os_alarm.c \
|
||||
os_cache.c \
|
||||
os_init.c \
|
||||
os_system.c \
|
||||
os_timer.c \
|
||||
os_tick.c \
|
||||
os_alarm.c \
|
||||
os_irqHandler.c \
|
||||
os_interrupt.c \
|
||||
os_interrupt_common.c \
|
||||
|
||||
@ -31,11 +31,12 @@ BROM_PROC = ARM9
|
||||
SRCDIR = . ../common
|
||||
|
||||
SRCS = \
|
||||
os_alarm.c \
|
||||
os_cache.c \
|
||||
os_init.c \
|
||||
os_system.c \
|
||||
os_timer.c \
|
||||
os_tick.c \
|
||||
os_alarm.c \
|
||||
os_irqHandler.c \
|
||||
os_interrupt.c \
|
||||
os_interrupt_common.c \
|
||||
|
||||
854
trunk/bootrom/build/libraries/os/common/os_cache.c
Normal file
854
trunk/bootrom/build/libraries/os/common/os_cache.c
Normal file
@ -0,0 +1,854 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CtrBrom - libraries - OS
|
||||
File: os_cache.c
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <brom/os.h>
|
||||
|
||||
#include <brom/code32.h>
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE CONTROL
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osEnableDCache
|
||||
|
||||
Description: enable data cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osEnableDCache( void )
|
||||
{
|
||||
PRESERVE8
|
||||
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_DC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_DC_ENABLE_SFT
|
||||
orr r1, r1, #HW_C1_DC_ENABLE
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDisableDCache
|
||||
|
||||
Description: disable data cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osDisableDCache( void )
|
||||
{
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_DC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_DC_ENABLE_SFT
|
||||
bic r1, r1, #HW_C1_DC_ENABLE
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osRestoreDCache
|
||||
|
||||
Description: set state of data cache
|
||||
|
||||
Arguments: data cache state to be set
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osRestoreDCache( BOOL enable )
|
||||
{
|
||||
//---- 引数処理
|
||||
cmp r0, #0
|
||||
moveq r2, #0
|
||||
movne r2, #HW_C1_DC_ENABLE
|
||||
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_DC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_DC_ENABLE_SFT
|
||||
bic r1, r1, #HW_C1_DC_ENABLE
|
||||
orr r1, r1, r2
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for all range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheAll
|
||||
|
||||
Description: invalidate all data cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateDCacheAll( void )
|
||||
{
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c6, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheAll
|
||||
|
||||
Description: clean all data cache
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osStoreDCacheAll( void )
|
||||
{
|
||||
mov r1, #0
|
||||
LSYM(1)
|
||||
mov r0, #0
|
||||
LSYM(2)
|
||||
orr r2, r1, r0
|
||||
mcr p15, 0, r2, c7, c10, 2
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, #HW_DC_SIZE/4
|
||||
blt BSYM(2)
|
||||
|
||||
add r1, r1, #1<<HW_C7_CACHE_WAY_NO_SFT
|
||||
cmp r1, #0
|
||||
bne BSYM(1)
|
||||
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheAll
|
||||
|
||||
Description: clean and invalidate all data cache
|
||||
(write cache data to memory, and invalidate cache)
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osFlushDCacheAll( void )
|
||||
{
|
||||
mov r12, #0
|
||||
mov r1, #0 // r1: セットNoカウンタ(0 ~ 3)
|
||||
|
||||
LSYM(1)
|
||||
mov r0, #0 // r0: ラインカウンタ(0 ~ DCACHE_SIZE/4)
|
||||
|
||||
LSYM(2)
|
||||
orr r2, r1, r0
|
||||
mcr p15, 0, r12, c7, c10, 4 /* wait write buffer empty */
|
||||
mcr p15, 0, r2, c7, c14, 2 /* flush */
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, #HW_DC_SIZE/4
|
||||
blt BSYM(2)
|
||||
|
||||
add r1, r1, #1<<HW_C7_CACHE_WAY_NO_SFT
|
||||
cmp r1, #0
|
||||
bne BSYM(1)
|
||||
|
||||
bx lr
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for specified range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheRange
|
||||
|
||||
Description: invalidate data cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateDCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c6, 1
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheRange
|
||||
|
||||
Description: clean data cache in specified range
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osStoreDCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c10, 1
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheRange
|
||||
|
||||
Description: clean and invalidate data cache in specified range
|
||||
(write cache data to memory, and invalidate cache)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osFlushDCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
mov r12, #0
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
LSYM(1)
|
||||
mcr p15, 0, r12, c7, c10, 4 /* wait write buffer empty */
|
||||
mcr p15, 0, r0, c7, c14, 1 /* flush */
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheRangeOrAll
|
||||
|
||||
Description: invalidate data cache in specified range or all
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osInvalidateDCacheRangeOrAll( void* startAddr, u32 nBytes )
|
||||
{
|
||||
if ( nBytes < HW_DC_SIZE )
|
||||
{
|
||||
osInvalidateDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
osInvalidateDCacheAll();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheRangeOrAll
|
||||
|
||||
Description: clean data cache in specified range
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osStoreDCacheRangeOrAll( void* startAddr, u32 nBytes )
|
||||
{
|
||||
if ( nBytes < HW_DC_SIZE )
|
||||
{
|
||||
osStoreDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
osStoreDCacheAll();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheRangeOrAll
|
||||
|
||||
Description: clean data cache in specified range
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osFlushDCacheRangeOrAll( void* startAddr, u32 nBytes )
|
||||
{
|
||||
if ( nBytes < HW_DC_SIZE )
|
||||
{
|
||||
osFlushDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
osFlushDCacheAll();
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for specified range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osLockdownDCacheRange
|
||||
|
||||
Description: lock specified area to prevent not to release data cache
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osLockdownDCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
#ifdef SDK_ARM9
|
||||
INASM_EXTERN( osDisableInterrupts )
|
||||
INASM_EXTERN( osRestoreInterrupts )
|
||||
|
||||
add r1, r1, r0 // r1: エンドアドレス
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
mrc p15, 0, r3, c9, c0, 0
|
||||
and r3, r3, #HW_C9_LOCKDOWN_WAY_NO_MASK // r3: カレントセットNo
|
||||
cmp r3, #3 // 3セットをロックダウンしていればエラー
|
||||
mvneq r0, #0
|
||||
bxeq lr
|
||||
|
||||
stmfd sp!, { lr, r0, r1 }
|
||||
ldr r0, =osDisableInterrupts
|
||||
blx r0
|
||||
mov r2, r0
|
||||
ldmfd sp!, { lr, r0, r1 }
|
||||
|
||||
orr r3, r3, #HW_C9_LOCKDOWN_LOAD_MODE // キャッシュロックダウン・ロードモード
|
||||
mcr p15, 0, r3, c9, c0, 0
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c14, 1 // キャッシュに乗っているデータを一旦クリーン/無効化する
|
||||
ldr r12, [r0] // データを読み込みキャッシュに乗せる
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
add r3, r3, #1 // キャッシュ通常モード & セットNoのインクリメント
|
||||
bic r0, r3, #HW_C9_LOCKDOWN_LOAD_MODE
|
||||
mcr p15, 0, r3, c9, c0, 0
|
||||
|
||||
stmfd sp!, { lr }
|
||||
mov r0, r2
|
||||
ldr r1, =osRestoreInterrupts
|
||||
blx r1
|
||||
ldmfd sp!, { lr }
|
||||
|
||||
bx lr
|
||||
#else // SDK_ARM11
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownDCacheAll
|
||||
|
||||
Description: unlock all data cache to enable to release
|
||||
|
||||
Arguments: none.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osUnlockdownDCacheAll( void )
|
||||
{
|
||||
#ifdef SDK_ARM9
|
||||
mov r3, #0
|
||||
mcr p15, 0, r3, c9, c0, 0
|
||||
bx lr
|
||||
#else // SDK_ARM11
|
||||
#endif
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownDCache
|
||||
|
||||
Description: unlock any data cache to enable to release
|
||||
|
||||
Arguments: num - specify number of datablock to unlock.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osUnlockdownDCache( u32 num )
|
||||
{
|
||||
#ifdef SDK_ARM9
|
||||
mrc p15, 0, r3, c9, c0, 0
|
||||
and r3, r3, #HW_C9_LOCKDOWN_WAY_NO_MASK
|
||||
subs r3, r3, r0
|
||||
movmi r3, #0
|
||||
mcr p15, 0, r3, c9, c0, 0
|
||||
bx lr
|
||||
#else // SDK_ARM11
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osWaitWriteBufferEmpty
|
||||
|
||||
Description: wait till write buffer becomes to be empty
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osWaitWriteBufferEmpty( void )
|
||||
{
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c10, 4
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osTouchDCacheRange
|
||||
|
||||
Description: include specified area to data cache in advance
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osTouchDCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
|
||||
LSYM(1)
|
||||
#ifdef SDK_ARM11
|
||||
pld [r0]
|
||||
#else // SDK_ARM9
|
||||
ldr r2, [r0]
|
||||
#endif // SDK_ARM9
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osKeepDataAccessOrder
|
||||
|
||||
Description: keep data access order
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osKeepDataAccessOrder( void )
|
||||
{
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c10, 5
|
||||
bx lr
|
||||
}
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// INSTRUCTION CACHE CONTROL
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osEnableICache
|
||||
|
||||
Description: enable instruction cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osEnableICache( void )
|
||||
{
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_IC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_IC_ENABLE_SFT
|
||||
orr r1, r1, #HW_C1_IC_ENABLE
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDisableICache
|
||||
|
||||
Description: disable instruction cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osDisableICache( void )
|
||||
{
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_IC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_IC_ENABLE_SFT
|
||||
bic r1, r1, #HW_C1_IC_ENABLE
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osRestoreICache
|
||||
|
||||
Description: set state of instruction cache
|
||||
|
||||
Arguments: instruction cache state to be set
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM BOOL osRestoreICache( BOOL enable )
|
||||
{
|
||||
//---- 引数処理
|
||||
cmp r0, #0
|
||||
moveq r2, #0
|
||||
movne r2, #HW_C1_IC_ENABLE
|
||||
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
and r0, r1, #HW_C1_IC_ENABLE
|
||||
mov r0, r0, LSR #HW_C1_IC_ENABLE_SFT
|
||||
bic r1, r1, #HW_C1_IC_ENABLE
|
||||
orr r1, r1, r2
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// INSTRUCTION CACHE
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheAll
|
||||
|
||||
Description: invalidate all instruction cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateICacheAll( void )
|
||||
{
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c5, 0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheRange
|
||||
|
||||
Description: invalidate instruction cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateICacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c5, 1
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheRangeOrAll
|
||||
|
||||
Description: invalidate instruction cache in specified range or all
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osInvalidateICacheRangeOrAll( void* startAddr, u32 nBytes )
|
||||
{
|
||||
if ( nBytes < HW_DC_SIZE )
|
||||
{
|
||||
osInvalidateICacheRange( startAddr, nBytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
osInvalidateICacheAll();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osLockdownICacheRange
|
||||
|
||||
Description: lock specified area to prevent not to release instruction cache
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osLockdownICacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
INASM_EXTERN( osDisableInterrupts )
|
||||
INASM_EXTERN( osRestoreInterrupts )
|
||||
|
||||
add r1, r1, r0 // r1: エンドアドレス
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
mrc p15, 0, r3, c9, c0, 1
|
||||
and r3, r3, #HW_C9_LOCKDOWN_WAY_NO_MASK // r3: カレントセットNo
|
||||
cmp r3, #3 // 3セットをロックダウンしていればエラー
|
||||
mvneq r0, #0
|
||||
bxeq lr
|
||||
|
||||
stmfd sp!, { lr, r0, r1 }
|
||||
ldr r0, =osDisableInterrupts
|
||||
blx r0
|
||||
mov r2, r0
|
||||
ldmfd sp!, { lr, r0, r1 }
|
||||
|
||||
orr r3, r3, #HW_C9_LOCKDOWN_LOAD_MODE // キャッシュロックダウン・ロードモード
|
||||
mcr p15, 0, r3, c9, c0, 1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c5, 1 // キャッシュから一旦無効化
|
||||
mcr p15, 0, r0, c7, c13, 1 // プリフェッチ
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
add r3, r3, #1 // キャッシュ通常モード & セットNoのインクリメント
|
||||
bic r0, r3, #HW_C9_LOCKDOWN_LOAD_MODE
|
||||
mcr p15, 0, r3, c9, c0, 1
|
||||
|
||||
stmfd sp!, { lr }
|
||||
mov r0, r2
|
||||
ldr r1, =osRestoreInterrupts
|
||||
blx r1
|
||||
ldmfd sp!, { lr }
|
||||
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownICacheAll
|
||||
|
||||
Description: unlock all instruction cache to enable to release
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osUnlockdownICacheAll( void )
|
||||
{
|
||||
mov r3, #0
|
||||
mcr p15, 0, r3, c9, c0, 1
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownICache
|
||||
|
||||
Description: unlock any instruction cache to enable to release
|
||||
|
||||
Arguments: num - specify number of datablock to unlock.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osUnlockdownICache( u32 num )
|
||||
{
|
||||
mrc p15, 0, r3, c9, c0, 1
|
||||
and r3, r3, #HW_C9_LOCKDOWN_WAY_NO_MASK
|
||||
subs r3, r3, r0
|
||||
movmi r3, #0
|
||||
mcr p15, 0, r3, c9, c0, 1
|
||||
bx lr
|
||||
}
|
||||
|
||||
#else // SDK_ARM11
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osPrefetchICacheRange
|
||||
|
||||
Description: include specified area to instruction cache in advance
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osPrefetchICacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #HW_CACHE_LINE_SIZE - 1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c13, 1
|
||||
add r0, r0, #HW_CACHE_LINE_SIZE
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateInstPrefetchBuffer
|
||||
|
||||
Description: invalidate instruction prefetch buffer
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateInstPrefetchBuffer( void )
|
||||
{
|
||||
mov r3, #0
|
||||
mcr p15, 0, r3, c7, c5, 4
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDoInstMemoryBarrierAll
|
||||
|
||||
Description: do all Instruction Memory Barrier
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osDoInstMemoryBarrierAll( void )
|
||||
{
|
||||
osStoreDCacheAll();
|
||||
osWaitWriteBufferEmpty();
|
||||
osInvalidateICacheAll();
|
||||
osInvalidateInstPrefetchBuffer();
|
||||
osInvalidateBCacheAll();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDoInstMemoryBarrierRange
|
||||
|
||||
Description: do Instruction Memory Barrier in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
void osDoInstMemoryBarrierRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
osStoreDCacheRange( startAddr, nBytes );
|
||||
osWaitWriteBufferEmpty();
|
||||
osInvalidateICacheRange( startAddr, nBytes );
|
||||
osInvalidateInstPrefetchBuffer();
|
||||
osInvalidateBCacheRange( startAddr, nBytes );
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// BRANCH TARGET ADDRESS CACHE
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateBCacheAll
|
||||
|
||||
Description: invalidate all branch target address cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateBCacheAll( void )
|
||||
{
|
||||
mov r3, #0
|
||||
mcr p15, 0, r3, c7, c5, 6
|
||||
bx lr
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateBCacheRange
|
||||
|
||||
Description: invalidate branch target address cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
ASM void osInvalidateBCacheRange( void* startAddr, u32 nBytes )
|
||||
{
|
||||
add r1, r1, r0
|
||||
bic r0, r0, #1
|
||||
|
||||
LSYM(1)
|
||||
mcr p15, 0, r0, c7, c5, 7
|
||||
add r0, r0, #2
|
||||
cmp r0, r1
|
||||
blt BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
|
||||
#include <brom/codereset.h>
|
||||
|
||||
@ -37,6 +37,7 @@ extern "C" {
|
||||
#include <brom/os/common/thread.h>
|
||||
#include <brom/os/common/timer.h>
|
||||
#include <brom/os/common/interrupt.h>
|
||||
#include <brom/os/common/cache.h>
|
||||
#if 0
|
||||
#include <brom/os/common/systemWork.h>
|
||||
#include <brom/os/common/exception.h>
|
||||
|
||||
549
trunk/bootrom/include/brom/os/common/cache.h
Normal file
549
trunk/bootrom/include/brom/os/common/cache.h
Normal file
@ -0,0 +1,549 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CtrBrom - OS - include
|
||||
File: cache.h
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef BROM_OS_CACHE_H_
|
||||
#define BROM_OS_CACHE_H_
|
||||
|
||||
#include <brom/misc.h>
|
||||
#include <brom/types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE CONTROL
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osEnableDCache
|
||||
|
||||
Description: enable data cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osEnableDCache( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDisableDCache
|
||||
|
||||
Description: disable data cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osDisableDCache( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osRestoreDCache
|
||||
|
||||
Description: set state of data cache
|
||||
|
||||
Arguments: data cache state to be set
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osRestoreDCache( BOOL enable );
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for all range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheAll
|
||||
|
||||
Description: invalidate all data cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateDCacheAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheAll
|
||||
|
||||
Description: clean all data cache
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osStoreDCacheAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheAll
|
||||
|
||||
Description: clean and invalidate all data cache
|
||||
(write cache data to memory, and invalidate cache)
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osFlushDCacheAll( void );
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for specified range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheRange
|
||||
|
||||
Description: invalidate data cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateDCacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheRange
|
||||
|
||||
Description: clean data cache in specified range
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osStoreDCacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheRange
|
||||
|
||||
Description: clean and invalidate data cache in specified range
|
||||
(write cache data to memory, and invalidate cache)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osFlushDCacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateDCacheRangeOrAll
|
||||
|
||||
Description: invalidate data cache in specified range or all
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateDCacheRangeOrAll( void* startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osStoreDCacheRangeOrAll
|
||||
|
||||
Description: clean data cache in specified range or all
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osStoreDCacheRangeOrAll( void* startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osFlushDCacheRangeOrAll
|
||||
|
||||
Description: clean data cache in specified range or all
|
||||
(write cache data to memory)
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osFlushDCacheRangeOrAll( void* startAddr, u32 nBytes );
|
||||
|
||||
//===========================================================================
|
||||
// DATA CACHE (for specified range)
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osLockdownDCacheRange
|
||||
|
||||
Description: lock specified area to prevent not to release data cache
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osLockdownDCacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownDCacheAll
|
||||
|
||||
Description: unlock all data cache to enable to release
|
||||
|
||||
Arguments: none.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osUnlockdownDCacheAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: dcUnlockdown
|
||||
|
||||
Description: unlock any data cache to enable to release
|
||||
|
||||
Arguments: num - specify number of datablock to unlock.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osUnlockdownDCache( u32 num );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osWaitWriteBufferEmpty
|
||||
|
||||
Description: wait till write buffer becomes to be empty
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osWaitWriteBufferEmpty( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osTouchDCacheRange
|
||||
|
||||
Description: include specified area to data cache in advance
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osTouchDCacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osKeepDataAccessOrder
|
||||
|
||||
Description: keep data access order
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osKeepDataAccessOrder( void );
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// ALIAS OF DATA CACHE function
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osCleanDCacheAll
|
||||
|
||||
Description: alias for osStoreDcacheAll
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline void osCleanDCacheAll( void )
|
||||
{
|
||||
osStoreDCacheAll();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osCleanAndInvalidateDCacheAll
|
||||
|
||||
Description: alias for osFlushDCacheAll
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline void osCleanAndInvalidateDCacheAll( void )
|
||||
{
|
||||
osFlushDCacheAll();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osCleanDCacheRange
|
||||
|
||||
Description: alias for osStoreDCacheRange
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline void osCleanDCacheRange( void *startAddr, u32 nBytes )
|
||||
{
|
||||
osStoreDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osCleanAndInvalidateDCacheRange
|
||||
|
||||
Description: alias for osFlushDCacheRange
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline void osCleanAndInvalidateDCacheRange( void *startAddr, u32 nBytes )
|
||||
{
|
||||
osFlushDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osPreloadDCacheRange
|
||||
|
||||
Description: alias for osTouchDCacheRange
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
static inline void osPreloadDCacheRange( void *startAddr, u32 nBytes )
|
||||
{
|
||||
osTouchDCacheRange( startAddr, nBytes );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDoDataMemoryBarrier
|
||||
|
||||
Description: Do Data Memory Barrier
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
static inline void osDoDataMemoryBarrier( void )
|
||||
{
|
||||
osKeepDataAccessOrder();
|
||||
}
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
//===========================================================================
|
||||
// INSTRUCTION CACHE CONTROL
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osEnableICache
|
||||
|
||||
Description: enable instruction cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous state
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osEnableICache( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDisableICache
|
||||
|
||||
Description: disable instruction cache
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osDisableICache( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osRestoreICache
|
||||
|
||||
Description: set state of instruction cache
|
||||
|
||||
Arguments: instruction cache state to be set
|
||||
|
||||
Returns: previous stats
|
||||
*---------------------------------------------------------------------------*/
|
||||
BOOL osRestoreICache( BOOL enable );
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// INSTRUCTION CACHE
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheAll
|
||||
|
||||
Description: invalidate all instruction cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateICacheAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheRange
|
||||
|
||||
Description: invalidate instruction cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateICacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateICacheRangeOrAll
|
||||
|
||||
Description: invalidate instruction cache in specified range or all
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateICacheRangeOrAll( void* startAddr, u32 nBytes );
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osLockdownICacheRange
|
||||
|
||||
Description: lock specified area to prevent not to release instruction cache
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osLockdownICacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownICache
|
||||
|
||||
Description: unlock any instruction cache to enable to release
|
||||
|
||||
Arguments: num - specify number of datablock to unlock.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osUnlockdownICache( u32 num );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osUnlockdownICacheAll
|
||||
|
||||
Description: unlock all instruction cache to enable to release
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osUnlockdownICacheAll( void );
|
||||
|
||||
#else // SDK_ARM11
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osPrefetchICacheRange
|
||||
|
||||
Description: include specified area to instruction cache in advance
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osPrefetchICacheRange( void *startAddr, u32 nBytes );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateInstPrefetchBuffer
|
||||
|
||||
Description: invalidate instruction prefetch buffer
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateInstPrefetchBuffer( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDoInstMemoryBarrierAll
|
||||
|
||||
Description: do all Instruction Memory Barrier
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osDoInstMemoryBarrierAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osDoInstMemoryBarrierRange
|
||||
|
||||
Description: do Instruction Memory Barrier in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osDoInstMemoryBarrierRange( void* startAddr, u32 nBytes );
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// BRANCH TARGET ADDRESS CACHE
|
||||
//===========================================================================
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateBCacheAll
|
||||
|
||||
Description: invalidate all branch target address cache
|
||||
|
||||
Arguments: None.
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateBCacheAll( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInvalidateBCacheRange
|
||||
|
||||
Description: invalidate branch target address cache in specified range
|
||||
|
||||
Arguments: startAddr start address
|
||||
nBytes size (in byte)
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInvalidateBCacheRange( void* startAddr, u32 nBytes );
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // BROM_OS_CACHE_H_
|
||||
@ -28,8 +28,8 @@ extern "C" {
|
||||
#define HW_CPU_CLOCK_ARM9 (67027964 * 2)
|
||||
#define HW_CPU_CLOCK HW_CPU_CLOCK_ARM9
|
||||
|
||||
#define HW_ICACHE_SIZE 0x2000 // 命令キャッシュ
|
||||
#define HW_DCACHE_SIZE 0x1000 // データキャッシュ
|
||||
#define HW_IC_SIZE 0x2000 // 命令キャッシュ
|
||||
#define HW_DC_SIZE 0x1000 // データキャッシュ
|
||||
#define HW_CACHE_LINE_SIZE 32
|
||||
|
||||
#define HW_SYSTEM_CLOCK 33514000 // 正確には33513982?
|
||||
@ -52,14 +52,14 @@ extern "C" {
|
||||
#define HW_C1_CACHE_PSEUDO_RANDOM 0x00000000 // 擬似ランダム
|
||||
#define HW_C1_EXCEPT_VEC_UPPER 0x00002000 // 例外ベクタ 上位アドレス(こちらに設定して下さい)
|
||||
#define HW_C1_EXCEPT_VEC_LOWER 0x00000000 // 下位アドレス
|
||||
#define HW_C1_ICACHE_ENABLE 0x00001000 // 命令キャッシュ イネーブル
|
||||
#define HW_C1_DCACHE_ENABLE 0x00000004 // データキャッシュ イネーブル
|
||||
#define HW_C1_IC_ENABLE 0x00001000 // 命令キャッシュ イネーブル
|
||||
#define HW_C1_DC_ENABLE 0x00000004 // データキャッシュ イネーブル
|
||||
#define HW_C1_LITTLE_ENDIAN 0x00000000 // リトルエンディアン
|
||||
#define HW_C1_BIG_ENDIAN 0x00000080 // ビッグエンディアン
|
||||
#define HW_C1_PROTECT_UNIT_ENABLE 0x00000001 // プロテクションユニット イネーブル
|
||||
|
||||
#define HW_C1_ICACHE_ENABLE_SHIFT 12
|
||||
#define HW_C1_DCACHE_ENABLE_SHIFT 2
|
||||
#define HW_C1_IC_ENABLE_SFT 12
|
||||
#define HW_C1_DC_ENABLE_SFT 2
|
||||
|
||||
|
||||
// レジスタ2(プロテクションリージョン・キャッシュ設定)
|
||||
@ -109,8 +109,8 @@ extern "C" {
|
||||
#define HW_C6_PR_SIZE_MASK 0x0000003e // プロテクションリージョン サイズ
|
||||
#define HW_C6_PR_BASE_MASK 0xfffff000 // ベースアドレス
|
||||
|
||||
#define HW_C6_PR_SIZE_SHIFT 1
|
||||
#define HW_C6_PR_BASE_SHIFT 12
|
||||
#define HW_C6_PR_SIZE_SFT 1
|
||||
#define HW_C6_PR_BASE_SFT 12
|
||||
|
||||
#define HW_C6_PR_ENABLE 1 // プロテクションリージョン イネーブル
|
||||
#define HW_C6_PR_DISABLE 0 // ディセーブル
|
||||
@ -147,17 +147,17 @@ extern "C" {
|
||||
|
||||
#define HW_C7_ICACHE_INDEX_MASK 0x00000fe0 // 命令キャッシュ インデックス
|
||||
#define HW_C7_DCACHE_INDEX_MASK 0x000003e0 // データキャッシュ インデックス
|
||||
#define HW_C7_CACHE_SET_NO_MASK 0xc0000000 // キャッシュ セットNo
|
||||
#define HW_C7_CACHE_WAY_NO_MASK 0xc0000000 // キャッシュ ウェイNo
|
||||
|
||||
#define HW_C7_CACHE_INDEX_SHIFT 5
|
||||
#define HW_C7_CACHE_SET_NO_SHIFT 30
|
||||
#define HW_C7_CACHE_INDEX_SFT 5
|
||||
#define HW_C7_CACHE_WAY_NO_SFT 30
|
||||
|
||||
|
||||
// レジスタ9.0(キャッシュロックダウン)
|
||||
|
||||
#define HW_C9_LOCKDOWN_SET_NO_MASK 0x00000003 // キャッシュロックダウン セットNo
|
||||
#define HW_C9_LOCKDOWN_WAY_NO_MASK 0x00000003 // キャッシュロックダウン ウェイNo
|
||||
|
||||
#define HW_C9_LOCKDOWN_SET_NO_SHIFT 0
|
||||
#define HW_C9_LOCKDOWN_WAY_NO_SFT 0
|
||||
|
||||
#define HW_C9_LOCKDOWN_LOAD_MODE 0x80000000 // キャッシュロックダウン ロードモード
|
||||
|
||||
@ -167,8 +167,8 @@ extern "C" {
|
||||
#define HW_C9_TCMR_SIZE_MASK 0x0000003e // TCMリージョン サイズ
|
||||
#define HW_C9_TCMR_BASE_MASK 0xfffff000 // ベースアドレス
|
||||
|
||||
#define HW_C9_TCMR_SIZE_SHIFT 1
|
||||
#define HW_C9_TCMR_BASE_SHIFT 12
|
||||
#define HW_C9_TCMR_SIZE_SFT 1
|
||||
#define HW_C9_TCMR_BASE_SFT 12
|
||||
|
||||
#define HW_C9_TCMR_4KB 0x06 // リージョンサイズ 4KByte
|
||||
#define HW_C9_TCMR_8KB 0x08 // 8KByte
|
||||
|
||||
Loading…
Reference in New Issue
Block a user