T-EMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Data Fields
temu_CpuIface Struct Reference

Common CPU interface. More...

#include <temu-c/Target/Cpu.h>

Collaboration diagram for temu_CpuIface:

Public Member Functions

void __attribute__ ((noreturn))(*raiseTrap)(void *Obj
 
void __attribute__ ((noreturn))(*exitEmuCore)(void *Cpu
 

Data Fields

void(* reset )(void *Cpu, int ResetType)
 
temu_CpuExitReason(* run )(void *Cpu, uint64_t Cycles)
 
temu_CpuExitReason(* runUntil )(void *Cpu, uint64_t Cycles)
 
temu_CpuExitReason(* step )(void *Cpu, uint64_t Steps)
 
temu_CpuExitReason(* stepUntil )(void *Cpu, uint64_t Steps, uint64_t Cycles)
 
void int Trap
 
void(* enterIdleMode )(void *Obj)
 
void temu_CpuExitReason Reason
 
uint64_t(* getFreq )(void *Cpu)
 
int64_t(* getCycles )(void *Cpu)
 
int64_t(* getSteps )(void *Cpu)
 
temu_CpuState(* getState )(void *Cpu)
 
void(* setPc )(void *Cpu, uint64_t Pc)
 
uint64_t(* getPc )(void *Cpu)
 
void(* setGpr )(void *Cpu, int Reg, uint64_t Value)
 
uint64_t(* getGpr )(void *Cpu, unsigned Reg)
 
void(* setFpr32 )(void *Cpu, unsigned Reg, uint32_t Value)
 
uint32_t(* getFpr32 )(void *Cpu, unsigned Reg)
 
void(* setFpr64 )(void *Cpu, unsigned Reg, uint64_t Value)
 
uint64_t(* getFpr64 )(void *Cpu, unsigned Reg)
 
void(* setSpr )(void *Cpu, unsigned Reg, uint64_t Value)
 
uint64_t(* getSpr )(void *Cpu, unsigned Reg)
 
int(* getRegId )(void *Cpu, const char *RegName)
 
const char *(* getRegName )(void *Cpu, int RegId)
 
uint32_t(* assemble )(void *Cpu, const char *AsmStr)
 
char *(* disassemble )(void *Cpu, uint32_t Instr)
 
void(* enableTraps )(void *Cpu)
 
void(* disableTraps )(void *Cpu)
 
void(* invalidateAtc )(void *Obj, uint64_t Addr, uint64_t Pages, uint32_t Flags)
 
uint64_t(* translateAddress )(void *Cpu, uint64_t Va, uint32_t *Flags)
 
temu_PowerState(* getPowerState )(void *Cpu)
 
void(* setPowerState )(void *Cpu, temu_PowerState Ps)
 
void(* enableTrapEvents )(void *Cpu)
 
void(* disableTrapEvents )(void *Cpu)
 
void(* enableErrorModeEvents )(void *Cpu)
 
void(* disableErrorModeEvents )(void *Cpu)
 

Detailed Description

Common CPU interface.

The CPU interface provides common functionality that all processors must implement. This includes the reset and run methods. But also different register access functions. The register access functions are functions, because registers may be banked and we want some type of common interface that can access the current registers. Note that the interface currently only support 32 bit processors.

Warning
Some functions will not return and execute longjmps to the emulation loop instead. These functions should NOT be called from any C++ code that needs destructors to be called on exit or from any events handlers.

reset The function executing a reset. It takes as parameter the reset type, which is 0 for a default cold reset.

run Run the main emulator loop for a given number of cycles.

runUntil Run the main emulator loop until its cycle counter reach the end cycles.

step Run the given number of steps. A step is one instruction, completed or not. E.g. a trapping instruction does not complete but is counted as a step.

stepUntil Step the emulator, but stop if the step exceeds a certain fixed time.

raiseTrap Raises a trap on the CPU. THIS FUNCTION DOES NOT RETURN!!!

Warning
The raiseTrap function will normally be constructed using longjmp, that implies that you should not call this from a model which must properly unwind the stack and call destructors on the way.

enterIdleMode Will call longjmp and enter idle mode immediately, this is useful for devices that activates power down mode.

Warning
This function does not return and destructors will not be called when the stack is unwound.

exitEmuCore Will call longjmp to exit the emulator core. This can be used in certain cases where the other exit functions do not suite well. One being that a reset is called from an MMIO write or read, or from a watchdog event. The reset can otherwise be called when the emulator is not running, so in a model you can call reset and then exitEmuCore.

getGpr Read the currently visible general purpose registers. For banked registers (e.g. SPARC reg windows), you should look at the arch specific interface instead.

getFpr32 Read the currently visible floating point registers.

setSpr Set special purpose registers. The indexes have been explicitly choosen to be equal to what is assumed by the GDB protocol, but re-based at zero.

getSpr Read special purpose registers. The indexes have been explicitly choosen to be equal to what is assumed by GDB but rebased at zero.

disassemble This function will disassemble an instruction. The function returns a heap-allocated string (allocated with malloc()). The caller is responsible for calling free() and managing the lifetime.

invalidateAtc Invalidates the ATC cache for the given address range. Flags can be set to control the invalidation. Bit 0: don't invalidate fetch. Bit 1: don't Invalidate read, bit 2: don't invalidate write, bit 3 don't invalidate user, bit 4 don't invalidate super.

translateAddress Does a table walk and translates the virtual address to physical page address. For MMU free systems, the function returns the Va masked with ~(page size-1). Otherwise, the return is the translated page address and in the case of failure -1.

Definition at line 137 of file Cpu.h.

Member Function Documentation

void temu_CpuIface::__attribute__ ( (noreturn)  )
void temu_CpuIface::__attribute__ ( (noreturn)  )

Field Documentation

uint32_t(* temu_CpuIface::assemble)(void *Cpu, const char *AsmStr)

Definition at line 164 of file Cpu.h.

void(* temu_CpuIface::disableErrorModeEvents)(void *Cpu)

Definition at line 180 of file Cpu.h.

void(* temu_CpuIface::disableTrapEvents)(void *Cpu)

Definition at line 177 of file Cpu.h.

void(* temu_CpuIface::disableTraps)(void *Cpu)

Definition at line 167 of file Cpu.h.

char*(* temu_CpuIface::disassemble)(void *Cpu, uint32_t Instr)

Definition at line 165 of file Cpu.h.

void(* temu_CpuIface::enableErrorModeEvents)(void *Cpu)

Definition at line 179 of file Cpu.h.

void(* temu_CpuIface::enableTrapEvents)(void *Cpu)

Definition at line 176 of file Cpu.h.

void(* temu_CpuIface::enableTraps)(void *Cpu)

Definition at line 166 of file Cpu.h.

void(* temu_CpuIface::enterIdleMode)(void *Obj)

Definition at line 145 of file Cpu.h.

int64_t(* temu_CpuIface::getCycles)(void *Cpu)

Definition at line 149 of file Cpu.h.

uint32_t(* temu_CpuIface::getFpr32)(void *Cpu, unsigned Reg)

Definition at line 157 of file Cpu.h.

uint64_t(* temu_CpuIface::getFpr64)(void *Cpu, unsigned Reg)

Definition at line 159 of file Cpu.h.

uint64_t(* temu_CpuIface::getFreq)(void *Cpu)

Definition at line 148 of file Cpu.h.

uint64_t(* temu_CpuIface::getGpr)(void *Cpu, unsigned Reg)

Definition at line 155 of file Cpu.h.

uint64_t(* temu_CpuIface::getPc)(void *Cpu)

Definition at line 153 of file Cpu.h.

temu_PowerState(* temu_CpuIface::getPowerState)(void *Cpu)

Definition at line 173 of file Cpu.h.

int(* temu_CpuIface::getRegId)(void *Cpu, const char *RegName)

Definition at line 162 of file Cpu.h.

const char*(* temu_CpuIface::getRegName)(void *Cpu, int RegId)

Definition at line 163 of file Cpu.h.

uint64_t(* temu_CpuIface::getSpr)(void *Cpu, unsigned Reg)

Definition at line 161 of file Cpu.h.

temu_CpuState(* temu_CpuIface::getState)(void *Cpu)

Definition at line 151 of file Cpu.h.

int64_t(* temu_CpuIface::getSteps)(void *Cpu)

Definition at line 150 of file Cpu.h.

void(* temu_CpuIface::invalidateAtc)(void *Obj, uint64_t Addr, uint64_t Pages, uint32_t Flags)

Definition at line 168 of file Cpu.h.

void temu_CpuExitReason temu_CpuIface::Reason

Definition at line 146 of file Cpu.h.

void(* temu_CpuIface::reset)(void *Cpu, int ResetType)

Definition at line 138 of file Cpu.h.

temu_CpuExitReason(* temu_CpuIface::run)(void *Cpu, uint64_t Cycles)

Definition at line 139 of file Cpu.h.

temu_CpuExitReason(* temu_CpuIface::runUntil)(void *Cpu, uint64_t Cycles)

Definition at line 140 of file Cpu.h.

void(* temu_CpuIface::setFpr32)(void *Cpu, unsigned Reg, uint32_t Value)

Definition at line 156 of file Cpu.h.

void(* temu_CpuIface::setFpr64)(void *Cpu, unsigned Reg, uint64_t Value)

Definition at line 158 of file Cpu.h.

void(* temu_CpuIface::setGpr)(void *Cpu, int Reg, uint64_t Value)

Definition at line 154 of file Cpu.h.

void(* temu_CpuIface::setPc)(void *Cpu, uint64_t Pc)

Definition at line 152 of file Cpu.h.

void(* temu_CpuIface::setPowerState)(void *Cpu, temu_PowerState Ps)

Definition at line 174 of file Cpu.h.

void(* temu_CpuIface::setSpr)(void *Cpu, unsigned Reg, uint64_t Value)

Definition at line 160 of file Cpu.h.

temu_CpuExitReason(* temu_CpuIface::step)(void *Cpu, uint64_t Steps)

Definition at line 141 of file Cpu.h.

temu_CpuExitReason(* temu_CpuIface::stepUntil)(void *Cpu, uint64_t Steps, uint64_t Cycles)

Definition at line 142 of file Cpu.h.

uint64_t(* temu_CpuIface::translateAddress)(void *Cpu, uint64_t Va, uint32_t *Flags)

Definition at line 171 of file Cpu.h.

void int temu_CpuIface::Trap

Definition at line 144 of file Cpu.h.


The documentation for this struct was generated from the following file: