module xdc.runtime.knl.SyncGeneric

Generic ISync implementation

This module allows users to plug in their own functions for signal, wait and query.
XDCspec summary sourced in xdc/runtime/knl/SyncGeneric.xdc
module SyncGeneric {  ...
    // inherits xdc.runtime.IModule
instance:  ...
C synopsis target-domain
#include <xdc/runtime/knl/SyncGeneric.h>
module-wide constants & types
 
        SyncGeneric_WaitStatus_ERROR,
 
module-wide built-ins
per-instance object types
 
per-instance config parameters
        IInstance_Params *instance;
        UArg signalArg// user signal function arg;
        UArg waitArg// user wait function arg;
    } SyncGeneric_Params;
 
per-instance creation
per-instance deletion
per-instance functions
per-instance convertors
per-instance built-ins
 
XDCscript usage meta-domain
var SyncGeneric = xdc.useModule('xdc.runtime.knl.SyncGeneric');
module-wide constants & types
 
        const SyncGeneric.WaitStatus_ERROR;
        const SyncGeneric.WaitStatus_TIMEOUT;
        const SyncGeneric.WaitStatus_SUCCESS;
module-wide config parameters
per-instance config parameters
    var params = new SyncGeneric.Params// Instance config-params object;
        params.signalArg// user signal function arg = UArg null;
        params.userQuery// user query function = Bool(*)(Int) null;
        params.userSignal// user signal function = Void(*)(UArg) null;
        params.userWait// user wait function = Bool(*)(UArg,UInt) null;
        params.waitArg// user wait function arg = UArg null;
per-instance creation
    var inst = SyncGeneric.create// Create an instance-object( params );
 
XDCspec declarations sourced in xdc/runtime/knl/SyncGeneric.xdc
package xdc.runtime.knl;
 
module SyncGeneric inherits ISync {
module-wide constants & types
    const UInt NO_WAIT// Used to specify no waiting = 0;
    const Int Q_BLOCKING// Blocking quality = 1;
    const UInt WAIT_FOREVER// Used to wait forever = ~(0);
 
        WaitStatus_ERROR,
        WaitStatus_TIMEOUT,
        WaitStatus_SUCCESS
    };
 
    typedef Bool (*WaitFunc// typedef for user specified wait function)(UArg,UInt);
module-wide config parameters
 
 
instance:
per-instance config parameters
    config UArg signalArg// user signal function arg = null;
    config UArg waitArg// user wait function arg = null;
per-instance creation
per-instance functions
    Bool query// Query for a particular quality( Int qual );
}
 
const SyncGeneric.NO_WAIT

Used to specify no waiting

XDCscript usage meta-domain
const SyncGeneric.NO_WAIT = 0;
C synopsis target-domain
#define SyncGeneric_NO_WAIT (UInt)0
 
 
const SyncGeneric.Q_BLOCKING

Blocking quality

XDCscript usage meta-domain
const SyncGeneric.Q_BLOCKING = 1;
C synopsis target-domain
#define SyncGeneric_Q_BLOCKING (Int)1
 
DETAILS
Implementations with this "quality" may cause the calling thread to block;
 
const SyncGeneric.WAIT_FOREVER

Used to wait forever

XDCscript usage meta-domain
const SyncGeneric.WAIT_FOREVER = ~(0);
C synopsis target-domain
#define SyncGeneric_WAIT_FOREVER (UInt)~(0)
 
 
enum SyncGeneric.WaitStatus

Error codes returned by Semaphore_pend

XDCscript usage meta-domain
values of type SyncGeneric.WaitStatus
    const SyncGeneric.WaitStatus_ERROR;
    const SyncGeneric.WaitStatus_TIMEOUT;
    const SyncGeneric.WaitStatus_SUCCESS;
C synopsis target-domain
typedef enum SyncGeneric_WaitStatus {
    SyncGeneric_WaitStatus_ERROR,
    SyncGeneric_WaitStatus_TIMEOUT,
    SyncGeneric_WaitStatus_SUCCESS
} SyncGeneric_WaitStatus;
 
 
typedef SyncGeneric.QueryFunc

typedef for user specified wait function

C synopsis target-domain
typedef Bool (*SyncGeneric_QueryFunc)(Int);
 
 
typedef SyncGeneric.SignalFunc

typedef for user specified signal function

C synopsis target-domain
typedef Void (*SyncGeneric_SignalFunc)(UArg);
 
 
typedef SyncGeneric.WaitFunc

typedef for user specified wait function

C synopsis target-domain
typedef Bool (*SyncGeneric_WaitFunc)(UArg,UInt);
 
 
metaonly config SyncGeneric.common$  // module-wide

Common module configuration parameters

XDCscript usage meta-domain
SyncGeneric.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
 
module-wide built-ins

C synopsis target-domain
Types_ModuleId SyncGeneric_Module_id( );
// Get this module's unique id
 
Bool SyncGeneric_Module_startupDone( );
// Test if this module has completed startup
 
IHeap_Handle SyncGeneric_Module_heap( );
// The heap from which this module allocates memory
 
Bool SyncGeneric_Module_hasMask( );
// Test whether this module has a diagnostics mask
 
Bits16 SyncGeneric_Module_getMask( );
// Returns the diagnostics mask for this module
 
Void SyncGeneric_Module_setMask( Bits16 mask );
// Set the diagnostics mask for this module
 
per-instance object types

C synopsis target-domain
typedef struct SyncGeneric_Object SyncGeneric_Object;
// Opaque internal representation of an instance object
 
typedef SyncGeneric_Object *SyncGeneric_Handle;
// Client reference to an instance object
 
