| 76 | |
| 77 | Every driver must define a ''driver_t'' structure which links to a ''driver_ops_t'' structure. |
| 78 | ''driver_ops_t'' fields point to various driver entry points. ''dev_add'' is necessary in order |
| 79 | for the driver to work. ''dev_remove'', ''dev_gone'', ''fun_online'', ''fun_offline'' are required |
| 80 | in order for the driver to support hot unplug (all drivers should support hot unplug). |
| 81 | |
| 82 | === Driver Entry Points (driver_opts_t) === |
| 83 | ==== dev_add ==== |
| 84 | {{{ |
| 85 | int (*dev_add)(ddf_dev_t *dev) |
| 86 | }}} |
| 87 | This entry point is called by DDF to ask the driver to take ownership of a new device. The driver |
| 88 | should probe the device to verify that it is there and operational. If not, it should return failure. |
| 89 | If the device is operational, the driver should take ownership and return EOK. The driver should |
| 90 | also allocate soft state and create functions to expose functionality of the device (in case of bus driver |
| 91 | some of these will correspond to devices currently connected to the bus). |
| 92 | |
| 93 | It is up to the driver to which extent it wants to perform these initialization steps |
| 94 | before or after returning from ''dev_add''. This entry point is mandatory, it must always be implemented. |
| 95 | |
| 96 | ==== dev_remove ==== |
| 97 | {{{ |
| 98 | int (*dev_remove)(ddf_dev_t *dev) |
| 99 | }}} |
| 100 | This entry point is called by DDF to ask the driver to gracefully give up ownership of a device. The driver |
| 101 | should gracefully terminate any pending operations on the device, quiesce the device and return it |
| 102 | to some suitable, clean state (from which it could be picked up by ''dev_add'', for example). |
| 103 | |
| 104 | The driver must unbind all functions belonging to this device and it should also clean up any |
| 105 | software state associated with the device. If this entry point is not implemented, it should |
| 106 | be either set to NULL or it should always return ENOTSUP. |
| 107 | |
| 108 | ==== dev_gone ==== |
| 109 | {{{ |
| 110 | int (*dev_gone)(ddf_dev_t *dev) |
| 111 | }}} |
| 112 | This entry point is called by DDF to inform the driver that connectivity to a device has been lost |
| 113 | (e.g. because the device has been physically unplugged). The driver must coordinate with its parent |
| 114 | to terminate any pending operations on the device. The parent will normally not allow any new operations |
| 115 | to be started and, possibly, it will abort all outstanding operations (or wait for the driver to |
| 116 | abort them). |
| 117 | |
| 118 | The driver must unbind all functions belonging to this device and it should also clean up any |
| 119 | software state associated with the device. If this entry point is not implemented, it should |
| 120 | be either set to NULL or it should always return ENOTSUP. |