src/Sim/System/SystemManager.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 SIM_SYSTEM_SYSTEM_MANAGER_H
00033 #define SIM_SYSTEM_SYSTEM_MANAGER_H
00034 
00035 #include "Sim/System/SystemBase.h"
00036 #include "Sim/System/ExtraOpDecoder.h"
00037 
00038 namespace Onikiri
00039 {
00040     class SystemManager : 
00041         public SystemManagerIF, SystemIF,
00042         public ParamExchange
00043     {
00044     public:
00045         // Hooks for the notify of process information
00046         enum PROCESS_NOTIFY_TYPE
00047         {
00048             PNT_TERMINATION = 0,        // process termination
00049             PNT_READ_FILE_TO_MEMORY,    // read data from a file to memory
00050             PNT_WRITE_FILE_FROM_MEMORY, // write data from memory to a file
00051             PNT_ALLOCATE_MEMORY,        // allocate memory
00052             PNT_FREE_MEMORY,            // free memory
00053         };
00054         
00055         struct ProcessNotifyParam
00056         {
00057             PROCESS_NOTIFY_TYPE type;
00058             int  pid;
00059             Addr addr;
00060             u64  size;
00061             u64  totalSize;
00062         };
00063         static HookPoint<SystemManager, ProcessNotifyParam> s_processNotifyHook;
00064 
00065         SystemManager();
00066         virtual ~SystemManager();
00067 
00068         virtual void Main();
00069 
00070         // SystemIF
00071         virtual void NotifyProcessTermination(int pid);
00072         virtual void NotifySyscallReadFileToMemory(const Addr& addr, u64 size);
00073         virtual void NotifySyscallWriteFileFromMemory(const Addr& addr, u64 size);
00074         virtual void NotifyMemoryAllocation(const Addr& addr, u64 size, bool allocate);
00075         BEGIN_PARAM_MAP( "/Session/" )
00076             BEGIN_PARAM_PATH("Emulator/")
00077                 PARAM_ENTRY("@TargetArchitecture",      m_context.targetArchitecture)
00078             END_PARAM_PATH()
00079             BEGIN_PARAM_PATH("Simulator/")
00080                 PARAM_ENTRY("System/@Mode",             m_context.mode)
00081                 PARAM_ENTRY("System/@SimulationCycles", m_simulationCycles)
00082                 PARAM_ENTRY("System/@SimulationInsns",  m_simulationInsns)
00083                 PARAM_ENTRY("System/@SkipInsns",        m_skipInsns)
00084                 PARAM_ENTRY("System/Inorder/@EnableBPred",      m_context.inorderParam.enableBPred  )
00085                 PARAM_ENTRY("System/Inorder/@EnableHMPred", m_context.inorderParam.enableHMPred )
00086                 PARAM_ENTRY("System/Inorder/@EnableCache",      m_context.inorderParam.enableCache  )
00087                 PARAM_ENTRY("System/Debug/@DebugPort",  m_context.debugParam.debugPort  )
00088             END_PARAM_PATH()
00089             BEGIN_PARAM_PATH( "Result/" )
00090                 PARAM_ENTRY("System/@ExecutedCycles",   m_executedCycles)
00091                 PARAM_ENTRY("System/@ExecutedInsns",    m_executedInsns)
00092                 PARAM_ENTRY("System/@SkippedInsns",     m_skippedInsns)
00093                 PARAM_ENTRY("System/@IPC",              m_ipc)
00094                 PARAM_ENTRY("System/@ProcessMemoryUsage",   m_processMemoryUsage)
00095             END_PARAM_PATH()
00096         END_PARAM_MAP()
00097 
00098 
00099     protected:
00100         typedef SystemBase::SystemContext SystemContext;
00101 
00102         SystemContext m_context;
00103         SystemIF*     m_system;
00104 
00105         s64 m_simulationCycles; // simulation sTCN
00106         s64 m_executedCycles;   // タタsTCN
00107         
00108         s64 m_simulationInsns;  // simulation s
00109         s64 m_skipInsns;        // skip
00110 
00111         std::vector<s64> m_executedInsns;   // タタs
00112         std::vector<s64> m_skippedInsns;    // タXLbvタsTCN
00113 
00114         std::vector<double> m_ipc;          // ipc
00115         std::vector<u64> m_processMemoryUsage;  // vZXgp
00116         ExtraOpDecoder m_extraOpDecoder;
00117 
00118         virtual void InitializeEmulator();
00119         virtual void InitializeResources();
00120         virtual void InitializeSimulationContext();
00121 
00122         virtual void Initialize();
00123         virtual void Finalize();
00124         virtual void Run();
00125 
00126         virtual void GetInitialContext( ArchitectureStateList* archState );
00127         virtual bool SetSimulationContext( const ArchitectureStateList& archState );
00128 
00129         virtual void RunSimulation( SystemContext* context );
00130         virtual void RunEmulation( SystemContext* context );
00131         virtual void RunEmulationTrace( SystemContext* context );
00132         virtual void RunEmulationDebug( SystemContext* context );
00133         virtual void RunInorder( SystemContext* context );
00134 
00135         virtual void NotifyProcessTerminationBody( ProcessNotifyParam* );
00136         virtual void NotifySyscallReadFileToMemoryBody( ProcessNotifyParam* );
00137         virtual void NotifySyscallWriteFileFromMemoryBody( ProcessNotifyParam* );
00138         virtual void NotifyMemoryAllocationBody( ProcessNotifyParam* );
00139 
00140         virtual void SetSystem( SystemIF* system );
00141         
00142         virtual void NotifyChangingMode( PhysicalResourceNode::SimulationMode mode );
00143 
00144     };
00145 }   // namespace Onikiri
00146 
00147 #endif // #ifndef SIM_SYSTEM_SYSTEM_MANAGER_H
00148 

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