Changeset 76b5a95c in mainline for uspace/lib/drv/include/ddf/driver.h
- Timestamp:
- 2011-03-23T20:53:30Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 71af5a4
- Parents:
- 5716e9a (diff), ab10b842 (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
r5716e9a r76b5a95c 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 <kernel/ddi/irq.h>39 #include <adt/list.h>40 #include <devman.h>41 39 #include <ipc/devman.h> 42 40 #include <ipc/dev_iface.h> 43 #include <assert.h>44 #include <ddi.h>45 #include <libarch/ddi.h>46 #include <fibril_synch.h>47 #include <malloc.h>48 41 49 #include " dev_iface.h"42 #include "../dev_iface.h" 50 43 51 struct device;52 typedef struct d evice device_t;44 typedef struct ddf_dev ddf_dev_t; 45 typedef struct ddf_fun ddf_fun_t; 53 46 54 47 /* 55 * Device class48 * Device 56 49 */ 57 50 58 51 /** Devices operations */ 59 typedef struct d evice_ops {52 typedef struct ddf_dev_ops { 60 53 /** 61 54 * Optional callback function called when a client is connecting to the 62 55 * device. 63 56 */ 64 int (*open)(d evice_t *);57 int (*open)(ddf_fun_t *); 65 58 66 59 /** … … 68 61 * the device. 69 62 */ 70 void (*close)(d evice_t *);63 void (*close)(ddf_fun_t *); 71 64 72 65 /** The table of standard interfaces implemented by the device. */ … … 79 72 */ 80 73 remote_handler_t *default_handler; 81 } device_ops_t; 82 83 84 /* 85 * Device 86 */ 74 } ddf_dev_ops_t; 87 75 88 76 /** Device structure */ 89 struct d evice{77 struct ddf_dev { 90 78 /** 91 79 * Globally unique device identifier (assigned to the device by the … … 100 88 int parent_phone; 101 89 102 /** Parent device if handled by this driver, NULL otherwise */103 device_t *parent;104 90 /** Device name */ 105 91 const char *name; 106 /** List of device ids for device-to-driver matching */ 107 match_id_list_t match_ids; 92 108 93 /** Driver-specific data associated with this device */ 109 94 void *driver_data; 110 /** The implementation of operations provided by this device */111 device_ops_t *ops;112 95 113 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 */ 114 122 link_t link; 115 123 }; … … 122 130 typedef struct driver_ops { 123 131 /** Callback method for passing a new device to the device driver */ 124 int (*add_device)(d evice_t *dev);132 int (*add_device)(ddf_dev_t *dev); 125 133 /* TODO: add other generic driver operations */ 126 134 } driver_ops_t; … … 134 142 } driver_t; 135 143 136 intdriver_main(driver_t *);144 extern int ddf_driver_main(driver_t *); 137 145 138 /** Create new device structure. 139 * 140 * @return The device structure. 141 */ 142 extern device_t *create_device(void); 143 extern void delete_device(device_t *); 144 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); 145 150 146 extern int child_device_register(device_t *, device_t *); 147 extern int child_device_register_wrapper(device_t *, const char *, const char *, 148 int); 149 150 /* 151 * Interrupts 152 */ 153 154 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *); 155 156 typedef struct interrupt_context { 157 int id; 158 device_t *dev; 159 int irq; 160 interrupt_handler_t *handler; 161 link_t link; 162 } interrupt_context_t; 163 164 typedef struct interrupt_context_list { 165 int curr_id; 166 link_t contexts; 167 fibril_mutex_t mutex; 168 } interrupt_context_list_t; 169 170 extern interrupt_context_t *create_interrupt_context(void); 171 extern void delete_interrupt_context(interrupt_context_t *); 172 extern void init_interrupt_context_list(interrupt_context_list_t *); 173 extern void add_interrupt_context(interrupt_context_list_t *, 174 interrupt_context_t *); 175 extern void remove_interrupt_context(interrupt_context_list_t *, 176 interrupt_context_t *); 177 extern interrupt_context_t *find_interrupt_context_by_id( 178 interrupt_context_list_t *, int); 179 extern interrupt_context_t *find_interrupt_context( 180 interrupt_context_list_t *, device_t *, int); 181 182 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *, 183 irq_code_t *); 184 extern int unregister_interrupt_handler(device_t *, int); 185 186 extern remote_handler_t *device_get_default_handler(device_t *); 187 extern int add_device_to_class(device_t *, const char *); 151 extern int ddf_fun_add_to_class(ddf_fun_t *, const char *); 188 152 189 153 #endif
Note:
See TracChangeset
for help on using the changeset viewer.