typedef struct SyncGeneric_Struct SyncGeneric_Struct;
// Opaque client structure large enough to hold an instance object
 
SyncGeneric_Handle SyncGeneric_handle( SyncGeneric_Struct *structP );
// Convert this instance structure pointer into an instance handle
 
SyncGeneric_Struct *SyncGeneric_struct( SyncGeneric_Handle handle );
// Convert this instance handle into an instance structure pointer
 
per-instance config parameters

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
// Instance config-params object
    params.signalArg = UArg null;
    // user signal function arg
    params.userQuery = Bool(*)(Int) null;
    // user query function
    params.userSignal = Void(*)(UArg) null;
    // user signal function
    params.userWait = Bool(*)(UArg,UInt) null;
    // user wait function
    params.waitArg = UArg null;
    // user wait function arg
C synopsis target-domain
typedef struct SyncGeneric_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    UArg signalArg;
    // user signal function arg
    SyncGeneric_QueryFunc userQuery;
    // user query function
    SyncGeneric_SignalFunc userSignal;
    // user signal function
    SyncGeneric_WaitFunc userWait;
    // user wait function
    UArg waitArg;
    // user wait function arg
} SyncGeneric_Params;
 
Void SyncGeneric_Params_init( SyncGeneric_Params *params );
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
config SyncGeneric.signalArg  // per-instance

user signal function arg

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
  ...
params.signalArg = UArg null;
C synopsis target-domain
      ...
    UArg signalArg;
 
 
config SyncGeneric.userQuery  // per-instance

user query function

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
  ...
params.userQuery = Bool(*)(Int) null;
C synopsis target-domain
      ...
    SyncGeneric_QueryFunc userQuery;
 
 
config SyncGeneric.userSignal  // per-instance

user signal function

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
  ...
params.userSignal = Void(*)(UArg) null;
C synopsis target-domain
      ...
    SyncGeneric_SignalFunc userSignal;
 
 
config SyncGeneric.userWait  // per-instance

user wait function

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
  ...
params.userWait = Bool(*)(UArg,UInt) null;
C synopsis target-domain
      ...
    SyncGeneric_WaitFunc userWait;
 
 
config SyncGeneric.waitArg  // per-instance

user wait function arg

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
  ...
params.waitArg = UArg null;
C synopsis target-domain
      ...
    UArg waitArg;
 
 
per-instance creation

XDCscript usage meta-domain
var params = new SyncGeneric.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = SyncGeneric.create( params );
// Create an instance-object
C synopsis target-domain
SyncGeneric_Handle SyncGeneric_create( const SyncGeneric_Params *params, Error_Block *eb );
// Allocate and initialize a new instance object and return its handle
 
Void SyncGeneric_construct( SyncGeneric_Struct *structP, const SyncGeneric_Params *params );
// Initialize a new instance object inside the provided structure
ARGUMENTS
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
 
per-instance deletion

C synopsis target-domain
Void SyncGeneric_delete( SyncGeneric_Handle *handleP );
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void SyncGeneric_destruct( SyncGeneric_Struct *structP );
// Finalize the instance object inside the provided structure
 
SyncGeneric.query( )  // per-instance

Query for a particular quality

C synopsis target-domain
Bool SyncGeneric_query( SyncGeneric_Handle handle, Int qual );
 
ARGUMENTS
handle — handle of a previously-created SyncGeneric instance object
qual — quality
RETURNS
TRUE or FALSE.
DETAILS
FALSE is returned if quality not supported.
 
SyncGeneric.signal( )  // per-instance

Called at completion of an activity

C synopsis target-domain
Void SyncGeneric_signal( SyncGeneric_Handle handle );
 
ARGUMENTS
handle — handle of a previously-created SyncGeneric instance object
DETAILS
This function is non-blocking. It is also required that the underlying sync be binary in nature.
This function does not take an Error.Block intentionally because it can be called from ISR context.
 
SyncGeneric.wait( )  // per-instance

Called to wait/poll for completion of an activity

C synopsis target-domain
Int SyncGeneric_wait( SyncGeneric_Handle handle, UInt timeout, Error_Block *eb );
 
ARGUMENTS
handle — handle of a previously-created SyncGeneric instance object
timeout — Timeout
eb — Hist Pointer to Error.Block
RETURNS
Refer to description above
DETAILS
This function can block. Non-blocking implementations should return false to indicate a timeout.
 
per-instance convertors

C synopsis target-domain
ISync_Handle SyncGeneric_Handle_upCast( SyncGeneric_Handle handle );
// unconditionally move one level up the inheritance hierarchy
 
SyncGeneric_Handle SyncGeneric_Handle_downCast( ISync_Handle handle );
// conditionally move one level down the inheritance hierarchy; NULL upon failure
 
per-instance built-ins

C synopsis target-domain
Int SyncGeneric_Object_count( );
// The number of statically-created instance objects
 
SyncGeneric_Handle SyncGeneric_Object_get( SyncGeneric_Object *array, Int i );
// The handle of the i-th statically-created instance object (array == NULL)
 
SyncGeneric_Handle SyncGeneric_Object_first( );
// The handle of the first dynamically-created instance object, or NULL
 
SyncGeneric_Handle SyncGeneric_Object_next( SyncGeneric_Handle handle );
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle SyncGeneric_Object_heap( );
// The heap used to allocate dynamically-created instance objects
 
Types_Label *SyncGeneric_Handle_label( SyncGeneric_Handle handle, Types_Label *buf );
// The label associated with this instance object
 
String SyncGeneric_Handle_name( SyncGeneric_Handle handle );
// The name of this instance object
generated on Fri, 04 Sep 2009 23:26:27 GMT