Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

driver.h: Drivers API
[platform independant portions of code]


Data Structures

struct  _Driver
struct  _DriverHierarchyItem

Typedefs

typedef enum _DriverAcessMethod DriverAccessMethod
typedef enum _DriverParameterType DriverParameterType
typedef ErrorCode(* DriverAccessFunction )(DriverAccessMethod access, uint32 name,...)
typedef _DriverHierarchyItem DriverHierarchyItem
typedef _DriverDriver

Enumerations

enum  _DriverAcessMethod { DriverAccessRead, DriverAccessWrite }
enum  _DriverParameterType {
  DriverParameterTypeInt64, DriverParameterTypeInt32, DriverParameterTypeInt16, DriverParameterTypeInt8,
  DriverParameterTypeString0, DriverParameterTypeLength32String, DriverParameterTypeLength8String, DriverParameterPointer
}

Functions

ErrorCode driverCreate (Driver *driver, uint8 *name)
ErrorCode driverSet (Driver driver, uint8 *name, void *param)
ErrorCode driverGet (Driver driver, uint8 *name, void **param)
ErrorCode driverDestroy (Driver *driver)
ErrorCode driverReserveInterrupts (Driver driver, uint32 ints[], uint32 numInts)
ErrorCode driverReservePorts (Driver driver, uint32 ports[], uint32 numPorts)

Detailed Description

 * *  *  * Defines the ndk driver architecture (keeping in mind that this must be accessable on the command line), eg:
/bin/ndkshell/$ echo org.neuraldk.serial(1).read(1024)
The idea is to allow a hierachy of drivers, perhaps similar to unix's /dev directory, but more more to the extreme.
A driver must export: --------------------- ErrorCode drvInit(void); ErrorCode drvFinal(void); ErrorCode getName(uint8 **name); // returns eg. { "org", "neuraldk", "serial" } ErrorCode getParams(uint8 **params); // returns eg. { DriverTypeUint32, "port", "1-3" } ErrorCode getHierarchy(DriverHierarchyItem **items, uint32 *numItems); // must be sorted!

A driver will be read in by the system, and it's namespace and name will be gathered through the drivers getName() function. It's hierarchy may or not be saved.

When a user app or shell wishes to control an object it can do the following:

Driver driver; uint8 data[1024];

ec = driverCreate(&driver, "org.neuraldk.serial(1)"); if(!ec && driver) { driverSet(driver, "baudrate", 9600 ); driverGet(driver, "buffer(1024)", &data ); // note that we can't have driverSet(driver, "buffer", 1024, &data) as then that leaves open // a hole whereby a user could driverSet(driver, "buffer", 1024) and ndk would have no // idea that 'data' had been left out (as this would have to be taken care of by a ...) } driverDestroy(&driver);
Keep in mind that the user could, just as easily, create a driver starting at the beginning of the namespace:
driverCreate(&driver, "org.neuraldk");
And have access to everything. Should this be allowed?  

Typedef Documentation

typedef struct _Driver* Driver
 

Definition at line 112 of file driver.h.

typedef ErrorCode(* DriverAccessFunction)( DriverAccessMethod access, uint32 name, ...)
 

Will be called whenever something wants to set/get an item from a driver. In the above example, we would see the following two calls:

access(driver, DriverAccessSet, DRIVER_SET_NUMBER_FOR_BAUDRATE, 9600) access(driver, DriverAccessGet, DRIVER_SET_NUMBER_FOR_RErrorCode driverSet(Driver driver, uint8 *name, void *param );EADING, 1024, data);

Definition at line 91 of file driver.h.

typedef enum _DriverAcessMethod DriverAccessMethod
 

typedef struct _DriverHierarchyItem DriverHierarchyItem
 

typedef enum _DriverParameterType DriverParameterType
 


Enumeration Type Documentation

enum _DriverAcessMethod
 

Enumeration values:
DriverAccessRead 
DriverAccessWrite 

Definition at line 65 of file driver.h.

enum _DriverParameterType
 

Enumeration values:
DriverParameterTypeInt64 
DriverParameterTypeInt32 
DriverParameterTypeInt16 
DriverParameterTypeInt8 
DriverParameterTypeString0 
DriverParameterTypeLength32String 
DriverParameterTypeLength8String 
DriverParameterPointer 

Definition at line 71 of file driver.h.


Function Documentation

ErrorCode driverCreate Driver driver,
uint8 name
 

ErrorCode driverDestroy Driver driver  ) 
 

ErrorCode driverGet Driver  driver,
uint8 name,
void **  param
 

ErrorCode driverReserveInterrupts Driver  driver,
uint32  ints[],
uint32  numInts
 

ErrorCode driverReservePorts Driver  driver,
uint32  ports[],
uint32  numPorts
 

ErrorCode driverSet Driver  driver,
uint8 name,
void *  param
 


Generated on Thu Apr 7 16:24:10 2005 for ndk by doxygen 1.3.2