mirror of https://github.com/dzavalishin/openpod
dev desc and fncs
This commit is contained in:
parent
daf95f8170
commit
90d02e4f66
|
@ -110,3 +110,75 @@ First of them, ``pod_default_enqueue``, will just call syncronous entry point of
|
||||||
three other are no-ops.
|
three other are no-ops.
|
||||||
|
|
||||||
|
|
||||||
|
----------------
|
||||||
|
Driver functions
|
||||||
|
----------------
|
||||||
|
|
||||||
|
All the driver lifecycle functions are trivial.
|
||||||
|
|
||||||
|
Constructor and destructor (``simple_driver_construct`` and ``simple_driver_destruct``) are just
|
||||||
|
empty - we don't need them for this driver to work.
|
||||||
|
|
||||||
|
|
||||||
|
simple_driver_activate
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
This function is mostly copied from system default implementation.
|
||||||
|
|
||||||
|
.. code:: c
|
||||||
|
:linenos:
|
||||||
|
:emphasize-lines: 4,9,12
|
||||||
|
|
||||||
|
errno_t simple_driver_activate( struct pod_driver *drv )
|
||||||
|
{
|
||||||
|
errno_t rc;
|
||||||
|
|
||||||
|
drv->private_data = &simple_device;
|
||||||
|
|
||||||
|
struct pod_device *dev = drv->private_data; // we are very simple
|
||||||
|
|
||||||
|
if( dev == 0 ) return ENOENT;
|
||||||
|
|
||||||
|
POD_DEV_STATE_CLEAR( dev, POD_DEV_STATE_PAUSE );
|
||||||
|
POD_DEV_STATE_SET( dev, POD_DEV_STATE_LINKED );
|
||||||
|
|
||||||
|
rc = pod_dev_link( drv, dev );
|
||||||
|
if( rc ) return rc;
|
||||||
|
|
||||||
|
rc = pod_dev_event( drv, dev, POD_EVENT_LOG, "device activated" );
|
||||||
|
if( rc ) return rc;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
simple_driver_deactivate
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Again, function is copied from system default implementation.
|
||||||
|
|
||||||
|
.. code:: c
|
||||||
|
:linenos:
|
||||||
|
:emphasize-lines: 8,11
|
||||||
|
|
||||||
|
errno_t simple_driver_deactivate( struct pod_driver *drv )
|
||||||
|
{
|
||||||
|
errno_t rc;
|
||||||
|
struct pod_device *dev = drv->private_data; // we are very simple
|
||||||
|
|
||||||
|
if( dev == 0 ) return ENOENT;
|
||||||
|
|
||||||
|
rc = pod_dev_event( drv, dev, POD_EVENT_LOG, "device deactivated" );
|
||||||
|
if( rc ) return rc;
|
||||||
|
|
||||||
|
rc = pod_dev_unlink( drv, dev );
|
||||||
|
if( rc ) return rc;
|
||||||
|
|
||||||
|
//POD_DEV_STATE_SET( dev, POD_DEV_STATE_PAUSE );
|
||||||
|
POD_DEV_STATE_CLEAR( dev, POD_DEV_STATE_LINKED );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,53 @@ Device class specifies API this device exports to the kernel.
|
||||||
Driver descriptor
|
Driver descriptor
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
.. code:: c
|
||||||
|
|
||||||
|
typedef struct pod_driver
|
||||||
|
{
|
||||||
|
uint32_t magic;
|
||||||
|
|
||||||
|
uint8_t API_version_major;
|
||||||
|
uint8_t API_version_minor;
|
||||||
|
|
||||||
|
uint8_t arch_major;
|
||||||
|
uint8_t arch_minor; // undefined, must be 0
|
||||||
|
|
||||||
|
uint8_t class_id;
|
||||||
|
uint8_t pad0;
|
||||||
|
uint8_t pad1;
|
||||||
|
uint8_t state_flags; // Driver state
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
pod_dev_required_f calls;
|
||||||
|
pod_dev_optional_f *optional;
|
||||||
|
|
||||||
|
pod_properties *prop;
|
||||||
|
|
||||||
|
void *private_data;
|
||||||
|
|
||||||
|
kernel_f *kernel_driver_api;
|
||||||
|
|
||||||
|
} pod_driver;
|
||||||
|
|
||||||
|
All the fields of this structure will be described in reference part of this
|
||||||
|
document, now we will just note the most interesting ones.
|
||||||
|
|
||||||
|
**state_flags**
|
||||||
|
Used to track driver state, such as if driver found its hardware or not.
|
||||||
|
|
||||||
|
**name**
|
||||||
|
Driver name, printable text for user to ideitify it.
|
||||||
|
|
||||||
|
**calls**
|
||||||
|
Main set of driver entry points, see below.
|
||||||
|
|
||||||
|
**private_data**
|
||||||
|
Private driver's state. Simple drivers keep here a link to an only
|
||||||
|
device descriptor.
|
||||||
|
|
||||||
|
All the other fields can be zeroes or have default predefined values.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
Driver methods
|
Driver methods
|
||||||
|
|
|
@ -15,6 +15,9 @@ errno_t simple_driver_activate( struct pod_driver *drv )
|
||||||
// Register dev
|
// Register dev
|
||||||
|
|
||||||
errno_t rc;
|
errno_t rc;
|
||||||
|
|
||||||
|
drv->private_data = &simple_device;
|
||||||
|
|
||||||
struct pod_device *dev = drv->private_data; // we are very simple
|
struct pod_device *dev = drv->private_data; // we are very simple
|
||||||
|
|
||||||
if( dev == 0 ) return ENOENT;
|
if( dev == 0 ) return ENOENT;
|
||||||
|
|
Loading…
Reference in New Issue