1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_StackMemoryBlock.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 /* 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 class StackMemoryBlock : 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 */ StackMemoryBlock()67 StackMemoryBlock() {} 68 69 /* Please see man pages for details 70 71 72 73 74 75 76 77 78 */ StackMemoryBlock(size_t size)79 explicit StackMemoryBlock(size_t size) { Initialize(size); } 80 81 /* Please see man pages for details 82 83 84 85 86 87 88 89 */ 90 void Initialize(size_t size); 91 92 /* Please see man pages for details 93 94 95 96 97 */ ~StackMemoryBlock()98 ~StackMemoryBlock() { Finalize(); } 99 100 /* Please see man pages for details 101 102 */ 103 void Finalize(); 104 105 /* Please see man pages for details 106 107 108 109 110 111 */ GetStackBottom()112 uptr GetStackBottom() const { return GetAddress() + GetSize(); } 113 114 /* Please see man pages for details 115 116 117 118 119 120 */ GetStackSize()121 size_t GetStackSize() const { return GetSize(); } 122 }; 123 124 namespace detail 125 { 126 void Switch(StackMemoryBlock* pTo, StackMemoryBlock* pFrom); 127 } 128 129 }} // namespace nn::os 130 131 #endif // __cplusplus 132 133 // C declarations follow 134 135 #include <nn/util/detail/util_CLibImpl.h> 136 137 /* Please see man pages for details 138 139 140 141 142 143 144 145 146 */ 147 148 /* Please see man pages for details 149 150 151 152 153 */ 154 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosStackMemoryBlock, nn::os::StackMemoryBlock, 24, u32); 155 156 NN_EXTERN_C void nnosStackMemoryBlockInitialize(nnosStackMemoryBlock* p); 157 158 /* Please see man pages for details 159 160 */ 161 NN_EXTERN_C void nnosStackMemoryBlockAllocate(nnosStackMemoryBlock* p, size_t size); 162 163 /* 164 165 */ 166 NN_EXTERN_C void nnosStackMemoryBlockFree(nnosStackMemoryBlock* p); 167 168 /* Please see man pages for details 169 170 */ 171 NN_EXTERN_C uptr nnosStackMemoryBlockGetAddress(nnosStackMemoryBlock* p); 172 173 /* Please see man pages for details 174 175 */ 176 NN_EXTERN_C size_t nnosStackMemoryBlockGetSize(nnosStackMemoryBlock* p); 177 178 /* Please see man pages for details 179 180 */ 181 NN_EXTERN_C uptr nnosStackMemoryBlockGetStackBottom(nnosStackMemoryBlock* p); 182 183 /* 184 185 186 187 */ 188 189 #endif // if NN_PLATFORM_HAS_MMU 190 #endif /* NN_OS_OS_STACKMEMORYBLOCK_H_ */ 191