TEMU
2
The Terma Emulator
|
Go to the source code of this file.
Typedefs | |
typedef void(* | temu_SparcAsrHandler )(void *Cpu, uint32_t Instr) |
typedef void(* | temu_SafeCb )(void *) |
Functions | |
TEMU_API uint64_t | temu_cpuGetFreq (void *Cpu) |
Get the clock frequency for the CPU. More... | |
TEMU_API void | temu_cpuSetPc (void *Cpu, uint64_t Pc) |
Set the program counter. More... | |
TEMU_API uint64_t | temu_cpuGetPc (void *Cpu) |
Get the program counter. More... | |
TEMU_API void | temu_cpuReset (void *Cpu, int ResetType) |
Reset the processor. More... | |
TEMU_API uint64_t | temu_cpuRun (void *Cpu, uint64_t Cycles) |
Run the processor for a number of cycles. More... | |
TEMU_API uint64_t | temu_cpuStep (void *Cpu, uint64_t Steps) |
Run the processor for a number of steps. More... | |
TEMU_API int | temu_cpuTranslateAddress (void *Cpu, uint64_t Va, uint32_t flags, uint64_t *physAddressResult) |
temu_cpuTranslateAddress Uses the MMU to translate the given virtual address Va to the physical address in the emulator More... | |
TEMU_API uint64_t | temu_cpuGetReg (void *Cpu, unsigned Reg) |
TEMU_API void | temu_cpuSetReg (void *Cpu, unsigned Reg, uint64_t Value) |
TEMU_API float | temu_cpuGetFpr32 (void *Cpu, unsigned Reg) |
TEMU_API uint32_t | temu_cpuGetFpr32Bits (void *Cpu, unsigned Reg) |
TEMU_API void | temu_cpuSetFpr32 (void *Cpu, unsigned Reg, float Value) |
TEMU_API void | temu_cpuSetFpr32Bits (void *Cpu, unsigned Reg, uint32_t Value) |
TEMU_API double | temu_cpuGetFpr64 (void *Cpu, unsigned Reg) |
TEMU_API uint64_t | temu_cpuGetFpr64Bits (void *Cpu, unsigned Reg) |
TEMU_API void | temu_cpuSetFpr64 (void *Cpu, unsigned Reg, double Value) |
TEMU_API void | temu_cpuSetFpr64Bits (void *Cpu, unsigned Reg, uint64_t Value) |
TEMU_API void | temu_cpuEnableTraps (void *Cpu) |
TEMU_API void | temu_cpuDisableTraps (void *Cpu) |
TEMU_API void | temu_cpuRaiseTrap (void *Cpu, int Trap, unsigned Flags) |
TEMU_API int | temu_sparcGetWindowCount (void *Cpu) |
TEMU_API uint32_t | temu_sparcGetWindowedReg (void *Cpu, int Window, unsigned Reg) |
TEMU_API void | temu_sparcSetWindowedReg (void *Cpu, int Window, unsigned Reg, uint32_t Value) |
TEMU_API void | temu_sparcSetY (void *Cpu, uint64_t Value) |
TEMU_API uint64_t | temu_sparcGetY (void *Cpu) |
TEMU_API void | temu_sparcSetAsr (void *Cpu, unsigned Reg, uint64_t Value) |
TEMU_API uint64_t | temu_sparcGetAsr (void *Cpu, unsigned Reg) |
TEMU_API void | temu_sparcSetAsrWriter (void *Cpu, unsigned Asr, temu_SparcAsrHandler Handler) |
TEMU_API void | temu_sparcSetAsrReader (void *Cpu, unsigned Asr, temu_SparcAsrHandler Handler) |
TEMU_API void | temu_sparcSetPsr (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_sparcGetPsr (void *Cpu) |
TEMU_API void | temu_sparcSetTbr (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_sparcGetTbr (void *Cpu) |
TEMU_API void | temu_sparcSetWim (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_sparcGetWim (void *Cpu) |
TEMU_API void | temu_sparcSetNPc (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_sparcGetNPc (void *Cpu) |
TEMU_API void | temu_armSetAPSR (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_armGetAPSR (void *Cpu) |
TEMU_API void | temu_armSetFPSCR (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_armGetFPSCR (void *Cpu) |
TEMU_API void | temu_armSetFPEXC (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_armGetFPEXC (void *Cpu) |
TEMU_API void | temu_armSetFPINST (void *Cpu, int Idx, uint32_t Value) |
TEMU_API uint32_t | temu_armGetFPINST (void *Cpu, int Idx) |
TEMU_API unsigned | temu_armGetExecMode (void *Cpu) |
TEMU_API void | temu_armSetExecMode (void *Cpu, unsigned Mode) |
TEMU_API void | temu_ppcSetCrReg (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_ppcGetCrReg (void *Cpu) |
TEMU_API void | temu_ppcSetXerReg (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_ppcGetXerReg (void *Cpu) |
TEMU_API void | temu_ppcSetMsrReg (void *Cpu, uint64_t Value) |
TEMU_API uint64_t | temu_ppcGetMsrReg (void *Cpu) |
TEMU_API void | temu_ppcSetReserveAddress (void *Cpu, uint64_t reserveAddress) |
TEMU_API uint64_t | temu_ppcGetReserveAddress (void *Cpu) |
TEMU_API void | temu_ppcClearAddressReservation (void *Cpu) |
TEMU_API int | temu_ppcIsReservationBitSet (void *Cpu) |
TEMU_API void | temu_ppcSetCtrReg (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_ppcGetCtrReg (void *Cpu) |
TEMU_API void | temu_ppcSetFpscrReg (void *Cpu, uint32_t Value) |
TEMU_API uint32_t | temu_ppcGetFpscrReg (void *Cpu) |
TEMU_API void | temu_ppcSetLrReg (void *Cpu, uint64_t Value) |
TEMU_API uint64_t | temu_ppcGetLrReg (void *Cpu) |
TEMU_API void | temu_cpuSetSpr (void *Cpu, unsigned RegId, uint64_t Value) |
TEMU_API uint64_t | temu_cpuGetSpr (void *Cpu, unsigned RegId) |
TEMU_API void * | temu_cpuGetMachine (void *Cpu) |
Get the Machine for a given CPU. More... | |
TEMU_API void | temu_machineReset (void *Machine, int ResetType) |
Reset the Machine. More... | |
TEMU_API uint64_t | temu_machineRun (void *Machine, uint64_t NanoSecs) |
Run the machine for a number of nanoseconds. More... | |
TEMU_API void | temu_postCallback (void *Obj, temu_SafeCb Cb, void *Arg) |
typedef void(* temu_SafeCb)(void *) |
Post a callback in a CPU or Machine object (implementing the EventIface).
The posting will be thread-safe and the callback will be excuted by the main thread (the one calling the cpu or machine run / step functions). The main thread is the thread calling cpu run if there is only a single cpu in the system, and the thread calling machine run if there are multiple CPUs in the system.
The callback will be executed as soon as possible, when the even queue is checked for events. Which in practice mean:
The posting of this callback is thread-safe but not async / signal safe. I.e. do not do this from signal handler or async io callbacks.
When the event is executed, it is safe to do most emulator operations, including posting of events, calling API functions, etc.
The callback must however not:
typedef void(* temu_SparcAsrHandler)(void *Cpu, uint32_t Instr) |
TEMU_API uint32_t temu_armGetAPSR | ( | void * | Cpu | ) |
TEMU_API unsigned temu_armGetExecMode | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_armGetFPEXC | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_armGetFPINST | ( | void * | Cpu, |
int | Idx | ||
) |
TEMU_API uint32_t temu_armGetFPSCR | ( | void * | Cpu | ) |
TEMU_API void temu_armSetAPSR | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_armSetExecMode | ( | void * | Cpu, |
unsigned | Mode | ||
) |
TEMU_API void temu_armSetFPEXC | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_armSetFPINST | ( | void * | Cpu, |
int | Idx, | ||
uint32_t | Value | ||
) |
TEMU_API void temu_armSetFPSCR | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_cpuDisableTraps | ( | void * | Cpu | ) |
Disable traps on processor
Cpu | CPU pointer |
TEMU_API void temu_cpuEnableTraps | ( | void * | Cpu | ) |
Enable traps on processor
Cpu | CPU pointer |
TEMU_API float temu_cpuGetFpr32 | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Get a 32 bit floating point register
Cpu | CPU pointer |
Reg | FPU register number |
TEMU_API uint32_t temu_cpuGetFpr32Bits | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Get a 32 bit floating point register
Cpu | CPU pointer |
Reg | FPU register number |
TEMU_API double temu_cpuGetFpr64 | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Get 64 bit floating point register as double
Cpu | CPU pointer |
Reg | FPU register number |
TEMU_API uint64_t temu_cpuGetFpr64Bits | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Get 64 bit floating point register contents
Cpu | CPU pointer |
Reg | FPU register number |
TEMU_API uint64_t temu_cpuGetFreq | ( | void * | Cpu | ) |
Get the clock frequency for the CPU.
Cpu | The CPU object |
TEMU_API void* temu_cpuGetMachine | ( | void * | Cpu | ) |
Get the Machine for a given CPU.
Cpu | Pointer to the CPU object |
TEMU_API uint64_t temu_cpuGetPc | ( | void * | Cpu | ) |
Get the program counter.
The program counter will be returned.
Cpu | The CPU object |
TEMU_API uint64_t temu_cpuGetReg | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Gets the register in the processor
Cpu | CPU pointer |
Reg | Register number |
TEMU_API uint64_t temu_cpuGetSpr | ( | void * | Cpu, |
unsigned | RegId | ||
) |
TEMU_API void temu_cpuRaiseTrap | ( | void * | Cpu, |
int | Trap, | ||
unsigned | Flags | ||
) |
Raise a trap The function simulates a trap being raised at the current PC.
Cpu | Processor pointer |
Trap | Trap ID. This is target dependent, for the SPARC this is the TT value of the trap. |
Flags | set flag 1 to enable longjmp trap (this is useful in MMIO handlers to force a trap while a core is running). Set to 0 if called from outside the core or in e.g. an event handler. |
TEMU_API void temu_cpuReset | ( | void * | Cpu, |
int | ResetType | ||
) |
Reset the processor.
Resetting the CPU will result in a reset cascade where all connected devices are also reset.
Cpu | The CPU object |
ResetType | The type of reset, by convention 0 means cold reset, and 1 indicates a warm reset. |
TEMU_API uint64_t temu_cpuRun | ( | void * | Cpu, |
uint64_t | Cycles | ||
) |
Run the processor for a number of cycles.
The function runs the processor for a number of cycles. If you wish to run the processor with another time unit, you can compute the cycles from the clock frequency of the emulated processor.
In case the processor halts or enters idle mode and there are no pending events the function will return early.
Cpu | The CPU object |
Cycles | The number of cycles to run the processor for. |
TEMU_API void temu_cpuSetFpr32 | ( | void * | Cpu, |
unsigned | Reg, | ||
float | Value | ||
) |
Set floating point register value
Cpu | CPU pointer |
Reg | Floating point register number |
Value | Floating point value to set |
TEMU_API void temu_cpuSetFpr32Bits | ( | void * | Cpu, |
unsigned | Reg, | ||
uint32_t | Value | ||
) |
Set 32 bit floating point register value
Cpu | CPU pointer |
Reg | Floating point register number |
Value | Floating point value to set |
TEMU_API void temu_cpuSetFpr64 | ( | void * | Cpu, |
unsigned | Reg, | ||
double | Value | ||
) |
Set FPU register value
Cpu | CPU pointer |
Reg | FPU register number |
Value | Value to set to register |
TEMU_API void temu_cpuSetFpr64Bits | ( | void * | Cpu, |
unsigned | Reg, | ||
uint64_t | Value | ||
) |
Set FPU register value
Cpu | CPU pointer |
Reg | FPU register number |
Value | Value to set to register |
TEMU_API void temu_cpuSetPc | ( | void * | Cpu, |
uint64_t | Pc | ||
) |
Set the program counter.
The program counter will be set to the supplied value.
Cpu | The CPU object |
Pc | The program counter. |
TEMU_API void temu_cpuSetReg | ( | void * | Cpu, |
unsigned | Reg, | ||
uint64_t | Value | ||
) |
Set the register in the processor
Cpu | CPU pointer |
Reg | Register number |
Value | Value to write to register |
TEMU_API void temu_cpuSetSpr | ( | void * | Cpu, |
unsigned | RegId, | ||
uint64_t | Value | ||
) |
TEMU_API uint64_t temu_cpuStep | ( | void * | Cpu, |
uint64_t | Steps | ||
) |
Run the processor for a number of steps.
This function is different from temu_cpuRun, which runs for a time. The steps here indicates instructions executed (including trapping instructions). This can be contrasted to the run function which may advance the cycle counter by more than one for an instruction (depending on the timing models).
The function may return early in case the processor halts its execution or has entered idle mode and there are no events pending.
Cpu | The CPU object |
Steps | The number of steps to run the processor for. |
TEMU_API int temu_cpuTranslateAddress | ( | void * | Cpu, |
uint64_t | Va, | ||
uint32_t | flags, | ||
uint64_t * | physAddressResult | ||
) |
temu_cpuTranslateAddress Uses the MMU to translate the given virtual address Va to the physical address in the emulator
Cpu | the CPU object |
Va | the virtual address to be translated |
flags | flags for the translation (CPU specific) |
physAddressResult | the result in a uint64_t pointer |
TEMU_API void temu_machineReset | ( | void * | Machine, |
int | ResetType | ||
) |
Reset the Machine.
Resetting the Machine will result in a reset cascade where all connected devices and processors are also reset.
Machine | The Machine object |
ResetType | The type of reset, by convention 0 means cold reset, and 1 indicates a warm reset. |
TEMU_API uint64_t temu_machineRun | ( | void * | Machine, |
uint64_t | NanoSecs | ||
) |
Run the machine for a number of nanoseconds.
The function runs the machine and for a number of nanoseconds. This will run all the CPUs in the system.
In case a processor halts or enters idle mode, the function returns early.
Machine | The machine object |
NanoSecs | The number of nanosecs to run each processor for. |
TEMU_API void temu_postCallback | ( | void * | Obj, |
temu_SafeCb | Cb, | ||
void * | Arg | ||
) |
TEMU_API void temu_ppcClearAddressReservation | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_ppcGetCrReg | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_ppcGetCtrReg | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_ppcGetFpscrReg | ( | void * | Cpu | ) |
TEMU_API uint64_t temu_ppcGetLrReg | ( | void * | Cpu | ) |
TEMU_API uint64_t temu_ppcGetMsrReg | ( | void * | Cpu | ) |
TEMU_API uint64_t temu_ppcGetReserveAddress | ( | void * | Cpu | ) |
TEMU_API uint32_t temu_ppcGetXerReg | ( | void * | Cpu | ) |
TEMU_API int temu_ppcIsReservationBitSet | ( | void * | Cpu | ) |
TEMU_API void temu_ppcSetCrReg | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_ppcSetCtrReg | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_ppcSetFpscrReg | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API void temu_ppcSetLrReg | ( | void * | Cpu, |
uint64_t | Value | ||
) |
TEMU_API void temu_ppcSetMsrReg | ( | void * | Cpu, |
uint64_t | Value | ||
) |
TEMU_API void temu_ppcSetReserveAddress | ( | void * | Cpu, |
uint64_t | reserveAddress | ||
) |
TEMU_API void temu_ppcSetXerReg | ( | void * | Cpu, |
uint32_t | Value | ||
) |
TEMU_API uint64_t temu_sparcGetAsr | ( | void * | Cpu, |
unsigned | Reg | ||
) |
Get ASR register value
Cpu | SPARC CPU pointer |
Reg | ASR register ID |
TEMU_API uint32_t temu_sparcGetNPc | ( | void * | Cpu | ) |
Get the nPC value
Cpu | SPARC CPU pointer |
TEMU_API uint32_t temu_sparcGetPsr | ( | void * | Cpu | ) |
Get the Processor State Register
Cpu | SPARC CPU pointer |
TEMU_API uint32_t temu_sparcGetTbr | ( | void * | Cpu | ) |
Get Trap Base Register value
Cpu | SPARC CPU pointer |
TEMU_API uint32_t temu_sparcGetWim | ( | void * | Cpu | ) |
Get window invalidation mask register
Cpu | SPARC CPU pointer |
TEMU_API int temu_sparcGetWindowCount | ( | void * | Cpu | ) |
Get how many register windows are supported by the CPU
Cpu | SPARC CPU pointer |
TEMU_API uint32_t temu_sparcGetWindowedReg | ( | void * | Cpu, |
int | Window, | ||
unsigned | Reg | ||
) |
Get a windowed SPARC register
Cpu | SPARC CPU pointer |
Window | Window number (-1 for current window) |
Reg | Register number within window |
TEMU_API uint64_t temu_sparcGetY | ( | void * | Cpu | ) |
Get the Y register of the CPU,
Cpu | SPARC CPU pointer |
TEMU_API void temu_sparcSetAsr | ( | void * | Cpu, |
unsigned | Reg, | ||
uint64_t | Value | ||
) |
Set the ASR register
Cpu | SPARC CPU pointer |
Reg | ASR register ID |
Value | Value to write |
TEMU_API void temu_sparcSetAsrReader | ( | void * | Cpu, |
unsigned | Asr, | ||
temu_SparcAsrHandler | Handler | ||
) |
Install the handler to be called when an ASR is read
Cpu | SPARC CPU pointer |
Asr | ASR register ID |
Handler | Function to call. |
TEMU_API void temu_sparcSetAsrWriter | ( | void * | Cpu, |
unsigned | Asr, | ||
temu_SparcAsrHandler | Handler | ||
) |
Install the handler to be called when an ASR is written
Cpu | SPARC CPU pointer |
Asr | ASR register ID |
Handler | Function to call. |
TEMU_API void temu_sparcSetNPc | ( | void * | Cpu, |
uint32_t | Value | ||
) |
Set the nPC value (next program counter)
NOTE: When you use the setPC function, the NPC is also updated to PC+4. Use this to explicitly set NPC.
Cpu | SPARC CPU pointer |
Value | Value to write to NPC |
TEMU_API void temu_sparcSetPsr | ( | void * | Cpu, |
uint32_t | Value | ||
) |
Set the Processor State Register
Cpu | SPARC CPU pointer |
Value | Value to write |
TEMU_API void temu_sparcSetTbr | ( | void * | Cpu, |
uint32_t | Value | ||
) |
Set the Trap Base Register
Cpu | SPARC CPU pointer, |
Value | Value for TBR register |
TEMU_API void temu_sparcSetWim | ( | void * | Cpu, |
uint32_t | Value | ||
) |
Set window invalidation mask register
Cpu | SPARC CPU pointer |
Value | value to set in WIM |
TEMU_API void temu_sparcSetWindowedReg | ( | void * | Cpu, |
int | Window, | ||
unsigned | Reg, | ||
uint32_t | Value | ||
) |
Set a windowed SPARC register
Cpu | SPARC CPU pointer |
Window | Window number (-1 for current window) |
Reg | Register number within window |
Value | Register value |
TEMU_API void temu_sparcSetY | ( | void * | Cpu, |
uint64_t | Value | ||
) |
Set the Y register of the CPU,
Cpu | SPARC CPU pointer |
Value | Value to write to the Y register |