1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_MemoryBlockBase.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 /* 17 18 19 20 */ 21 22 #ifndef NN_OS_OS_MEMORYBLOCKBASE_H_ 23 #define NN_OS_OS_MEMORYBLOCKBASE_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/fnd/fnd_LinkedList.h> 32 #include <nn/os/CTR/os_MemoryConfig.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 // Forward declaration 41 union nnosMemoryBlockBase; 42 43 namespace nn{ namespace os{ 44 45 46 /* Please see man pages for details 47 48 49 50 */ 51 class MemoryBlockBase 52 : public nn::fnd::IntrusiveLinkedList<MemoryBlockBase>::Item 53 { 54 friend class AddressSpaceManager; 55 56 private: 57 uptr m_Addr; 58 size_t m_Size; 59 bool m_ReadOnly; 60 NN_PADDING3; 61 62 protected: 63 MemoryBlockBase()64 MemoryBlockBase() : m_Addr(0), m_Size(0), m_ReadOnly(false) {} 65 ~MemoryBlockBase()66 ~MemoryBlockBase() {} SetAddressAndSize(uptr addr,size_t size)67 void SetAddressAndSize(uptr addr, size_t size) 68 { 69 this->m_Addr = addr; 70 this->m_Size = size; 71 } SetReadOnly(bool readOnly)72 void SetReadOnly(bool readOnly) { this->m_ReadOnly = readOnly; } 73 74 public: 75 /* Please see man pages for details 76 77 78 79 */ GetAddress()80 uptr GetAddress() const { return m_Addr; } 81 82 /* Please see man pages for details 83 84 85 86 */ GetSize()87 size_t GetSize() const { return m_Size; } 88 89 /* Please see man pages for details 90 91 92 93 */ IsReadOnly()94 bool IsReadOnly() const { return m_ReadOnly; } 95 96 }; 97 98 99 namespace detail 100 { 101 ConvertToC(MemoryBlockBase * p)102 inline nnosMemoryBlockBase* ConvertToC(MemoryBlockBase* p) 103 { 104 return reinterpret_cast<nnosMemoryBlockBase*>(p); 105 } 106 } 107 108 109 }} // namespace nn::os 110 111 #endif // __cplusplus 112 113 #include <nn/util/detail/util_CLibImpl.h> 114 115 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosMemoryBlockBase, nn::os::MemoryBlockBase, 20, bit32); 116 117 118 #endif // if NN_PLATFORM_HAS_MMU 119 #endif /* NN_OS_OS_MEMORYBLOCKBASE_H_ */ 120