1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: MemoryManager.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. 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 $Rev: 46365 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef MEMORY_MANAGER_H_ 17 #define MEMORY_MANAGER_H_ 18 19 #include <nn.h> 20 21 namespace demo 22 { 23 namespace memory_manager 24 { 25 26 namespace detail 27 { 28 /* Please see man pages for details 29 30 31 32 */ 33 34 class MemoryManager : private nn::util::NonCopyable<MemoryManager> 35 { 36 public: 37 /* Please see man pages for details 38 39 */ 40 MemoryManager(void); 41 42 /* Please see man pages for details 43 44 */ 45 virtual ~MemoryManager(); 46 47 /* Please see man pages for details 48 49 50 51 52 53 54 55 56 57 */ 58 void Initialize(const uptr fcramAddress, const size_t memorySize); 59 60 /* Please see man pages for details 61 62 */ 63 void Finalize(void); 64 65 /* Please see man pages for details 66 67 68 69 70 71 72 73 74 */ 75 void* Allocate(GLenum area, GLenum aim, GLuint id, GLsizei size); 76 77 /* Please see man pages for details 78 79 80 81 82 83 84 85 86 */ 87 void Deallocate(GLenum area, GLenum aim, GLuint id, void* addr); 88 89 90 /* Please see man pages for details 91 92 */ 93 void PrintFreeMemorySize(void); 94 95 private: 96 bool m_Initialized; 97 u8 m_Pad[3]; 98 uptr m_pStartAddrFcram; 99 uptr m_CurrentAddrVramA; 100 uptr m_CurrentAddrVramB; 101 nn::fnd::ExpHeap m_HeapOnFcram; 102 size_t m_AllocatedBlockSize; 103 104 public: 105 bool m_DebugPrint; 106 NN_PADDING3; 107 }; 108 } // namespace detail 109 110 /* Please see man pages for details 111 112 113 114 115 */ 116 void InitializeMemoryManager(const uptr fcramAddress, const size_t memorySize); 117 118 /* Please see man pages for details 119 120 */ 121 void FinalizeMemoryManager(void); 122 123 /* Please see man pages for details 124 125 */ 126 void PrintMemoryManagerInfo(void); 127 128 /* Please see man pages for details 129 130 131 132 133 134 135 136 137 */ 138 void* GetAllocator(GLenum area, GLenum aim, GLuint id, GLsizei size); 139 140 /* Please see man pages for details 141 142 143 144 145 146 147 */ 148 void GetDeallocator(GLenum area, GLenum aim, GLuint id, void* addr); 149 150 /* Please see man pages for details 151 152 153 154 155 156 157 158 159 160 161 */ 162 163 void* Alloc(size_t size); 164 165 void* Alloc(GLenum aim, const size_t size); 166 void* Alloc(GLenum area, GLenum aim, const size_t size); 167 168 /* Please see man pages for details 169 170 171 172 173 174 175 176 */ 177 void Free(void* ptr); 178 179 } 180 } 181 182 #endif 183