1 /*---------------------------------------------------------------------------*
2   Project:  Cafe
3   File:     OSMemory.h
4 
5   Copyright 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_MEMORY_H__
16 #define __OS_MEMORY_H__
17 
18 #include <types.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /*---------------------------------------------------------------------------*/
25 
26 typedef enum _osMemType
27 {
28     OSMem_MEM1=1,
29     OSMem_MEM2=2
30 } OSMemType;
31 
32 int     OSGetMemBound(OSMemType memType, u32 *apRetStart, u32 *apRetSizeBytes);
33 int     OSSetMemBound(OSMemType memType, u32 aStart, u32 aSizeBytes);
34 
35 void *  OSAllocFromSystem(u32 aSize, int aAlign);
36 void    OSFreeToSystem(void *aPtr);
37 
38 /*---------------------------------------------------------------------------*/
39 
40 void *  OSBlockMove(void* dst, const void* src, size_t size, BOOL flush);
41 void *  OSBlockSet(void* dst, u8 val, size_t size);
42 
43 
44 /*---------------------------------------------------------------------------*/
45 
46 typedef enum _osShared
47 {
48     SHARED_FONT_CAFECN,
49     SHARED_FONT_CAFEKR,
50     SHARED_FONT_CAFESTD,
51     SHARED_FONT_CAFETW
52 } OSShared;
53 
54 BOOL OSGetSharedData(OSShared aShared, u32 aFlags, void **appRetArea, u32 *apRetSizeBytes);
55 
56 BOOL OSIsAddressValid(void *addr);
57 
58 #define OVERLAY_ARENA_ERROR_INVALID               0xFFFFFFFF
59 #define OVERLAY_ARENA_ERROR_IN_SHUTDOWN           0xFFFFFFFD
60 #define OVERLAY_ARENA_ERROR_TIMEOUT               0xFFFFFFFC
61 #define OVERLAY_ARENA_ERROR_ALREADY_ENABLED       0xFFFFFFFB
62 #define OVERLAY_ARENA_ERROR_NOT_ENABLED           0xFFFFFFFA
63 #define OVERLAY_ARENA_ERROR_UNKNOWN               0xFFFFFFF9
64 #define OVERLAY_ARENA_ERROR_NOT_SET_IN_PLAT_INFO  0xFFFFFFF8
65 
66 BOOL OSIsEnabledOverlayArenaDev(void);
67 void OSEnableOverlayArenaDev(BOOL allowAV, u32 *addr, u32 *size);
68 BOOL OSEnableOverlayArenaWithTimeoutDev(BOOL allowAV, u32 timeout, u32 *error, u32 *addr, u32 *size);
69 void OSDisableOverlayArenaDev(void);
70 BOOL OSDisableOverlayArenaWithTimeoutDev(u32 timeout, u32 *error);
71 
72 /*---------------------------------------------------------------------------*/
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif // __OS_MEMORY_H__
79 
80 
81 
82 
83 
84