1 /*---------------------------------------------------------------------------*
2   Project:  Cafe
3   File:     OSMemmap.h
4 
5   Copyright (C) 2011 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  *---------------------------------------------------------------------------*/
14 
15 #ifndef __OS_MEMMAP_H__
16 #define __OS_MEMMAP_H__
17 
18 #include <types.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define	OS_MAP_INVALID	 0
25 #define	OS_MAP_RO	 1
26 #define	OS_MAP_RW	 2
27 #define	OS_MAP_FREE      3
28 #define	OS_MAP_ALLOCATED 4
29 
30 #define	OS_CODEGEN_DEFAULT 0
31 #define	OS_CODEGEN_MEMCPY  0x40000000u
32 #define	OS_CODEGEN_SECURE  0x80000000u
33 
34 typedef u32	va_t;
35 typedef u32	pa_t;
36 
37 #define OSGetPageSize()		(128 * 1024)
38 
39 va_t	OSAllocVirtAddr(va_t va, size_t size, size_t align);
40 BOOL	OSFreeVirtAddr(va_t va, size_t size);
41 int	OSQueryVirtAddr(va_t va);
42 void	OSGetMapVirtAddrRange(va_t *va, size_t *size);
43 void	OSGetDataPhysAddrRange(pa_t *datapa, size_t *datasize);
44 void	OSGetAvailPhysAddrRange(pa_t *availpa, size_t *availsize);
45 void	OSGetCodegenVirtAddrRange(va_t *codegenva, size_t *codegensize);
46 u32	OSGetCodegenCore(void);
47 u32	OSGetCodegenMode(void);
48 BOOL	OSMapMemory(va_t va, pa_t pa, size_t size, int mode);
49 BOOL	OSUnmapMemory(va_t va, size_t size);
50 void	OSSwitchSecCodeGenMode(BOOL execute);
51 BOOL	OSGetSecCodeGenMode(void);
52 BOOL	OSCodegenCopy(va_t codegenva, va_t va, size_t size);
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif // __OS_MEMMAP_H__
59 
60