TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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)
 
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)
 

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.

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.

Definition at line 164 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 191 of file Cpu.h.

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

Definition at line 207 of file Cpu.h.

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

Definition at line 204 of file Cpu.h.

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

Definition at line 194 of file Cpu.h.

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

Definition at line 192 of file Cpu.h.

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

Definition at line 206 of file Cpu.h.

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

Definition at line 203 of file Cpu.h.

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

Definition at line 193 of file Cpu.h.

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

Definition at line 172 of file Cpu.h.

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.

Definition at line 219 of file Cpu.h.

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

Definition at line 214 of file Cpu.h.

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

Definition at line 176 of file Cpu.h.

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

Definition at line 184 of file Cpu.h.

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

Definition at line 186 of file Cpu.h.

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

Definition at line 175 of file Cpu.h.

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

Definition at line 182 of file Cpu.h.

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

Definition at line 209 of file Cpu.h.

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

Definition at line 180 of file Cpu.h.

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

Definition at line 200 of file Cpu.h.

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

Definition at line 189 of file Cpu.h.

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

Definition at line 190 of file Cpu.h.

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

Definition at line 188 of file Cpu.h.

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

Definition at line 178 of file Cpu.h.

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

Definition at line 177 of file Cpu.h.

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

Definition at line 212 of file Cpu.h.

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

Definition at line 195 of file Cpu.h.

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

Definition at line 210 of file Cpu.h.

void temu_CpuExitReason temu_CpuIface::Reason

Definition at line 173 of file Cpu.h.

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

Definition at line 165 of file Cpu.h.

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

Definition at line 166 of file Cpu.h.

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

Definition at line 167 of file Cpu.h.

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

Definition at line 183 of file Cpu.h.

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

Definition at line 185 of file Cpu.h.

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

Definition at line 181 of file Cpu.h.

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

Definition at line 179 of file Cpu.h.

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

Definition at line 201 of file Cpu.h.

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

Definition at line 187 of file Cpu.h.

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

Definition at line 168 of file Cpu.h.

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

Definition at line 169 of file Cpu.h.

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

Definition at line 198 of file Cpu.h.

void int temu_CpuIface::Trap

Definition at line 171 of file Cpu.h.

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

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

Definition at line 216 of file Cpu.h.


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