Changeset 52b7b1bb in mainline for uspace/lib/libdrv/include/driver.h
- Timestamp:
- 2010-04-01T14:08:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 57937dd
- Parents:
- a1769ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libdrv/include/driver.h
ra1769ee r52b7b1bb 39 39 #include <ipc/devman.h> 40 40 #include <ipc/dev_iface.h> 41 #include <assert.h> 41 42 42 43 struct device; … … 50 51 51 52 typedef struct { 52 int method_count;53 size_t method_count; 53 54 remote_iface_func_ptr_t *methods; 54 55 } remote_iface_t; … … 68 69 } 69 70 71 remote_iface_t* get_remote_iface(dev_inferface_id_t id); 72 remote_iface_func_ptr_t get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx); 73 74 70 75 // device 71 76 77 /** The device. */ 72 78 struct device { 79 /** Globally unique device identifier (assigned to the device by the device manager). */ 73 80 device_handle_t handle; 81 /** The phone to the parent device driver.*/ 74 82 ipcarg_t parent_phone; 83 /** The device's name.*/ 75 84 const char *name; 85 /** The list of device ids for device-to-driver matching.*/ 76 86 match_id_list_t match_ids; 87 /** The device driver's data associated with this device.*/ 77 88 void *driver_data; 89 /** The table of interfaces exported by this device. */ 78 90 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 */ 82 92 link_t link; 83 93 }; … … 86 96 // driver 87 97 98 /** Generic device driver operations. */ 88 99 typedef struct driver_ops { 100 /** Callback method for passing a new device to the device driver.*/ 89 101 bool (*add_device)(device_t *dev); 90 102 // TODO add other generic driver operations 91 103 } driver_ops_t; 92 104 105 /** The driver structure.*/ 93 106 typedef struct driver { 107 /** The name of the device driver. */ 94 108 const char *name; 109 /** Generic device driver operations. */ 95 110 driver_ops_t *driver_ops; 96 111 } driver_t; … … 102 117 int driver_main(driver_t *drv); 103 118 119 /** Create new device structure. 120 * 121 * @return the device structure. 122 */ 104 123 static inline device_t * create_device() 105 124 { … … 112 131 } 113 132 133 /** Delete device structure. 134 * 135 * @param dev the device structure. 136 */ 114 137 static inline void delete_device(device_t *dev) 115 138 { … … 129 152 } 130 153 154 static 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 131 162 bool child_device_register(device_t *child, device_t *parent); 132 163
Note:
See TracChangeset
for help on using the changeset viewer.