Changes in uspace/srv/devman/main.c [9b415c9:fc8c2b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r9b415c9 rfc8c2b6 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\n");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.\n",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.\n", 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.\n", 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.\n", 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.\n");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.\n"); 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.\n",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.\n",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.\n", 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 245 /* Check that function with same name is not there already. */ 246 if (find_fun_node_in_device(pdev, fun_name) != NULL) { 247 fibril_rwlock_write_unlock(&tree->rwlock); 248 async_answer_0(callid, EEXISTS); 249 printf(NAME ": Warning, driver tried to register `%s' twice.\n", 250 fun_name); 251 free(fun_name); 252 return; 253 } 254 250 255 fun_node_t *fun = create_fun_node(); 251 256 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { … … 270 275 fibril_rwlock_write_unlock(&tree->rwlock); 271 276 272 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")\n", fun->pathname);277 printf(NAME ": devman_add_function %s\n", fun->pathname); 273 278 274 279 devman_receive_match_ids(match_count, &fun->match_ids); … … 352 357 devmap_register_class_dev(class_info); 353 358 354 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.\n",355 fun->pathname, class_name, class_info->dev_name);359 printf(NAME ": function'%s' added to class '%s', class name '%s' was " 360 "asigned to it\n", fun->pathname, class_name, class_info->dev_name); 356 361 357 362 async_answer_0(callid, EOK); … … 368 373 369 374 initialize_running_driver(driver, &device_tree); 370 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.\n",375 printf(NAME ": the %s driver was successfully initialized. \n", 371 376 driver->name); 372 377 return 0; … … 390 395 fid_t fid = fibril_create(init_running_drv, driver); 391 396 if (fid == 0) { 392 log_msg(LVL_ERROR, "Failed to create initialization fibril " \393 " for driver `%s' .\n", driver->name);397 printf(NAME ": Error creating fibril for the initialization of " 398 "the newly registered running driver.\n"); 394 399 return; 395 400 } … … 443 448 } 444 449 450 /** Find handle for the device instance identified by device class name. */ 451 static void devman_function_get_handle_by_class(ipc_callid_t iid, 452 ipc_call_t *icall) 453 { 454 char *classname; 455 char *devname; 456 457 int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0); 458 if (rc != EOK) { 459 async_answer_0(iid, rc); 460 return; 461 } 462 rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0); 463 if (rc != EOK) { 464 free(classname); 465 async_answer_0(iid, rc); 466 return; 467 } 468 469 470 fun_node_t *fun = find_fun_node_by_class(&class_list, 471 classname, devname); 472 473 free(classname); 474 free(devname); 475 476 if (fun == NULL) { 477 async_answer_0(iid, ENOENT); 478 return; 479 } 480 481 async_answer_1(iid, EOK, fun->handle); 482 } 483 445 484 446 485 /** Function for handling connections from a client to the device manager. */ … … 462 501 devman_function_get_handle(callid, &call); 463 502 break; 503 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS: 504 devman_function_get_handle_by_class(callid, &call); 505 break; 464 506 default: 465 507 async_answer_0(callid, ENOENT); … … 489 531 */ 490 532 if (dev == NULL) { 491 log_msg(LVL_ERROR, "IPC forwarding failed - no device or"492 " function withhandle %" PRIun " was found.\n", handle);533 printf(NAME ": devman_forward error - no device or function with " 534 "handle %" PRIun " was found.\n", handle); 493 535 async_answer_0(iid, ENOENT); 494 536 return; … … 496 538 497 539 if (fun == NULL && !drv_to_parent) { 498 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot " 499 "connect to handle %" PRIun ", refers to a device.\n", 500 handle); 540 printf(NAME ": devman_forward error - cannot connect to " 541 "handle %" PRIun ", refers to a device.\n", handle); 501 542 async_answer_0(iid, ENOENT); 502 543 return; … … 519 560 520 561 if (driver == NULL) { 521 log_msg(LVL_ERROR, "IPC forwarding refused - " \522 " the device %" PRIun " is not inusable state.\n", handle);562 printf(NAME ": devman_forward error - the device is not in %" PRIun 563 " usable state.\n", handle); 523 564 async_answer_0(iid, ENOENT); 524 565 return; … … 532 573 533 574 if (driver->phone <= 0) { 534 log_msg(LVL_ERROR,535 "Could not forward to driver `%s' (phone is %d).\n",536 driver->name, (int)driver->phone);575 printf(NAME ": devman_forward: cound not forward to driver %s ", 576 driver->name); 577 printf("the driver's phone is %" PRIun ").\n", driver->phone); 537 578 async_answer_0(iid, EINVAL); 538 579 return; … … 540 581 541 582 if (fun != NULL) { 542 log_msg(LVL_DEBUG, 543 "Forwarding request for `%s' function to driver `%s'.\n", 544 fun->pathname, driver->name); 583 printf(NAME ": devman_forward: forward connection to function %s to " 584 "driver %s.\n", fun->pathname, driver->name); 545 585 } else { 546 log_msg(LVL_DEBUG, 547 "Forwarding request for `%s' device to driver `%s'.\n", 548 dev->pfun->pathname, driver->name); 586 printf(NAME ": devman_forward: forward connection to device %s to " 587 "driver %s.\n", dev->pfun->pathname, driver->name); 549 588 } 550 589 … … 578 617 async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0, 579 618 IPC_FF_NONE); 580 log_msg(LVL_DEBUG, 581 "Forwarding devmapper request for `%s' function to driver `%s'.\n", 582 fun->pathname, dev->drv->name); 619 printf(NAME ": devman_connection_devmapper: forwarded connection to " 620 "device %s to driver %s.\n", fun->pathname, dev->drv->name); 583 621 } 584 622 … … 615 653 static bool devman_init(void) 616 654 { 617 log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n");655 printf(NAME ": devman_init - looking for available drivers.\n"); 618 656 619 657 /* Initialize list of available drivers. */ … … 621 659 if (lookup_available_drivers(&drivers_list, 622 660 DRIVER_DEFAULT_STORE) == 0) { 623 log_msg(LVL_FATAL, "no drivers found.");661 printf(NAME " no drivers found."); 624 662 return false; 625 663 } 626 664 627 log_msg(LVL_DEBUG, "devman_init- list of drivers has been initialized.\n");665 printf(NAME ": devman_init - list of drivers has been initialized.\n"); 628 666 629 667 /* Create root device node. */ 630 668 if (!init_device_tree(&device_tree, &drivers_list)) { 631 log_msg(LVL_FATAL, "Failed to initialize device tree.");669 printf(NAME " failed to initialize device tree."); 632 670 return false; 633 671 } … … 650 688 printf(NAME ": HelenOS Device Manager\n"); 651 689 652 if (log_init(NAME, LVL_ERROR) != EOK) {653 printf(NAME ": Error initializing logging subsystem.\n");654 return -1;655 }656 657 690 if (!devman_init()) { 658 log_msg(LVL_ERROR, "Error while initializing service.\n");691 printf(NAME ": Error while initializing service\n"); 659 692 return -1; 660 693 } … … 664 697 665 698 /* Register device manager at naming service. */ 666 if (service_register(SERVICE_DEVMAN) != EOK) { 667 log_msg(LVL_ERROR, "Failed registering as a service.\n"); 699 if (service_register(SERVICE_DEVMAN) != EOK) 668 700 return -1; 669 } 670 671 printf(NAME ": Accepting connections.\n"); 701 702 printf(NAME ": Accepting connections\n"); 672 703 async_manager(); 673 704
Note:
See TracChangeset
for help on using the changeset viewer.