1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - MI 3 File: mi_wram.c 4 5 Copyright 2003-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-09-18#$ 14 $Rev: 8573 $ 15 $Author: okubata_ryoma $ 16 17 *---------------------------------------------------------------------------*/ 18 19 #include <nitro/mi/wram.h> 20 #include <nitro/misc.h> 21 22 23 // assert definition 24 #define MIi_WRAM_ASSERT( x ) \ 25 SDK_ASSERT( (x) == MI_WRAM_ARM9_ALL || \ 26 (x) == MI_WRAM_1616_1 || \ 27 (x) == MI_WRAM_1616_2 || \ 28 (x) == MI_WRAM_ARM7_ALL ) 29 30 31 #ifdef SDK_ARM9 32 /*---------------------------------------------------------------------------* 33 Name: MI_SetWramBank 34 35 Description: set common-Wram bank status 36 37 Arguments: cnt status of common-Wram. 38 MI_WRAM_ARM9_ALL : allocate all blocks for ARM9 39 MI_WRAM_1616_1 : allocate block1 for ARM9, block for ARM7 40 MI_WRAM_1616_2 : allocate block0 for ARM9, block for ARM7 41 MI_WRAM_ARM7_ALL : allocate all blocks for ARM7 42 43 Returns: None. 44 45 *Notice: only ARM9 can set common-Wram status. 46 ARM7 can read only. 47 *---------------------------------------------------------------------------*/ 48 #ifdef SDK_CW_WARNOFF_SAFESTRB 49 #include <nitro/code32.h> 50 #endif MI_SetWramBank(MIWram cnt)51void MI_SetWramBank(MIWram cnt) 52 { 53 MIi_WRAM_ASSERT(cnt); 54 reg_GX_VRAMCNT_WRAM = (u8)cnt; // safe byte access 55 } 56 57 #ifdef SDK_CW_WARNOFF_SAFESTRB 58 #include <nitro/codereset.h> 59 #endif 60 61 #endif // SDK_ARM9 62 63 64 /*---------------------------------------------------------------------------* 65 Name: MI_GetWramBank 66 67 Description: get common-Wram bank status 68 69 Arguments: None. 70 71 Returns: status of common-Wram. 72 MI_WRAM_ARM9_ALL : allocate all blocks for ARM9 73 MI_WRAM_1616_1 : allocate block1 for ARM9, block for ARM7 74 MI_WRAM_1616_2 : allocate block0 for ARM9, block for ARM7 75 MI_WRAM_ARM7_ALL : allocate all blocks for ARM7 76 *---------------------------------------------------------------------------*/ MI_GetWramBank(void)77MIWram MI_GetWramBank(void) 78 { 79 // (register names are different between ARM9 and ARM7) 80 #ifdef SDK_ARM9 81 return (MIWram)(reg_GX_VRAMCNT_WRAM & MI_WRAM_ARM9_ALL); // safe byte access 82 #else 83 return (MIWram)(reg_GX_WVRAMSTAT & MI_WRAM_ARM9_ALL); 84 #endif 85 } 86