1 /*---------------------------------------------------------------------------* 2 Project: OS - memory protection API 3 File: OSMemory.h 4 5 Copyright 2001-2006 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 $Log: OSMemory.h,v $ 14 Revision 1.5 2008/01/16 07:42:32 hirose 15 Added OSDisableCodeExecOnMEM1* functions. 16 Added OSEnableCodeExecOnMEM2* functions. 17 18 Revision 1.4 2006/02/06 10:21:30 hirose 19 Changed definition of OSGetPhysicalMemSize/OSGetConsoleSimulatedMemSize 20 as aliases to Mem1 size functions. 21 22 Revision 1.3 2006/02/04 11:56:47 hashida 23 (none) 24 25 Revision 1.2 2006/01/28 09:34:06 hirose 26 Moved memory size APIs from os.h. Added MEM2 related functions. 27 28 Revision 1.1.1.1 2005/12/29 06:53:28 hiratsu 29 Initial import. 30 31 Revision 1.1.1.1 2005/05/12 02:41:07 yasuh-to 32 Ported from dolphin sheath tree. 33 34 35 1 2001/08/15 17:56 Shiki 36 Initial check-in. 37 $NoKeywords: $ 38 *---------------------------------------------------------------------------*/ 39 40 #ifndef __OSMEMORY_H__ 41 #define __OSMEMORY_H__ 42 43 #include <revolution/types.h> 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /*---------------------------------------------------------------------------* 50 Memory size APIs 51 *---------------------------------------------------------------------------*/ 52 u32 OSGetPhysicalMem1Size(void); // 24Mbyte typical 53 u32 OSGetPhysicalMem2Size(void); // 64Mbyte or 128Mbyte 54 u32 OSGetConsoleSimulatedMem1Size(void); // 24Mbyte typical 55 u32 OSGetConsoleSimulatedMem2Size(void); // 64Mbyte or 128Mbyte 56 57 // Conventional definitions 58 #define OSGetPhysicalMemSize OSGetPhysicalMem1Size 59 #define OSGetConsoleSimulatedMemSize OSGetConsoleSimulatedMem1Size 60 61 /*---------------------------------------------------------------------------* 62 Memory protection APIs 63 *---------------------------------------------------------------------------*/ 64 #define OS_PROTECT_CHAN0 0 65 #define OS_PROTECT_CHAN1 1 66 #define OS_PROTECT_CHAN2 2 67 #define OS_PROTECT_CHAN3 3 68 69 // Capability bits 70 #define OS_PROTECT_CONTROL_NONE 0x00 71 #define OS_PROTECT_CONTROL_READ 0x01 // OK to read [addr, addr + nBytes) 72 #define OS_PROTECT_CONTROL_WRITE 0x02 // OK to write [addr, addr + nBytes) 73 #define OS_PROTECT_CONTROL_RDWR (OS_PROTECT_CONTROL_READ | OS_PROTECT_CONTROL_WRITE) 74 75 // dsisr bits for memory protection error handler, which tells 76 // from which region the error was reported 77 #define OS_PROTECT0_BIT 0x00000001 // by OS_PROTECT_CHAN0 range 78 #define OS_PROTECT1_BIT 0x00000002 // by OS_PROTECT_CHAN1 range 79 #define OS_PROTECT2_BIT 0x00000004 // by OS_PROTECT_CHAN2 range 80 #define OS_PROTECT3_BIT 0x00000008 // by OS_PROTECT_CHAN3 range 81 #define OS_PROTECT_ADDRERR_BIT 0x00000010 // by [24M or 48M, 64M) 82 83 void OSProtectRange( u32 chan, void* addr, u32 nBytes, u32 control ); 84 85 void OSDisableCodeExecOnMEM1Hi8MB ( void ); 86 void OSDisableCodeExecOnMEM1Hi16MB ( void ); 87 void OSEnableCodeExecOnMEM2Lo8MB ( void ); 88 void OSEnableCodeExecOnMEM2Lo16MB ( void ); 89 90 /*---------------------------------------------------------------------------*/ 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif // __OSMEMORY_H__ 97