Changeset b5e68c8 in mainline for uspace/srv/devman/devman.h
- Timestamp:
- 2011-05-12T16:49:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f36787d7
- Parents:
- e80329d6 (diff), 750636a (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 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
re80329d6 rb5e68c8 40 40 #include <adt/list.h> 41 41 #include <adt/hash_table.h> 42 #include <ipc/ipc.h>43 42 #include <ipc/devman.h> 44 43 #include <ipc/devmap.h> … … 57 56 #define DEVMAP_SEPARATOR '\\' 58 57 59 struct node; 60 typedef struct node node_t; 58 struct dev_node; 59 typedef struct dev_node dev_node_t; 60 61 struct fun_node; 62 typedef struct fun_node fun_node_t; 61 63 62 64 typedef enum { … … 86 88 87 89 /** Phone asociated with this driver. */ 88 i pcarg_t phone;90 int phone; 89 91 /** Name of the device driver. */ 90 92 char *name; … … 118 120 } device_state_t; 119 121 120 /** Representation of anode in the device tree. */121 struct node {122 /** Device node in the device tree. */ 123 struct dev_node { 122 124 /** The global unique identifier of the device. */ 123 device_handle_t handle; 124 /** The name of the device specified by its parent. */ 125 char *name; 126 127 /** 128 * Full path and name of the device in device hierarchi (i. e. in full 129 * path in device tree). 130 */ 131 char *pathname; 132 133 /** The node of the parent device. */ 134 node_t *parent; 135 136 /** 137 * Pointers to previous and next child devices in the linked list of 138 * parent device's node. 139 */ 140 link_t sibling; 141 142 /** List of child device nodes. */ 143 link_t children; 144 /** List of device ids for device-to-driver matching. */ 145 match_id_list_t match_ids; 125 devman_handle_t handle; 126 127 /** (Parent) function the device is attached to. */ 128 fun_node_t *pfun; 129 130 /** List of device functions. */ 131 link_t functions; 146 132 /** Driver of this device. */ 147 133 driver_t *drv; 148 134 /** The state of the device. */ 149 135 device_state_t state; 150 /** 151 * Pointer to the previous and next device in the list of devices 152 * owned by one driver. 153 */ 136 /** Link to list of devices owned by driver (driver_t.devices) */ 154 137 link_t driver_devices; 155 138 156 /** The list of device classes to which this device belongs. */ 139 /** 140 * Used by the hash table of devices indexed by devman device handles. 141 */ 142 link_t devman_dev; 143 144 /** 145 * Whether this device was already passed to the driver. 146 */ 147 bool passed_to_driver; 148 }; 149 150 /** Function node in the device tree. */ 151 struct fun_node { 152 /** The global unique identifier of the function */ 153 devman_handle_t handle; 154 /** Name of the function, assigned by the device driver */ 155 char *name; 156 157 /** Full path and name of the device in device hierarchy */ 158 char *pathname; 159 160 /** Device which this function belongs to */ 161 dev_node_t *dev; 162 163 /** Link to list of functions in the device (ddf_dev_t.functions) */ 164 link_t dev_functions; 165 166 /** Child device node (if any attached). */ 167 dev_node_t *child; 168 /** List of device ids for device-to-driver matching. */ 169 match_id_list_t match_ids; 170 171 /** The list of device classes to which this device function belongs. */ 157 172 link_t classes; 158 /** Devmap handle if the device is registered by devmapper. */159 dev _handle_t devmap_handle;160 161 /** 162 * Used by the hash table of devices indexed by devman device handles.163 */ 164 link_t devman_ link;165 166 /** 167 * Used by the hash table of devices indexed by devmap device handles.168 */ 169 link_t devmap_ link;173 /** Devmap handle if the device function is registered by devmap. */ 174 devmap_handle_t devmap_handle; 175 176 /** 177 * Used by the hash table of functions indexed by devman device handles. 178 */ 179 link_t devman_fun; 180 181 /** 182 * Used by the hash table of functions indexed by devmap device handles. 183 */ 184 link_t devmap_fun; 170 185 }; 186 171 187 172 188 /** Represents device tree. */ 173 189 typedef struct dev_tree { 174 190 /** Root device node. */ 175 node_t *root_node;191 fun_node_t *root_node; 176 192 177 193 /** … … 179 195 * manner. 180 196 */ 181 dev ice_handle_t current_handle;197 devman_handle_t current_handle; 182 198 183 199 /** Synchronize access to the device tree. */ … … 187 203 hash_table_t devman_devices; 188 204 205 /** Hash table of all devices indexed by devman handles. */ 206 hash_table_t devman_functions; 207 189 208 /** 190 209 * Hash table of devices registered by devmapper, indexed by devmap 191 210 * handles. 192 211 */ 193 hash_table_t devmap_ devices;212 hash_table_t devmap_functions; 194 213 } dev_tree_t; 195 214 … … 223 242 224 243 /** 225 * Provides n-to-m mapping between device nodes and classes - each device may226 * be register to the arbitrary number of classes and each class maycontain227 * the arbitrary number of devices.244 * Provides n-to-m mapping between function nodes and classes - each function 245 * can register in an arbitrary number of classes and each class can contain 246 * an arbitrary number of device functions. 228 247 */ 229 248 typedef struct dev_class_info { … … 231 250 dev_class_t *dev_class; 232 251 /** The device. */ 233 node_t *dev;252 fun_node_t *fun; 234 253 235 254 /** … … 245 264 link_t dev_classes; 246 265 247 /** The name of the device within the class. */266 /** The name of the device function within the class. */ 248 267 char *dev_name; 249 268 /** The handle of the device by device mapper in the class namespace. */ 250 dev _handle_t devmap_handle;269 devmap_handle_t devmap_handle; 251 270 252 271 /** … … 266 285 * indexed by devmap handles. 267 286 */ 268 hash_table_t devmap_ devices;287 hash_table_t devmap_functions; 269 288 270 289 /** Fibril mutex for list of classes. */ … … 274 293 /* Match ids and scores */ 275 294 276 extern int get_match_score(driver_t *, node_t *);295 extern int get_match_score(driver_t *, dev_node_t *); 277 296 278 297 extern bool parse_match_ids(char *, match_id_list_t *); … … 288 307 extern int lookup_available_drivers(driver_list_t *, const char *); 289 308 290 extern driver_t *find_best_match_driver(driver_list_t *, node_t *);291 extern bool assign_driver( node_t *, driver_list_t *, dev_tree_t *);309 extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *); 310 extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *); 292 311 293 312 extern void add_driver(driver_list_t *, driver_t *); 294 extern void attach_driver( node_t *, driver_t *);295 extern void add_device(int, driver_t *, node_t *, dev_tree_t *);313 extern void attach_driver(dev_node_t *, driver_t *); 314 extern void add_device(int, driver_t *, dev_node_t *, dev_tree_t *); 296 315 extern bool start_driver(driver_t *); 297 316 298 317 extern driver_t *find_driver(driver_list_t *, const char *); 299 extern void set_driver_phone(driver_t *, ipcarg_t);300 318 extern void initialize_running_driver(driver_t *, dev_tree_t *); 301 319 … … 306 324 /* Device nodes */ 307 325 308 extern node_t *create_dev_node(void); 309 extern void delete_dev_node(node_t *node); 310 extern node_t *find_dev_node_no_lock(dev_tree_t *tree, 311 device_handle_t handle); 312 extern node_t *find_dev_node(dev_tree_t *tree, device_handle_t handle); 313 extern node_t *find_dev_node_by_path(dev_tree_t *, char *); 314 extern node_t *find_node_child(node_t *, const char *); 326 extern dev_node_t *create_dev_node(void); 327 extern void delete_dev_node(dev_node_t *node); 328 extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree, 329 devman_handle_t handle); 330 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle); 331 extern dev_node_t *find_dev_function(dev_node_t *, const char *); 332 333 extern fun_node_t *create_fun_node(void); 334 extern void delete_fun_node(fun_node_t *); 335 extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree, 336 devman_handle_t handle); 337 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle); 338 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *); 339 extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *); 340 extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *); 315 341 316 342 /* Device tree */ 317 343 318 344 extern bool init_device_tree(dev_tree_t *, driver_list_t *); 319 extern bool create_root_node(dev_tree_t *); 320 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *); 345 extern bool create_root_nodes(dev_tree_t *); 346 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *); 347 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *); 321 348 322 349 /* Device classes */ … … 326 353 extern size_t get_new_class_dev_idx(dev_class_t *); 327 354 extern char *create_dev_name_for_class(dev_class_t *, const char *); 328 extern dev_class_info_t *add_ device_to_class(node_t *, dev_class_t *,355 extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *, 329 356 const char *); 330 357 … … 333 360 extern dev_class_t *get_dev_class(class_list_t *, char *); 334 361 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *); 362 extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *); 335 363 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *); 336 364 337 365 /* Devmap devices */ 338 366 339 extern node_t *find_devmap_tree_device(dev_tree_t *, dev_handle_t); 340 extern node_t *find_devmap_class_device(class_list_t *, dev_handle_t); 341 342 extern void class_add_devmap_device(class_list_t *, dev_class_info_t *); 343 extern void tree_add_devmap_device(dev_tree_t *, node_t *); 367 extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *); 368 369 extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t); 370 extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t); 371 372 extern void class_add_devmap_function(class_list_t *, dev_class_info_t *); 373 extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *); 344 374 345 375 #endif
Note:
See TracChangeset
for help on using the changeset viewer.