1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     os_AddressSpaceManager.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: 17610 $
11  *---------------------------------------------------------------------------
12 
13 
14 */
15 
16 #ifndef NN_OS_OS_ADDRESSSPACEMANAGER_H_
17 #define NN_OS_OS_ADDRESSSPACEMANAGER_H_
18 
19 #include <nn/config.h>
20 #if NN_PLATFORM_HAS_MMU
21 
22 #include <nn/types.h>
23 #include <nn/os/os_MemoryBlockBase.h>
24 #include <nn/os/os_CriticalSection.h>
25 
26 // CHECK: Isn't the ifdef for C++ required?
27 //#ifdef __cplusplus
28 
29 namespace nn {
30     namespace os {
31 
32         /* Please see man pages for details
33 
34 
35 
36 */
37         class AddressSpaceManager
38         {
39         private:
40             typedef fnd::IntrusiveLinkedList<MemoryBlockBase>   BlockList;
41             typedef os::CriticalSection                         Lock;
42 
43         private:
44             uptr        m_SpaceBegin;    //
45             uptr        m_SpaceEnd;      //
46             BlockList   m_BlockList;     //
47             Lock        m_Lock;          //
48 
49         public:
50             // CHECK: Recommend initializing m_SpaceBegin and m_SpaceEnd with constructor.
51 
52             /* Please see man pages for details
53 
54 
55 
56 
57 */
58             void        Initialize(uptr begin, size_t size);
59 
60             /* Please see man pages for details
61 
62 
63 
64 
65 
66 
67 */
68             uptr        Allocate(MemoryBlockBase* pBlock, size_t size, size_t skipSize);
69 
70             /* Please see man pages for details
71 
72 
73 
74 */
75             void        Free(MemoryBlockBase* pBlock);
76 
77             /* Please see man pages for details
78 
79 
80 
81 
82 */
83             void        Switch(MemoryBlockBase* pTo, MemoryBlockBase* pFrom);
84 
85             /* Please see man pages for details
86 
87             */
88             void        Dump();
89 
90         private:
91             /* Please see man pages for details
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 */
104             MemoryBlockBase* FindSpace(size_t size, size_t skipSize);
105         };
106 
107 
108     }
109 }
110 
111 // CHECK: Isn't the ifdef for C++ required?
112 //#endif // __cplusplus
113 
114 #include <nn/util/detail/util_CLibImpl.h>
115 
116 /* Please see man pages for details
117 
118 
119 
120 
121 
122 
123 
124 
125 */
126 
127 /* Please see man pages for details
128 
129 
130 
131 
132 */
133 
134 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosAddressSpaceManager, nn::os::AddressSpaceManager, 24, bit32);
135 
136 /* Please see man pages for details
137 
138 */
139 NN_EXTERN_C void nnosAddressSpaceManagerInitialize(nnosAddressSpaceManager* p, uptr begin, size_t size);
140 
141 /* Please see man pages for details
142 
143 */
144 NN_EXTERN_C uptr nnosAddressSpaceManagerAllocate(nnosAddressSpaceManager* p, nnosMemoryBlockBase* pBlock, size_t size, size_t skipSize);
145 
146 /* Please see man pages for details
147 
148 */
149 NN_EXTERN_C void nnosAddressSpaceManagerFree(nnosAddressSpaceManager* p, nnosMemoryBlockBase* pBlock);
150 
151 /* Please see man pages for details
152 
153 */
154 NN_EXTERN_C void nnosAddressSpaceManagerSwitch(nnosAddressSpaceManager* p, nnosMemoryBlockBase* pTo, nnosMemoryBlockBase* pFrom);
155 
156 /*
157 
158 
159 
160 */
161 
162 #endif  // if NN_PLATFORM_HAS_MMU
163 #endif /* NN_OS_OS_ADDRESSSPACEMANAGER_H_ */
164