Changeset 3b5d1535 in mainline for uspace/lib/drv/include/ddf/driver.h
- Timestamp:
- 2011-02-23T10:28:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eb48f61
- Parents:
- e936e8e (diff), eb1a2f4 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/include/ddf/driver.h
re936e8e r3b5d1535 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
Note:
See TracChangeset
for help on using the changeset viewer.