Changeset 2b0db98 in mainline for uspace/srv/devman
- Timestamp:
- 2011-01-07T14:02:56Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6986418
- Parents:
- d99120f (diff), 0f191a2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/srv/devman
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
rd99120f r2b0db98 62 62 } 63 63 64 static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys, 65 link_t *item) 66 { 67 dev_class_info_t *class_info 68 = hash_table_get_instance(item, dev_class_info_t, devmap_link); 69 assert(class_info != NULL); 70 71 return (class_info->devmap_handle == (devmap_handle_t) key[0]); 72 } 73 64 74 static void devices_remove_callback(link_t *item) 65 75 { … … 75 85 .hash = devices_hash, 76 86 .compare = devmap_devices_compare, 87 .remove_callback = devices_remove_callback 88 }; 89 90 static hash_table_operations_t devmap_devices_class_ops = { 91 .hash = devices_hash, 92 .compare = devmap_devices_class_compare, 77 93 .remove_callback = devices_remove_callback 78 94 }; … … 376 392 printf(NAME ": create_root_node\n"); 377 393 394 fibril_rwlock_write_lock(&tree->rwlock); 378 395 node = create_dev_node(); 379 396 if (node != NULL) { … … 385 402 tree->root_node = node; 386 403 } 404 fibril_rwlock_write_unlock(&tree->rwlock); 387 405 388 406 return node != NULL; … … 447 465 /** Start a driver 448 466 * 449 * The driver's mutex is assumed to be locked.450 *451 467 * @param drv The driver's structure. 452 468 * @return True if the driver's task is successfully spawned, false … … 457 473 int rc; 458 474 475 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 476 459 477 printf(NAME ": start_driver '%s'\n", drv->name); 460 478 … … 678 696 } 679 697 680 devmap_device_register(devmap_pathname, &node->devmap_handle); 698 devmap_device_register_with_iface(devmap_pathname, 699 &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP); 681 700 682 701 tree_add_devmap_device(tree, node); … … 850 869 /** Find the device node structure of the device witch has the specified handle. 851 870 * 852 * Device tree's rwlock should be held at least for reading.853 *854 871 * @param tree The device tree where we look for the device node. 855 872 * @param handle The handle of the device. … … 859 876 { 860 877 unsigned long key = handle; 861 link_t *link = hash_table_find(&tree->devman_devices, &key); 878 link_t *link; 879 880 assert(fibril_rwlock_is_locked(&tree->rwlock)); 881 882 link = hash_table_find(&tree->devman_devices, &key); 862 883 return hash_table_get_instance(link, node_t, devman_link); 863 884 } … … 915 936 /** Insert new device into device tree. 916 937 * 917 * The device tree's rwlock should be already held exclusively when calling this918 * function.919 *920 938 * @param tree The device tree. 921 939 * @param node The newly added device node. … … 932 950 assert(tree != NULL); 933 951 assert(dev_name != NULL); 952 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 934 953 935 954 node->name = dev_name; … … 1050 1069 1051 1070 info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t)); 1052 if (info != NULL) 1071 if (info != NULL) { 1053 1072 memset(info, 0, sizeof(dev_class_info_t)); 1073 list_initialize(&info->dev_classes); 1074 list_initialize(&info->devmap_link); 1075 list_initialize(&info->link); 1076 } 1054 1077 1055 1078 return info; … … 1175 1198 fibril_rwlock_initialize(&class_list->rwlock); 1176 1199 hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1, 1177 &devmap_devices_ ops);1200 &devmap_devices_class_ops); 1178 1201 } 1179 1202 … … 1223 1246 hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link); 1224 1247 fibril_rwlock_write_unlock(&class_list->rwlock); 1248 1249 assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL); 1225 1250 } 1226 1251 -
uspace/srv/devman/main.c
rd99120f r2b0db98 281 281 * handle. 282 282 */ 283 devmap_device_register(devmap_pathname, &cli->devmap_handle); 283 devmap_device_register_with_iface(devmap_pathname, 284 &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP); 284 285 285 286 /* … … 457 458 458 459 if (driver == NULL) { 459 printf(NAME ": devman_forward error - the device is not in %" PRIun 460 " usable state.\n", handle); 460 printf(NAME ": devman_forward error - the device %" PRIun \ 461 " (%s) is not in usable state.\n", 462 handle, dev->pathname); 461 463 ipc_answer_0(iid, ENOENT); 462 464 return; … … 486 488 static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall) 487 489 { 488 devmap_handle_t devmap_handle = IPC_GET_ IMETHOD(*icall);490 devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall); 489 491 node_t *dev; 490 492 … … 503 505 } 504 506 505 printf(NAME ": devman_connection_devmapper: forward connection to "506 "device %s to driver %s.\n", dev->pathname, dev->drv->name);507 507 ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0, 508 508 IPC_FF_NONE); 509 printf(NAME ": devman_connection_devmapper: forwarded connection to " 510 "device %s to driver %s.\n", dev->pathname, dev->drv->name); 509 511 } 510 512 … … 512 514 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall) 513 515 { 514 /*515 * Silly hack to enable the device manager to register as a driver by516 * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this517 * is not the forwarded connection from naming service, so it must be a518 * connection from the devmapper which thinks this is a devmapper-style519 * driver. So pretend this is a devmapper-style driver. (This does not520 * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper521 * passes device handle to the driver as an ipc method.)522 */523 if (IPC_GET_IMETHOD(*icall) != IPC_M_CONNECT_ME_TO)524 devman_connection_devmapper(iid, icall);525 526 /*527 * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection528 * from naming service by which we registered as device manager, so be529 * device manager.530 */531 532 516 /* Select interface. */ 533 517 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { … … 542 526 devman_forward(iid, icall, false); 543 527 break; 528 case DEVMAN_CONNECT_FROM_DEVMAP: 529 /* Someone connected through devmap node. */ 530 devman_connection_devmapper(iid, icall); 531 break; 544 532 case DEVMAN_CONNECT_TO_PARENTS_DEVICE: 545 533 /* Connect client to selected device. */
Note:
See TracChangeset
for help on using the changeset viewer.