CPUDyntransComponent Class Reference

Back to the index.

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CPUDyntransComponent Class Referenceabstract

A base-class for processors Component implementations that use dynamic translation. More...

#include <CPUDyntransComponent.h>

Inheritance diagram for CPUDyntransComponent:
CPUComponent Component AddressDataBus UnitTestable ReferenceCountable M88K_CPUComponent MIPS_CPUComponent

Public Member Functions

 CPUDyntransComponent (const string &className, const string &cpuKind)
 Constructs a CPUDyntransComponent. More...
 
virtual int Execute (GXemul *gxemul, int nrOfCycles)
 Execute one or more cycles. More...
 
- Public Member Functions inherited from CPUComponent
 CPUComponent (const string &className, const string &cpuKind)
 Constructs a CPUComponent. More...
 
SymbolRegistryGetSymbolRegistry ()
 Gets a reference to the CPU's symbol registry. More...
 
const SymbolRegistryGetSymbolRegistry () const
 
virtual void ResetState ()
 Resets the state variables of this component. More...
 
virtual double GetCurrentFrequency () const
 Returns the current frequency (in Hz) that the component runs at. More...
 
virtual CPUComponentAsCPUComponent ()
 Returns the component's CPUComponent interface. More...
 
virtual void GetMethodNames (vector< string > &names) const
 Retrieves a component's implemented method names. More...
 
virtual bool MethodMayBeReexecutedWithoutArgs (const string &methodName) const
 Returns whether a method name may be re-executed without args. More...
 
virtual void ExecuteMethod (GXemul *gxemul, const string &methodName, const vector< string > &arguments)
 Executes a method on the component. More...
 
virtual AddressDataBusAsAddressDataBus ()
 Returns the component's AddressDataBus interface, if any. More...
 
virtual void AddressSelect (uint64_t address)
 Place an address on the bus. More...
 
virtual bool ReadData (uint8_t &data, Endianness endianness)
 Reads 8-bit data from the currently selected address. More...
 
virtual bool ReadData (uint16_t &data, Endianness endianness)
 Reads 16-bit data from the currently selected address. More...
 
virtual bool ReadData (uint32_t &data, Endianness endianness)
 Reads 32-bit data from the currently selected address. More...
 
virtual bool ReadData (uint64_t &data, Endianness endianness)
 Reads 64-bit data from the currently selected address. More...
 
virtual bool WriteData (const uint8_t &data, Endianness endianness)
 Writes 8-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint16_t &data, Endianness endianness)
 Writes 16-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint32_t &data, Endianness endianness)
 Writes 32-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint64_t &data, Endianness endianness)
 Writes 64-bit data to the currently selected address. More...
 
virtual size_t DisassembleInstruction (uint64_t vaddr, size_t maxLen, unsigned char *instruction, vector< string > &result)=0
 Disassembles an instruction into readable strings. More...
 
- Public Member Functions inherited from Component
virtual ~Component ()
 
string GetClassName () const
 Gets the class name of the component. More...
 
string GetVisibleClassName () const
 Gets the visible class name of the component. More...
 
refcount_ptr< ComponentClone () const
 Clones the component and all its children. More...
 
const refcount_ptr< ComponentLightClone () const
 Makes a light clone of the component and all its children. More...
 
void DetectChanges (const refcount_ptr< Component > &oldClone, ostream &changeMessages) const
 Compare an older clone to the current tree, to find changes. More...
 
string GenerateTreeDump (const string &branchTemplate, bool htmlLinksForClassNames=false, string prefixForComponentUrls="") const
 Generates an ASCII tree dump of a component tree. More...
 
virtual string GenerateDetails () const
 Generate details about the component. More...
 
void Reset ()
 Resets the state of this component and all its children. More...
 
bool PreRunCheck (GXemul *gxemul)
 Checks the state of this component and all its children, before starting execution. More...
 
void FlushCachedState ()
 Resets the cached state of this component and all its children. More...
 
virtual RootComponentAsRootComponent ()
 Returns the component's RootComponent interface. More...
 
void SetParent (Component *parentComponent)
 Sets the parent component of this component. More...
 
ComponentGetParent ()
 Gets this component's parent component, if any. More...
 
const ComponentGetParent () const
 
string GeneratePath () const
 Generates a string representation of the path to the Component. More...
 
string GenerateShortestPossiblePath () const
 Generates a short string representation of the path to the Component. More...
 
