/*---------------------------------------------------------------------------* 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 #include #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 CONTROL //=========================================================================== /*---------------------------------------------------------------------------* Name: osEnableBCache Description: enable branch target address cache Arguments: None Returns: previous state *---------------------------------------------------------------------------*/ u32 osEnableBCache( void ); /*---------------------------------------------------------------------------* Name: osDisableBCache Description: disable branch target address cache Arguments: None Returns: previous stats *---------------------------------------------------------------------------*/ u32 osDisableBCache( void ); /*---------------------------------------------------------------------------* Name: osRestoreBCache Description: set state of branch target address cache Arguments: branch target address cache state to be set Returns: previous state *---------------------------------------------------------------------------*/ u32 osRestoreBCache( u32 state ); //=========================================================================== // 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_