Changeset 9b415c9 in mainline for uspace/srv/devman/main.c
- Timestamp:
- 2011-03-30T21:19:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fc51296
- Parents:
- 0418050
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r0418050 r9b415c9 43 43 #include <stdio.h> 44 44 #include <errno.h> 45 #include <str_error.h> 45 46 #include <bool.h> 46 47 #include <fibril_synch.h> … … 51 52 #include <sys/stat.h> 52 53 #include <ctype.h> 54 #include <io/log.h> 53 55 #include <ipc/devman.h> 54 56 #include <ipc/driver.h> … … 71 73 driver_t *driver = NULL; 72 74 73 printf(NAME ": devman_driver_register\n");75 log_msg(LVL_DEBUG, "devman_driver_register\n"); 74 76 75 77 iid = async_get_call(&icall); … … 88 90 } 89 91 90 printf(NAME ": the %s driver is trying to register by the service.\n",92 log_msg(LVL_DEBUG, "The `%s' driver is trying to register.\n", 91 93 drv_name); 92 94 … … 95 97 96 98 if (driver == NULL) { 97 printf(NAME ": no driver named %swas found.\n", drv_name);99 log_msg(LVL_ERROR, "No driver named `%s' was found.\n", drv_name); 98 100 free(drv_name); 99 101 drv_name = NULL; … … 106 108 107 109 /* Create connection to the driver. */ 108 printf(NAME ": creating connection to the %s driver.\n", driver->name); 110 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.\n", 111 driver->name); 109 112 ipc_call_t call; 110 113 ipc_callid_t callid = async_get_call(&call); … … 118 121 set_driver_phone(driver, IPC_GET_ARG5(call)); 119 122 120 printf(NAME ": the %s driver was successfully registered as running.\n", 123 log_msg(LVL_NOTE, 124 "The `%s' driver was successfully registered as running.\n", 121 125 driver->name); 122 126 … … 142 146 callid = async_get_call(&call); 143 147 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 144 printf(NAME ": ERROR: devman_receive_match_id - invalid "145 " protocol.\n");148 log_msg(LVL_ERROR, 149 "Invalid protocol when trying to receive match id.\n"); 146 150 async_answer_0(callid, EINVAL); 147 151 delete_match_id(match_id); … … 150 154 151 155 if (match_id == NULL) { 152 printf(NAME ": ERROR: devman_receive_match_id - failed to " 153 "allocate match id.\n"); 156 log_msg(LVL_ERROR, "Failed to allocate match id.\n"); 154 157 async_answer_0(callid, ENOMEM); 155 158 return ENOMEM; … … 165 168 if (rc != EOK) { 166 169 delete_match_id(match_id); 167 printf(NAME ": devman_receive_match_id - failed to receive "168 "match id string.\n");170 log_msg(LVL_ERROR, "Failed to receive match id string: %s.\n", 171 str_error(rc)); 169 172 return rc; 170 173 } … … 172 175 list_append(&match_id->link, &match_ids->ids); 173 176 174 printf(NAME ": received match id '%s', score = %d\n",177 log_msg(LVL_DEBUG, "Received match id `%s', score %d.\n", 175 178 match_id->id, match_id->score); 176 179 return rc; … … 228 231 if (ftype != fun_inner && ftype != fun_exposed) { 229 232 /* Unknown function type */ 230 printf(NAME ": Error, unknown function type provided by driver!\n"); 233 log_msg(LVL_ERROR, 234 "Unknown function type %d provided by driver.\n", 235 (int) ftype); 231 236 232 237 fibril_rwlock_write_unlock(&tree->rwlock); … … 265 270 fibril_rwlock_write_unlock(&tree->rwlock); 266 271 267 printf(NAME ": devman_add_function %s\n", fun->pathname);272 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")\n", fun->pathname); 268 273 269 274 devman_receive_match_ids(match_count, &fun->match_ids); … … 347 352 devmap_register_class_dev(class_info); 348 353 349 printf(NAME ": function'%s' added to class '%s', class name '%s' was "350 "asigned to it\n",fun->pathname, class_name, class_info->dev_name);354 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.\n", 355 fun->pathname, class_name, class_info->dev_name); 351 356 352 357 async_answer_0(callid, EOK); … … 363 368 364 369 initialize_running_driver(driver, &device_tree); 365 printf(NAME ": the %s driver was successfully initialized.\n",370 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.\n", 366 371 driver->name); 367 372 return 0; … … 385 390 fid_t fid = fibril_create(init_running_drv, driver); 386 391 if (fid == 0) { 387 printf(NAME ": Error creating fibril for the initialization of "388 " the newly registered running driver.\n");392 log_msg(LVL_ERROR, "Failed to create initialization fibril " \ 393 "for driver `%s' .\n", driver->name); 389 394 return; 390 395 } … … 484 489 */ 485 490 if (dev == NULL) { 486 printf(NAME ": devman_forward error - no device or function with"487 " handle %" PRIun " was found.\n", handle);491 log_msg(LVL_ERROR, "IPC forwarding failed - no device or " 492 "function with handle %" PRIun " was found.\n", handle); 488 493 async_answer_0(iid, ENOENT); 489 494 return; … … 491 496 492 497 if (fun == NULL && !drv_to_parent) { 493 printf(NAME ": devman_forward error - cannot connect to " 494 "handle %" PRIun ", refers to a device.\n", handle); 498 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot " 499 "connect to handle %" PRIun ", refers to a device.\n", 500 handle); 495 501 async_answer_0(iid, ENOENT); 496 502 return; … … 513 519 514 520 if (driver == NULL) { 515 printf(NAME ": devman_forward error - the device is not in %" PRIun516 " usable state.\n", handle);521 log_msg(LVL_ERROR, "IPC forwarding refused - " \ 522 "the device %" PRIun " is not in usable state.\n", handle); 517 523 async_answer_0(iid, ENOENT); 518 524 return; … … 526 532 527 533 if (driver->phone <= 0) { 528 printf(NAME ": devman_forward: cound not forward to driver %s ",529 driver->name);530 printf("the driver's phone is %" PRIun ").\n",driver->phone);534 log_msg(LVL_ERROR, 535 "Could not forward to driver `%s' (phone is %d).\n", 536 driver->name, (int) driver->phone); 531 537 async_answer_0(iid, EINVAL); 532 538 return; … … 534 540 535 541 if (fun != NULL) { 536 printf(NAME ": devman_forward: forward connection to function %s to " 537 "driver %s.\n", fun->pathname, driver->name); 542 log_msg(LVL_DEBUG, 543 "Forwarding request for `%s' function to driver `%s'.\n", 544 fun->pathname, driver->name); 538 545 } else { 539 printf(NAME ": devman_forward: forward connection to device %s to " 540 "driver %s.\n", dev->pfun->pathname, driver->name); 546 log_msg(LVL_DEBUG, 547 "Forwarding request for `%s' device to driver `%s'.\n", 548 dev->pfun->pathname, driver->name); 541 549 } 542 550 … … 570 578 async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0, 571 579 IPC_FF_NONE); 572 printf(NAME ": devman_connection_devmapper: forwarded connection to " 573 "device %s to driver %s.\n", fun->pathname, dev->drv->name); 580 log_msg(LVL_DEBUG, 581 "Forwarding devmapper request for `%s' function to driver `%s'.\n", 582 fun->pathname, dev->drv->name); 574 583 } 575 584 … … 606 615 static bool devman_init(void) 607 616 { 608 printf(NAME ":devman_init - looking for available drivers.\n");617 log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n"); 609 618 610 619 /* Initialize list of available drivers. */ … … 612 621 if (lookup_available_drivers(&drivers_list, 613 622 DRIVER_DEFAULT_STORE) == 0) { 614 printf(NAME "no drivers found.");623 log_msg(LVL_FATAL, "no drivers found."); 615 624 return false; 616 625 } 617 626 618 printf(NAME ": devman_init- list of drivers has been initialized.\n");627 log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.\n"); 619 628 620 629 /* Create root device node. */ 621 630 if (!init_device_tree(&device_tree, &drivers_list)) { 622 printf(NAME " failed to initialize device tree.");631 log_msg(LVL_FATAL, "Failed to initialize device tree."); 623 632 return false; 624 633 } … … 641 650 printf(NAME ": HelenOS Device Manager\n"); 642 651 652 if (log_init(NAME, LVL_ERROR) != EOK) { 653 printf(NAME ": Error initializing logging subsystem.\n"); 654 return -1; 655 } 656 643 657 if (!devman_init()) { 644 printf(NAME ": Error while initializing service\n");658 log_msg(LVL_ERROR, "Error while initializing service.\n"); 645 659 return -1; 646 660 } … … 650 664 651 665 /* Register device manager at naming service. */ 652 if (service_register(SERVICE_DEVMAN) != EOK) 666 if (service_register(SERVICE_DEVMAN) != EOK) { 667 log_msg(LVL_ERROR, "Failed registering as a service.\n"); 653 668 return -1; 654 655 printf(NAME ": Accepting connections\n"); 669 } 670 671 printf(NAME ": Accepting connections.\n"); 656 672 async_manager(); 657 673
Note:
See TracChangeset
for help on using the changeset viewer.