From c40e45b75eb76d79a05c7fa85c1fa9b5c728a12f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 7 Oct 2016 15:10:20 +0200 Subject: Update to FreeBSD head 2016-08-23 Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd. --- rtemsbsd/include/rtems/bsd/local/device_if.h | 49 +++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'rtemsbsd/include/rtems/bsd/local/device_if.h') diff --git a/rtemsbsd/include/rtems/bsd/local/device_if.h b/rtemsbsd/include/rtems/bsd/local/device_if.h index 7a2cbc72..e27c2b52 100644 --- a/rtemsbsd/include/rtems/bsd/local/device_if.h +++ b/rtemsbsd/include/rtems/bsd/local/device_if.h @@ -52,28 +52,29 @@ typedef int device_probe_t(device_t dev); * the probe before returning. The return value of DEVICE_PROBE() * is used to elect which driver is used - the driver which returns * the largest non-error value wins the election and attaches to - * the device. + * the device. Common non-error values are described in the + * DEVICE_PROBE(9) manual page. * * If a driver matches the hardware, it should set the device * description string using device_set_desc() or - * device_set_desc_copy(). This string is - * used to generate an informative message when DEVICE_ATTACH() - * is called. + * device_set_desc_copy(). This string is used to generate an + * informative message when DEVICE_ATTACH() is called. * * As a special case, if a driver returns zero, the driver election * is cut short and that driver will attach to the device - * immediately. + * immediately. This should rarely be used. * - * For example, a probe method for a pci device driver might look + * For example, a probe method for a PCI device driver might look * like this: * * @code - * int foo_probe(device_t dev) + * int + * foo_probe(device_t dev) * { * if (pci_get_vendor(dev) == FOOVENDOR && * pci_get_device(dev) == FOODEVICE) { * device_set_desc(dev, "Foo device"); - * return (0); + * return (BUS_PROBE_DEFAULT); * } * return (ENXIO); * } @@ -88,7 +89,8 @@ typedef int device_probe_t(device_t dev); * * @param dev the device to probe * - * @retval 0 if the driver strongly matches this device + * @retval 0 if this is the only possible driver for this + * device * @retval negative if the driver can match this device - the * least negative value is used to select the * driver @@ -337,4 +339,33 @@ static __inline int DEVICE_QUIESCE(device_t dev) return ((device_quiesce_t *) _m)(dev); } +/** @brief Unique descriptor for the DEVICE_REGISTER() method */ +extern struct kobjop_desc device_register_desc; +/** @brief A function implementing the DEVICE_REGISTER() method */ +typedef void * device_register_t(device_t dev); +/** + * @brief This is called when the driver is asked to register handlers. + * + * + * To include this method in a device driver, use a line like this + * in the driver's method list: + * + * @code + * KOBJMETHOD(device_register, foo_register) + * @endcode + * + * @param dev the device for which handlers are being registered + * + * @retval NULL method not implemented + * @retval non-NULL a pointer to implementation specific static driver state + * + */ + +static __inline void * DEVICE_REGISTER(device_t dev) +{ + kobjop_t _m; + KOBJOPLOOKUP(((kobj_t)dev)->ops,device_register); + return ((device_register_t *) _m)(dev); +} + #endif /* _device_if_h_ */ -- cgit v1.2.3