src/Sim/System/EmulationSystem/EmulationOp.cpp

説明を見る。
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 #include <pch.h>
00033 #include "Sim/System/EmulationSystem/EmulationOp.h"
00034 
00035 using namespace std;
00036 using namespace Onikiri;
00037 
00038 
00039 EmulationOp::EmulationOp( MemIF* mainMem ) :
00040     m_opInfo ( NULL ),
00041     m_taken  ( false ),
00042     m_mem( mainMem )
00043 {
00044 }
00045 
00046 EmulationOp::EmulationOp( const EmulationOp& op ) :
00047     m_pc     ( op.m_pc ),
00048     m_opInfo ( op.m_opInfo ),
00049     m_takenPC( op.m_takenPC ),
00050     m_taken  ( op.m_taken ),
00051     m_mem( op.m_mem ),
00052     m_dstReg ( op.m_dstReg ),
00053     m_srcReg ( op.m_srcReg )
00054 {
00055 }
00056 
00057 EmulationOp::~EmulationOp()
00058 {
00059 }
00060 
00061 void EmulationOp::SetPC( const PC& pc ) {
00062     m_pc = pc;
00063 }
00064 
00065 void EmulationOp::SetOpInfo( OpInfo* opInfo ) {
00066     m_opInfo = opInfo;
00067 }
00068 
00069 const OpInfo* EmulationOp::GetOpInfo() const
00070 {
00071     return m_opInfo;
00072 }
00073 
00074 void EmulationOp::SetMem( MemIF* mem )
00075 {
00076     m_mem = mem;
00077 }
00078 
00079 // OpStateIF
00080 PC EmulationOp::GetPC() const
00081 {
00082     return m_pc;
00083 }
00084 
00085 const u64 EmulationOp::GetSrc( const int index ) const
00086 {
00087     return m_srcReg[index];
00088 }
00089 
00090 void EmulationOp::SetSrc( const int index, const u64 value )
00091 {
00092     m_srcReg[index] = value;
00093 }
00094 
00095 const u64 EmulationOp::GetDst( const int index ) const
00096 {
00097     return m_dstReg[index];
00098 }
00099 
00100 
00101 void EmulationOp::SetDst( const int index, const u64 value )
00102 {
00103     m_dstReg[index] = value;
00104 }
00105 
00106 void EmulationOp::SetTakenPC( const PC takenPC )
00107 {
00108     m_takenPC = takenPC;
00109 }
00110 
00111 PC EmulationOp::GetTakenPC() const
00112 {
00113     return m_takenPC;
00114 }
00115 
00116 void EmulationOp::SetTaken( const bool taken )
00117 {
00118     m_taken = taken;
00119 }
00120 
00121 bool EmulationOp::GetTaken() const
00122 {
00123     return m_taken;
00124 }
00125 
00126 // MemIF
00127 void EmulationOp::Read( MemAccess* access )
00128 {
00129     ASSERT( m_mem != NULL );
00130     
00131     // Write correct 'tid', because an emulator does not initialized it.
00132     access->address.tid = m_pc.tid;
00133     
00134     m_mem->Read( access );
00135     if( access->result != MemAccess::MAR_SUCCESS ){
00136         RUNTIME_WARNING( "An access violation occurs.\n%s", access->ToString().c_str() );
00137     }
00138 }
00139 
00140 void EmulationOp::Write( MemAccess* access )
00141 {
00142     ASSERT( m_mem != NULL );
00143 
00144     // Write correct 'tid', because an emulator does not initialized it.
00145     access->address.tid = m_pc.tid;
00146 
00147     m_mem->Write( access );
00148     if( access->result != MemAccess::MAR_SUCCESS ){
00149         RUNTIME_WARNING( "An access violation occurs.\n%s", access->ToString().c_str() );
00150     }
00151 }

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