The DEV Device Manager manages the table of IOM drivers. Drivers can
be added or removed from the system using DEV_create() and DEV_delete().
DEV_create() calls mdBindDev() for the underlying IOM driver. If
successful, the driver gets added to the driver table. GIO_create()
looks in this table for matching device name when opening an I/O
channel.
DEV_delete() calls mdUnBindDev() for the underlying IOM driver and
removes the entry from the driver table.
typedef DEV_InitFxn |
|
Init function type definition
typedef Void (*DEV_InitFxn)();
config DEV_tableSize // module-wide |
|
Size of the device table
extern const UInt DEV_tableSize;
DETAILS
This size needs to be large enough to hold the sum of the drivers
created at configuration time and runtime.
DEV_match() // module-wide |
|
DEV_match searches the device table for the first device name that
matches a prefix of 'name'. The output parameter, device, points to
the appropriate entry in the device table if successful and is set to
NULL on error
String DEV_match(
String name,
DEV_Handle *
device);
ARGUMENTS
name
name of device
device
pointer to DEV Handle (output param)
RETURNS
pointer to remaining characters after match
DETAILS
The suffix string return value contains a pointer to the characters
remaining after the match. This string can be used to specify device
parameters or the name of another device driver.
For example, if you have "/uart" in the device table, then the
suffix return value for the following would return a pointer to "0".
suffix = DEV_match("/uart0", &device);
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool DEV_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool DEV_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 DEV_Module_getMask();
// Returns the diagnostics mask for this module
Void DEV_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
|
typedef struct DEV_Object DEV_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct DEV_Struct DEV_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
|
typedef struct DEV_Params {
// Instance config-params structure
// Common per-instance configs
Ptr deviceParams;
// Device-specific parameters
Int devid;
// Device id
// Driver Initialization function
} DEV_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config DEV_Params.deviceParams // instance |
|
Device-specific parameters
DETAILS
This parameter is passed as the last parameter to the underlying
IOM driver's mdBindDevice function.
config DEV_Params.devid // instance |
|
Device id
config DEV_Params.initFxn // instance |
|
Driver Initialization function
DETAILS
This function is called once for every entry in the device table.
If this parameter is set to NULL (the default), then no function
will be called.
Runtime Instance Creation |
|
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
name
name of device (must be a static string)
fxns
pointer to IOM_Fxns table
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)
DETAILS
The 'name' parameter must be a static string since this name
is referenced via a pointer and is not copied. For example:
Error_init(&eb);
DEV_create("/a2d", &A2DFXNS, &myparams, &eb);
The following code will not work since 'localstring' is a local
variable:
{
Char localstring[10];
strcpy(localstring, "/a2d");
Error_init(&eb);
DEV_create(localstring, &A2DFXNS, &myparams, &eb);
}
Instance Deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
DEV_getDeviceParams() // instance |
|
Get deviceParams of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
deviceParams
DETAILS
DEV_getDeviceParams returns the deviceParams of the referenced device.
DEV_getDevid() // instance |
|
Get devid of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
devid
DETAILS
DEV_getDevid returns the devid of the referenced device.
DEV_getDevp() // instance |
|
Get devp of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
devp
DETAILS
DEV_getDevp returns the devp of the referenced device.
DEV_getFxns() // instance |
|
Get IOM function table of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
pointer to device function table
DETAILS
DEV_getFxns returns the IOM function table of the referenced device.
DEV_getInitFxn() // instance |
|
Get initialized function of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
init function pointer
DETAILS
DEV_getInitFxn returns the init function of the referenced device.
DEV_getName() // instance |
|
Get name of device
ARGUMENTS
handle
handle of a previously-created DEV instance object
RETURNS
device name
DETAILS
DEV_getName returns the name of the referenced device.
Instance Built-Ins |
|
Int DEV_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object
metaonly struct DEV.BasicView |
|
var obj = new DEV.BasicView;
obj.name = String ...
obj.fxns = Ptr ...
obj.initFxn = String[] ...
obj.devid = Int ...
obj.deviceParams = Ptr ...
obj.devp = Ptr ...
config DEV.tableSize // module-wide |
|
Size of the device table
DETAILS
This size needs to be large enough to hold the sum of the drivers
created at configuration time and runtime.
C SYNOPSIS
metaonly config DEV.common$ // module-wide |
|
Common module configuration parameters
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.
metaonly config DEV.rovViewInfo // module-wide |
|
Instance Config Parameters |
|
var params = new DEV.Params;
// Instance config-params object
params.deviceParams = Ptr null;
// Device-specific parameters
params.devid = Int 0;
// Device id
params.initFxn = Void(*)() null;
// Driver Initialization function
config DEV.Params.deviceParams // instance |
|
Device-specific parameters
var params = new DEV.Params;
...
params.deviceParams = Ptr null;
DETAILS
This parameter is passed as the last parameter to the underlying
IOM driver's mdBindDevice function.
C SYNOPSIS
config DEV.Params.devid // instance |
|
Device id
var params = new DEV.Params;
...
params.devid = Int 0;
C SYNOPSIS
config DEV.Params.initFxn // instance |
|
Driver Initialization function
var params = new DEV.Params;
...
params.initFxn = Void(*)() null;
DETAILS
This function is called once for every entry in the device table.
If this parameter is set to NULL (the default), then no function
will be called.
C SYNOPSIS
Static Instance Creation |
|
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = DEV.create(String name, Ptr fxns, params);
// Create an instance-object
ARGUMENTS
name
name of device (must be a static string)
fxns
pointer to IOM_Fxns table
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)
DETAILS
The 'name' parameter must be a static string since this name
is referenced via a pointer and is not copied. For example:
Error_init(&eb);
DEV_create("/a2d", &A2DFXNS, &myparams, &eb);
The following code will not work since 'localstring' is a local
variable:
{
Char localstring[10];
strcpy(localstring, "/a2d");
Error_init(&eb);
DEV_create(localstring, &A2DFXNS, &myparams, &eb);
}