Functions
temu_addArrayProperty
Signature
int temu_addArrayProperty(temu_Class * Cls, const char * Name, int offset, temu_Type T, int NumElems, const char * Doc)
temu_addArrayPseudoProperty
Signature
int temu_addArrayPseudoProperty(temu_Class * Cls, const char * Name, temu_Type T, int NumElems, const char * Doc)
temu_addField
Signature
void temu_addField(temu_Register * R, const char * Name, uint64_t Mask, uint64_t Reset, uint64_t Flags, const char * Doc)
Parameters
Parameter | Type | Description |
---|---|---|
R |
Meta register pointer. |
|
Name |
const char * |
Name of of field (must be a C-compatible identifier) |
Mask |
uint64_t |
Mask identifying the bits in the register corresponding to the field. Mask must contain consecutive bits only. |
Reset |
uint64_t |
Reset value. |
Flags |
uint64_t |
Flags used: TEMU_FIELD_WR means field is writable, TEMU_FIELD_WARM_RESET means the field is subject to reset actions also on warm resets. |
Doc |
const char * |
Documentation string |
temu_addInterfaceArray
Signature
void temu_addInterfaceArray(temu_Class * Cls, const char * IfaceName, const char * IfaceType, void * Iface, size_t Count, size_t Size, const char * Doc)
Description
Add an array of interfaces to a class
Interface arrays are especially useful when e.g. multiple "network ports" are available, although they can be added manually with distinct names (e.g. uartaiface, uartbiface, etc), the interface array registration allows for the addition of several interfaces at once. Individual interfaces are then referred to with normal index syntax, e.g. obj:uartiface[0].
Parameters
Parameter | Type | Description |
---|---|---|
Cls |
Class pointer |
|
IfaceName |
const char * |
name of interface |
IfaceType |
const char * |
name of interface type |
Iface |
void * |
Pointer to array of interfaces |
Count |
size_t |
Number of interfaces in array |
Size |
size_t |
Size of one interface (e.g. sizeof(uartiface[0])) |
Doc |
const char * |
Documentation comment for interface |
temu_addInterfaceReference
Signature
void temu_addInterfaceReference(temu_Class * Cls, const char * PropName, int Offset, const char * TypeName, int Count, unsigned int Flags, temu_PropWriter Wr, temu_PropReader Rd, const char * Doc)
Parameters
Parameter | Type | Description |
---|---|---|
Cls |
The class object |
|
PropName |
const char * |
Name of the property to add. |
Offset |
int |
Offset in bytes from the start of the class to the value the property refers to. |
TypeName |
const char * |
Interface type name. |
Count |
int |
Set to > 1 to indicate that the property is an array, the value is the length of the array. |
Flags |
unsigned int |
Flags for property, 1 implies property is mandatory to set. |
Wr |
temu_PropWriter |
Property write function. This function can have side-effects. |
Rd |
Property read function. This function can have side-effects. |
|
Doc |
const char * |
Documentation string |
temu_addLoggingCategory
Signature
int temu_addLoggingCategory(temu_Class * Cls, unsigned int CategoryId, const char * Category)
temu_addPort
Signature
int temu_addPort(temu_Class * C, const char * IfaceRefName, const char * IfaceName, const char * Doc)
Description
Make interface reference property and an interface inverses
A port is a bidirectional interface. Thus, if an interface reference is connected to another objects interface, the remote object will be told to issue a reverse connection. This is convenient as it simplifies device connection during system configuration and construction. That is, instead of calling the connect two times with the inverse connections explicitly, only one call is needed.
temu_addProperty
Signature
void temu_addProperty(temu_Class * Cls, const char * PropName, int Offset, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, const char * Doc)
Parameters
Parameter | Type | Description |
---|---|---|
Cls |
The class object |
|
PropName |
const char * |
Name of the property to add. |
Offset |
int |
Offset in bytes from the start of the class to the value the property refers to. |
Typ |
temu_Type |
Type of the property. |
Count |
int |
Set to > 1 to indicate that the property is an array, the value is the length of the array. |
Wr |
temu_PropWriter |
Property write function. This function can have side-effects. |
Rd |
Property read function. This function can have side-effects. |
|
Doc |
const char * |
Documentation string |
temu_addPseudoInterfaceReference
Signature
void temu_addPseudoInterfaceReference(temu_Class * Cls, const char * PropName, const char * TypeName, int Count, unsigned int Flags, temu_PropWriter Wr, temu_PropReader Rd, temu_PropWriter Set, temu_PropReader Get, const char * Doc)
Parameters
Parameter | Type | Description |
---|---|---|
Cls |
The class object |
|
PropName |
const char * |
Name of the property to add. |
TypeName |
const char * |
Interface type name. |
Count |
int |
Set to > 1 to indicate that the property is an array, the value is the length of the array. |
Flags |
unsigned int |
Flags for property, 1 implies property is mandatory to set. |
Wr |
temu_PropWriter |
Property write function. This function can have side-effects. |
Rd |
Property read function. This function can have side-effects. |
|
Set |
temu_PropWriter |
Property set function. Non-semantic. |
Get |
Property get function. Non-semantic. |
|
Doc |
const char * |
Documentation string |
temu_addPseudoProperty
Signature
void temu_addPseudoProperty(temu_Class * Cls, const char * PropName, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, temu_PropWriter Set, temu_PropReader Get, const char * Doc)
Description
Add property without storage
A pseudo property does not have backing storage (and therefore no offset). They exist to provide access to computed properties.
Pseudo properties also work fine with C++ types with non-standard layout.
Pseudo properties are snapshotted if the set and get functions are implemented. The set and get should implement read and write without semantic effect. That is, if the property is a register, then the read and write should have the effect of an actual register access (including event rescheduling etc), while for a get/set, only the value of the register is modified, event restoration is done differently.
Parameters
Parameter | Type | Description |
---|---|---|
Cls |
class to add pseudo property to |
|
PropName |
const char * |
name of pseudo property |
Typ |
temu_Type |
Type of property |
Count |
int |
number of elements, 1 for a scalar. |
Wr |
temu_PropWriter |
Property write function (semantic effect) |
Rd |
Property read function (semantic effect) |
|
Set |
temu_PropWriter |
Property set function (non-semantic) |
Get |
Property get function (non-semantic) |
|
Doc |
const char * |
Documentation string |
temu_addRegister
Signature
temu_Register * temu_addRegister(temu_RegisterBank * Bank, const char * Name, int Offset, temu_Type Typ, int Count, temu_PropWriter Wr, temu_PropReader Rd, const char * Doc, uint32_t DeviceOffset, uint32_t Stride)
Description
Add register property to class
Adds a register with the given name to a class. It returns a reference to a meta register which can be used to add fields.
Parameters
Parameter | Type | Description |
---|---|---|
Bank |
Register bank to add register to |
|
Name |
const char * |
Name of register (must be a valid C-identifier) |
Offset |
int |
Offset to storage element in the device struct. |
Typ |
temu_Type |
Type of register, note that registers are limited to unsigned integer types with fixed width. |
Count |
int |
Number of registers (normally 1) |
Wr |
temu_PropWriter |
Register write function |
Rd |
Register read function |
|
Doc |
const char * |
Documentation string for register. |
DeviceOffset |
uint32_t |
Offset of register in memory system. This is the same offset that is used in the memory transaction interface. |
Stride |
uint32_t |
In case the register is an array of registers, then the stride is used for the offset in physical address space between each register. |
temu_addRegisterBank
Signature
temu_RegisterBank * temu_addRegisterBank(temu_Class * C, const char * Name, temu_MemAccessIface * MemAccessIface)
temu_addScalarProperty
Signature
int temu_addScalarProperty(temu_Class * Cls, const char * Name, int offset, temu_Type T, const char * Doc)
temu_addScalarPseudoProperty
Signature
int temu_addScalarPseudoProperty(temu_Class * Cls, const char * Name, temu_Type T, const char * Doc)
temu_asyncSocketAdd
Signature
int temu_asyncSocketAdd(temu_TimeSource * TS, int Sock, unsigned int Flags, void (*)(void *) CB, void * Data)
Parameters
Parameter | Type | Description |
---|---|---|
TS |
the synchronous queue or time source object (normally a CPU object) |
|
Sock |
int |
File descriptor for the socket. This can also be a pipe FD. Note that the function is likely to be renamed. Note that in case you are intending to read from the socket, make sure it is non-blocking. |
Flags |
unsigned int |
TEMU_ASYNC_READ in case you wish to be notified about data available to read. |
temu_asyncTimerAdd
Signature
int temu_asyncTimerAdd(temu_TimeSource * TS, double T, unsigned int Flags, void (*)(void *) CB, void * Data)
Description
Add asynchronously activated wall-clock timed events
The callback function will be called synchronously by the emulator core associated with Q. That means that when CB is executing it is safe to do anything that can be done from a normal event or MMIO handler.
Note that the event is only called when a CPU core or machine is running. When the timer has triggered, it is temporarily disabled and the CB is posted on the synchornous event queue as an async event. This will be executed when the next normal event expires (e.g. at the end of the current quanta). After the event has been called, depending on wether the timer is cyclic or not, it will be reactivated. This means that if the emulator is paused, at most one call to the event handler will be issued, and this will be done when the emulator is resumed.
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
T |
double |
Delta seconds in the future for the first event to be posted. |
Flags |
unsigned int |
Set to TEMU_ASYNC_CYCLIC if the event should be executed as a cyclic event. |
CB |
void (*)(void *) |
Call back function on when timer expires |
Data |
void * |
Context data to be passed to the callback function |
temu_bitreverse16
temu_bitreverse32
temu_buffCopy
temu_buffDispose
temu_buffReadableData
temu_buffRemoveHead
Description
Remove len bytes from the start of the buffer.
Removing bytes from the buffer start will not change the underlying buffer object. And is not seen as a write for the purpose of the data block.
This does not affect other copies of this buffer.
temu_buffRemoveTail
Description
Remove len bytes from the end of the buffer.
Removing bytes from the buffer tail will not change the underlying buffer object. And is not seen as a write for the purpose of the data block.
This does not affect other copies of this buffer.
temu_buffWritableData
temu_checkSanity
Description
Check object system sanity.
The function traverses all objects and their properties and ensures that all (scalar) interface properties are connected. An object can override the default check by implementing the checkSanity function in the ObjectIface.
temu_classCmdAddParam
Signature
int temu_classCmdAddParam(void * Cmd, const char * Name, temu_CmdOptionKind Type, int Required, const char * Doc)
Parameters
Parameter | Type | Description |
---|---|---|
Cmd |
void * |
Command handle |
Name |
const char * |
Name of parameter to add |
Type |
temu_CmdOptionKind |
Type of the parameter |
Required |
int |
Set to 1 if the parameter must be set for the command |
Doc |
const char * |
Documentation string for the parameter |
temu_classCmdGetOption
temu_classCmdGetOptionAsInteger
Signature
int64_t temu_classCmdGetOptionAsInteger(int argc, const temu_CmdArg * args, const char * OptName)
temu_classCmdGetOptionAsUnsigned
Signature
uint64_t temu_classCmdGetOptionAsUnsigned(int argc, const temu_CmdArg * args, const char * OptName)
temu_classGetCmd
Description
Get an already registered command handle from class
This function can be used to for example get commands registered in the metaclass, such as the new command. The command can then have arguments added.
temu_cmdAddOption
Signature
void temu_cmdAddOption(void * Cmd, const char * OptName, temu_CmdOptionKind Type, int Required, const char * Doc, const char * Default)
Parameters
Parameter | Type | Description |
---|---|---|
Cmd |
void * |
Pointer to the command object |
OptName |
const char * |
Option name |
Type |
temu_CmdOptionKind |
Option type |
Required |
int |
Pass 0 if the option is not required, otherwise required |
Doc |
const char * |
Option documentation |
Default |
const char * |
Default value of the option |
temu_cmdGetData
temu_cmdGetInterpreter
temu_cmdGetOptionAsInteger
temu_cmdGetOptionAsObject
temu_cmdGetOptionAsReal
temu_cmdGetOptionAsString
temu_cmdGetPosOpt
temu_cmdGetPosOptSize
temu_cmdOptionIsValid
temu_componentAddDelegateIface
Signature
void temu_componentAddDelegateIface(temu_Component * Comp, const char * Name, temu_IfaceRef Iface)
Description
Add delegate interface to component
Delegate interfaces are interfaces in objects internal in the component. It is possible to use the connect function to attach directly to a component delegated interface (although, in practice the connection is done to the internal object’s interface).
Note that delegate interface do not support interface arrays, and can only expose a single interface instance at present.
temu_componentAddDelegateProp
Signature
void temu_componentAddDelegateProp(temu_Component * Comp, const char * Name, temu_Object * Obj, const char * PropName)
Description
Add delegate property to component
Delegate property are properties in objects internal in the component. It is possible to use the connect function to connect from a delegated property directly using the component instead of the underlying object.
temu_componentCreate
Description
Allocate a component object.
The component create shall be called in the component constructor/create function (the create function passed to the registerComponent function). It will allocate an opaque component object with the relevant name.
The returned component is what the component constructor should return.
temu_componentDispose
Description
Deallocate a component object
The component dispose shall be called by the component destructor/dispose function registered in the registerComponent call.
Note that a component is seen as owning all the objects created with createComponentObject, and subsequently, all objects created will be recursively deleted when deleting the component.
temu_componentGetDelegateIface
Description
Query the component for a delegated interface
Normally this function is not needed for the end user, however some usecases can be seen for exposing this. It returns the IfaceRef that has been added as a delegate interface. The main use is to redelegate delegated interfaces in a component of components.
temu_componentGetDelegateProp
Description
Query the compontent for a delegated property
Normally this should not be called by the user. But is useful in case the user constructs components of components in which case a component can redelegate delegated properties.
temu_componentGetObject
temu_connect
Signature
int temu_connect(temu_Object * A, const char * PropName, temu_Object * B, const char * IfaceName)
Description
Connect an interface property in object A to the interface in object B. If A.PropName is an interface array, B,B:IfaceName will be appended to it. For dynamic arrays, it is pushed to the end, for static arrays, it is placed in the first null slot (unless, the indexing syntax is used in the property name).
temu_cpuRaiseTrap
Parameters
Parameter | Type | Description |
---|---|---|
Cpu |
void * |
Processor pointer |
Trap |
int |
Trap ID. This is target dependent, for the SPARC this is the TT value of the trap. |
Flags |
unsigned int |
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_cpuReset
temu_cpuRun
Description
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.
temu_cpuSetPc
temu_cpuStep
Description
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.
temu_cpuTranslateAddress
temu_createClassCmd
Signature
void * temu_createClassCmd(temu_Class * Cls, const char * Name, const char * Doc, temu_ObjectCommandFunc F)
temu_createCmd
Signature
void * temu_createCmd(const char * Name, temu_CommandFunc F, const char * Doc, void * Data)
Parameters
Parameter | Type | Description |
---|---|---|
Name |
const char * |
Name of command |
F |
temu_CommandFunc |
Command function to invoke |
Doc |
const char * |
Documentation string |
Data |
void * |
Data pointer. Some commands e.g. disassemble will increase the address between invocations. This must be saved in some data object which can be provided when the command is created. |
temu_createComponentObject
Signature
temu_Object * temu_createComponentObject(temu_Component * Comp, const char * Class, const temu_CreateArg * Args, const char * ObjNameFmt, ...)
Description
Create an object in a component.
This function works as the temu_createObject, except that the object created is inserted in the component.
The function is indended to be used in the component constructor.
Object names are uniqued using the objnamefmt paramters and following varargs. Plus, that the name of the component itself is prefixed as '[compname]-'.
Parameters
Parameter | Type | Description |
---|---|---|
Comp |
The component under which the object is to be created. |
|
Class |
const char * |
class of the created object |
Args |
const temu_CreateArg * |
NULL terminated array of create arguments for the constructor. |
ObjNameFmt |
const char * |
Name of created object, but it allows for printf style string names, simplifying the creation of multiple objects of the same type. |
temu_createObject
Signature
temu_Object * temu_createObject(const char * ClsName, const char * ObjName, const temu_CreateArg * Args)
Result
Allocated object. Result is NULL in case of: class does not exist, object already allocated with the given name, out of memory.
Parameters
Parameter | Type | Description |
---|---|---|
ClsName |
const char * |
Name of class used for instantiation |
ObjName |
const char * |
Name of object in object system |
Args |
const temu_CreateArg * |
Named argument pairs to pass into constructor. The list of args should be terminated by a TEMU_NULL_ARG. In case no arguments are passed, pass in NULL. |
temu_cyclesToOtherFreqRoundedUp
temu_cyclesToOtherFreqTruncated
temu_cyclesToSteps
temu_cyclesToStepsRoundedUp
temu_deserialiseJSON
temu_deserialiseProp
temu_dictDispose
temu_dictGetNextKey
temu_dictGetValue
temu_dictInsertValue
temu_dictRemoveValue
temu_disassembleMemory
temu_disposeObject
temu_disposeSymtab
temu_eventDepublish
temu_eventGetCycles
temu_eventGetNanos
temu_eventGetSecs
temu_eventPostAsync
Signature
void temu_eventPostAsync(temu_TimeSource * TS, temu_ThreadSafeCb CB, void * Data, temu_SyncEvent Sync)
Parameters
Parameter | Type | Description |
---|---|---|
TS |
the asynchronous queue or time source object (normally a CPU object) |
|
CB |
temu_ThreadSafeCb |
The callback function to call when the event happens |
Data |
void * |
The context data to be passed to the callback function |
Sync |
temu_SyncEvent |
Execute on CPU or machine level. |
temu_eventPostCycles
Signature
void temu_eventPostCycles(temu_TimeSource * TS, int64_t EvID, int64_t Delta, temu_SyncEvent Sync)
Description
Post events with a relative time in cycles in the future
Note that if posting a scheduled event, a warning will be printed and the event will be automatically descheduled before being inserted in the event queue.
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
Delta |
int64_t |
The number of CPU clock cycles in the future to post the event. This should be > 0. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPostCyclesAbsolute
Signature
void temu_eventPostCyclesAbsolute(temu_TimeSource * TS, int64_t EvID, int64_t AbsTime, temu_SyncEvent Sync)
Description
Post events with an absolute time in cycles The function is only well defined for times >= current time. Timestamps
current time will have undefined behaviour.
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
AbsTime |
int64_t |
The absolute time stamp to run the event at, this should be > current time. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPostNanos
Signature
void temu_eventPostNanos(temu_TimeSource * TS, int64_t EvID, int64_t Delta, temu_SyncEvent Sync)
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
Delta |
int64_t |
The number of nanoseconds in the future to post the event. This should be > 0. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPostNanosAbsolute
Signature
void temu_eventPostNanosAbsolute(temu_TimeSource * TS, int64_t EvID, int64_t AbsTime, temu_SyncEvent Sync)
Description
Post events with an absolute time in nanoseconds The function is only well defined for times >= current time. Timestamps
current time will have undefined behaviour.
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
AbsTime |
int64_t |
The absolute time stamp to run the event at, this should be > current time. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPostSecs
Signature
void temu_eventPostSecs(temu_TimeSource * TS, int64_t EvID, double Delta, temu_SyncEvent Sync)
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
Delta |
double |
The number of seconds in the future to post the event. This should be > 0. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPostStack
Description
Post events in the event queue stack
Stacked events are executed either after the current instruction is finished or when the machine quanta expires in case of machine synchronised events.
temu_eventPostSteps
Signature
void temu_eventPostSteps(temu_TimeSource * TS, int64_t EvID, int64_t Delta, temu_SyncEvent Sync)
Description
Post events with a relative trigger in steps
Posting an event in steps is not effected by the IPC/CPI setting of the clock.
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
Delta |
int64_t |
The number of CPU steps in the future to post the event. This should be > 0. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventPublish
Description
Publish an event.
The function will allocate an event structure in the global event heap and return the event ID.
A typical use is to call the function in the object constructor and assign the event id to a field in the object. This field should not be snapshotted (i.e. it will be reassigned in the constructor) when restoring an object anyway.
This function is non thread safe. Object construction is expected to be done in a single thread (e.g. the main thread). |
temu_eventPublishStruct
Signature
int64_t temu_eventPublishStruct(const char * EvName, temu_Event * Ev, void * Obj, void (*)(temu_Event *) Func)
Description
Publish a preallocated event object.
The event objects can be embedded in your own class if needed.
temu_eventQueueGetFreq
temu_eventRescheduleCycles
Signature
void temu_eventRescheduleCycles(temu_TimeSource * TS, int64_t EvID, int64_t Delta, temu_SyncEvent Sync)
Description
Reschedule event with relative time in cycles
This function automatically deschedules the event before scheduling it again. The function ensures only one lock is taken for the pattern:
-
is scheduled?
-
de-schedule
-
post
Parameters
Parameter | Type | Description |
---|---|---|
TS |
The time source object (normally a CPU object) |
|
EvID |
int64_t |
The even ID returned by one of the event publish functions. |
Delta |
int64_t |
The number of CPU clock cycles in the future to post the event. This should be > 0. |
Sync |
temu_SyncEvent |
whether the event should be executed on the CPU queue or the machine queue. |
temu_eventSetPeriodCycles
Description
Set the cycles property on an event.
Periodic events have the advantage that they do not slip due to reposting of event with respect to the event triggering time and behaves as if the reposting is 1, automatic and 2, is relative to the event schedule time. which differ from the triggering time by possibly a few cycles. Note, calling this function does not reschedule the event.
temu_eventSetRTPeriodNanos
temu_eventSetRTTime
temu_eventSetRealTime
Description
Mark an event as real-time.
With a real-time event, it is meant that the event will execute at roughly real-time. In the case when the event is posted, it will compute a rough triggering time in wall clock. When the event is executed it will do two things:
-
Check if the event wall-clock time is before the current time, if so emit a "temu.realtime-slip" notification".
-
Check if the event is triggered in the future (with respect to wall clock), if so sleep until the wall-clock has caught up.
Due to the behaviour, the real-time events are suitable only for relatively short event times, as long sleep times may make the emulator non responsive. Especially at present, this will block the execution of async events as the event queue is halted until the wall-clock catches up to the simulated time.
Note that RT event support is primarily used to slow down the emulator artificially, this is accomplished by enabling real-time mode on the relevant model.
This function should only be called on in-flight events.
temu_foreachClass
temu_foreachInterface
Signature
void temu_foreachInterface(temu_Class * C, void (*)(temu_Class *, const char *, void *) Func, void * Arg)
Description
Call function on every interface in a class. The function is called with the class pointer, interface name and the argument. NOTE: This function is experimental.
temu_foreachObject
temu_foreachProcessor
temu_foreachProperty
Signature
void temu_foreachProperty(temu_Class * C, void (*)(temu_Class *, const char *, void *) Func, void * Arg)
Description
Call function on every property in a class. The function is called with the class pointer, property name and the argument. NOTE: This function is experimental.
temu_generateObjectGraph
temu_getCycles
temu_getFieldValue
Signature
uint64_t temu_getFieldValue(temu_Object * Obj, const char * RegName, unsigned int RegIdx, const char * FieldName)
temu_getInterfaceName
temu_getInterfaceRef
temu_getLoggingCategory
temu_getModelRegisterBankInfo
temu_getNanos
temu_getPropAccessor
Signature
temu_PropAccessor temu_getPropAccessor(temu_Object * Obj, const char * PropName, int PropIdx)
Description
Get a reference to the named property
This is useful as a replacement of temu_getPropref and temu_getPropName. The resulting data structure lets you automatically disambiguate between properties and pseudo properties.
The index used will be PropIdx,
or K if the PropName string has an array suffix [K]
.
temu_getPropDynLength
temu_getPropName
temu_getPropref
temu_getRegister
temu_getRegisterBank
temu_getRegisterBankName
temu_getRegisterColdResetValue
Description
Returns the cold reset value of the register (computed from the field info data). Cold reset is also known as a hard reset, and implies that the power has been off for some time.
temu_getRegisterDocs
temu_getRegisterInfo
temu_getRegisterName
temu_getRegisterReadMask
temu_getRegisterWarmResetValue
temu_getRegisterWriteMask
temu_getSecs
temu_getSteps
temu_getVTable
temu_getVTableForClass
temu_getValue
temu_getValueDouble
temu_getValueI16
temu_getValueI32
temu_getValueI64
temu_getValueI8
temu_getValueSigned
temu_getValueU16
temu_getValueU32
temu_getValueU64
temu_getValueU8
temu_getValueUnsigned
temu_ifaceRefArrayGet
temu_ifaceRefArrayPush
temu_ifaceRefArrayPush2
temu_ifaceRefArraySize
temu_indexForInterface
temu_initLicense
temu_initPathSupport
Description
Initialise path finding support
This function initialises auxillary path support needed by TEMU for locating supporting tools (e.g. stuff in libexec) and automatically appending of scripting search paths.
In the future, this will likely be merged into initSupportLib for a unified init function, but this will break API compatibility, so this change is deferred to TEMU 3.
Call the Function passing Argv0 of whatever you would do to invoke the temu command line tool. E.g. if temu is in your path and this is the installation you wish to use, the parameter should be "temu". However, if you wish to use a custom installation, pass the full path to the temu program. The base path can contain ~ for the current home dir and ~foo for the home dir of user foo.
Note that it is not an error to omit this initialisation, but omitting it will imply that temu cannot launch UI models such as the ConsoleUI model.
temu_initSupportLib
Description
Initialisation of TEMU support library.
Call this function before any other use of TEMU. The function does not return failures, but halts on failed initialisation.
The function should be called as early as possible in the application’s execution. Preferably in the main function (though there is no strict requirement for this).
The initialisation function is at present not thread safe, call it in the main thread only!
temu_inlineDeserialiseJSON
Description
De-serialise the simulation state.
This function directly restores properties on already created objects. It does not clear the objects system. Thus pointers to objects remains stable after a snapshot restore.
If a class implements the ObjectIface, the (optional) deserialise procedure will be called.
temu_isCpu
temu_isMachine
temu_isNormalProperty
temu_isPseudoProperty
temu_listAppend
temu_listDispose
temu_listGetHead
temu_listGetNext
temu_listGetPrev
temu_listGetTail
temu_listNodeGetVal
temu_listPrepend
temu_listRemoveHead
temu_listRemoveTail
temu_loadBinaryImage
temu_loadElfImageAndStartAddr
temu_loadImage
temu_loadImageAndStartAddr
Description
Loads a binary image to the memory object.
The function will autodetect the file type (based on extensions and magic headers in the file).
Binary images will be placed at address 0.
The image can be one of the supported file formats.
This specific variant, will return the start address of the binary, the StartAddr is typically embedded in the ELF or SREC files. The function therefore allows you to set the program counter to the correct start address after the function has been called.
temu_loadPlugin
Description
Load a plugin. When a plugin is loaded the temu_pluginInit function will be called. This function should create and define any classes that the plugin provides.
The function loads plugins following the operating system’s loading rules. This means in particular that first, the plugin will be found in the RPATH location of libTEMUSupport (which refers to the TEMU lib directory). Secondly, it will look in the LD_LIBRARY_PATH and other standard load directories.
In practice, it will look for lib Plugin .so in the TEMU plugin paths, or libTEMU Plugin .so in the same paths. It will then fallback on attempting to load libTEMU Plugin .so from the system load paths. If the plugin name contains a slash '/' it will be treated as a path and not a plugin name.
temu_loadPluginGlobal
Description
Load a plugin. When a plugin is loaded the temu_pluginInit function will be called. This function should create and define any classes that the plugin provides.
The plugin will be made available globally for the linker (e.g. using RTLD_GLOBAL).
This is not recommended for normal TEMU plugins.
The function loads plugins following the operating system’s loading rules. This means in particular that first, the plugin will be found in the RPATH location of libTEMUSupport (which refers to the TEMU lib directory). Secondly, it will look in the LD_LIBRARY_PATH and other standard load directories.
In practice, it will look for lib Plugin .so in the TEMU plugin paths, or libTEMU Plugin .so in the same paths. It will then fallback on attempting to load libTEMU Plugin .so from the system load paths. If the plugin name contains a slash '/' it will be treated as a path and not a plugin name.
temu_loadSrecImageAndStartAddr
temu_loadSymtab
Description
Loads the symbol table from a given ELF file.
The symbol table is allocated and the pointer of the allocated symbol table is placed in Sym. The user is responsible for disposing the symbol table with temu_disposeSymtab().
temu_logSetAdvancedFunc
Signature
void temu_logSetAdvancedFunc(void (*)(void *, temu_Object *, unsigned int, temu_LogLevel, const char *) LogFunc, void * UserData)
Description
Set advanced logging function.
It is possible to provide a custom function for handling logging messages from TEMU. This can be used by a simulator that provides a centralized logging facility to also handle TEMU logging messages. By default, the messages will be printed to stderr using fputs.
The advanced logging function does not get messages with a terminating linefeed. In addition, the function receives the object, category and log level as its own parameters.
The message does not contain object name / time stamps. The integrator would be expected to extract the time stamp from the objects time source if set.
LogFunc will take the following parameters:
- User data
-
Void pointer passed to UserData parameter (may be NULL).
- Object pointer
-
Pointer to object issuing the log message (may be NULL).
- Category
-
Category id of log message.
- Log level
-
Severity of logging message.
- Message
-
The log message, as a '
' terminated string.
temu_logSetDefaultFile
temu_logSetFunc
Description
Set logging function.
It is possible to provide a custom function for handling logging messages from TEMU. This can be used by a simulator that provides a centralized logging facility to also handle TEMU logging messages. By default, the messages will be printed to stderr using fputs. Note that messages will be terminated by " n
", so if your logging system adds a linefeed, the message may need to be transformed.
temu_logSetLevel
temu_logTargetFatal
temu_logToCategory
Signature
void temu_logToCategory(const void * Obj, unsigned int Category, temu_LogLevel Severity, const char * Msg, ...)
Parameters
Parameter | Type | Description |
---|---|---|
Obj |
const void * |
Object that is the source of the log message |
Category |
unsigned int |
Category of message (e.g. |
Severity |
temu_LogLevel |
The log level for which the message shall be emitted. |
Msg |
const char * |
Printf formatted message string. |
temu_machineReset
temu_machineRun
temu_mapMemorySpace
Parameters
Parameter | Type | Description |
---|---|---|
Obj |
void * |
The memory space object |
Addr |
uint64_t |
Physical address where to map the device |
Len |
uint64_t |
Length in bytes of area where the object is mapped. |
MemObj |
The memory object. This object must correspond to the MemAccessIface |
temu_mapMemorySpaceFlags
Signature
int temu_mapMemorySpaceFlags(void * Obj, uint64_t Addr, uint64_t Len, temu_Object * MemObj, uint32_t Flags)
Parameters
Parameter | Type | Description |
---|---|---|
Obj |
void * |
The memory space object |
Addr |
uint64_t |
Physical address where to map the device |
Len |
uint64_t |
Length in bytes of area where the object is mapped. |
MemObj |
The memory object. This object must correspond to the MemAccessIface |
|
Flags |
uint32_t |
Sticky flags for memory accesses to that object (e.g. cachable) |
temu_memoryMap
Signature
int temu_memoryMap(void * Obj, uint64_t Addr, uint64_t Len, void * MemObj, uint32_t Flags)
Description
temu_memoryMap Maps an object into a memory space. The object must have an interface named MemAccessIface, of the type defined as TEMU_MEM_ACCESS_IFACE_TYPE
Parameters
Parameter | Type | Description |
---|---|---|
Obj |
void * |
is the memory space object |
Addr |
uint64_t |
the physical address |
Len |
uint64_t |
the length in bytes |
MemObj |
void * |
is the object that is mapped into the memory space it needs to be of a class that follows the rules above |
Flags |
uint32_t |
are flags that are copied into the memory transaction object’s flag field when a transaction reaches an object |
temu_memoryMapNamedIface
Signature
int temu_memoryMapNamedIface(void * Obj, uint64_t Addr, uint64_t Len, void * MemObj, const char * IfaceName, uint32_t Flags)
Description
temu_memoryMapNamedIface Maps an object into a memory space using the named memory access interface. The interface named by IfaceName must be of the type TEMU_MEM_ACCESS_IFACE_TYPE
Parameters
Parameter | Type | Description |
---|---|---|
Obj |
void * |
is the memory space object |
Addr |
uint64_t |
the physical address |
Len |
uint64_t |
the length in bytes |
MemObj |
void * |
is the object that is mapped into the memory space it needs to be of a class that follows the rules above |
IfaceName |
const char * |
Name of the memory access interface |
Flags |
uint32_t |
are flags that are copied into the memory transaction object’s flag field when a transaction reaches an object |
temu_memoryRead
Result
Negative on failures. Other values indicate success. The convention is to return the number of bytes read which should be == size.
Parameters
Parameter | Type | Description |
---|---|---|
mem |
void * |
Pointer to memory space object |
buff |
uint8_t * |
The buffer to which the memory should be stored |
addr |
uint64_t |
The address of the memory block to be read |
size |
uint32_t |
The size to be read |
swap |
int |
setting this to 0 indicates reading a byte array, 1 a uint16 array, 2 a uint32 array and 3 a uint64 array |
temu_memoryReadData
Signature
int temu_memoryReadData(void * obj, uint64_t addr, uint8_t * buff, unsigned int unitSize, uint32_t size, unsigned int flags)
Parameters
Parameter | Type | Description |
---|---|---|
obj |
void * |
Memory space object |
addr |
uint64_t |
Physical address inside memory space |
buff |
uint8_t * |
Data buffer |
unitSize |
unsigned int |
Log size of transaction unit size (0 = u8, 1 = u16, 2 = u32, 3 = u64) |
size |
uint32_t |
Number of units to transfer |
flags |
unsigned int |
Memory transaction flags (e.g. TEMU_MT_LITTLE_ENDIAN) |
temu_memoryWrite
Result
Negative on failure. Other values indicate success. The convention is to return the number of bytes written, which should be == size.
Parameters
Parameter | Type | Description |
---|---|---|
mem |
void * |
Pointer to memory space object |
buff |
uint8_t * |
The buffer to which the memory should be stored |
addr |
uint64_t |
The address, at which the write should be done |
size |
uint32_t |
The size to be read |
swap |
int |
Negative on failures. Other values indicate success. |
temu_memoryWriteData
Signature
int temu_memoryWriteData(void * obj, uint64_t addr, const uint8_t * buff, unsigned int unitSize, uint32_t size, unsigned int flags)
Parameters
Parameter | Type | Description |
---|---|---|
obj |
void * |
Memory space object |
addr |
uint64_t |
Physical address inside memory space |
buff |
const uint8_t * |
Data buffer |
unitSize |
unsigned int |
Log size of transaction unit size (0 = u8, 1 = u16, 2 = u32, 3 = u64) |
size |
uint32_t |
Number of units to transfer |
flags |
unsigned int |
Memory transaction flags (e.g. TEMU_MT_LITTLE_ENDIAN) |
temu_nameForClass
temu_nanosToCycles
temu_nanosToCyclesRoundedUp
temu_normaliseRead16
temu_normaliseRead32
temu_normaliseWrite16
Description
Normalise a value for writes where only 16 bit transactions are supported by the device model, but the target is allowed to write non-16 bit quantity. The function mixes the old register value with the new one based on the size and offset parameter. The problem exists because the memory access interface has a value entry, which always ends up in the lower bits, so if we write to the higher bits in in a 16 bit register, then by just forwarding the the value as is to the write handler, will result in a write of the lower bits and a clear of the upper bits (for a store unsigned).
Thus a normalisation is neded where we mix the written word with the old bits. So for transaction size of 8, and an offset of8, the resulting word is (old
0x00ff) | (new
8)
temu_normaliseWrite32
Description
Normalise a value for writes where only 32 bit transactions are supported by the device model, but the target is allowed to write non-32 bit quantity. The function mixes the old register value with the new one based on the size and offset parameter. The problem exists because the memory access interface has a value entry, which always ends up in the lower bits, so if we write to the higher bits in in a 32 bit register, then by just forwarding the the value as is to the write handler, will result in a write of the lower bits and a clear of the upper bits (for a store unsigned).
Thus a normalisation is needed where we mix the written word with the old bits. So for transaction size of 16, and an offset of 16, the resulting word is (old
0x0000ffff) | (new
16)
temu_notify
temu_notifyFast
temu_objectInvokeCmd
Signature
int temu_objectInvokeCmd(temu_Object * Obj, void * I, const char * Name, int Argc, temu_CmdArg * Argv)
temu_parseCommandLineOptions
Description
Parses command line options The TEMU command supports a number of built in command line options. A simulator embedding TEMU may want initialise these options in the same way that the TEMU CLI does. Note that not all options are supported this way as some options will only be registered by the temu CLI application itself.
In general interactive options will not work (options that can be interpreted as a command). It is possible to use temu_printCommandLineHelp() to list currently registered options from an application that embedds temu.
temu_pluginPathRemove
temu_postCallback
Description
Post a callback in a time source
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:
-
At the end of the current time quanta for multi-cpu systems.
-
At regular intervals for single CPU systems (a CPU runs a null-event periodically. Note that the callback will be called as soon as either a normal or the null event is executed.
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:
-
Manipulate the object system meta state (i.e. creating or modifying classes)
-
Replace signal handlers (e.g. SIGINT)
-
Run or step the emulator in any way (e.g. by calling machineRun(), cpuRun() or using the CpuIface or MachineIface interfaces.
temu_printerr
Description
fprintf(stderr, …) wrapper. The function prints a formatted message to what TEMU considers to be the standard error. This function respects internal rerouting rules. Unlike plain fprintf, which writes to an explicit file.
The function is limited in that it keeps a local fixed length buffer for printing. This buffer is currently 1024 bytes, hence it is not possible to print messages longer than 1023 bytes.
temu_printf
Description
Printf wrapper. The function prints a formatted message to what TEMU considers to be the standard output. This function respects internal rerouting rules. Unlike plain printf, which writes only to stdout.
The function is limited in that it keeps a local fixed length buffer for printing. This buffer is 1024 bytes, hence it is not possible to print messages longer than 1023 bytes.
temu_propInfoForClass
Signature
int temu_propInfoForClass(temu_Class * Cls, unsigned int PIIndex, unsigned int PICount, temu_PropInfo * PI)
Description
Get property info for class
It is possible to extract low level property info data using this function. This can be useful if integrating in another simulator or if integrating the system in e.g. a GUI in which you need to provide object introspection.
The function can be called with the PI array set to NULL to return the number of properties in the class.
You can read out all property fields using the following sequence:
temu_publishNotification
temu_qualifyAs
temu_qualifyAsCpu
Description
Bless the class so that the isCpu predicate returns 1. There are certain assumptions that CPU classes must meet. These assumptions are not stable yet, so do not use this in user code.
temu_qualifyAsMachine
Description
Bless the class so that the isMachine predicate returns 1. There are certain assumptions that machine classes must meet. These assumptions are not stable yet, so do not use this in user code.
temu_qualifyAsMemory
temu_readFieldValue
Signature
uint64_t temu_readFieldValue(temu_Object * Obj, const char * RegName, unsigned int RegIdx, const char * FieldName)
temu_readPCIeConfigRegister
temu_readProp
temu_readValue
Result
The property value corresponding to the name. In case of the property not being found, the Typ field of the returned property will be teTY_Invalid.
temu_readValueDouble
temu_readValueI16
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueI32
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueI64
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueI8
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueSigned
temu_readValueU16
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueU32
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueU64
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueU8
Description
Read typed properties.
The readValue[U|I][8|16|32|64] function reads a typed property. The accessor will fail with a fatal error if the read type is not the same as the property type. If the property type is unknown, use the temu_readValue function instead.
temu_readValueUnsigned
temu_registerClass
Signature
temu_Class * temu_registerClass(const char * ClsName, temu_ObjectCreateFunc Create, temu_ObjectDisposeFunc Dispose)
Description
Register a class in the TEMU object system. With these classes, the TEMU object system is responsible for allocation and de-allocation.
Result
A pointer to the class object that can be further used to register properties and interfaces.
Parameters
Parameter | Type | Description |
---|---|---|
ClsName |
const char * |
The name of the class that is to be created. |
Create |
temu_ObjectCreateFunc |
A constructor, the constructor is responsible for allocation and initialisation of the object. |
Dispose |
temu_ObjectDisposeFunc |
A destructor, this function is responsible for deleting the objects of the class. |
temu_registerComponent
temu_requireInterface
Signature
void temu_requireInterface(temu_Class * Cls, const char * PropName, const char * IfaceType)
Description
Associate the interface reference property with an interface type.
Setting the type, prevents the connect command / function to assign the connection if the target interface type is not the same as the property interface reference type.
temu_serialiseJSON
Description
Serialise the simulation state to the given file name.
The serialisation writes a JSON formatted file and calls the serialise procedure in the (optional) ObjectIface if it is implemented.
The serialisation interface can for example be used to write out memory buffers to separate files as such data should not be written to a JSON file.
temu_serialiseProp
Signature
void temu_serialiseProp(void * Ctxt, const char * Name, temu_Type Typ, int Count, void * Data)
Description
Serialise an explicit property, this can be called from the serialisiation interface. Note that the availability of pseudo properties makes this function and the serialise interface more or less obsolete.
Parameters
Parameter | Type | Description |
---|---|---|
Ctxt |
void * |
The context object that has the property (same as passed to serialise function in the interface) |
Name |
const char * |
The name of the property |
Typ |
temu_Type |
The type of the property |
Count |
int |
0 if the property is not an array, otherwise the element number in the property |
Data |
void * |
Serialized data |
temu_setFieldValue
Signature
int temu_setFieldValue(temu_Object * Obj, const char * RegName, unsigned int RegIdx, const char * FieldName, uint64_t Value)
temu_setTimeSource
temu_setVTable
Description
Set the VTable pointer.
Temu classes, provides the ability to, for internal objects query for a VTable manually in O(1) time. In practice this can be any pointer, but it is typically used to register performance sensitive interfaces. E.g. the CPU and machine classes have their own VTable types that refer to a number of interfaces they implement.
temu_setValue
temu_setValueDouble
temu_setValueI16
temu_setValueI32
temu_setValueI64
temu_setValueI8
temu_setValueSigned
temu_setValueU16
temu_setValueU32
temu_setValueU64
temu_setValueU8
temu_setValueUnsigned
Signature
void temu_setValueUnsigned(temu_Object * Obj, const char * PropName, uint64_t Val, int Idx)
temu_sparcSetNPc
temu_step
Description
Step a processor in the current scheduler
Note that, the other processors may run if the step exceeds the quanta. The step function currently runs processors in sequence, it is not running processors in parallel. This means that stepping is always deterministic.
temu_stepsToCycles
temu_stepsToCyclesRoundedUp
temu_subscribeNotification
Signature
int temu_subscribeNotification(const char * NotName, temu_Object * Source, void * Arg, temu_NotificationHandler NotFunc)
Parameters
Parameter | Type | Description |
---|---|---|
NotName |
const char * |
Name of the notification |
Source |
If source is NULL, the event subscriber will be notified by all the sources for the given name. |
|
Arg |
void * |
Context argument to be passed to the callback notification function |
NotFunc |
temu_NotificationHandler |
The callback function on notification |
temu_swapBigHost16
temu_swapBigHost32
temu_swapBigHost32Half
temu_swapBigHost64
temu_swapBigHost64Word
temu_swapLittleHost16
temu_swapLittleHost32
temu_swapLittleHost32Half
temu_swapLittleHost64
temu_swapLittleHost64Word
temu_symtabGetFuncName
Signature
void temu_symtabGetFuncName(temu_Symtab * Sym, const char ** LocalFile, const char ** Symbol, uint64_t Addr)
Description
Get the function name associated with the given address
The address can be any address within the range of the function, i.e. from the start to othe end of the function. Thus this serves as a way to find the name of the current function given a PC value.
The function first searches for local symbols (e.g. static symbols in C). It then searches for global symbols and last for weak symbols.
If a local symbol is found, the LocalFile pointer will point at a string with the file name it is associated to, otherwise the local file pointer will be set to null.
The returned pointers are valid until the symbol table is disposed.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
Symboltable |
|
LocalFile |
const char ** |
The pointer it refers to will be set to NULL if the symbol found is global. |
Symbol |
const char ** |
The pointer will be set to NULL if a function cannot be found at the address. |
Addr |
uint64_t |
Virtual address to find a function name for. |
temu_symtabGetGlobalFuncRange
Signature
int temu_symtabGetGlobalFuncRange(temu_Symtab * Sym, const char * FuncName, uint64_t * Addr, uint64_t * Size)
Description
Get the range of a global function
On success, the Addr and the Size references will be set to the starting virtual address of the function and the size in bytes respectively.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
The Symbol table, from which the function is to be retrieved |
|
FuncName |
const char * |
The function, whose range is required |
Addr |
uint64_t * |
On success, gives the address of the function |
Size |
uint64_t * |
On success, gives the size of the function start from Addr |
temu_symtabGetGlobalObjRange
Signature
int temu_symtabGetGlobalObjRange(temu_Symtab * Sym, const char * ObjectName, uint64_t * Addr, uint64_t * Size)
Description
Get the range of a global object
On success, the Addr and the Size references will be set to the starting virtual address of the object and the size in bytes respecivelly.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
The Symbol table, from which the object to be retrieved |
|
ObjectName |
const char * |
Name of the object, whose address range is to be obtained |
Addr |
uint64_t * |
On success, gives the address of the object |
Size |
uint64_t * |
On success, gives the size of the object start from Addr |
temu_symtabGetLocalFuncRange
Signature
int temu_symtabGetLocalFuncRange(temu_Symtab * Sym, const char * FileName, const char * FuncName, uint64_t * Addr, uint64_t * Size)
Description
Get the range of a local/static function
On success, the Addr and the Size references will be set to the starting virtual address of the function and the size in bytes respectively.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
The Symbol table, from which the function to be retrieved |
|
FileName |
const char * |
The file/compilation unit that contains the function |
FuncName |
const char * |
The function, whose range is required |
Addr |
uint64_t * |
On success, gives the address of the function |
Size |
uint64_t * |
On success, gives the size of the function start from Addr |
temu_symtabGetLocalObjRange
Signature
int temu_symtabGetLocalObjRange(temu_Symtab * Sym, const char * FileName, const char * ObjectName, uint64_t * Addr, uint64_t * Size)
Description
Get the range of a local/static object
On success, the Addr and the Size references will be set to the starting virtual address of the object and the size in bytes respecivelly.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
The Symbol table, from which the object to be retrieved |
|
FileName |
const char * |
The file/compilation unit that contains the function |
ObjectName |
const char * |
The object, whose range is required |
Addr |
uint64_t * |
On success, gives the address of the object |
Size |
uint64_t * |
On success, gives the size of the object start from Addr |
temu_symtabGetObjName
Signature
void temu_symtabGetObjName(temu_Symtab * Sym, const char ** LocalFile, const char ** Symbol, uint64_t Addr)
Description
Get the object name associated with the given address
The address can be any address within the range of the object. Thus this serves as a way to find the name of a global or static object given an address.
The function first searches for local symbols (e.g. static symbols in C). It then searches for global symbols and last for weak symbols.
If a local symbol is found, the LocalFile pointer will point at a string with the file name it is associated to, otherwise the local file pointer will be set to NULL.
The returned pointers are valid until the symbol table is disposed.
Parameters
Parameter | Type | Description |
---|---|---|
Sym |
Symboltable |
|
LocalFile |
const char ** |
The pointer it refers to will be set to NULL if the symbol found is global. |
Symbol |
const char ** |
The pointer will be set to NULL if an object cannot be found at the address. |
Addr |
uint64_t |
Virtual address to find an object name for. |
temu_timeGetCurrentSrtNanos
temu_timeGetMonotonicWct
Description
Get monotonic time in nanoseconds.
The monotonic time is relative since some epoch of undefined start, but it is monotonic, unaffected by adjustments due to leap seconds, setting of the system clock, etc.
This function is primarily useful for doing performance measurements since the time returned is relative to an undefined point (although that undefined point will be consistent while the program is running).
In practice, on systems with clock_gettime() implemented, this function returns the timespec converted to nanoseconds, but on systems without clock_gettime(), e.g. Darwin and Windows, the function will only ensure that some notion of monotonic nanoseconds are returned. In Darwin for example, this results in a monotonic time returned which is relative to the first call to the function.
temu_unsubscribeNotification
Signature
int temu_unsubscribeNotification(const char * NotName, temu_Object * Source, temu_NotificationHandler NotFunc)
Description
Remove notification handler for the given name and source. Note that this function runs in O(N) time. It is not meant for being used in performance critical code.
Parameters
Parameter | Type | Description |
---|---|---|
NotName |
const char * |
Name of the notification |
Source |
If source is NULL, the event subscriber will be notified by all the sources for the given name. |
|
NotFunc |
temu_NotificationHandler |
The callback function to be called on notification |
temu_unsubscribeNotificationArg
Signature
int temu_unsubscribeNotificationArg(const char * NotName, temu_Object * Source, temu_NotificationHandler NotFunc, void * Arg)
Description
Remove notification handler for the given name, source and arg. Note that this function runs in O(N) time. It is not meant for being used in performance critical code.
Parameters
Parameter | Type | Description |
---|---|---|
NotName |
const char * |
Name of the notification |
Source |
If source is NULL, the event subscriber will be notified by all the sources for the given name. |
|
NotFunc |
temu_NotificationHandler |
The callback function to be called on notification |
Arg |
void * |
Context argument to be passed to the callback notification function |
temu_vecDispose
temu_vecGetData
temu_vecGetSize
temu_vecPush
temu_writeFieldValue
Signature
int temu_writeFieldValue(temu_Object * Obj, const char * RegName, unsigned int RegIdx, const char * FieldName, uint64_t Value)
temu_writePCIeConfigRegister
Signature
void temu_writePCIeConfigRegister(temu_PCIExpressConfig * devConf, uint32_t offset, uint32_t value)
temu_writeProp
temu_writeValue
temu_writeValueDouble
temu_writeValueI16
temu_writeValueI32
temu_writeValueI64
temu_writeValueI8
temu_writeValueObj
Signature
void temu_writeValueObj(temu_Object * Obj, const char * PropName, temu_Object * Val, int Idx)
temu_writeValueSigned
Signature
void temu_writeValueSigned(temu_Object * Obj, const char * PropName, int64_t Val, int Idx)
temu_writeValueU16
temu_writeValueU32
temu_writeValueU64
temu_writeValueU8
temu_writeValueUnsigned
Signature
void temu_writeValueUnsigned(temu_Object * Obj, const char * PropName, uint64_t Val, int Idx)