Changeset e280857 in mainline for uspace/srv/devman/main.c
- Timestamp:
- 2011-08-18T12:35:59Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99ac5cf
- Parents:
- 12f9f0d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r12f9f0d0 re280857 64 64 static driver_list_t drivers_list; 65 65 static dev_tree_t device_tree; 66 static class_list_t class_list;67 66 68 67 /** Register running driver. */ … … 333 332 } 334 333 335 static void loc_register_class_dev(dev_class_info_t *cli)336 {337 /* Create loc path and name for the service. */338 char *loc_pathname = NULL;339 340 asprintf(&loc_pathname, "%s/%s%c%s", LOC_CLASS_NAMESPACE,341 cli->dev_class->name, LOC_SEPARATOR, cli->dev_name);342 if (loc_pathname == NULL)343 return;344 345 /*346 * Register the device with location service and remember its347 * service ID.348 */349 loc_service_register_with_iface(loc_pathname,350 &cli->service_id, DEVMAN_CONNECT_FROM_LOC);351 352 /*353 * Add device to the hash map of class devices registered with354 * location service.355 */356 class_add_loc_function(&class_list, cli);357 358 free(loc_pathname);359 }360 361 334 static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call) 362 335 { … … 380 353 } 381 354 382 dev_class_t *cl = get_dev_class(&class_list, class_name);383 dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);384 385 /* Register the device's class alias with location service. */386 loc_register_class_dev(class_info);387 388 355 rc = loc_category_get_id(class_name, &cat_id, IPC_FLAG_BLOCKING); 389 356 if (rc == EOK) { … … 394 361 } 395 362 396 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",397 fun->pathname, class_name , class_info->dev_name);363 log_msg(LVL_NOTE, "Function `%s' added to class `%s'.", 364 fun->pathname, class_name); 398 365 399 366 async_answer_0(callid, EOK); … … 483 450 } 484 451 485 /** Find handle for the device instance identified by device class name. */486 static void devman_function_get_handle_by_class(ipc_callid_t iid,487 ipc_call_t *icall)488 {489 char *classname;490 char *devname;491 492 int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);493 if (rc != EOK) {494 async_answer_0(iid, rc);495 return;496 }497 rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);498 if (rc != EOK) {499 free(classname);500 async_answer_0(iid, rc);501 return;502 }503 504 505 fun_node_t *fun = find_fun_node_by_class(&class_list,506 classname, devname);507 508 free(classname);509 free(devname);510 511 if (fun == NULL) {512 async_answer_0(iid, ENOENT);513 return;514 }515 516 async_answer_1(iid, EOK, fun->handle);517 }518 519 452 /** Find device path by its handle. */ 520 453 static void devman_get_device_path_by_handle(ipc_callid_t iid, … … 554 487 } 555 488 489 /** Find handle for the function instance identified by its service ID. */ 490 static void devman_fun_sid_to_handle(ipc_callid_t iid, ipc_call_t *icall) 491 { 492 fun_node_t *fun; 493 494 fun = find_loc_tree_function(&device_tree, IPC_GET_ARG1(*icall)); 495 496 if (fun == NULL) { 497 async_answer_0(iid, ENOENT); 498 return; 499 } 500 501 async_answer_1(iid, EOK, fun->handle); 502 } 556 503 557 504 /** Function for handling connections from a client to the device manager. */ … … 572 519 devman_function_get_handle(callid, &call); 573 520 break; 574 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:575 devman_function_get_handle_by_class(callid, &call);576 break;577 521 case DEVMAN_DEVICE_GET_DEVICE_PATH: 578 522 devman_get_device_path_by_handle(callid, &call); 523 break; 524 case DEVMAN_FUN_SID_TO_HANDLE: 525 devman_fun_sid_to_handle(callid, &call); 579 526 break; 580 527 default: … … 678 625 679 626 fun = find_loc_tree_function(&device_tree, service_id); 680 if (fun == NULL)681 fun = find_loc_class_function(&class_list, service_id);682 627 683 628 if (fun == NULL || fun->dev->drv == NULL) { … … 750 695 } 751 696 752 init_class_list(&class_list);753 754 697 /* 755 698 * !!! devman_connection ... as the device manager is not a real loc
Note:
See TracChangeset
for help on using the changeset viewer.