Changeset 2b0db98 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2011-01-07T14:02:56Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
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.
Message:

Merged development into lelian/hidd

Location:
uspace/srv/devman
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    rd99120f r2b0db98  
    6262}
    6363
     64static 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
    6474static void devices_remove_callback(link_t *item)
    6575{
     
    7585        .hash = devices_hash,
    7686        .compare = devmap_devices_compare,
     87        .remove_callback = devices_remove_callback
     88};
     89
     90static hash_table_operations_t devmap_devices_class_ops = {
     91        .hash = devices_hash,
     92        .compare = devmap_devices_class_compare,
    7793        .remove_callback = devices_remove_callback
    7894};
     
    376392        printf(NAME ": create_root_node\n");
    377393
     394        fibril_rwlock_write_lock(&tree->rwlock);
    378395        node = create_dev_node();
    379396        if (node != NULL) {
     
    385402                tree->root_node = node;
    386403        }
     404        fibril_rwlock_write_unlock(&tree->rwlock);
    387405
    388406        return node != NULL;
     
    447465/** Start a driver
    448466 *
    449  * The driver's mutex is assumed to be locked.
    450  *
    451467 * @param drv           The driver's structure.
    452468 * @return              True if the driver's task is successfully spawned, false
     
    457473        int rc;
    458474
     475        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     476       
    459477        printf(NAME ": start_driver '%s'\n", drv->name);
    460478       
     
    678696        }
    679697       
    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);
    681700       
    682701        tree_add_devmap_device(tree, node);
     
    850869/** Find the device node structure of the device witch has the specified handle.
    851870 *
    852  * Device tree's rwlock should be held at least for reading.
    853  *
    854871 * @param tree          The device tree where we look for the device node.
    855872 * @param handle        The handle of the device.
     
    859876{
    860877        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);
    862883        return hash_table_get_instance(link, node_t, devman_link);
    863884}
     
    915936/** Insert new device into device tree.
    916937 *
    917  * The device tree's rwlock should be already held exclusively when calling this
    918  * function.
    919  *
    920938 * @param tree          The device tree.
    921939 * @param node          The newly added device node.
     
    932950        assert(tree != NULL);
    933951        assert(dev_name != NULL);
     952        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    934953       
    935954        node->name = dev_name;
     
    10501069       
    10511070        info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
    1052         if (info != NULL)
     1071        if (info != NULL) {
    10531072                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        }
    10541077       
    10551078        return info;
     
    11751198        fibril_rwlock_initialize(&class_list->rwlock);
    11761199        hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
    1177             &devmap_devices_ops);
     1200            &devmap_devices_class_ops);
    11781201}
    11791202
     
    12231246        hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
    12241247        fibril_rwlock_write_unlock(&class_list->rwlock);
     1248
     1249        assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
    12251250}
    12261251
  • uspace/srv/devman/main.c

    rd99120f r2b0db98  
    281281         * handle.
    282282         */
    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);
    284285       
    285286        /*
     
    457458       
    458459        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);
    461463                ipc_answer_0(iid, ENOENT);
    462464                return;
     
    486488static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
    487489{
    488         devmap_handle_t devmap_handle = IPC_GET_IMETHOD(*icall);
     490        devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
    489491        node_t *dev;
    490492
     
    503505        }
    504506       
    505         printf(NAME ": devman_connection_devmapper: forward connection to "
    506             "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    507507        ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
    508508            IPC_FF_NONE);
     509        printf(NAME ": devman_connection_devmapper: forwarded connection to "
     510            "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    509511}
    510512
     
    512514static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
    513515{
    514         /*
    515          * Silly hack to enable the device manager to register as a driver by
    516          * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this
    517          * is not the forwarded connection from naming service, so it must be a
    518          * connection from the devmapper which thinks this is a devmapper-style
    519          * driver. So pretend this is a devmapper-style driver. (This does not
    520          * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper
    521          * 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 connection
    528          * from naming service by which we registered as device manager, so be
    529          * device manager.
    530          */
    531        
    532516        /* Select interface. */
    533517        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
     
    542526                devman_forward(iid, icall, false);
    543527                break;
     528        case DEVMAN_CONNECT_FROM_DEVMAP:
     529                /* Someone connected through devmap node. */
     530                devman_connection_devmapper(iid, icall);
     531                break;
    544532        case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
    545533                /* Connect client to selected device. */
Note: See TracChangeset for help on using the changeset viewer.