const refcount_ptr< ComponentLookupPath (string path) const
 Looks up a path from this Component, and returns a pointer to the found Component, if any. More...
 
vector< string > FindPathByPartialMatch (const string &partialPath, bool shortestPossible=false) const
 Finds complete component paths, given a partial path. More...
 
void AddChild (refcount_ptr< Component > childComponent, size_t insertPosition=(size_t)-1)
 Adds a reference to a child component. More...
 
size_t RemoveChild (Component *childToRemove)
 Removes a reference to a child component. More...
 
ComponentsGetChildren ()
 Gets pointers to child components. More...
 
const ComponentsGetChildren () const
 Gets pointers to child components, as a const reference. More...
 
void GetVariableNames (vector< string > &names) const
 Retrieves a component's state variable names. More...
 
StateVariableGetVariable (const string &name)
 Gets a pointer to a state variable. More...
 
const StateVariableGetVariable (const string &name) const
 Gets a pointer to a state variable. More...
 
bool SetVariableValue (const string &name, const string &expression)
 Sets a variable to a new value. More...
 
void Serialize (ostream &ss, SerializationContext &context) const
 Serializes the Component into a string stream. More...
 
bool CheckConsistency () const
 Checks consistency by serializing and deserializing the component (including all its child components), and comparing the checksum of the original tree with the deserialized tree. More...
 
void AddChecksum (Checksum &checksum) const
 Adds this component's state, including children, to a checksum. More...
 
- Public Member Functions inherited from ReferenceCountable
 ReferenceCountable ()
 Default constructor, which initializes the reference count to zero. More...
 
 ~ReferenceCountable ()
 
- Public Member Functions inherited from AddressDataBus
 AddressDataBus ()
 Constructs an AddressDataBus instance. More...
 
virtual ~AddressDataBus ()
 

Static Public Member Functions

static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from CPUComponent
static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from Component
static string GetAttribute (const string &attributeName)
 Creates a Component. More...
 
static refcount_ptr< ComponentDeserialize (ostream &messages, const string &str, size_t &pos)
 Deserializes a string into a component tree. More...
 
- Static Public Member Functions inherited from UnitTestable
static void RunUnitTests (int &nSucceeded, int &nFailures)
 Runs unit test cases. More...
 

Protected Member Functions

virtual int GetDyntransICshift () const =0
 
void DyntransToBeTranslatedBegin (struct DyntransIC *)
 
bool DyntransReadInstruction (uint16_t &iword)
 
bool DyntransReadInstruction (uint32_t &iword)
 
void DyntransToBeTranslatedDone (struct DyntransIC *)
 
void DyntransResyncPC ()
 Calculate m_pc based on m_nextIC and m_firstIConPage. More...
 
