Changeset eb1a2f4 in mainline for uspace/lib/drv/include
- Timestamp:
- 2011-02-22T23:30:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3b5d1535, a9c674e0
- Parents:
- dbe25f1 (diff), 664af708 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/drv/include
- Files:
-
- 1 added
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/include/ddf/driver.h
rdbe25f1 reb1a2f4 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 33 34 */ 34 35 35 #ifndef LIBDRV_DRIVER_H_36 #define LIBDRV_DRIVER_H_36 #ifndef DDF_DRIVER_H_ 37 #define DDF_DRIVER_H_ 37 38 38 #include <sys/types.h>39 #include <kernel/ddi/irq.h>40 #include <adt/list.h>41 #include <devman.h>42 39 #include <ipc/devman.h> 43 40 #include <ipc/dev_iface.h> 44 #include <assert.h>45 #include <ddi.h>46 #include <libarch/ddi.h>47 #include <fibril_synch.h>48 #include <malloc.h>49 41 50 #include " dev_iface.h"42 #include "../dev_iface.h" 51 43 52 struct device;53 typedef struct d evice device_t;44 typedef struct ddf_dev ddf_dev_t; 45 typedef struct ddf_fun ddf_fun_t; 54 46 55 47 /* 56 * Device class48 * Device 57 49 */ 58 50 59 51 /** Devices operations */ 60 typedef struct d evice_ops {52 typedef struct ddf_dev_ops { 61 53 /** 62 54 * Optional callback function called when a client is connecting to the 63 55 * device. 64 56 */ 65 int (*open)(d evice_t *);57 int (*open)(ddf_fun_t *); 66 58 67 59 /** … … 69 61 * the device. 70 62 */ 71 void (*close)(d evice_t *);63 void (*close)(ddf_fun_t *); 72 64 73 65 /** The table of standard interfaces implemented by the device. */ … … 80 72 */ 81 73 remote_handler_t *default_handler; 82 } device_ops_t; 83 84 85 /* 86 * Device 87 */ 74 } ddf_dev_ops_t; 88 75 89 76 /** Device structure */ 90 struct d evice{77 struct ddf_dev { 91 78 /** 92 79 * Globally unique device identifier (assigned to the device by the … … 101 88 int parent_phone; 102 89 103 /** Parent device if handled by this driver, NULL otherwise */104 device_t *parent;105 90 /** Device name */ 106 91 const char *name; 107 /** List of device ids for device-to-driver matching */ 108 match_id_list_t match_ids; 92 109 93 /** Driver-specific data associated with this device */ 110 94 void *driver_data; 111 /** The implementation of operations provided by this device */112 device_ops_t *ops;113 95 114 96 /** Link in the list of devices handled by the driver */ 97 link_t link; 98 }; 99 100 /** Function structure */ 101 struct ddf_fun { 102 /** True if bound to the device manager */ 103 bool bound; 104 /** Function indentifier (asigned by device manager) */ 105 devman_handle_t handle; 106 107 /** Device which this function belogs to */ 108 ddf_dev_t *dev; 109 110 /** Function type */ 111 fun_type_t ftype; 112 /** Function name */ 113 const char *name; 114 /** List of device ids for driver matching */ 115 match_id_list_t match_ids; 116 /** Driver-specific data associated with this function */ 117 void *driver_data; 118 /** Implementation of operations provided by this function */ 119 ddf_dev_ops_t *ops; 120 121 /** Link in the list of functions handled by the driver */ 115 122 link_t link; 116 123 }; … … 123 130 typedef struct driver_ops { 124 131 /** Callback method for passing a new device to the device driver */ 125 int (*add_device)(d evice_t *dev);132 int (*add_device)(ddf_dev_t *dev); 126 133 /* TODO: add other generic driver operations */ 127 134 } driver_ops_t; … … 135 142 } driver_t; 136 143 137 intdriver_main(driver_t *);144 extern int ddf_driver_main(driver_t *); 138 145 139 /** Create new device structure. 140 * 141 * @return The device structure. 142 */ 143 extern device_t *create_device(void); 144 extern void delete_device(device_t *); 145 extern void *device_get_ops(device_t *, dev_inferface_idx_t); 146 extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *); 147 extern void ddf_fun_destroy(ddf_fun_t *); 148 extern int ddf_fun_bind(ddf_fun_t *); 149 extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int); 146 150 147 extern int child_device_register(device_t *, device_t *); 148 extern int child_device_register_wrapper(device_t *, const char *, const char *, 149 int, devman_handle_t *); 150 151 /* 152 * Interrupts 153 */ 154 155 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *); 156 157 typedef struct interrupt_context { 158 int id; 159 device_t *dev; 160 int irq; 161 interrupt_handler_t *handler; 162 link_t link; 163 } interrupt_context_t; 164 165 typedef struct interrupt_context_list { 166 int curr_id; 167 link_t contexts; 168 fibril_mutex_t mutex; 169 } interrupt_context_list_t; 170 171 extern interrupt_context_t *create_interrupt_context(void); 172 extern void delete_interrupt_context(interrupt_context_t *); 173 extern void init_interrupt_context_list(interrupt_context_list_t *); 174 extern void add_interrupt_context(interrupt_context_list_t *, 175 interrupt_context_t *); 176 extern void remove_interrupt_context(interrupt_context_list_t *, 177 interrupt_context_t *); 178 extern interrupt_context_t *find_interrupt_context_by_id( 179 interrupt_context_list_t *, int); 180 extern interrupt_context_t *find_interrupt_context( 181 interrupt_context_list_t *, device_t *, int); 182 183 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *, 184 irq_code_t *); 185 extern int unregister_interrupt_handler(device_t *, int); 186 187 extern remote_handler_t *device_get_default_handler(device_t *); 188 extern int add_device_to_class(device_t *, const char *); 151 extern int ddf_fun_add_to_class(ddf_fun_t *, const char *); 189 152 190 153 #endif -
uspace/lib/drv/include/dev_iface.h
rdbe25f1 reb1a2f4 43 43 */ 44 44 45 struct d evice;45 struct ddf_fun; 46 46 47 47 /* … … 49 49 * devices driver. 50 50 */ 51 typedef void remote_iface_func_t(struct d evice*, void *, ipc_callid_t,51 typedef void remote_iface_func_t(struct ddf_fun *, void *, ipc_callid_t, 52 52 ipc_call_t *); 53 53 typedef remote_iface_func_t *remote_iface_func_ptr_t; 54 typedef void remote_handler_t(struct d evice*, ipc_callid_t, ipc_call_t *);54 typedef void remote_handler_t(struct ddf_fun *, ipc_callid_t, ipc_call_t *); 55 55 56 56 typedef struct { -
uspace/lib/drv/include/ops/char_dev.h
rdbe25f1 reb1a2f4 36 36 #define LIBDRV_OPS_CHAR_DEV_H_ 37 37 38 #include "../d river.h"38 #include "../ddf/driver.h" 39 39 40 40 typedef struct { 41 int (*read)(d evice_t *, char *, size_t);42 int (*write)(d evice_t *, char *, size_t);41 int (*read)(ddf_fun_t *, char *, size_t); 42 int (*write)(ddf_fun_t *, char *, size_t); 43 43 } char_dev_ops_t; 44 44 -
uspace/lib/drv/include/ops/hw_res.h
rdbe25f1 reb1a2f4 39 39 #include <sys/types.h> 40 40 41 #include "../d river.h"41 #include "../ddf/driver.h" 42 42 43 43 typedef struct { 44 hw_resource_list_t *(*get_resource_list)(d evice_t *);45 bool (*enable_interrupt)(d evice_t *);44 hw_resource_list_t *(*get_resource_list)(ddf_fun_t *); 45 bool (*enable_interrupt)(ddf_fun_t *); 46 46 } hw_res_ops_t; 47 47 -
uspace/lib/drv/include/usb_iface.h
rdbe25f1 reb1a2f4 38 38 #define LIBDRV_USB_IFACE_H_ 39 39 40 #include "d river.h"40 #include "ddf/driver.h" 41 41 #include <usb/usb.h> 42 42 typedef enum { … … 75 75 /** USB device communication interface. */ 76 76 typedef struct { 77 int (*get_address)(d evice_t *, devman_handle_t, usb_address_t *);78 int (*get_interface)(d evice_t *, devman_handle_t, int *);79 int (*get_hc_handle)(d evice_t *, devman_handle_t *);77 int (*get_address)(ddf_fun_t *, devman_handle_t, usb_address_t *); 78 int (*get_interface)(ddf_fun_t *, devman_handle_t, int *); 79 int (*get_hc_handle)(ddf_fun_t *, devman_handle_t *); 80 80 } usb_iface_t; 81 81 -
uspace/lib/drv/include/usbhc_iface.h
rdbe25f1 reb1a2f4 38 38 #define LIBDRV_USBHC_IFACE_H_ 39 39 40 #include "d river.h"40 #include "ddf/driver.h" 41 41 #include <usb/usb.h> 42 42 #include <bool.h> … … 171 171 172 172 /** Callback for outgoing transfer. */ 173 typedef void (*usbhc_iface_transfer_out_callback_t)(d evice_t *,173 typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *, 174 174 int, void *); 175 175 176 176 /** Callback for incoming transfer. */ 177 typedef void (*usbhc_iface_transfer_in_callback_t)(d evice_t *,177 typedef void (*usbhc_iface_transfer_in_callback_t)(ddf_fun_t *, 178 178 int, size_t, void *); 179 179 180 180 181 181 /** Out transfer processing function prototype. */ 182 typedef int (*usbhc_iface_transfer_out_t)(d evice_t *, usb_target_t, size_t,182 typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t, size_t, 183 183 void *, size_t, 184 184 usbhc_iface_transfer_out_callback_t, void *); … … 188 188 189 189 /** In transfer processing function prototype. */ 190 typedef int (*usbhc_iface_transfer_in_t)(d evice_t *, usb_target_t, size_t,190 typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t, size_t, 191 191 void *, size_t, 192 192 usbhc_iface_transfer_in_callback_t, void *); … … 194 194 /** USB host controller communication interface. */ 195 195 typedef struct { 196 int (*reserve_default_address)(d evice_t *, usb_speed_t);197 int (*release_default_address)(d evice_t *);198 int (*request_address)(d evice_t *, usb_speed_t, usb_address_t *);199 int (*bind_address)(d evice_t *, usb_address_t, devman_handle_t);200 int (*release_address)(d evice_t *, usb_address_t);196 int (*reserve_default_address)(ddf_fun_t *, usb_speed_t); 197 int (*release_default_address)(ddf_fun_t *); 198 int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *); 199 int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t); 200 int (*release_address)(ddf_fun_t *, usb_address_t); 201 201 202 202 usbhc_iface_transfer_out_t interrupt_out; … … 206 206 usbhc_iface_transfer_in_t bulk_in; 207 207 208 int (*control_write)(d evice_t *, usb_target_t,208 int (*control_write)(ddf_fun_t *, usb_target_t, 209 209 size_t, 210 210 void *, size_t, void *, size_t, 211 211 usbhc_iface_transfer_out_callback_t, void *); 212 212 213 int (*control_read)(d evice_t *, usb_target_t,213 int (*control_read)(ddf_fun_t *, usb_target_t, 214 214 size_t, 215 215 void *, size_t, void *, size_t,
Note:
See TracChangeset
for help on using the changeset viewer.