diff --git a/build/libraries/os/ARM9/Makefile b/build/libraries/os/ARM9/Makefile index 4f840f5..a8f7940 100644 --- a/build/libraries/os/ARM9/Makefile +++ b/build/libraries/os/ARM9/Makefile @@ -52,6 +52,7 @@ SRCS = \ os_message.c \ os_mutex.c \ os_cache.c \ + os_cache_tag.c \ os_arena.c \ os_alloc.c \ os_tcm.c \ diff --git a/build/libraries/os/ARM9/os_cache_tag.c b/build/libraries/os/ARM9/os_cache_tag.c new file mode 100644 index 0000000..8c39ed1 --- /dev/null +++ b/build/libraries/os/ARM9/os_cache_tag.c @@ -0,0 +1,268 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS + File: os_cache_tag.c + + Copyright 2007 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. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + + +//=========================================================================== +// DATA CACHE (for specified range) +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: DC_ClearTagAll + + Description: clear tag in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearTagAll( void ) +{ + DC_FillTagAll( 0 ); +} + +/*---------------------------------------------------------------------------* + Name: DC_FillTagAll + + Description: clear tag in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +asm void DC_FillTagAll( u32 data ) +{ + mov r12, #0 +@1: + mov r2, #0 +@2: + orr r3, r2, r12 + mcr p15, 3, r3, c15, c0, 0 // set index + mcr p15, 3, r0, c15, c2, 0 // clear tag + add r2, r2, #HW_CACHE_LINE_SIZE + cmp r2, #HW_DCACHE_SIZE/4 + blt @2 + + add r12, r12, #1< diff --git a/include/twl/os.h b/include/twl/os.h index bebef23..7f341d3 100644 --- a/include/twl/os.h +++ b/include/twl/os.h @@ -23,6 +23,10 @@ #include #include +#ifdef SDK_ARM9 +#include +#endif // SDK_ARM9 + #ifdef SDK_DEBUGGER_KMC #include #endif // SDK_DEBUGGER_KMC diff --git a/include/twl/os/ARM9/cache_tag.h b/include/twl/os/ARM9/cache_tag.h new file mode 100644 index 0000000..31c65e7 --- /dev/null +++ b/include/twl/os/ARM9/cache_tag.h @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS - include + File: cache_tag.h + + Copyright 2007 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. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ + +#ifndef TWL_OS_CACHE_TAG_H_ +#define TWL_OS_CACHE_TAG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +//=========================================================================== +// DATA CACHE (for specified range) +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: DC_ClearTagAll + + Description: clear tag in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_ClearDataAll + + Description: clear data in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearDataAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_FillTagAll + + Description: clear tag in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_FillDataAll + + Description: fill data in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillDataAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_GetTagAndDataAll + + Description: get tag and data in data cache + + Arguments: tag tag address + data data address + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_GetTagAndDataAll( void* tag, void* data ); + +//=========================================================================== +// INSTRUCTION CACHE +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: IC_ClearTagAll + + Description: clear tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_ClearInstructionAll + + Description: clear instruction in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearInstructionAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_FillTagAll + + Description: fill tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_FillInstructionAll + + Description: fill instruction in instruction cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillInstructionAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_GetTagAndInstructionAll + + Description: get tag and instruction in instruction cache + + Arguments: tag tag address + inst instruction address + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_GetTagAndInstructionAll( void* tag, void* inst ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_OS_CACHE_TAG_H_ */ +#endif