/*---------------------------------------------------------------------------* 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 #include //=========================================================================== // 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<