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