1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_StackMemoryBlock.h 4 5 Copyright (C)2009 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: 38846 $ 14 *---------------------------------------------------------------------------*/ 15 16 /* Please see man pages for details 17 18 19 20 */ 21 22 #ifndef NN_OS_OS_STACKMEMORYBLOCK_H_ 23 #define NN_OS_OS_STACKMEMORYBLOCK_H_ 24 25 #include <nn/config.h> 26 #if NN_PLATFORM_HAS_MMU 27 28 #include <nn/types.h> 29 #include <nn/Handle.h> 30 #include <nn/svc.h> 31 #include <nn/os/CTR/os_MemoryConfig.h> 32 #include <nn/os/os_MemoryBlockBase.h> 33 34 #ifdef __cplusplus 35 36 #include <nn/util/util_NonCopyable.h> 37 #include <nn/os/os_SvcTypes.autogen.h> 38 #include <nn/util/util_Result.h> 39 40 namespace nn{ namespace os{ 41 42 namespace detail 43 { 44 void InitializeStackMemoryBlock(); 45 } 46 47 48 /* Please see man pages for details 49 50 51 52 53 54 55 56 */ 57 class StackMemoryBlock : public MemoryBlockBase 58 { 59 private: 60 uptr m_MemoryAddress; 61 62 public: 63 /* Please see man pages for details 64 65 66 67 68 69 */ StackMemoryBlock()70 StackMemoryBlock() {} 71 72 /* Please see man pages for details 73 74 75 76 77 78 79 80 81 */ StackMemoryBlock(size_t size)82 explicit StackMemoryBlock(size_t size) { Initialize(size); } 83 84 /* Please see man pages for details 85 86 87 88 89 90 91 92 */ 93 void Initialize(size_t size); 94 95 /* Please see man pages for details 96 97 98 99 100 */ ~StackMemoryBlock()101 ~StackMemoryBlock() { Finalize(); } 102 103 /* Please see man pages for details 104 105 */ 106 void Finalize(); 107 108 /* Please see man pages for details 109 110 111 112 113 114 */ GetStackBottom()115 uptr GetStackBottom() const { return GetAddress() + GetSize(); } 116 117 /* Please see man pages for details 118 119 120 121 122 123 */ GetStackSize()124 size_t GetStackSize() const { return GetSize(); } 125 }; 126 127 namespace detail 128 { 129 void Switch(StackMemoryBlock* pTo, StackMemoryBlock* pFrom); 130 } 131 132 }} // namespace nn::os 133 134 #endif // __cplusplus 135 136 // Below is the C declaration 137 138 #include <nn/util/detail/util_CLibImpl.h> 139 140 /* Please see man pages for details 141 142 143 144 145 146 147 148 149 */ 150 151 /* Please see man pages for details 152 153 154 155 156 */ 157 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosStackMemoryBlock, nn::os::StackMemoryBlock, 24, u32); 158 159 NN_EXTERN_C void nnosStackMemoryBlockInitialize(nnosStackMemoryBlock* p); 160 161 /* Please see man pages for details 162 163 */ 164 NN_EXTERN_C void nnosStackMemoryBlockAllocate(nnosStackMemoryBlock* p, size_t size); 165 166 /* 167 168 */ 169 NN_EXTERN_C void nnosStackMemoryBlockFree(nnosStackMemoryBlock* p); 170 171 /* Please see man pages for details 172 173 */ 174 NN_EXTERN_C uptr nnosStackMemoryBlockGetAddress(nnosStackMemoryBlock* p); 175 176 /* Please see man pages for details 177 178 */ 179 NN_EXTERN_C size_t nnosStackMemoryBlockGetSize(nnosStackMemoryBlock* p); 180 181 /* Please see man pages for details 182 183 */ 184 NN_EXTERN_C uptr nnosStackMemoryBlockGetStackBottom(nnosStackMemoryBlock* p); 185 186 /* 187 188 189 190 */ 191 192 #endif // if NN_PLATFORM_HAS_MMU 193 #endif /* NN_OS_OS_STACKMEMORYBLOCK_H_ */ 194