Interfaces
temu_AhbIface
Description
AHB bus plug and play interface
A device providing plug and play info for the AHB bridge, should implement this interface. The recommended way is to put a temu_AhbPnpInfo struct inside your model struct and then return a pointer to this one. This way the PNP info can be changed on a per object basis.
temu_ApbIface
Description
APB bus plug and play interface
A device providing plug and play info for the APB bridge, should implement this interface. The recommended way is to put a temu_ApbPnpInfo struct inside your model struct and then return a pointer to this one. This way the PNP info can be changed on a per object basis.
temu_CpuIface
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.
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!!!
field enterIdleMode Will call longjmp and enter idle mode immediately, this is useful for devices that activates power down mode.
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.
Fields
Field | Type | Description |
---|---|---|
wakeUp |
int (*)(void *) |
Wake up CPU if it is idling, return 1 if woken up 0 if no state change occurred |
forceEarlyExit |
void (*)(void *) |
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. |
temu_GpioBusIface
Type
struct temu_GpioBusIface {
void (*)(void *, uint64_t, uint64_t) setGpioBits;
uint64_t (*)(void *, uint64_t) getGpioBits;
}
Description
Interface implemented by the GPIO bus class.
Normally this does not have to be implemented yourself. It exist for the bus model only. In-case you need a separate bus model, you can implement this interface.
Note that this interface is deprecated for future models and it is expected that the signal interface is used instead.
Fields
Field | Type | Description |
---|---|---|
setGpioBits |
void (*)(void *, uint64_t, uint64_t) |
setGpioBits should set or clear the bits in Bits if they are set in Mask. Upon a set, the GPIO bus model should notify any connected GPIO clients about the changed bits. This is done using the temu_GpioClientIface. In the built in bus model, notifications are only delivered if any of the bits actually changed. |
getGpioBits |
uint64_t (*)(void *, uint64_t) |
Get the gpio-bits currently on the bus. The bits in mask will be extracted from the bus and returned in the result. |
temu_GpioClientIface
Description
Interface for GPIO clients.
A GPIO client is a device that interface with the GPIO bus. Such a client can poll using the GpioBusIface, but it is likely better to be lazily notified about changes to the bus values. Such notifications will be delivered to the GpioClientIface.
Note that this interface is deprecated for future models and it is expected that the signal interface is used instead.
temu_IrqClientIface
Description
Interface to be defined for classes that uses an IRQ controller object. An IRQ controller may acknowledge to the IRQ controller client, or it may notify the IrqClient that the underlying IRQ controller has been modified and any pending IRQs should be re-issued. Typically, an updateInterrupt call happens if the IRQ registers change in such a way that the IRQ controller does not know the next interrupt to be issued. E.g. On the sparc, the updateInterrupts function will be called on its IRQ controller whenever the ET or PIL field has changed. That is updateInterrupts are called by lazy IRQ controllers.
temu_IrqControllerIface
Description
Interrupt controller interface. An interrupt controller can raise and lower IRQ signals. For systems which has interrupts which can be configured to be active high, low or rising or falling, the raise and lower irq have different semantics. For rising edge triggering, the raiseInterrupt function should trigger the IRQ.
temu_MemAccessIface
Type
struct temu_MemAccessIface {
void (*)(void *, temu_MemTransaction *) fetch;
void (*)(void *, temu_MemTransaction *) read;
void (*)(void *, temu_MemTransaction *) write;
void (*)(void *, temu_MemTransaction *) exchange;
const temu_MemAccessCapabilities *(*)(void *) getCapabilities;
}
Description
Memory access interface implemented by all memory mapped devices Exposed to the emulator core by a memory object.
Fields
Field | Type | Description |
---|---|---|
fetch |
void (*)(void *, temu_MemTransaction *) |
Function called on fetches. The function can be null in case fetches are not allowed from the model. |
read |
void (*)(void *, temu_MemTransaction *) |
Function called on reads. |
write |
void (*)(void *, temu_MemTransaction *) |
Function called on writes. |
exchange |
void (*)(void *, temu_MemTransaction *) |
Function called on atomic exchanges, by default if this is not defined, the memory space will call read followed by write in order. |
getCapabilities |
const temu_MemAccessCapabilities ()(void *) |
Query for supported features Function is optional. By default the assumption is that the base capabilities are equal to R_ALL |
temu_MemoryIface
Description
For objects which have actualm memory (not just registers) This is for the simulator (not the emu core). The procedures should write the data given in bytes to the given physical offset. The offset is a 64 bit uint to support 64 bit targets. The interface is used for example by DMA transactions.
The size argument is in bytes.
The swap argument is used to swap bytes to the host endianess. Specify the log size of the read data types. - 0: We are reading bytes (bytes will be in target memory order) - 1: We are reading half words (will be swapped to host order) - 2: We are reading words (will be swapped) - 3: We are reading double words (will be swapped) With 0 for swap, we are basically reading a byte array
readBytes and writeBytes should return the number of bytes read / written or negative on error.
temu_Mil1553DevIface
Type
struct temu_Mil1553DevIface {
void (*)(void *, temu_Mil1553BusIfaceRef, int) connected;
void (*)(void *, temu_Mil1553BusIfaceRef, int) disconnected;
void (*)(void *, temu_Mil1553Msg *) receive;
void (*)(void *, temu_Mil1553BusIdleInfo *) busEnteredIdle;
}
Fields
Field | Type | Description |
---|---|---|
connected |
void (*)(void *, temu_Mil1553BusIfaceRef, int) |
Called after device is connected to bus |
disconnected |
void (*)(void *, temu_Mil1553BusIfaceRef, int) |
Called after device is disconnected |
receive |
void (*)(void *, temu_Mil1553Msg *) |
Receive of 1553 message |
busEnteredIdle |
void (*)(void *, temu_Mil1553BusIdleInfo *) |
Notifies the bus controller the bus enters an idle |
temu_ObjectIface
Type
struct temu_ObjectIface {
void (*)(void *, const char *, void *) serialise;
void (*)(void *, const char *, void *) deserialise;
int (*)(void *, int) checkSanity;
void (*)(void *) timeSourceSet;
void (*)(void *) printObject;
}
Description
Generic object interface The object interface provides generic functionality such as serialisation and sanity checking support.
Fields
Field | Type | Description |
---|---|---|
serialise |
void (*)(void *, const char *, void *) |
Optional function Called after an object has been written to the snapshot, this function can write out additional properties to the snapshot and take other actions. Note that with the pseudoproperties supporting snapshotting, this function is very rarely needed. |
deserialise |
void (*)(void *, const char *, void *) |
Optional function Called after an object has been restored from a snapshot, this function can read additional properties to the snapshot and take other actions. Note that with the pseudoproperties supporting snapshotting, this function is very rarely needed. |
checkSanity |
int (*)(void *, int) |
Return zero if the object is connected as expected, return non-zero if the object is not fully connected the default check will ensure that all the Interface references are connected, but does not care about optional interfaces or |
timeSourceSet |
void (*)(void *) |
Optional function Called when the time source has been set on the object The function can for example post initial events. |
printObject |
void (*)(void *) |
Optional function Pretty prints the object to stdout, called by the object-print command. |
temu_SpwPortIface
Type
struct temu_SpwPortIface {
void (*)(void *, void *, temu_SpwPacket *) receive;
void (*)(void *, temu_SpwLinkState) signalLinkStateChange;
temu_SpwLinkState (*)(void *) getOtherSideLinkState;
void (*)(void *, temu_SpwPortIfaceRef) connect;
void (*)(void *) disconnect;
uint64_t (*)(void *, uint64_t) timeToSendPacketNs;
}
Description
SpaceWire port interface. A model must implement this interface for each SpaceWire port.
Fields
Field | Type | Description |
---|---|---|
receive |
void (*)(void *, void *, temu_SpwPacket *) |
Implement to receive and handle the SpaceWire packet. This will be called by the model on the other end that sends or forwards the packet. |
signalLinkStateChange |
void (*)(void *, temu_SpwLinkState) |
The other end device (A) uses this to inform this device (B) about its (A) change of link state. |
getOtherSideLinkState |
temu_SpwLinkState (*)(void *) |
Should return the link state of the device. Called by the other end device to handle connection. |
connect |
void (*)(void *, temu_SpwPortIfaceRef) |
Connect a device to this port. |
disconnect |
void (*)(void *) |
Disconnects the device currently connected to this port. |
timeToSendPacketNs |
uint64_t (*)(void *, uint64_t) |
Return the amount of time required to send a packet through the port, in nano seconds. |