/*---------------------------------------------------------------------------* Project: Horizon File: os_MemoryBlockBase.h Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 24156 $ *---------------------------------------------------------------------------*/ /* @file @brief OS からメモリを確保するための API の宣言 :include nn/os.h */ #ifndef NN_OS_OS_MEMORYBLOCKBASE_H_ #define NN_OS_OS_MEMORYBLOCKBASE_H_ #include #if NN_PLATFORM_HAS_MMU #include #include #include #include #include #ifdef __cplusplus #include #include #include // 前方宣言 union nnosMemoryBlockBase; namespace nn{ namespace os{ /*! @brief 連続するメモリ領域を扱うクラスの基底クラスです。 */ class MemoryBlockBase : public nn::fnd::IntrusiveLinkedList::Item { friend class AddressSpaceManager; private: uptr m_Addr; size_t m_Size; bool m_ReadOnly; NN_PADDING3; protected: MemoryBlockBase() : m_Addr(0), m_Size(0), m_ReadOnly(false) {} ~MemoryBlockBase() {} void SetAddressAndSize(uptr addr, size_t size) { this->m_Addr = addr; this->m_Size = size; } void SetReadOnly(bool readOnly) { this->m_ReadOnly = readOnly; } public: /*! @brief メモリ領域の先頭アドレスを取得します。 @return メモリ領域の先頭アドレスを返します。 */ uptr GetAddress() const { return m_Addr; } /*! @brief メモリ領域のサイズを取得します。 @return メモリ領域のサイズを返します。 */ size_t GetSize() const { return m_Size; } /*! @brief メモリ領域が読み込み専用かどうかを取得します。 @return メモリ領域が読み込み専用であれば true を返し、そうでなければ false を返します。 */ bool IsReadOnly() const { return m_ReadOnly; } }; namespace detail { inline nnosMemoryBlockBase* ConvertToC(MemoryBlockBase* p) { return reinterpret_cast(p); } } }} // namespace nn::os #endif // __cplusplus #include NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnosMemoryBlockBase, nn::os::MemoryBlockBase, 20, bit32); #endif // if NN_PLATFORM_HAS_MMU #endif /* NN_OS_OS_MEMORYBLOCKBASE_H_ */