Changeset e85920d in mainline
- Timestamp:
- 2010-02-18T15:23:15Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0c3666d
- Parents:
- 08d9c4e6
- Location:
- uspace/srv/devman
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r08d9c4e6 re85920d 244 244 node_t * create_root_node() 245 245 { 246 printf(NAME ": create_root_node\n"); 246 247 node_t *node = create_dev_node(); 247 248 if (node) { … … 257 258 driver_t * find_best_match_driver(link_t *drivers_list, node_t *node) 258 259 { 260 printf(NAME ": find_best_match_driver\n"); 259 261 driver_t *best_drv = NULL, *drv = NULL; 260 262 int best_score = 0, score = 0; … … 267 269 best_score = score; 268 270 best_drv = drv; 269 } 271 } 272 link = link->next; 270 273 } 271 274 … … 281 284 bool start_driver(driver_t *drv) 282 285 { 286 printf(NAME ": start_driver\n"); 287 283 288 char *argv[2]; 284 289 … … 293 298 } 294 299 300 drv->state = DRIVER_STARTING; 295 301 return true; 296 302 } … … 298 304 bool add_device(driver_t *drv, node_t *node) 299 305 { 306 printf(NAME ": add_device\n"); 307 300 308 // TODO 301 309 … … 310 318 bool assign_driver(node_t *node, link_t *drivers_list) 311 319 { 320 printf(NAME ": assign_driver\n"); 321 312 322 // find the driver which is the most suitable for handling this device 313 323 driver_t *drv = find_best_match_driver(drivers_list, node); 314 324 if (NULL == drv) { 325 printf(NAME ": no driver found for device.\n"); 315 326 return false; 316 327 } … … 319 330 attach_driver(node, drv); 320 331 321 if ( !drv->running) {332 if (DRIVER_NOT_STARTED == drv->state) { 322 333 // start driver 323 334 start_driver(drv); 324 } else { 335 } 336 337 if (DRIVER_RUNNING == drv->state) { 325 338 // notify driver about new device 326 339 add_device(drv, node); … … 332 345 bool init_device_tree(dev_tree_t *tree, link_t *drivers_list) 333 346 { 334 printf(NAME ": init_device_tree. ");347 printf(NAME ": init_device_tree.\n"); 335 348 // create root node and add it to the device tree 336 349 if (NULL == (tree->root_node = create_root_node())) { -
uspace/srv/devman/devman.h
r08d9c4e6 re85920d 40 40 #include <adt/list.h> 41 41 #include <ipc/ipc.h> 42 #include <fibril_synch.h> 42 43 43 44 #include "util.h" … … 74 75 } match_id_list_t; 75 76 77 typedef enum { 78 /** driver has not been started */ 79 DRIVER_NOT_STARTED = 0, 80 /** driver has been started, but has not registered as running and ready to receive requests */ 81 DRIVER_STARTING, 82 /** driver is running and prepared to serve incomming requests */ 83 DRIVER_RUNNING 84 } driver_state_t; 85 76 86 /** Representation of device driver. 77 87 */ … … 79 89 /** Pointers to previous and next drivers in a linked list */ 80 90 link_t drivers; 81 /** Specifies whether the driver has been started .*/82 bool running;91 /** Specifies whether the driver has been started and wheter is running and prepared to receive requests.*/ 92 int state; 83 93 /** Phone asociated with this driver */ 84 94 ipcarg_t phone; … … 91 101 /** Pointer to the linked list of devices controlled by this driver */ 92 102 link_t devices; 103 /** Fibril mutex for this driver - driver state, list of devices, phone.*/ 104 fibril_mutex_t driver_mutex; 93 105 } driver_t; 106 107 /** The list of drivers. */ 108 typedef struct driver_list { 109 /** List of drivers */ 110 link_t drivers; 111 /** Fibril mutex for list of drivers. */ 112 fibril_mutex_t drivers_mutex; 113 } driver_list_t; 94 114 95 115 /** Representation of a node in the device tree.*/ … … 101 121 /** List of child device nodes. */ 102 122 link_t children; 123 /** Fibril mutex for the list of child device nodes of this node. */ 124 fibril_mutex_t children_mutex; 103 125 /** List of device ids for device-to-driver matching.*/ 104 126 match_id_list_t match_ids;
Note:
See TracChangeset
for help on using the changeset viewer.