Changeset 084ff99 in mainline for uspace/srv/devman/devman.c
- Timestamp:
- 2010-03-14T09:14:50Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7707954
- Parents:
- 67ba309
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r67ba309 r084ff99 34 34 #include <fcntl.h> 35 35 #include <sys/stat.h> 36 #include <ipc/driver.h> 37 #include <ipc/devman.h> 36 38 37 39 #include "devman.h" … … 308 310 } 309 311 310 /** Create root device node of the device tree. 311 * 312 * @return root device node. 313 */ 314 node_t * create_root_node() 312 /** Create root device node in the device tree. 313 * 314 * @param tree the device tree. 315 * @return true on success, false otherwise. 316 */ 317 bool create_root_node(dev_tree_t *tree) 315 318 { 316 319 printf(NAME ": create_root_node\n"); 317 320 node_t *node = create_dev_node(); 318 321 if (node) { 319 in it_dev_node(node, NULL);322 insert_dev_node(tree, node, NULL); 320 323 match_id_t *id = create_match_id(); 321 324 id->id = "root"; 322 325 id->score = 100; 323 326 add_match_id(&node->match_ids, id); 324 } 325 return node; 327 tree->root_node = node; 328 } 329 return node != NULL; 326 330 } 327 331 … … 448 452 link_t *link; 449 453 450 link = driver->devices.next; 451 while (link != &driver->devices) { 452 dev = list_get_instance(link, node_t, driver_devices); 453 add_device(driver, dev); 454 link = link->next; 455 } 454 int phone = ipc_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0); 455 456 if (0 < phone) { 457 458 link = driver->devices.next; 459 while (link != &driver->devices) { 460 dev = list_get_instance(link, node_t, driver_devices); 461 add_device(phone, driver, dev); 462 link = link->next; 463 } 464 465 ipc_hangup(phone); 466 } 456 467 } 457 468 … … 463 474 */ 464 475 void initialize_running_driver(driver_t *driver) 465 { 476 { 466 477 fibril_mutex_lock(&driver->driver_mutex); 467 478 … … 480 491 * @param node the device's node in the device tree. 481 492 */ 482 void add_device( driver_t *drv, node_t *node)493 void add_device(int phone, driver_t *drv, node_t *node) 483 494 { 484 495 printf(NAME ": add_device\n"); 485 486 // TODO 487 488 // pass a new device to the running driver, which was previously assigned to it 489 // send the phone of the parent's driver and device's handle within the parent's driver to the driver 490 // let the driver to probe the device and specify whether the device is actually present 491 // if the device is present, remember its handle within the driver 496 497 ipcarg_t ret; 498 ipcarg_t rc = async_req_1_1(phone, DRIVER_ADD_DEVICE, node->handle, &ret); 499 if (rc != EOK) { 500 // TODO handle error 501 return false; 502 } 503 504 // TODO inspect return value (ret) to find out whether the device was successfully probed and added 492 505 493 506 return true; 494 507 } 495 508 496 /** 509 /** 497 510 * Find suitable driver for a device and assign the driver to it. 498 511 * … … 523 536 if (DRIVER_RUNNING == drv->state) { 524 537 // notify driver about new device 525 add_device(drv, node); 538 int phone = ipc_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0); 539 if (phone > 0) { 540 add_device(phone, drv, node); 541 ipc_hangup(phone); 542 } 526 543 } 527 544 … … 542 559 printf(NAME ": init_device_tree.\n"); 543 560 561 atomic_set(&tree->current_handle, 0); 562 544 563 // create root node and add it to the device tree 545 if ( NULL == (tree->root_node = create_root_node())) {564 if (!create_root_node(tree)) { 546 565 return false; 547 566 }
Note:
See TracChangeset
for help on using the changeset viewer.