Changeset 52b7b1bb in mainline for uspace/lib/libdrv/include/driver.h


Ignore:
Timestamp:
2010-04-01T14:08:55Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
57937dd
Parents:
a1769ee
Message:

device interfaces - parts of code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libdrv/include/driver.h

    ra1769ee r52b7b1bb  
    3939#include <ipc/devman.h>
    4040#include <ipc/dev_iface.h>
     41#include <assert.h>
    4142
    4243struct device;
     
    5051
    5152typedef struct {
    52         int method_count;
     53        size_t method_count;
    5354        remote_iface_func_ptr_t *methods;
    5455} remote_iface_t;
     
    6869}
    6970
     71remote_iface_t* get_remote_iface(dev_inferface_id_t id);
     72remote_iface_func_ptr_t get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx);
     73
     74
    7075// device
    7176
     77/** The device. */
    7278struct device {
     79        /** Globally unique device identifier (assigned to the device by the device manager). */
    7380        device_handle_t handle;
     81        /** The phone to the parent device driver.*/
    7482        ipcarg_t parent_phone;
     83        /** The device's name.*/
    7584        const char *name;
     85        /** The list of device ids for device-to-driver matching.*/
    7686        match_id_list_t match_ids;
     87        /** The device driver's data associated with this device.*/
    7788        void *driver_data;
     89        /** The table of interfaces exported by this device. */
    7890        void *interfaces[DEV_IFACE_COUNT];
    79 
    80         // TODO add more items
    81 
     91        /** Pointer to the previous and next device in the list of devices handled by the driver */
    8292        link_t link;
    8393};
     
    8696// driver
    8797
     98/** Generic device driver operations. */
    8899typedef struct driver_ops {
     100        /** Callback method for passing a new device to the device driver.*/
    89101        bool (*add_device)(device_t *dev);
    90102        // TODO add other generic driver operations
    91103} driver_ops_t;
    92104
     105/** The driver structure.*/
    93106typedef struct driver {
     107        /** The name of the device driver. */
    94108        const char *name;
     109        /** Generic device driver operations. */
    95110        driver_ops_t *driver_ops;
    96111} driver_t;
     
    102117int driver_main(driver_t *drv);
    103118
     119/** Create new device structure.
     120 *
     121 * @return the device structure.
     122 */
    104123static inline device_t * create_device()
    105124{
     
    112131}
    113132
     133/** Delete device structure.
     134 *
     135 * @param dev the device structure.
     136 */
    114137static inline void delete_device(device_t *dev)
    115138{
     
    129152}
    130153
     154static inline void * device_get_iface(device_t *dev, dev_inferface_id_t id)
     155{
     156        assert(is_valid_iface_id(id));
     157       
     158        int idx = get_iface_index(id);
     159        return dev->interfaces[idx];   
     160}
     161
    131162bool child_device_register(device_t *child, device_t *parent);
    132163
Note: See TracChangeset for help on using the changeset viewer.