void DyntransPCtoPointers ()
 Calculate m_nextIC and m_firstIConPage, based on m_pc. More...
 
 DECLARE_DYNTRANS_INSTR (nop)
 
 DECLARE_DYNTRANS_INSTR (abort)
 
 DECLARE_DYNTRANS_INSTR (endOfPage)
 
 DECLARE_DYNTRANS_INSTR (endOfPage2)
 
 DECLARE_DYNTRANS_INSTR (branch_samepage)
 
 DECLARE_DYNTRANS_INSTR (set_u64_imms32)
 
 DECLARE_DYNTRANS_INSTR (mov_u64_u64)
 
 DECLARE_DYNTRANS_INSTR (add_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (add_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_imms32_truncS32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_u64_truncS32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_imms32)
 
 DECLARE_DYNTRANS_INSTR (sub_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (sub_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (sub_u64_u64_u64_truncS32)
 
 DECLARE_DYNTRANS_INSTR (and_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (and_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (or_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (or_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (or_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (xor_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u64_u64_u64)
 
 DECLARE_DYNTRANS_INSTR (shift_left_u64_u64_imm5_truncS32)
 
 DECLARE_DYNTRANS_INSTR (shift_right_u64_u64asu32_imm5_truncS32)
 
- Protected Member Functions inherited from CPUComponent
virtual void FlushCachedStateForComponent ()
 Resets the cached state of this component. More...
 
virtual bool PreRunCheckForComponent (GXemul *gxemul)
 Checks the state of this component, before starting execution. More...
 
virtual void ShowRegisters (GXemul *gxemul, const vector< string > &arguments) const
 
uint64_t Unassemble (int nRows, bool indicatePC, uint64_t vaddr, ostream &output)
 
virtual bool VirtualToPhysical (uint64_t vaddr, uint64_t &paddr, bool &writable)=0
 Virtual to physical address translation (MMU). More...
 
virtual string VirtualAddressAsString (uint64_t vaddr)
 Format a virtual address as a displayable string. More...
 
virtual uint64_t PCtoInstructionAddress (uint64_t pc)
 Convert PC value to instuction address. More...
 
bool FunctionTraceCall ()
 
bool FunctionTraceReturn ()
 
virtual int FunctionTraceArgumentCount ()
 
virtual int64_t FunctionTraceArgument (int n)
 
virtual bool FunctionTraceReturnImpl (int64_t &retval)
 
- Protected Member Functions inherited from Component
 Component (const string &className, const string &visibleClassName)
 Base constructor for a Component. More...
 
template<class T >
bool AddVariable (const string &name, T *variablePointer)
 Adds a state variable of type T to the Component. More...
 
bool AddCustomVariable (const string &name, CustomStateVariableHandler *variableHandler)
 Adds a custom state variable to the Component. More...
 
virtual bool CheckVariableWrite (StateVariable &var, const string &oldValue)
 Checks whether a write to a variable is OK. More...
 
GXemulGetRunningGXemulInstance ()
 Returns a reference to the current GXemul instance. More...
 
UIGetUI ()
 Gets an UI reference for outputting debug messages during runtime. More...
 

Protected Attributes

virtual void(*)(CPUDyntransComponent
*cpu, DyntransIC *ic) 
GetDyntransToBeTranslated ()
 
struct DyntransICm_firstIConPage
 
struct DyntransICm_nextIC
 
int m_dyntransPageMask
 
int m_dyntransICentriesPerPage
 
int m_dyntransICshift
 
int m_executedCycles
 
int m_nrOfCyclesToExecute
 
DyntransTranslationCache m_translationCache
 
struct DyntransIC m_abortIC
 
- Protected Attributes inherited from CPUComponent
double m_frequency
 
bool m_paused
 
string m_cpuArchitecture
 
int m_pageSize
 
uint64_t m_pc
 
uint64_t m_lastDumpAddr
 
uint64_t m_lastUnassembleVaddr
 
bool m_hasUsedUnassemble
 
bool m_isBigEndian
 
bool m_showFunctionTraceCall
 
bool m_showFunctionTraceReturn
 
int32_t m_functionCallTraceDepth
 
int64_t m_nrOfTracedFunctionCalls
 
bool m_inDelaySlot
 
uint64_t m_delaySlotTarget
 
AddressDataBusm_addressDataBus
 
uint64_t m_addressSelect
 
bool m_exceptionOrAbortInDelaySlot
 

Detailed Description

A base-class for processors Component implementations that use dynamic translation.

Definition at line 85 of file CPUDyntransComponent.h.

Constructor & Destructor Documentation

CPUDyntransComponent::CPUDyntransComponent ( const string &  className,
const string &  cpuKind 
)

Constructs a CPUDyntransComponent.

Parameters
classNameThe class name for the component.
cpuKindThe CPU kind, e.g. "MIPS R4400" for a MIPS R4400 processor.

Definition at line 36 of file CPUDyntransComponent.cc.

References DyntransIC::f, and m_abortIC.

Member Function Documentation

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( nop  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( abort  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( endOfPage  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( endOfPage2  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( branch_samepage  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( set_u64_imms32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( mov_u64_u64  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u32_u32_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u32_u32_u32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_imms32_truncS32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_u64_truncS32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_imms32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u32_u32_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u32_u32_u32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u64_u64_u64_truncS32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( and_u32_u32_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( and_u64_u64_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u32_u32_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u32_u32_u32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u64_u64_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u32_u32_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u32_u32_u32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u64_u64_immu32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u64_u64_u64  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( shift_left_u64_u64_imm5_truncS32  )
protected
CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( shift_right_u64_u64asu32_imm5_truncS32  )
protected
void CPUDyntransComponent::DyntransPCtoPointers ( )
protected

Calculate m_nextIC and m_firstIConPage, based on m_pc.

This function may return pointers to within an existing translation page (hopefully the most common case, since it is the fastest), or it may allocate a new empty page.

Definition at line 232 of file CPUDyntransComponent.cc.

References DyntransIC::f, m_dyntransPageMask, m_firstIConPage, m_nextIC, and CPUComponent::m_pc.

Referenced by DyntransToBeTranslatedDone(), and Execute().

bool CPUDyntransComponent::DyntransReadInstruction ( uint16_t &  iword)
protected
bool CPUDyntransComponent::DyntransReadInstruction ( uint32_t &  iword)
protected
void CPUDyntransComponent::DyntransResyncPC ( )
protected

Calculate m_pc based on m_nextIC and m_firstIConPage.

Definition at line 252 of file CPUDyntransComponent.cc.

References m_abortIC, m_dyntransICentriesPerPage, m_dyntransICshift, m_dyntransPageMask, m_firstIConPage, m_nextIC, and CPUComponent::m_pc.

Referenced by DyntransToBeTranslatedBegin(), and Execute().

void CPUDyntransComponent::DyntransToBeTranslatedBegin ( struct DyntransIC ic)
protected

Definition at line 297 of file CPUDyntransComponent.cc.

References DyntransResyncPC(), DyntransIC::f, and m_nextIC.

void CPUDyntransComponent::DyntransToBeTranslatedDone ( struct DyntransIC ic)
protected
int CPUDyntransComponent::Execute ( GXemul gxemul,
int  nrOfCycles 
)
virtual

Execute one or more cycles.

Note 1: A component must attempt to execute exactly the number of specified cycles.

Note 2: If e.g. a breakpoint is reached, or some fatal error occurs (such as an unimplemented feature in the emulation of the component is triggered), then it is ok to return fewer than the requested number of cycles. Execution will then stop (or the breakpoint will be handled, etc).

Note 3: The framework will only call this function if the component has a StateVariable named "frequency". Components that do not have any frequency do not execute anything periodically by themselves.

Parameters
gxemulA pointer to the GXemul instance.
nrOfCyclesThe requested number of cycles to run.
Returns
The number of cycles actually executed.

Reimplemented from Component.

Definition at line 89 of file CPUDyntransComponent.cc.

References DyntransPCtoPointers(), DyntransResyncPC(), f(), DyntransIC::f, GetDyntransToBeTranslated, GXemul::GetRunState(), GXemul::GetUI(), IC, m_executedCycles, m_firstIConPage, CPUComponent::m_inDelaySlot, m_nextIC, m_nrOfCyclesToExecute, CPUComponent::m_pc, CPUComponent::PCtoInstructionAddress(), UI::ShowDebugMessage(), GXemul::SingleStepping, and CPUComponent::Unassemble().

virtual int CPUDyntransComponent::GetDyntransICshift ( ) const
protectedpure virtual

Implemented in M88K_CPUComponent, and MIPS_CPUComponent.

static void CPUDyntransComponent::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

Member Data Documentation

virtual void(*)(CPUDyntransComponent* cpu, DyntransIC* ic) CPUDyntransComponent::GetDyntransToBeTranslated()
protected

Definition at line 108 of file CPUDyntransComponent.h.

Referenced by DyntransToBeTranslatedDone(), and Execute().

struct DyntransIC CPUDyntransComponent::m_abortIC
protected
int CPUDyntransComponent::m_dyntransICentriesPerPage
protected

Definition at line 612 of file CPUDyntransComponent.h.

Referenced by DyntransResyncPC().

int CPUDyntransComponent::m_dyntransICshift
protected

Definition at line 613 of file CPUDyntransComponent.h.

Referenced by DyntransResyncPC().

int CPUDyntransComponent::m_dyntransPageMask
protected

Definition at line 611 of file CPUDyntransComponent.h.

Referenced by DyntransPCtoPointers(), and DyntransResyncPC().

int CPUDyntransComponent::m_executedCycles
protected

Definition at line 614 of file CPUDyntransComponent.h.

Referenced by DyntransToBeTranslatedDone(), and Execute().

struct DyntransIC* CPUDyntransComponent::m_firstIConPage
protected

Definition at line 609 of file CPUDyntransComponent.h.

Referenced by DyntransPCtoPointers(), DyntransResyncPC(), and Execute().

struct DyntransIC* CPUDyntransComponent::m_nextIC
protected
int CPUDyntransComponent::m_nrOfCyclesToExecute
protected

Definition at line 615 of file CPUDyntransComponent.h.

Referenced by DyntransToBeTranslatedDone(), and Execute().

DyntransTranslationCache CPUDyntransComponent::m_translationCache
protected

Definition at line 620 of file CPUDyntransComponent.h.


The documentation for this class was generated from the following files:

Generated on Sun Aug 17 2014 10:51:04 for GXemul by doxygen 1.8.3.1