1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_StackMemory.h 4 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 $Rev: 36083 $ 11 *--------------------------------------------------------------------------- 12 13 14 */ 15 16 #ifndef NN_OS_OS_STACKMEMORY_H_ 17 #define NN_OS_OS_STACKMEMORY_H_ 18 19 #include <nn/config.h> 20 #if NN_PLATFORM_HAS_MMU 21 22 #include <nn/types.h> 23 #include <nn/Handle.h> 24 #include <nn/svc.h> 25 #include <nn/os/CTR/os_MemoryConfig.h> 26 #include <nn/os/os_MemoryBlockBase.h> 27 28 #ifdef __cplusplus 29 30 #include <nn/util/util_NonCopyable.h> 31 #include <nn/os/os_SvcTypes.autogen.h> 32 #include <nn/util/util_Result.h> 33 34 namespace nn{ namespace os{ 35 36 namespace detail 37 { 38 void InitializeStackMemory(); 39 } 40 41 42 /* Please see man pages for details 43 44 45 46 47 48 49 50 51 52 53 */ 54 class StackMemory : public MemoryBlockBase 55 { 56 private: 57 uptr m_MemoryAddress; 58 59 public: 60 /* Please see man pages for details 61 62 63 64 65 66 */ StackMemory()67 StackMemory() {} 68 69 /* Please see man pages for details 70 71 72 73 74 75 76 77 78 79 80 */ StackMemory(void * pMem,size_t size)81 explicit StackMemory(void* pMem, size_t size) { Initialize(pMem, size); } 82 83 84 /* Please see man pages for details 85 86 87 88 89 90 91 92 93 94 95 96 97 98 */ 99 void Initialize(void* pMem, size_t size); 100 101 /* Please see man pages for details 102 103 104 105 106 */ ~StackMemory()107 ~StackMemory() { Finalize(); } 108 109 /* Please see man pages for details 110 111 112 113 114 */ 115 void* Finalize(); 116 117 /* Please see man pages for details 118 119 120 121 122 123 */ GetStackBottom()124 uptr GetStackBottom() const { return GetAddress() + GetSize(); } 125 126 /* Please see man pages for details 127 128 129 130 131 132 */ GetStackSize()133 size_t GetStackSize() const { return GetSize(); } 134 135 void MoveFrom(StackMemory* pFrom); 136 }; 137 138 139 140 }} // namespace nn::os 141 142 #endif // __cplusplus 143 144 // C declarations follow 145 146 #include <nn/util/detail/util_CLibImpl.h> 147 148 /* Please see man pages for details 149 150 151 152 153 154 155 156 157 */ 158 159 /* Please see man pages for details 160 161 162 163 164 */ 165 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosStackMemory, nn::os::StackMemory, 24, u32); 166 167 168 /* Please see man pages for details 169 170 */ 171 NN_EXTERN_C void nnosStackMemoryProtect(nnosStackMemory* p, void* pMem, size_t size); 172 173 /* 174 175 */ 176 NN_EXTERN_C void nnosStackMemoryUnprotect(nnosStackMemory* p); 177 178 /* Please see man pages for details 179 180 */ 181 NN_EXTERN_C uptr nnosStackMemoryGetAddress(nnosStackMemory* p); 182 183 /* Please see man pages for details 184 185 */ 186 NN_EXTERN_C size_t nnosStackMemoryGetSize(nnosStackMemory* p); 187 188 /* Please see man pages for details 189 190 */ 191 NN_EXTERN_C uptr nnosStackMemoryGetStackBottom(nnosStackMemory* p); 192 193 /* 194 195 196 197 */ 198 199 #endif // if NN_PLATFORM_HAS_MMU 200 #endif /* NN_OS_OS_STACKMEMORY_H_ */ 201