ChorusOS 4.0.1 Simulator for the Solaris Operating Environment (SPARC Platform Edition) User's Guide

Use of UNIX Services

Although it is possible for actors to make UNIX system calls directly, you should avoid doing this because some calls change the state of processes, leading to unpredictable behavior from the ChorusOS operating system. Examples of these system calls are:

In addition, the ChorusOS embedded library may conflict with the Standard C library because there are function names in both libraries which are identical.

UNIX system calls can be called indirectly, without linking with their corresponding libraries, by using a special structure whose fields are pointers to function entry points. However, this feature limits what functions can be accessed to the following:

Retrieving UNIX Function Addresses

Example 3-1 illustrates how to retrieve a structure containing addresses of UNIX function calls which can later be used to make indirect system calls. This structure is stored as a property called PROP_CPU_FUNCTION_ARRAY which is attached to the CPU node of the device tree.


Example 3-1 Retrieving UNIX Function Addresses

/* include files */
#include <cpu/unixProp.h>
#include <exec/chLoader.h>

        .
        .

/* declaration of pointer for address handling */                
static UnixFct* unixFct;

        .
        .

DevProperty prop;
void** tmpPtr;
  
/* looking for the CPU node in the device tree */
cpuNode = dtreeNodeFind(dtreeNodeRoot(), NODE_CPU);
if (cpuNode == NULL) {
    DKI_ERR(("No NODE_CPU in the device tree\n"));
    return;
}
  
/* Retrieve PROP_CPU_FUNCTION_ARRAY property */
prop = dtreePropFind(cpuNode, PROP_CPU_FUNCTION_ARRAY);
if (prop == NULL) {
    DKI_ERR(("No PROP_CPU_FUNCTION_ARRAY property in the NODE_CPU node\n"));
    return;
}
    
/* reading of its value */
tmpPtr = dtreePropValue(prop);
if (tmpPtr == NULL) {
    DKI_ERR(("No PROP_CPU_FUNCTION_ARRAY value in the NODE_CPU node\n"));
    return;
}
unixFct = *tmpPtr;

Access your UNIX functions using the -> structure operator:

unixFct->function_name

function_name is the name of the function you want to call.

Please refer to the exec/chLoader.h header file for a list of types and parameters. Note that some types and constants have been prefixed to avoid conflicts with ChorusOS types and constants.