Changes in uspace/srv/devman/main.c [ebcb05a:0418050] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
rebcb05a r0418050 43 43 #include <stdio.h> 44 44 #include <errno.h> 45 #include <str_error.h>46 45 #include <bool.h> 47 46 #include <fibril_synch.h> … … 52 51 #include <sys/stat.h> 53 52 #include <ctype.h> 54 #include <io/log.h>55 53 #include <ipc/devman.h> 56 54 #include <ipc/driver.h> … … 73 71 driver_t *driver = NULL; 74 72 75 log_msg(LVL_DEBUG, "devman_driver_register");73 printf(NAME ": devman_driver_register \n"); 76 74 77 75 iid = async_get_call(&icall); … … 90 88 } 91 89 92 log_msg(LVL_DEBUG, "The `%s' driver is trying to register.",90 printf(NAME ": the %s driver is trying to register by the service.\n", 93 91 drv_name); 94 92 … … 97 95 98 96 if (driver == NULL) { 99 log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);97 printf(NAME ": no driver named %s was found.\n", drv_name); 100 98 free(drv_name); 101 99 drv_name = NULL; … … 108 106 109 107 /* Create connection to the driver. */ 110 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.", 111 driver->name); 108 printf(NAME ": creating connection to the %s driver.\n", driver->name); 112 109 ipc_call_t call; 113 110 ipc_callid_t callid = async_get_call(&call); … … 121 118 set_driver_phone(driver, IPC_GET_ARG5(call)); 122 119 123 log_msg(LVL_NOTE, 124 "The `%s' driver was successfully registered as running.", 120 printf(NAME ": the %s driver was successfully registered as running.\n", 125 121 driver->name); 126 122 … … 146 142 callid = async_get_call(&call); 147 143 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 148 log_msg(LVL_ERROR,149 " Invalid protocol when trying to receive match id.");144 printf(NAME ": ERROR: devman_receive_match_id - invalid " 145 "protocol.\n"); 150 146 async_answer_0(callid, EINVAL); 151 147 delete_match_id(match_id); … … 154 150 155 151 if (match_id == NULL) { 156 log_msg(LVL_ERROR, "Failed to allocate match id."); 152 printf(NAME ": ERROR: devman_receive_match_id - failed to " 153 "allocate match id.\n"); 157 154 async_answer_0(callid, ENOMEM); 158 155 return ENOMEM; … … 168 165 if (rc != EOK) { 169 166 delete_match_id(match_id); 170 log_msg(LVL_ERROR, "Failed to receive match id string: %s.",171 str_error(rc));167 printf(NAME ": devman_receive_match_id - failed to receive " 168 "match id string.\n"); 172 169 return rc; 173 170 } … … 175 172 list_append(&match_id->link, &match_ids->ids); 176 173 177 log_msg(LVL_DEBUG, "Received match id `%s', score %d.",174 printf(NAME ": received match id '%s', score = %d \n", 178 175 match_id->id, match_id->score); 179 176 return rc; … … 231 228 if (ftype != fun_inner && ftype != fun_exposed) { 232 229 /* Unknown function type */ 233 log_msg(LVL_ERROR, 234 "Unknown function type %d provided by driver.", 235 (int) ftype); 230 printf(NAME ": Error, unknown function type provided by driver!\n"); 236 231 237 232 fibril_rwlock_write_unlock(&tree->rwlock); … … 248 243 } 249 244 250 /* Check that function with same name is not there already. */251 if (find_fun_node_in_device(pdev, fun_name) != NULL) {252 fibril_rwlock_write_unlock(&tree->rwlock);253 async_answer_0(callid, EEXISTS);254 printf(NAME ": Warning, driver tried to register `%s' twice.\n",255 fun_name);256 free(fun_name);257 return;258 }259 260 245 fun_node_t *fun = create_fun_node(); 261 246 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { … … 280 265 fibril_rwlock_write_unlock(&tree->rwlock); 281 266 282 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")", fun->pathname);267 printf(NAME ": devman_add_function %s\n", fun->pathname); 283 268 284 269 devman_receive_match_ids(match_count, &fun->match_ids); … … 362 347 devmap_register_class_dev(class_info); 363 348 364 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",365 fun->pathname, class_name, class_info->dev_name);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); 366 351 367 352 async_answer_0(callid, EOK); … … 378 363 379 364 initialize_running_driver(driver, &device_tree); 380 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.",365 printf(NAME ": the %s driver was successfully initialized. \n", 381 366 driver->name); 382 367 return 0; … … 400 385 fid_t fid = fibril_create(init_running_drv, driver); 401 386 if (fid == 0) { 402 log_msg(LVL_ERROR, "Failed to create initialization fibril " \403 " for driver `%s'.", driver->name);387 printf(NAME ": Error creating fibril for the initialization of " 388 "the newly registered running driver.\n"); 404 389 return; 405 390 } … … 453 438 } 454 439 455 /** Find handle for the device instance identified by device class name. */456 static void devman_function_get_handle_by_class(ipc_callid_t iid,457 ipc_call_t *icall)458 {459 char *classname;460 char *devname;461 462 int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);463 if (rc != EOK) {464 async_answer_0(iid, rc);465 return;466 }467 rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);468 if (rc != EOK) {469 free(classname);470 async_answer_0(iid, rc);471 return;472 }473 474 475 fun_node_t *fun = find_fun_node_by_class(&class_list,476 classname, devname);477 478 free(classname);479 free(devname);480 481 if (fun == NULL) {482 async_answer_0(iid, ENOENT);483 return;484 }485 486 async_answer_1(iid, EOK, fun->handle);487 }488 489 440 490 441 /** Function for handling connections from a client to the device manager. */ … … 506 457 devman_function_get_handle(callid, &call); 507 458 break; 508 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:509 devman_function_get_handle_by_class(callid, &call);510 break;511 459 default: 512 460 async_answer_0(callid, ENOENT); … … 536 484 */ 537 485 if (dev == NULL) { 538 log_msg(LVL_ERROR, "IPC forwarding failed - no device or"539 " function with handle %" PRIun " was found.", handle);486 printf(NAME ": devman_forward error - no device or function with " 487 "handle %" PRIun " was found.\n", handle); 540 488 async_answer_0(iid, ENOENT); 541 489 return; … … 543 491 544 492 if (fun == NULL && !drv_to_parent) { 545 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot " 546 "connect to handle %" PRIun ", refers to a device.", 547 handle); 493 printf(NAME ": devman_forward error - cannot connect to " 494 "handle %" PRIun ", refers to a device.\n", handle); 548 495 async_answer_0(iid, ENOENT); 549 496 return; … … 566 513 567 514 if (driver == NULL) { 568 log_msg(LVL_ERROR, "IPC forwarding refused - " \569 " the device %" PRIun " is not in usable state.", handle);515 printf(NAME ": devman_forward error - the device is not in %" PRIun 516 " usable state.\n", handle); 570 517 async_answer_0(iid, ENOENT); 571 518 return; … … 579 526 580 527 if (driver->phone <= 0) { 581 log_msg(LVL_ERROR,582 "Could not forward to driver `%s' (phone is %d).",583 driver->name, (int)driver->phone);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); 584 531 async_answer_0(iid, EINVAL); 585 532 return; … … 587 534 588 535 if (fun != NULL) { 589 log_msg(LVL_DEBUG, 590 "Forwarding request for `%s' function to driver `%s'.", 591 fun->pathname, driver->name); 536 printf(NAME ": devman_forward: forward connection to function %s to " 537 "driver %s.\n", fun->pathname, driver->name); 592 538 } else { 593 log_msg(LVL_DEBUG, 594 "Forwarding request for `%s' device to driver `%s'.", 595 dev->pfun->pathname, driver->name); 539 printf(NAME ": devman_forward: forward connection to device %s to " 540 "driver %s.\n", dev->pfun->pathname, driver->name); 596 541 } 597 542 … … 625 570 async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0, 626 571 IPC_FF_NONE); 627 log_msg(LVL_DEBUG, 628 "Forwarding devmapper request for `%s' function to driver `%s'.", 629 fun->pathname, dev->drv->name); 572 printf(NAME ": devman_connection_devmapper: forwarded connection to " 573 "device %s to driver %s.\n", fun->pathname, dev->drv->name); 630 574 } 631 575 … … 662 606 static bool devman_init(void) 663 607 { 664 log_msg(LVL_DEBUG, "devman_init - looking for available drivers.");608 printf(NAME ": devman_init - looking for available drivers.\n"); 665 609 666 610 /* Initialize list of available drivers. */ … … 668 612 if (lookup_available_drivers(&drivers_list, 669 613 DRIVER_DEFAULT_STORE) == 0) { 670 log_msg(LVL_FATAL, "No drivers found.");614 printf(NAME " no drivers found."); 671 615 return false; 672 616 } 673 617 674 log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.");618 printf(NAME ": devman_init - list of drivers has been initialized.\n"); 675 619 676 620 /* Create root device node. */ 677 621 if (!init_device_tree(&device_tree, &drivers_list)) { 678 log_msg(LVL_FATAL, "Failed to initialize device tree.");622 printf(NAME " failed to initialize device tree."); 679 623 return false; 680 624 } … … 697 641 printf(NAME ": HelenOS Device Manager\n"); 698 642 699 if (log_init(NAME, LVL_ERROR) != EOK) {700 printf(NAME ": Error initializing logging subsystem.\n");701 return -1;702 }703 704 643 if (!devman_init()) { 705 log_msg(LVL_ERROR, "Error while initializing service.");644 printf(NAME ": Error while initializing service\n"); 706 645 return -1; 707 646 } … … 711 650 712 651 /* Register device manager at naming service. */ 713 if (service_register(SERVICE_DEVMAN) != EOK) { 714 log_msg(LVL_ERROR, "Failed registering as a service."); 652 if (service_register(SERVICE_DEVMAN) != EOK) 715 653 return -1; 716 } 717 718 printf(NAME ": Accepting connections.\n"); 654 655 printf(NAME ": Accepting connections\n"); 719 656 async_manager(); 720 657
Note:
See TracChangeset
for help on using the changeset viewer.