C H A P T E R 1 |
Configuration API |
This chapter describes the components and functions of the Configuration API. Topics include:
You can use the hardware architecture API to describe the target hardware architecture of the application.
The file teja_hardware_architecture.h file contains the declaration of the data types and API functions.
The hardware architecture definitions use the following data types.
Creates a new architecture with the specified name. The new architecture is contained in the container architecture. The top-level architecture is created by passing NULL as value for container. Legal values for the type parameter are found in the chip support package (CSP) specific properties, characterized by the TEJA_ARCHITECTURE_ prefix. Most of the types result in a read-only, preconfigured architecture. To create custom architectures, use the TEJA_ARCHITECTURE_USER_DEFINED value for type.
teja_architecture_t teja_architecture_create(teja_architecture_t container,
const char *name, const char *type);
container - Container for the new architecture.
name - Name of the new architecture.
type - Type of the architecture.
teja_architecture_t - value that can be used as handle for the new architecture
Sets the value of the property for the architecture object.
int teja_architecture_set_property(teja_architecture_t arch,
const char *property-name, const char *value);
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the value of the property for the architecture object. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_architecture_get_property(teja_architecture_t arch,
const char *property-name, char *value, int buf-size);
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Prevents modification of given architecture by subsequent processing.
int teja_architecture_set_read_only(teja_architecture_t arch);
int - Returns TEJA_SUCCESS or error code for failure.
teja_processor_t teja_processor_create(teja_architecture_t container,
const char *name, const char *type);
container - Container of the new processor.
name - Name of the new processor.
type - Type of the new processor.
teja_processor_t - Returns newly created processor object.
Sets the value of the property for the processor object.
int teja_processor_set_property(teja_processor_t processor,
const char *property-name, const char *value);
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the value of the property for the processor object. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_processor_get_property(teja_processor_t processor,
const char *property-name, char *value, int buf-size);
property-name - Name of the property.
value - Value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Adds a preprocessor symbol to the processor. All of the processes running on the processor have the same symbol defined. The function adds convenience when passing values from the hardware architecture code into the user code.
int teja_processor_add_preprocessor_symbol(teja_processor_t processor,
const char *symbol, const char *value);
processor - Processor instance to which the symbol is added.
int - Returns TEJA_SUCCESS or error code for failure.
teja_memory_t teja_memory_create(teja_architecture_t container,
const char *name, const char *type);
container - Container of the new memory.
name - Name of the new memory.
type - Type of the new memory.
teja_memory_t - Returns the newly created memory object.
Sets the value of the property for the memory object.
int teja_memory_set_property(teja_memory_t memory,
const char *property-name, const char *value);
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the value of the property for the memory object. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_memory_get_property(teja_memory_t memory,
const char *property-name, char *value, int buf-size);
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
teja_bus_t teja_bus_create(teja_architecture_t container,
const char *name, const char *type, teja_bus_visibility_t v);
container - Container of the new bus.
teja_bus_t - Returns newly created bus object.
Sets the value of the property for the bus object.
int teja_bus_set_property(teja_bus_t bus, const char *property-name,
const char *value);
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the value of the property for the bus object. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_bus_get_property(teja_bus_t bus, const char *property-name,
char *value, int buf-size);
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
teja_hardware_object_t teja_hardware_object_create(
teja_architecture_t container, const char *name, const char *type);
container - Container of the new hardware object.
name - Name of the new hardware object.
type - Type of the new hardware object.
teja_hardware_object_t - Returns newly created hardware object.
Sets the value of the property for the hardware object.
int teja_hardware_object_set_property(teja_hardware_object_t hardware-object,
const char *property-name, const char *value);
hardware-object - Hardware object.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the value of the property for the hardware_object. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_hardware_object_get_property(teja_hardware_object_t hardware-object,
const char *property-name, char *value, int buf-size);
hardware-object - Hardware object.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Connects an architecture to a bus.
int teja_architecture_connect(teja_architecture_t architecture,
const char *bus-name, teja_bus_t bus);
architecture - Architecture object that needs to be connected.
bus-name - Name of the bus inside the architecture that is connected to the bus.
bus - Bus object that needs to be connected to the architecture.
int - Returns TEJA_SUCCESS or error code for failure.
Connects a processor to a bus.
int teja_processor_connect(teja_processor_t processor, const char *bus-name,
teja_bus_t bus);
processor - Processor object that needs to be connected.
bus-name - Name of the bus inside the processor that is connected to the bus.
bus - Bus object that needs to be connected to the processor.
int - Returns TEJA_SUCCESS or error code for failure.
int teja_memory_connect(
teja_memory_t memory, const char *bus-name, teja_bus_t bus);
memory - Memory object that needs to be connected.
bus-nam - Name of the bus inside the memory that is connected to the bus.
bus - Bus object that needs to be connected to the memory.
int - Returns TEJA_SUCCESS or error code for failure.
Connects a hardware object to a bus.
int teja_hardware_object_connect(teja_hardware_object_t
hardware-object, const char *bus-name, teja_bus_t bus);
hardware-object - Hardware object that needs to be connected.
bus-name - Name of the bus inside the hardware object that is connected to the bus.
bus - Bus object that needs to be connected to the hardware object.
int - Returns TEJA_SUCCESS or error code for failure.
Looks up an architecture in the container.
teja_architecture_t teja_lookup_architecture(teja_architecture_t architecture,
const char *architecture-name);
architecture - Container architecture in which the user wants to look up the architecture.
architecture-name - Name of the architecture to look up in the container.
teja_architecture_t - The found architecture or NULL if not found.
Looks up a processor in the container.
teja_processor_t teja_lookup_processor(teja_architecture_t architecture,
const char *processor-name);
architecture - Container architecture in which the user wants to look up the processor.
processor-name - Name of the processor to look up in the container.
teja_processor_t - The found processor or NULL if not found.
Looks up a memory in the container.
teja_memory_t teja_lookup_memory(teja_architecture_t architecture,
const char *memory-name);
architecture - Container architecture in which the user wants to look up the memory.
memory-name - Name of the memory to look up in the container.
teja_memory_t - The found memory or NULL if not found.
Looks up a bus in the container.
teja_bus_t teja_lookup_bus(teja_architecture_t architecture,
const char *bus-name);
architecture - Container architecture in which the user wants to look up the bus.
bus-name - Name of the bus to look up in the container.
teja_bus_t - The found bus or NULL if not found.
Looks up a hardware object in the container.
teja_hardware_object_t teja_lookup_hardware_object(teja_architecture_t architecture,
const char *hardware-object-name);
architecture - Container architecture in which the user wants to look up the hardware object.
hardware-object-name - Name of the hardware object to look up in the container.
teja_hardware_object_t - The found hardware object or NULL if not found.
Creates a port in an hardware architecture. The port can be connected externally to ports of objects in the containing architecture, or ports of the containing architecture itself. See teja_architecture_set_port_internal. The port can also be connected internally to objects contained in this architecture. See teja_architecture_set_port.
teja_port_t teja_port_create(teja_architecture_t arch,
const char *port-name, const char *dir);
arch - Container architecture in which the port is created.
dir - Direction of the port. Legal values are IN and OUT.
teja_port_t - Returns the newly created port.
Assigns a value externally to an architecture port. If a port of another object in the architecture containing arch is assigned with the same value, the two ports are connected. Also, if ports belonging to the architecture containing arch are assigned internally with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_architecture_set_port(teja_architecture_t arch,
const char *port-name, const char *value);
arch - Architecture containing the port.
port-name - Name of the architecture port.
value - Value to be assigned externally to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Assigns a value internally to an architecture port. If a port of another object contained in arch is assigned with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_architecture_set_port_internal(teja_architecture_t arch,
const char *port-name, const char *value);
arch - Architecture containing the port.
port-name - Name of the architecture port.
value - Value to be assigned internally to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Assigns a value to a processor port. If a port of another object in the architecture containing the processor is assigned with the same value, the two ports are connected. Also, if ports belonging to the architecture containing the processor are assigned internally with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_processor_set_port(teja_processor_t proc,
const char *port-name, const char *value);
proc - Processor containing the port.
value - Value to be assigned to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Assigns a value to a memory port. If a port of another object in the architecture containing the memory is assigned with the same value, the two ports are connected. Also, if ports belonging to the architecture containing the memory are assigned internally with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_memory_set_port(teja_memory_t memory,
const char *port-name, const char *value);
memory - Memory containing the port.
value - Value to be assigned to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Assigns a value to a hardware object port. If a port of another object in the architecture containing the hardware object is assigned with the same value, the two ports are connected. Also, if ports belonging to the architecture containing the hardware object are assigned internally with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_hardware_object_set_port(teja_hardware_object_t hardware-object,
const char *port-name, const char *value);
hardware-object - Hardware object containing the port.
value - Value to be assigned to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Assigns a value to a bus port. If a port of another object in the architecture containing the bus is assigned with the same value, the two ports are connected. Also, if ports belonging to the architecture containing the bus are assigned internally with the same value, the two ports are connected. The value represents the name of a wire connecting the ports.
int teja_bus_set_port(teja_bus_t bus, const char *port-name,
const char *value);
bus - Bus containing the port.
value - Value to be assigned to the port.
int - Returns TEJA_SUCCESS or error code for failure.
Associates a new key=value pair to a port. This allows association of target-specific properties to ports.
int teja_port_add_property(teja_port_t port, const char *property-name,
const char *value, const char *description);
port - Port to which the property is added.
property-name - Name of the new property.
value - Value of the new property.
description - Description associated to the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the parent architecture for the specified architecture. If the specified architecture has no parent (for example, the top level architecture), NULL is returned.
teja_architecture_t teja_architecture_get_parent(teja_architecture_t architecture);
architecture - An architecture.
teja_architecture_t - The architecture containing the one passed as parameter, or NULL if such architecture is the top-level one.
Returns the architecture containing the specified processor.
teja_architecture_t teja_processor_get_parent(
teja_processor_t processor);
teja_architecture_t - The architecture containing the processor.
Returns the architecture containing the specified processor.
teja_architecture_t teja_bus_get_parent(teja_bus_t bus);
teja_architecture_t - The architecture containing the bus.
Returns the architecture containing the specified memory.
teja_architecture_t teja_memory_get_parent(teja_memory_t memory);
teja_architecture_t - The architecture containing the memory.
Returns the architecture containing the specified hardware object.
teja_architecture_t teja_hardware_object_get_parent(teja_hardware_object_t hardware-object);
hardware-object - A hardware object.
teja_architecture_t - The architecture containing the hardware object.
Returns an array of processors contained in the architecture. If the architecture contains N processors, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_processor_t *teja_architecture_get_processors(teja_architecture_t arch);
teja_processor_t * - The null-terminated array of processors contained in the architecture.
Returns an array of memories contained in the architecture. If the architecture contains N memories, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_memory_t *teja_architecture_get_memories(teja_architecture_t arch);
teja_memory_t * - The null-terminated array of memories contained in the architecture.
Returns an array of hardware objects contained in the architecture. If the architecture contains N objects, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_hardware_object_t *teja_architecture_get_hardware_objects(teja_architecture_t arch);
teja_hardware_object_t * - The null-terminated array of hardware objects contained in the architecture.
Returns an array of buses contained in the architecture. If the architecture contains N buses, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_bus_t *teja_architecture_get_busses(
teja_architecture_t arch);
teja_bus_t * - The null-terminated array of buses contained in the architecture.
Returns an array of architectures contained in the architecture. If the architecture contains N architectures, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_architecture_t *teja_architecture_get_architectures(teja_architecture_t arch);
teja_architecture_t * - The null-terminated array of architectures contained in the architecture.
Returns the bus connected to the specified internal processor, or NULL. For example, a bus b contained in the same architecture as a processor and connected to such processor, actually connects to an bus contained inside the processor. Given the processor and the name of the bus contained in it (internal-bus-name), this function returns b (teja_bus_t). If no bus is connected to the specified internal bus, NULL is returned.
teja_bus_t teja_processor_get_connected_bus(
teja_processor_t processor, const char *internal-bus-name);
internal-bus-name - Name of a bus internal to the processor.
teja_bus_t - The bus connected to the specified internal processor bus, or NULL.
Returns the bus connected to the specified memory, or NULL. For example, a bus b contained in the same architecture as a processor and connected to such memory, actually connects to an bus contained inside the memory. Given the memory and the name of the bus contained in it (internal-bus-name), this function returns b (teja_bus_t). If no bus is connected to the specified internal bus, NULL is returned.
teja_bus_t teja_memory_get_connected_bus(
teja_memory_t memory, const char *internal-bus-name);
internal-bus-name - Name to the bus internal to the memory.
teja_bus_t - The bus connected to the specified internal memory bus, or NULL.
Returns the bus connected to the specified hardware object, or NULL. For example, a bus b contained in the same architecture as a hardware object and connected to such hardware object, actually connects to an bus contained inside the hardware object. Given the hardware object and the name of the bus contained in it (internal-bus-name), this function returns b (teja_bus_t). If no bus is connected to the specified internal bus, NULL is returned.
teja_bus_t teja_hardware_object_get_connected_bus(
teja_hardware_object_t hardware-object, const char *internal-bus-name);
hardware-object - An hardware object.
internal-bus-name - Name of a bus internal to the hardware object.
teja_bus_t - The bus connected to the specified internal hardware object bus, or NULL.
Returns the bus connected to the specified architecture bus, or NULL. For example, consider an architecture arch1 contained in an architecture arch2, a bus b1 contained in arch1, and a bus b2 contained in arch2. If b1 and b2 are connected, calling this function with arch2 as first parameter (architecture) and the name of b2 as the second (internal-bus-name) returns b1. If no bus is connected to b2, NULL is returned.
teja_bus_t teja_architecture_get_connected_bus(teja_architecture_t architecture,
const char *internal-bus-name);
architecture - An architecture.
internal-bus-name - Name of a bus internal to the architecture.
teja_bus_t - The bus connected to the specified internal architecture bus, or NULL.
Returns an array of processors connected to the specified bus. If N processors are connected to the bus, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_processor_t *teja_bus_get_connected_processors(
teja_bus_t bus);
teja_processor_t * - A NULL-terminated array of processors connected to the bus.
Returns an array of memories connected to the specified bus. If N memories are connected to the bus, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_memory_t *teja_bus_get_connected_memories(teja_bus_t bus);
teja_memory_t * - A NULL-terminated array of memories connected to the bus.
Returns an array of hardware objects connected to the specified bus. If N hardware objects are connected to the bus, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_hardware_object_t *teja_bus_get_connected_hardware_objects(teja_bus_t bus);
teja_hardware_object_t * - A NULL-terminated array of hardware objects connected to the bus.
Returns an array of architectures connected to the specified bus. If N architectures are connected to the bus, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_architecture_t *teja_bus_get_connected_architectures(teja_bus_t bus);
teja_architecture_t * - A NULL-terminated array of architectures connected to the bus.
Returns an array of buses contained the specified processor. If the processor contains N buses, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_bus_t *teja_processor_get_busses(teja_processor_t processor);
teja_bus_t * - A NULL-terminated array of buses contained in the processor.
Returns an array of buses contained the specified memory. If the memory contains N buses, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_bus_t *teja_memory_get_busses(teja_memory_t memory);
teja_bus_t * - A NULL-terminated array of buses contained in the memory.
Returns an array of busses contained the specified hardware object. If the object contains N busses, the array contains N+1 entries, with entry N set to NULL. The user must deallocate the array by calling free() on it.
teja_bus_t *teja_hardware_object_get_busses(teja_hardware_object_t hardware-object);
hardware-object - A hardware object.
teja_bus_t * - A NULL-terminated array of buses contained in the hardware object.
Allocates an address space with the specified name, base, and high address, and associated to the specified architecture. Requests for address ranges with various constraints are performed against an address space. At compile time all the request are resolved into actual address ranges within the space. Base and high address are specified as strings containing the hexadecimal address representation (for example, 0x100000000).
teja_address_space_t teja_address_space_create(teja_architecture_t arch,
const char *name, const char *base, const char *high);
name - Name of an address space to be created.
base - Base address for the space.
high - Highest address in the space.
teja_address_space_t - The newly created address space.
Joins two address spaces. Address range requests performed against the two spaces is resolved as if the two addresses had been issued against a single space. The base-high range of the resulting address space is the union of the two original ranges.
int teja_address_space_join(teja_address_space_t s1,
teja_address_space_t s2);
int - TEJA_SUCCESS or error code for failure.
Creates an address range with the specified absolute address and size. The symbol has to be unique with respect to address ranges created against the same address space.
teja_address_range_t teja_address_range_create_absolute(teja_address_space_t space, const char *sym, const char *base,
const char *size,);
sym - A symbol to be associated to the range.
base - Base address for the range.
teja_address_range_t - The newly created address range.
Creates an address range with the specified size. When address range resolution is performed, this range is assigned a base address that is multiple of alignment, but not smaller than minaddr. The symbol has to be unique with respect to address ranges created against the same address space.
teja_address_range_t teja_address_range_create_aligned(teja_address_space_t space,
const char *sym, const char *alignment, const char *size, const char
*minaddr);
sym - A symbol to be associated to the range.
alignment - An alignment constraint.
minaddr - A lower bound to the base address for the range.
teja_address_range_t - The newly created address range.
Creates an address range with the specified size. When address range resolution is performed, this range is assigned a base address higher than minaddr. The symbol has to be unique with respect to address ranges created against the same address space.
teja_address_range_t teja_address_range_create_generic(teja_address_space_t space,
const char *sym, const char *size, const char *minaddr);
sym - A symbol to be associated to the range.
minaddr - A lower bound to the base address for the range.
teja_address_range_t - The newly created address range.
This function returns a handle for the lower bound of the address range. The handle can be set as value for any property. When address resolution is performed, tejacc replaces such value with the actual lower bound address assigned to the range. If the array passed as buffer to store the handle is not large enough, NULL is returned.
char *teja_address_range_get_lower_bound(teja_address_range_t range,
char *buf, int buf-size);
buf-size - Size of the array of characters.
char * - The array of characters filled with the handle, or NULL in case of error.
Returns a handle for the upper bound of the address range. The handle can be set as value for any property. When address resolution is performed, tejacc replaces the value with the actual upper bound address assigned to the range. If the array passed as a buffer to store the handle is not large enough, NULL is returned.
char *teja_address_range_get_upper_bound(teja_address_range_t range,
char *buf, int buf-size);
buf-size - Size of the array of characters.
char * - The array of characters filled with the handle, or NULL in case of error.
The software architecture API is used to describe the threads, processes, and OS composing the software part of the application, as well as Sun Netra DPS mutexes, queues, memory pools, and channels used by the various threads.
The teja_software_architecture.h file contains the declaration of the API functions.
The following data types are used in the software architecture definitions.
Creates an OS instance. Return value can be used to set or get properties of the OS.
teja_os_t teja_os_create(const char **processor-names,
const char *name, const char *type);
processor-names - NULL-terminated array of processor names on which the OS is running.
name - Name of the OS instance.
teja_os_t - Returns an object that represents the OS instance.
Sets the specified value of the property for the OS instance.
int teja_os_set_property(teja_os_t os, const char *property-name,
const char *value);
os - OS instance for which the property is being set.
property-name - Name of the property.
value - Value of the property to be set.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the current value of the OS property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_os_get_property(teja_os_t os, const char *property-name,
const char *value, int buf-size);
os - OS instance for which the property is being read.
property-name - Name of the property.
value - Value that is read and returned.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Creates a process instance. One or more processes can be created per OS. The source files listed in the source sets comprise the sources for the process.
teja_process_t teja_process_create(teja_os_t container,
const char *name, const char **srcset);
container - OS instance where the process is created.
srcset - NULL-terminated list of one or more source sets that are part of the process.
teja_process_t - Returns created process instance.
int teja_process_set_property(teja_process_t process,
const char *property-name, const char *value);
process - Process instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the current value of the process property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_process_get_property(teja_process_t process,
const char *property-name, const char *value, int buf-size);
process - Process instance for which the property is being read.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
See teja_processor_add_preprocessor_symbol
Creates a thread instance. One or more threads can be created per process.
teja_thread_t teja_thread_create(teja_process_t container,
const char *name);
container - Process instance where the thread is created.
teja_thread_t - Returns thread instance.
int teja_thread_set_property(teja_thread_t thread,
const char *property-name, const char *value);
thread - Thread instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the current value of a thread property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_thread_get_property(teja_thread_t thread,
const char *property-name, const char *value, int buf-size);
thread - Thread instance for which the property is being read.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Looks up an OS from its name in the software architecture.
teja_os_t teja_lookup_os(const char *os-name);
teja_os_t - Returns the found os instance or NULL.
Looks up a process from its name in the software architecture.
teja_process_t teja_lookup_process(const char *process-name);
process-name - Name of the process.
teja_process_t - Returns the found process instance or NULL.
Looks up a thread from its name in the software architecture.
teja_thread_t teja_lookup_thread(const char *thread-name);
thread-name - Name of the thread.
teja_thread_t - Returns the found thread instance or NULL.
Creates a new channel instance in the software architecture. The instance is accessed in the user-application code as a C preprocessor symbol with the same name as specified in this function.
teja_channel_t teja_channel_declare(const char *name, const char *type, teja_thread_t *producers, teja_thread_t *consumers);
producers - NULL-terminated list of producer thread instances.
consumers - NULL-terminated list of consumer thread instances.
teja_channel_t - Returns the created channel instance.
Sets a new value for a channel property.
int teja_channel_set_property(teja_channel_t channel, const char *property-name,
const char *value);
channel - Channel instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the current value of a channel property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_channel_get_property(teja_channel_t channel, const char *property-name,
const char *value, int buf-size);
channel - Channel instance for which the property is read.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Creates a new memory pool instance in the software architecture.
teja_memory_pool_t teja_memory_pool_declare(const char *name, const char *type, int num-nodes, long node-size, teja_thread_t *getters, teja_thread_t *setters, const char *memory-bank);
name - Name of the memory pool.
type - Type of the memory pool.
num-nodes - Number of nodes to allocate in the memory pool.
node-size - Size in bytes for each node.
getters - NULL-terminated list of getter threads.
setters - NULL-terminated list of setter threads.
memory-bank - Name of the memory bank (in the hardware architecture) from which the memory is allocated.
teja_memory_pool_t - Returns the memory pool instance.
Sets a new value for a memory pool property.
int teja_memory_pool_set_property(teja_memory_pool_t memory-pool,
const char *property-name, const char *value);
memory-pool - Memory pool instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns the current value of a memory pool property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_memory_pool_get_property(teja_memory_pool_t memory-pool,
const char *property-name, const char *value, int buf-size);
memory-pool - Memory pool instance for which the property is being read.
property_name - Name of the property.
value - Value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Creates a new queue instance in the software architecture.
teja_queue_t teja_queue_declare(const char *name,
const char *type, teja_thread_t *enqueuers, teja_thread_t *dequeuers);
enqueuers - NULL-terminated list of enqueuers threads.
dequeuers - NULL-terminated list of dequeuers threads.
teja_queue_t - Returns queue instance.
Sets a new value for a queue property.
int teja_queue_set_property(teja_queue_t queue, const char *property-name,
const char *value);
queue - Queue instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns current value of a queue property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_queue_get_property(teja_queue_t queue, const char *property-name,
const char *value, int buf-size);
queue - Queue instance for which the property is being read.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Creates a new mutex instance in the software architecture.
teja_mutex_t teja_mutex_declare(const char *name,
const char *type, teja_thread_t *users);
users - NULL-terminated list of user-threads.
teja_mutex_t - Returns a new mutex instance.
Sets a new value for a mutex property.
int teja_mutex_set_property(teja_mutex_t mutex, const char *property-name,
const char *value);
mutex - Mutex instance for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
Returns a current value of a mutex property. If the returned value+1 is greater than the size of the passed buffer, the returned value is truncated. The user must allocate a buffer with enough space to hold the value (returned value+1) and call the function again.
int teja_mutex_get_property(teja_mutex_t mutex, const char *property-name,
const char *value, int buf-size);
mutex - Mutex instance for which the property is being read.
property-name - Name of the property.
value - Returned value of the property.
buf-size - Size of the character buffer that was passed for the return value.
int - Returns the length of the current value of the property.
Looks up the channel instance in the software architecture using the channel name as a key.
teja_channel_t teja_lookup_channel(const char *channel-name);
channel-name - Name of the channel.
teja_channel_t - Returns the found channel instance or NULL.
Looks up the memory pool instance in the software architecture using the memory pool name as a key.
teja_memory_pool_t teja_lookup_memory_pool(const char *memory-pool-name);
memory-pool-name - Name of the memory pool.
teja_memory_pool_t - Returns the found memory pool instance or NULL.
Looks up the queue instance in the software architecture using the queue name as a key.
teja_queue_t teja_lookup_queue(const char *queue-name);
queue-name - Name of the queue.
teja_queue_t - Returns the found queue instance or NULL.
Looks up the mutex instance in the software architecture using the mutex name as a key.
teja_mutex_t teja_lookup_mutex(const char *mutex-name);
mutex-name - Name of the mutex.
teja_mutex_t - Returns the found mutex instance or NULL.
Adds a definition of symbol in the process same as passing -D option on the command line.
int teja_process_add_symbol(teja_process_t process, const char *symbol,
const char *value);
process - Process instance for which the symbol is being defined.
symbol - String that represents the symbol.
value - String that represents the value for the symbol.
int - Returns TEJA_SUCCESS or error code for failure.
The map API is used to describe the mapping between user-application source objects (functions and variables) and hardware architecture or software architecture.
The teja_mapping.h file contains the declaration of the Map data types and API functions.
The following data type is used in the map definitions.
teja_mapping_t |
Maps a function to run on a thread.
teja_mapping_t teja_map_function_to_thread(const char *function-name,
const char *thread-name);
function-name - Name of the function from the source files.
thread-name - Name of the thread.
teja_mapping_t - Returns a handle that represents this mapping.
teja_mapping_t teja_map_variable_to_memory(const char *var-name,
const char *memory-name);
var-name - Name of the variable from the source files.
memory-name - Name of the memory bank.
teja_mapping_t - Returns a handle that represents this mapping.
Creates an alias for a variable. This function helps in mapping two or more variables from different sources to the same location in memory. The user maps any one of these variables to a memory bank using teja_map_variable_to_memory. The remaining variables are mapped to that variable using this function.
teja_mapping_t teja_alias_variable(const char *var-name,
const char *target-var-name);
var-name - Name of the variable from the source files.
target-var-name - Name of the variable that the var_name maps to.
teja_mapping_t - Returns a handle that represents this mapping.
Maps one or more variables to memory using a regular expression. A regular expression can result in one or more variables from the source files. All the resultant variables are mapped to the memory bank.
teja_mapping_t *teja_map_variables_to_memory(const char *var-regexp,
const char *memory-name);
var-regexp - Regular expression that results in one or more variables from the source files.
memory-name - Name of the memory bank to map.
teja_mapping_t * - Returns an array of handles that represents this mapping.
Maps an initialization function to the process. This function is executed before any thread starts execution.
teja_mapping_t teja_map_initialization_function_to_process
(const char *function, const char *process);
function - Name of the function.
process - Name of the process as defined in the software architecture.
teja_mapping_t - Returns a handle that represents this mapping.
Sets a new value for a mapping.
int teja_mapping_set_property(teja_mapping_t mapping-handle,
const char *property-name, const char *value);
mapping-handle - Mapping handle for which the property is being set.
property-name - Name of the property.
value - Value of the property.
int - Returns TEJA_SUCCESS or error code for failure.
The error-handling API can be used to provide a user-defined function or behavior when an error occurs in the configuration API. The error-handling API is not available for the User API. The teja_error.h file contains the declaration of the error-handling data types and API functions.
The following data type is used in the error-handling definitions.
teja_error_handler_t |
When this function is called, the control is transferred to the caller of the library entry point function, which reports the error appropriately. When executed from the command line, tejacc terminates returning the provided error-code.
void teja_abort(int error-code, const char *error-message,);
error-message - Error message.
void - Aborts the execution of the hardware architecture, software architecture, or mapping definition.
Enables the user to implement a custom behavior in case of errors. When an error is encountered during the execution of a Sun Netra DPS hardware architecture, software architecture, or mapping API function, the registered error handler function is called.
teja_error_handler_t teja_register_error_handler(teja_error_handler_t handler);
handler - Error handler function.
teja_error_handler_t - The previously registered error handler.
int fn(int error_code, const char *error_msg);
The handler function is called with an error code and message, and returns a value. The value returned by the handler is in turn returned by the Sun Netra DPS API function that encountered the error. The default error handler does not return a value, but invokes teja_abort(), with the effect of transferring the control immediately to the caller of the library entry point function. The user can replace the default error handler using the teja_register_error_handler() function. For example, the user can replace the default handler with one that just returns an error code as follows:
The include/csp/sun/teja_cmt.h file lists all the hardware object types and properties that are supported by CMP CSP.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.