1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_MemoryBlockBase.h 4 5 Copyright (C)2009 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: 24156 $ 14 *---------------------------------------------------------------------------*/ 15 16 /* @file 17 @brief OS からメモリを確保するための API の宣言 18 19 :include nn/os.h 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 // 前方宣言 41 union nnosMemoryBlockBase; 42 43 namespace nn{ namespace os{ 44 45 46 /*! 47 @brief 連続するメモリ領域を扱うクラスの基底クラスです。 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 /*! 74 @brief メモリ領域の先頭アドレスを取得します。 75 76 @return メモリ領域の先頭アドレスを返します。 77 */ GetAddress()78 uptr GetAddress() const { return m_Addr; } 79 80 /*! 81 @brief メモリ領域のサイズを取得します。 82 83 @return メモリ領域のサイズを返します。 84 */ GetSize()85 size_t GetSize() const { return m_Size; } 86 87 /*! 88 @brief メモリ領域が読み込み専用かどうかを取得します。 89 90 @return メモリ領域が読み込み専用であれば true を返し、そうでなければ false を返します。 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