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

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.