TEMU  4.4
The Terma Emulator
temu_CpuIface Struct Reference

#include </builds/termade/temu/temu/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)
 
void *(* getMachine )(void *Cpu)
 
void(* raiseTrapNoJmp )(void *Cpu, int Trap)
 
const char *(* getTrapName )(void *Cpu, int Trap)
 
const temu_CpuInfo *(* getCPUInfo )(void *Cpu)
 
int(* wakeUp )(void *Cpu)
 
void(* forceEarlyExit )(void *Cpu)
 
void *(* translateIRAddress )(void *Obj, uint64_t Va)
 
void(* enableModeSwitchEvents )(void *Obj)
 
void(* disableModeSwitchEvents )(void *Obj)
 
void(* enableProfiling )(void *Obj)
 
void(* disableProfiling )(void *Obj)
 
void(* flushProfileCaches )(void *Obj)
 
int64_t(* getIdleSteps )(void *Cpu)
 
int64_t(* getIdleCycles )(void *Cpu)
 
void(* enterHaltedMode )(void *Obj)
 
void(* forceSpecificExit )(void *Cpu, temu_CpuExitReason reason)
 
void(* purgeDirtyPages )(void *Obj)
 
void(* invalidateFetchAtc )(void *Obj)
 
int(* translateAddressWithRoot )(void *Cpu, uint64_t Va, uint32_t *Flags, uint64_t RootPointer, uint64_t *PA)
 
temu_CpuExitReason(* synchronizingRun )(void *Obj, uint64_t Cycles)
 
temu_CpuExitReason(* synchronizingRunUntil )(void *Obj, uint64_t Cycles)
 
temu_CpuExitReason(* synchronizingStep )(void *Obj, uint64_t Steps)
 
temu_CpuExitReason(* synchronizingStepUntil )(void *Obj, uint64_t Steps, uint64_t Cycles)
 

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.

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

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

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

\field 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.

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

\field 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.

\field 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.

\field 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.

\field 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.

\field getFpr32 Read the currently visible floating point registers.

\field 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.

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

\field 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.

\field 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.

\field 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.

\field raiseTrapNoJmp Raises a trap without longjmp to emulator core main loop. This can be used in e.g. timed event handlers and when the core isn't running.

Member Function Documentation

◆ __attribute__() [1/2]

void temu_CpuIface::__attribute__ ( (noreturn)  )

◆ __attribute__() [2/2]

void temu_CpuIface::__attribute__ ( (noreturn)  )

Field Documentation

◆ assemble

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

◆ disableErrorModeEvents

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

◆ disableModeSwitchEvents

void(* temu_CpuIface::disableModeSwitchEvents) (void *Obj)

◆ disableProfiling

void(* temu_CpuIface::disableProfiling) (void *Obj)

◆ disableTrapEvents

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

◆ disableTraps

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

◆ disassemble

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

◆ enableErrorModeEvents

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

◆ enableModeSwitchEvents

void(* temu_CpuIface::enableModeSwitchEvents) (void *Obj)

◆ enableProfiling

void(* temu_CpuIface::enableProfiling) (void *Obj)

◆ enableTrapEvents

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

◆ enableTraps

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

◆ enterHaltedMode

void(* temu_CpuIface::enterHaltedMode) (void *Obj)

Make the processor enter halted mode using a stack posted event.

◆ enterIdleMode

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

◆ flushProfileCaches

void(* temu_CpuIface::flushProfileCaches) (void *Obj)

◆ forceEarlyExit

void(* temu_CpuIface::forceEarlyExit) (void *Cpu)

Force early return of core (after event cleanup), unless the core returns for normal reasons, the emulator will return teCER_Early after the current instruction.

◆ forceSpecificExit

void(* temu_CpuIface::forceSpecificExit) (void *Cpu, temu_CpuExitReason reason)

◆ getCPUInfo

const temu_CpuInfo*(* temu_CpuIface::getCPUInfo) (void *Cpu)

◆ getCycles

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

◆ getFpr32

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

◆ getFpr64

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

◆ getFreq

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

◆ getGpr

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

◆ getIdleCycles

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

◆ getIdleSteps

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

◆ getMachine

void*(* temu_CpuIface::getMachine) (void *Cpu)

◆ getPc

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

◆ getPowerState

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

◆ getRegId

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

◆ getRegName

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

◆ getSpr

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

◆ getState

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

◆ getSteps

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

◆ getTrapName

const char*(* temu_CpuIface::getTrapName) (void *Cpu, int Trap)

◆ invalidateAtc

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

◆ invalidateFetchAtc

void(* temu_CpuIface::invalidateFetchAtc) (void *Obj)

◆ purgeDirtyPages

void(* temu_CpuIface::purgeDirtyPages) (void *Obj)

◆ raiseTrapNoJmp

void(* temu_CpuIface::raiseTrapNoJmp) (void *Cpu, int Trap)

◆ Reason

void temu_CpuExitReason temu_CpuIface::Reason

◆ reset

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

◆ run

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

◆ runUntil

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

◆ setFpr32

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

◆ setFpr64

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

◆ setGpr

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

◆ setPc

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

◆ setPowerState

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

◆ setSpr

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

◆ step

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

◆ stepUntil

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

◆ synchronizingRun

temu_CpuExitReason(* temu_CpuIface::synchronizingRun) (void *Obj, uint64_t Cycles)

◆ synchronizingRunUntil

temu_CpuExitReason(* temu_CpuIface::synchronizingRunUntil) (void *Obj, uint64_t Cycles)

◆ synchronizingStep

temu_CpuExitReason(* temu_CpuIface::synchronizingStep) (void *Obj, uint64_t Steps)

◆ synchronizingStepUntil

temu_CpuExitReason(* temu_CpuIface::synchronizingStepUntil) (void *Obj, uint64_t Steps, uint64_t Cycles)

◆ translateAddress

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

◆ translateAddressWithRoot

int(* temu_CpuIface::translateAddressWithRoot) (void *Cpu, uint64_t Va, uint32_t *Flags, uint64_t RootPointer, uint64_t *PA)

◆ translateIRAddress

void*(* temu_CpuIface::translateIRAddress) (void *Obj, uint64_t Va)

◆ Trap

void int temu_CpuIface::Trap

◆ wakeUp

int(* temu_CpuIface::wakeUp) (void *Cpu)

Wake up CPU if it is idling, return 1 if woken up 0 if no state change occurred


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