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