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