src/Emu/Utility/System/Memory/MemorySystem.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef __EMULATORUTILITY_MEMORY_SYSTEM_H__
00033 #define __EMULATORUTILITY_MEMORY_SYSTEM_H__
00034 
00035 #include "Emu/Utility/System/Memory/HeapAllocator.h"
00036 #include "Emu/Utility/System/Memory/VirtualMemory.h"
00037 
00038 namespace Onikiri {
00039     namespace EmulatorUtility {
00040 
00041 
00042 
00043         class MemorySystem
00044         {
00045             static const int RESERVED_PAGES = 256; // Sa\y[W
00046             static const int RESERVED_PAGE_NULL = 0;
00047             static const int RESERVED_PAGE_ZERO_FILLED = 1;
00048         public:
00049             MemorySystem( int pid, bool bigEndian, SystemIF* simSystem );
00050             ~MemorySystem();
00051 
00052             // 
00053             // VXey[WTCY
00054             u64 GetPageSize();
00055 
00056             // AhX0AhX\D
00057             u64 GetReservedAddressRange(){ return GetPageSize() * RESERVED_PAGES - 1; };
00058 
00059             // mmapgq[vC[addr, addr+size) 
00060             void AddHeapBlock(u64 addr, u64 size);
00061 
00062             // brkl ([hC[W) 
00063             void SetInitialBrk(u64 initialBrk);
00064             u64 Brk(u64 addr);
00065             u64 MMap(u64 addr, u64 length);
00066             u64 MRemap(u64 old_addr, u64 old_size, u64 new_size, bool mayMove = false);
00067             int MUnmap(u64 addr, u64 length);
00068 
00069             // rbOGfBA
00070             bool IsBigEndian() const 
00071             {
00072                 return m_bigEndian;
00073             }
00074 
00075             u64 GetPageSize() const
00076             {
00077                 return m_virtualMemory.GetPageSize();
00078             }
00079 
00080             // [addr, addr+size) y[WD
00081             void AssignPhysicalMemory(u64 addr, u64 size, VIRTUAL_MEMORY_ATTR_TYPE attr )
00082             {
00083                 m_virtualMemory.AssignPhysicalMemory( addr, size, attr );
00084             }
00085 
00086             // 
00087             void ReadMemory( MemAccess* access ) 
00088             {
00089                 m_virtualMemory.ReadMemory( access );
00090             }
00091 
00092             void WriteMemory( MemAccess* access )
00093             {
00094                 m_virtualMemory.WriteMemory( access );
00095             }
00096 
00097 
00098             // Awp
00099             // targetAddrsizeoCgvaluel
00100             void TargetMemset(u64 targetAddr, int value, u64 size )
00101             {
00102                 m_virtualMemory.TargetMemset( targetAddr, value, size );
00103             }
00104             // target AhX src Chost AhX dst  size oCgRs[
00105             void MemCopyToHost(void* dst, u64 src, u64 size)
00106             {
00107                 m_virtualMemory.MemCopyToHost( dst, src, size );
00108             }
00109             // host AhX src Ctarget AhX dst  size oCgRs[
00110             void MemCopyToTarget(u64 dst, const void* src, u64 size)
00111             {
00112                 m_virtualMemory.MemCopyToTarget( dst, src, size );
00113             }
00114 
00115         private:
00116 
00117             // Cehck a value is aligned on a page boundary.
00118             void CheckValueOnPageBoundary( u64 addr, const char* signature );
00119 
00120             VirtualMemory m_virtualMemory;
00121             HeapAllocator m_heapAlloc;
00122 
00123             // タst@CI[ (currentBrk) Brk g
00124             u64 m_currentBrk;
00125 
00126             // mCV~[^R[obNC^[tF[X
00127             SystemIF* m_simSystem;
00128 
00129             // PID
00130             int m_pid;
00131 
00132             // ^[QbgrbOGfBA
00133             bool m_bigEndian;
00134         };
00135 
00136     } // namespace EmulatorUtility
00137 } // namespace Onikiri
00138 
00139 #endif

Onikiri2に対してTue Jun 18 14:34:20 2013に生成されました。  doxygen 1.4.7