Changeset eb1a2f4 in mainline for uspace/srv


Ignore:
Timestamp:
2011-02-22T23:30:56Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5d1535, a9c674e0
Parents:
dbe25f1 (diff), 664af708 (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:

Merge mainline changes (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
Location:
uspace/srv
Files:
5 edited

Legend:

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

    rdbe25f1 reb1a2f4  
    4141#include "devman.h"
    4242
     43fun_node_t *find_node_child(fun_node_t *parent, const char *name);
     44
    4345/* hash table operations */
    4446
     
    5153    link_t *item)
    5254{
    53         node_t *dev = hash_table_get_instance(item, node_t, devman_link);
     55        dev_node_t *dev = hash_table_get_instance(item, dev_node_t, devman_dev);
    5456        return (dev->handle == (devman_handle_t) key[0]);
    5557}
    5658
    57 static int devmap_devices_compare(unsigned long key[], hash_count_t keys,
     59static int devman_functions_compare(unsigned long key[], hash_count_t keys,
    5860    link_t *item)
    5961{
    60         node_t *dev = hash_table_get_instance(item, node_t, devmap_link);
    61         return (dev->devmap_handle == (devmap_handle_t) key[0]);
     62        fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devman_fun);
     63        return (fun->handle == (devman_handle_t) key[0]);
     64}
     65
     66static int devmap_functions_compare(unsigned long key[], hash_count_t keys,
     67    link_t *item)
     68{
     69        fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devmap_fun);
     70        return (fun->devmap_handle == (devmap_handle_t) key[0]);
    6271}
    6372
     
    8291};
    8392
     93static hash_table_operations_t devman_functions_ops = {
     94        .hash = devices_hash,
     95        .compare = devman_functions_compare,
     96        .remove_callback = devices_remove_callback
     97};
     98
    8499static hash_table_operations_t devmap_devices_ops = {
    85100        .hash = devices_hash,
    86         .compare = devmap_devices_compare,
     101        .compare = devmap_functions_compare,
    87102        .remove_callback = devices_remove_callback
    88103};
     
    381396}
    382397
    383 /** Create root device node in the device tree.
     398/** Create root device and function node in the device tree.
    384399 *
    385400 * @param tree  The device tree.
    386401 * @return      True on success, false otherwise.
    387402 */
    388 bool create_root_node(dev_tree_t *tree)
    389 {
    390         node_t *node;
    391 
    392         printf(NAME ": create_root_node\n");
    393 
     403bool create_root_nodes(dev_tree_t *tree)
     404{
     405        fun_node_t *fun;
     406        dev_node_t *dev;
     407       
     408        printf(NAME ": create_root_nodes\n");
     409       
    394410        fibril_rwlock_write_lock(&tree->rwlock);
    395         node = create_dev_node();
    396         if (node != NULL) {
    397                 insert_dev_node(tree, node, clone_string(""), NULL);
    398                 match_id_t *id = create_match_id();
    399                 id->id = clone_string("root");
    400                 id->score = 100;
    401                 add_match_id(&node->match_ids, id);
    402                 tree->root_node = node;
    403         }
     411       
     412        /*
     413         * Create root function. This is a pseudo function to which
     414         * the root device node is attached. It allows us to match
     415         * the root device driver in a standard manner, i.e. against
     416         * the parent function.
     417         */
     418       
     419        fun = create_fun_node();
     420        if (fun == NULL) {
     421                fibril_rwlock_write_unlock(&tree->rwlock);
     422                return false;
     423        }
     424       
     425        insert_fun_node(tree, fun, clone_string(""), NULL);
     426        match_id_t *id = create_match_id();
     427        id->id = clone_string("root");
     428        id->score = 100;
     429        add_match_id(&fun->match_ids, id);
     430        tree->root_node = fun;
     431       
     432        /*
     433         * Create root device node.
     434         */
     435        dev = create_dev_node();
     436        if (dev == NULL) {
     437                fibril_rwlock_write_unlock(&tree->rwlock);
     438                return false;
     439        }
     440       
     441        insert_dev_node(tree, dev, fun);
     442       
    404443        fibril_rwlock_write_unlock(&tree->rwlock);
    405 
    406         return node != NULL;
     444       
     445        return dev != NULL;
    407446}
    408447
     
    422461 *                      is found.
    423462 */
    424 driver_t *find_best_match_driver(driver_list_t *drivers_list, node_t *node)
     463driver_t *find_best_match_driver(driver_list_t *drivers_list, dev_node_t *node)
    425464{
    426465        driver_t *best_drv = NULL, *drv = NULL;
     
    450489 * @param drv           The driver.
    451490 */
    452 void attach_driver(node_t *node, driver_t *drv)
     491void attach_driver(dev_node_t *dev, driver_t *drv)
    453492{
    454493        printf(NAME ": attach_driver %s to device %s\n",
    455             drv->name, node->pathname);
     494            drv->name, dev->pfun->pathname);
    456495       
    457496        fibril_mutex_lock(&drv->driver_mutex);
    458497       
    459         node->drv = drv;
    460         list_append(&node->driver_devices, &drv->devices);
     498        dev->drv = drv;
     499        list_append(&dev->driver_devices, &drv->devices);
    461500       
    462501        fibril_mutex_unlock(&drv->driver_mutex);
     
    538577static void pass_devices_to_driver(driver_t *driver, dev_tree_t *tree)
    539578{
    540         node_t *dev;
     579        dev_node_t *dev;
    541580        link_t *link;
    542581        int phone;
     
    559598        link = driver->devices.next;
    560599        while (link != &driver->devices) {
    561                 dev = list_get_instance(link, node_t, driver_devices);
     600                dev = list_get_instance(link, dev_node_t, driver_devices);
    562601                if (dev->passed_to_driver) {
    563602                        link = link->next;
     
    677716}
    678717
    679 /** Create devmap path and name for the device. */
    680 static void devmap_register_tree_device(node_t *node, dev_tree_t *tree)
     718/** Create devmap path and name for the function. */
     719void devmap_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
    681720{
    682721        char *devmap_pathname = NULL;
    683722        char *devmap_name = NULL;
    684723       
    685         asprintf(&devmap_name, "%s", node->pathname);
     724        asprintf(&devmap_name, "%s", fun->pathname);
    686725        if (devmap_name == NULL)
    687726                return;
     
    697736       
    698737        devmap_device_register_with_iface(devmap_pathname,
    699             &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    700        
    701         tree_add_devmap_device(tree, node);
     738            &fun->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
     739       
     740        tree_add_devmap_function(tree, fun);
    702741       
    703742        free(devmap_name);
     
    710749 * @param node          The device's node in the device tree.
    711750 */
    712 void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree)
     751void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
    713752{
    714753        /*
     
    717756         */
    718757        printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,
    719             node->name);
     758            dev->pfun->name);
    720759       
    721760        sysarg_t rc;
     
    724763        /* Send the device to the driver. */
    725764        devman_handle_t parent_handle;
    726         if (node->parent) {
    727                 parent_handle = node->parent->handle;
     765        if (dev->pfun) {
     766                parent_handle = dev->pfun->handle;
    728767        } else {
    729768                parent_handle = 0;
    730769        }
    731770
    732         aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle,
     771        aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
    733772            parent_handle, &answer);
    734773       
    735774        /* Send the device's name to the driver. */
    736         rc = async_data_write_start(phone, node->name,
    737             str_size(node->name) + 1);
     775        rc = async_data_write_start(phone, dev->pfun->name,
     776            str_size(dev->pfun->name) + 1);
    738777        if (rc != EOK) {
    739778                /* TODO handle error */
     
    745784        switch(rc) {
    746785        case EOK:
    747                 node->state = DEVICE_USABLE;
    748                 devmap_register_tree_device(node, tree);
     786                dev->state = DEVICE_USABLE;
    749787                break;
    750788        case ENOENT:
    751                 node->state = DEVICE_NOT_PRESENT;
     789                dev->state = DEVICE_NOT_PRESENT;
    752790                break;
    753791        default:
    754                 node->state = DEVICE_INVALID;
    755         }
    756        
    757         node->passed_to_driver = true;
     792                dev->state = DEVICE_INVALID;
     793        }
     794       
     795        dev->passed_to_driver = true;
    758796
    759797        return;
     
    767805 *                      successfully assigned to the device, false otherwise.
    768806 */
    769 bool assign_driver(node_t *node, driver_list_t *drivers_list, dev_tree_t *tree)
    770 {
     807bool assign_driver(dev_node_t *dev, driver_list_t *drivers_list,
     808    dev_tree_t *tree)
     809{
     810        assert(dev != NULL);
     811        assert(drivers_list != NULL);
     812        assert(tree != NULL);
     813       
    771814        /*
    772815         * Find the driver which is the most suitable for handling this device.
    773816         */
    774         driver_t *drv = find_best_match_driver(drivers_list, node);
     817        driver_t *drv = find_best_match_driver(drivers_list, dev);
    775818        if (drv == NULL) {
    776819                printf(NAME ": no driver found for device '%s'.\n",
    777                     node->pathname);
     820                    dev->pfun->pathname);
    778821                return false;
    779822        }
    780823       
    781824        /* Attach the driver to the device. */
    782         attach_driver(node, drv);
     825        attach_driver(dev, drv);
    783826       
    784827        fibril_mutex_lock(&drv->driver_mutex);
     
    794837                int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
    795838                if (phone >= 0) {
    796                         add_device(phone, drv, node, tree);
     839                        add_device(phone, drv, dev, tree);
    797840                        async_hangup(phone);
    798841                }
     
    818861        hash_table_create(&tree->devman_devices, DEVICE_BUCKETS, 1,
    819862            &devman_devices_ops);
    820         hash_table_create(&tree->devmap_devices, DEVICE_BUCKETS, 1,
     863        hash_table_create(&tree->devman_functions, DEVICE_BUCKETS, 1,
     864            &devman_functions_ops);
     865        hash_table_create(&tree->devmap_functions, DEVICE_BUCKETS, 1,
    821866            &devmap_devices_ops);
    822867       
    823868        fibril_rwlock_initialize(&tree->rwlock);
    824869       
    825         /* Create root node and add it to the device tree. */
    826         if (!create_root_node(tree))
     870        /* Create root function and root device and add them to the device tree. */
     871        if (!create_root_nodes(tree))
    827872                return false;
    828873
    829874        /* Find suitable driver and start it. */
    830         return assign_driver(tree->root_node, drivers_list, tree);
     875        return assign_driver(tree->root_node->child, drivers_list, tree);
    831876}
    832877
     
    837882 * @return              A device node structure.
    838883 */
    839 node_t *create_dev_node(void)
    840 {
    841         node_t *res = malloc(sizeof(node_t));
     884dev_node_t *create_dev_node(void)
     885{
     886        dev_node_t *res = malloc(sizeof(dev_node_t));
    842887       
    843888        if (res != NULL) {
    844                 memset(res, 0, sizeof(node_t));
    845                 list_initialize(&res->children);
    846                 list_initialize(&res->match_ids.ids);
    847                 list_initialize(&res->classes);
     889                memset(res, 0, sizeof(dev_node_t));
     890                list_initialize(&res->functions);
     891                link_initialize(&res->driver_devices);
     892                link_initialize(&res->devman_dev);
    848893        }
    849894       
     
    855900 * @param node          The device node structure.
    856901 */
    857 void delete_dev_node(node_t *node)
    858 {
    859         assert(list_empty(&node->children));
    860         assert(node->parent == NULL);
    861         assert(node->drv == NULL);
    862        
    863         clean_match_ids(&node->match_ids);
    864         free_not_null(node->name);
    865         free_not_null(node->pathname);
    866         free(node);
     902void delete_dev_node(dev_node_t *dev)
     903{
     904        assert(list_empty(&dev->functions));
     905        assert(dev->pfun == NULL);
     906        assert(dev->drv == NULL);
     907       
     908        free(dev);
    867909}
    868910
     
    873915 * @return              The device node.
    874916 */
    875 node_t *find_dev_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
     917dev_node_t *find_dev_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
    876918{
    877919        unsigned long key = handle;
     
    881923       
    882924        link = hash_table_find(&tree->devman_devices, &key);
    883         return hash_table_get_instance(link, node_t, devman_link);
     925        return hash_table_get_instance(link, dev_node_t, devman_dev);
    884926}
    885927
     
    890932 * @return              The device node.
    891933 */
    892 node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle)
    893 {
    894         node_t *node = NULL;
     934dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle)
     935{
     936        dev_node_t *dev = NULL;
    895937       
    896938        fibril_rwlock_read_lock(&tree->rwlock);
    897         node = find_dev_node_no_lock(tree, handle);
     939        dev = find_dev_node_no_lock(tree, handle);
    898940        fibril_rwlock_read_unlock(&tree->rwlock);
    899941       
    900         return node;
    901 }
    902 
     942        return dev;
     943}
     944
     945/* Function nodes */
     946
     947/** Create a new function node.
     948 *
     949 * @return              A function node structure.
     950 */
     951fun_node_t *create_fun_node(void)
     952{
     953        fun_node_t *res = malloc(sizeof(fun_node_t));
     954       
     955        if (res != NULL) {
     956                memset(res, 0, sizeof(fun_node_t));
     957                link_initialize(&res->dev_functions);
     958                list_initialize(&res->match_ids.ids);
     959                list_initialize(&res->classes);
     960                link_initialize(&res->devman_fun);
     961                link_initialize(&res->devmap_fun);
     962        }
     963       
     964        return res;
     965}
     966
     967/** Delete a function node.
     968 *
     969 * @param fun           The device node structure.
     970 */
     971void delete_fun_node(fun_node_t *fun)
     972{
     973        assert(fun->dev == NULL);
     974        assert(fun->child == NULL);
     975       
     976        clean_match_ids(&fun->match_ids);
     977        free_not_null(fun->name);
     978        free_not_null(fun->pathname);
     979        free(fun);
     980}
     981
     982/** Find the function node with the specified handle.
     983 *
     984 * @param tree          The device tree where we look for the device node.
     985 * @param handle        The handle of the function.
     986 * @return              The function node.
     987 */
     988fun_node_t *find_fun_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
     989{
     990        unsigned long key = handle;
     991        link_t *link;
     992       
     993        assert(fibril_rwlock_is_locked(&tree->rwlock));
     994       
     995        link = hash_table_find(&tree->devman_functions, &key);
     996        if (link == NULL)
     997                return NULL;
     998       
     999        return hash_table_get_instance(link, fun_node_t, devman_fun);
     1000}
     1001
     1002/** Find the function node with the specified handle.
     1003 *
     1004 * @param tree          The device tree where we look for the device node.
     1005 * @param handle        The handle of the function.
     1006 * @return              The function node.
     1007 */
     1008fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle)
     1009{
     1010        fun_node_t *fun = NULL;
     1011       
     1012        fibril_rwlock_read_lock(&tree->rwlock);
     1013        fun = find_fun_node_no_lock(tree, handle);
     1014        fibril_rwlock_read_unlock(&tree->rwlock);
     1015       
     1016        return fun;
     1017}
    9031018
    9041019/** Create and set device's full path in device tree.
     
    9091024 *                      resources etc.).
    9101025 */
    911 static bool set_dev_path(node_t *node, node_t *parent)
    912 {
    913         assert(node->name != NULL);
    914        
    915         size_t pathsize = (str_size(node->name) + 1);
     1026static bool set_fun_path(fun_node_t *fun, fun_node_t *parent)
     1027{
     1028        assert(fun->name != NULL);
     1029       
     1030        size_t pathsize = (str_size(fun->name) + 1);
    9161031        if (parent != NULL)
    9171032                pathsize += str_size(parent->pathname) + 1;
    9181033       
    919         node->pathname = (char *) malloc(pathsize);
    920         if (node->pathname == NULL) {
     1034        fun->pathname = (char *) malloc(pathsize);
     1035        if (fun->pathname == NULL) {
    9211036                printf(NAME ": failed to allocate device path.\n");
    9221037                return false;
     
    9241039       
    9251040        if (parent != NULL) {
    926                 str_cpy(node->pathname, pathsize, parent->pathname);
    927                 str_append(node->pathname, pathsize, "/");
    928                 str_append(node->pathname, pathsize, node->name);
     1041                str_cpy(fun->pathname, pathsize, parent->pathname);
     1042                str_append(fun->pathname, pathsize, "/");
     1043                str_append(fun->pathname, pathsize, fun->name);
    9291044        } else {
    930                 str_cpy(node->pathname, pathsize, node->name);
     1045                str_cpy(fun->pathname, pathsize, fun->name);
    9311046        }
    9321047       
     
    9441059 *                      etc.).
    9451060 */
    946 bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name,
    947     node_t *parent)
    948 {
    949         assert(node != NULL);
     1061bool insert_dev_node(dev_tree_t *tree, dev_node_t *dev, fun_node_t *pfun)
     1062{
     1063        assert(dev != NULL);
    9501064        assert(tree != NULL);
    951         assert(dev_name != NULL);
    9521065        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    9531066       
    954         node->name = dev_name;
    955         if (!set_dev_path(node, parent)) {
     1067        /* Add the node to the handle-to-node map. */
     1068        dev->handle = ++tree->current_handle;
     1069        unsigned long key = dev->handle;
     1070        hash_table_insert(&tree->devman_devices, &key, &dev->devman_dev);
     1071
     1072        /* Add the node to the list of its parent's children. */
     1073        printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);
     1074        dev->pfun = pfun;
     1075        pfun->child = dev;
     1076       
     1077        return true;
     1078}
     1079
     1080/** Insert new function into device tree.
     1081 *
     1082 * @param tree          The device tree.
     1083 * @param node          The newly added function node.
     1084 * @param dev_name      The name of the newly added function.
     1085 * @param parent        Owning device node.
     1086 *
     1087 * @return              True on success, false otherwise (insufficient resources
     1088 *                      etc.).
     1089 */
     1090bool insert_fun_node(dev_tree_t *tree, fun_node_t *fun, char *fun_name,
     1091    dev_node_t *dev)
     1092{
     1093        fun_node_t *pfun;
     1094       
     1095        assert(fun != NULL);
     1096        assert(tree != NULL);
     1097        assert(fun_name != NULL);
     1098        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
     1099       
     1100        /*
     1101         * The root function is a special case, it does not belong to any
     1102         * device so for the root function dev == NULL.
     1103         */
     1104        pfun = (dev != NULL) ? dev->pfun : NULL;
     1105       
     1106        fun->name = fun_name;
     1107        if (!set_fun_path(fun, pfun)) {
    9561108                return false;
    9571109        }
    9581110       
    9591111        /* Add the node to the handle-to-node map. */
    960         node->handle = ++tree->current_handle;
    961         unsigned long key = node->handle;
    962         hash_table_insert(&tree->devman_devices, &key, &node->devman_link);
     1112        fun->handle = ++tree->current_handle;
     1113        unsigned long key = fun->handle;
     1114        hash_table_insert(&tree->devman_functions, &key, &fun->devman_fun);
    9631115
    9641116        /* Add the node to the list of its parent's children. */
    965         node->parent = parent;
    966         if (parent != NULL)
    967                 list_append(&node->sibling, &parent->children);
     1117        fun->dev = dev;
     1118        if (dev != NULL)
     1119                list_append(&fun->dev_functions, &dev->functions);
    9681120       
    9691121        return true;
    9701122}
    9711123
    972 /** Find device node with a specified path in the device tree.
     1124/** Find function node with a specified path in the device tree.
    9731125 *
    974  * @param path          The path of the device node in the device tree.
     1126 * @param path          The path of the function node in the device tree.
    9751127 * @param tree          The device tree.
    976  * @return              The device node if it is present in the tree, NULL
     1128 * @return              The function node if it is present in the tree, NULL
    9771129 *                      otherwise.
    9781130 */
    979 node_t *find_dev_node_by_path(dev_tree_t *tree, char *path)
     1131fun_node_t *find_fun_node_by_path(dev_tree_t *tree, char *path)
    9801132{
    9811133        fibril_rwlock_read_lock(&tree->rwlock);
    9821134       
    983         node_t *dev = tree->root_node;
     1135        fun_node_t *fun = tree->root_node;
    9841136        /*
    985          * Relative path to the device from its parent (but with '/' at the
     1137         * Relative path to the function from its parent (but with '/' at the
    9861138         * beginning)
    9871139         */
     
    9901142        bool cont = (rel_path[0] == '/');
    9911143       
    992         while (cont && dev != NULL) {
     1144        while (cont && fun != NULL) {
    9931145                next_path_elem  = get_path_elem_end(rel_path + 1);
    9941146                if (next_path_elem[0] == '/') {
     
    9991151                }
    10001152               
    1001                 dev = find_node_child(dev, rel_path + 1);
     1153                fun = find_node_child(fun, rel_path + 1);
    10021154               
    10031155                if (cont) {
     
    10101162        fibril_rwlock_read_unlock(&tree->rwlock);
    10111163       
    1012         return dev;
    1013 }
    1014 
    1015 /** Find child device node with a specified name.
     1164        return fun;
     1165}
     1166
     1167/** Find child function node with a specified name.
    10161168 *
    10171169 * Device tree rwlock should be held at least for reading.
    10181170 *
    1019  * @param parent        The parent device node.
    1020  * @param name          The name of the child device node.
    1021  * @return              The child device node.
    1022  */
    1023 node_t *find_node_child(node_t *parent, const char *name)
    1024 {
    1025         node_t *dev;
     1171 * @param parent        The parent function node.
     1172 * @param name          The name of the child function.
     1173 * @return              The child function node.
     1174 */
     1175fun_node_t *find_node_child(fun_node_t *pfun, const char *name)
     1176{
     1177        fun_node_t *fun;
    10261178        link_t *link;
    10271179       
    1028         link = parent->children.next;
    1029        
    1030         while (link != &parent->children) {
    1031                 dev = list_get_instance(link, node_t, sibling);
     1180        link = pfun->child->functions.next;
     1181       
     1182        while (link != &pfun->child->functions) {
     1183                fun = list_get_instance(link, fun_node_t, dev_functions);
    10321184               
    1033                 if (str_cmp(name, dev->name) == 0)
    1034                         return dev;
     1185                if (str_cmp(name, fun->name) == 0)
     1186                        return fun;
    10351187               
    10361188                link = link->next;
     
    11151267}
    11161268
    1117 /** Add the device to the class.
     1269/** Add the device function to the class.
    11181270 *
    11191271 * The device may be added to multiple classes and a class may contain multiple
     
    11281280 *                      with the class.
    11291281 */
    1130 dev_class_info_t *add_device_to_class(node_t *dev, dev_class_t *cl,
     1282dev_class_info_t *add_function_to_class(fun_node_t *fun, dev_class_t *cl,
    11311283    const char *base_dev_name)
    11321284{
    1133         dev_class_info_t *info = create_dev_class_info();
     1285        dev_class_info_t *info;
     1286
     1287        assert(fun != NULL);
     1288        assert(cl != NULL);
     1289
     1290        info = create_dev_class_info();
     1291
    11341292       
    11351293        if (info != NULL) {
    11361294                info->dev_class = cl;
    1137                 info->dev = dev;
     1295                info->fun = fun;
    11381296               
    11391297                /* Add the device to the class. */
     
    11431301               
    11441302                /* Add the class to the device. */
    1145                 list_append(&info->dev_classes, &dev->classes);
     1303                list_append(&info->dev_classes, &fun->classes);
    11461304               
    11471305                /* Create unique name for the device within the class. */
     
    11971355        list_initialize(&class_list->classes);
    11981356        fibril_rwlock_initialize(&class_list->rwlock);
    1199         hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
     1357        hash_table_create(&class_list->devmap_functions, DEVICE_BUCKETS, 1,
    12001358            &devmap_devices_class_ops);
    12011359}
     
    12041362/* Devmap devices */
    12051363
    1206 node_t *find_devmap_tree_device(dev_tree_t *tree, devmap_handle_t devmap_handle)
    1207 {
    1208         node_t *dev = NULL;
     1364fun_node_t *find_devmap_tree_function(dev_tree_t *tree, devmap_handle_t devmap_handle)
     1365{
     1366        fun_node_t *fun = NULL;
    12091367        link_t *link;
    12101368        unsigned long key = (unsigned long) devmap_handle;
    12111369       
    12121370        fibril_rwlock_read_lock(&tree->rwlock);
    1213         link = hash_table_find(&tree->devmap_devices, &key);
     1371        link = hash_table_find(&tree->devmap_functions, &key);
    12141372        if (link != NULL)
    1215                 dev = hash_table_get_instance(link, node_t, devmap_link);
     1373                fun = hash_table_get_instance(link, fun_node_t, devmap_fun);
    12161374        fibril_rwlock_read_unlock(&tree->rwlock);
    12171375       
    1218         return dev;
    1219 }
    1220 
    1221 node_t *find_devmap_class_device(class_list_t *classes,
     1376        return fun;
     1377}
     1378
     1379fun_node_t *find_devmap_class_function(class_list_t *classes,
    12221380    devmap_handle_t devmap_handle)
    12231381{
    1224         node_t *dev = NULL;
     1382        fun_node_t *fun = NULL;
    12251383        dev_class_info_t *cli;
    12261384        link_t *link;
     
    12281386       
    12291387        fibril_rwlock_read_lock(&classes->rwlock);
    1230         link = hash_table_find(&classes->devmap_devices, &key);
     1388        link = hash_table_find(&classes->devmap_functions, &key);
    12311389        if (link != NULL) {
    12321390                cli = hash_table_get_instance(link, dev_class_info_t,
    12331391                    devmap_link);
    1234                 dev = cli->dev;
     1392                fun = cli->fun;
    12351393        }
    12361394        fibril_rwlock_read_unlock(&classes->rwlock);
    12371395       
    1238         return dev;
    1239 }
    1240 
    1241 void class_add_devmap_device(class_list_t *class_list, dev_class_info_t *cli)
     1396        return fun;
     1397}
     1398
     1399void class_add_devmap_function(class_list_t *class_list, dev_class_info_t *cli)
    12421400{
    12431401        unsigned long key = (unsigned long) cli->devmap_handle;
    12441402       
    12451403        fibril_rwlock_write_lock(&class_list->rwlock);
    1246         hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
     1404        hash_table_insert(&class_list->devmap_functions, &key, &cli->devmap_link);
    12471405        fibril_rwlock_write_unlock(&class_list->rwlock);
    12481406
    1249         assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
    1250 }
    1251 
    1252 void tree_add_devmap_device(dev_tree_t *tree, node_t *node)
    1253 {
    1254         unsigned long key = (unsigned long) node->devmap_handle;
     1407        assert(find_devmap_class_function(class_list, cli->devmap_handle) != NULL);
     1408}
     1409
     1410void tree_add_devmap_function(dev_tree_t *tree, fun_node_t *fun)
     1411{
     1412        unsigned long key = (unsigned long) fun->devmap_handle;
    12551413        fibril_rwlock_write_lock(&tree->rwlock);
    1256         hash_table_insert(&tree->devmap_devices, &key, &node->devmap_link);
     1414        hash_table_insert(&tree->devmap_functions, &key, &fun->devmap_fun);
    12571415        fibril_rwlock_write_unlock(&tree->rwlock);
    12581416}
  • uspace/srv/devman/devman.h

    rdbe25f1 reb1a2f4  
    5656#define DEVMAP_SEPARATOR '\\'
    5757
    58 struct node;
    59 typedef struct node node_t;
     58struct dev_node;
     59typedef struct dev_node dev_node_t;
     60
     61struct fun_node;
     62typedef struct fun_node fun_node_t;
    6063
    6164typedef enum {
     
    117120} device_state_t;
    118121
    119 /** Representation of a node in the device tree. */
    120 struct node {
     122/** Device node in the device tree. */
     123struct dev_node {
    121124        /** The global unique identifier of the device. */
    122125        devman_handle_t handle;
    123         /** The name of the device specified by its parent. */
    124         char *name;
    125        
    126         /**
    127          * Full path and name of the device in device hierarchi (i. e. in full
    128          * path in device tree).
    129          */
    130         char *pathname;
    131        
    132         /** The node of the parent device. */
    133         node_t *parent;
    134        
    135         /**
    136          * Pointers to previous and next child devices in the linked list of
    137          * parent device's node.
    138          */
    139         link_t sibling;
    140        
    141         /** List of child device nodes. */
    142         link_t children;
    143         /** List of device ids for device-to-driver matching. */
    144         match_id_list_t match_ids;
     126       
     127        /** (Parent) function the device is attached to. */
     128        fun_node_t *pfun;
     129       
     130        /** List of device functions. */
     131        link_t functions;
    145132        /** Driver of this device. */
    146133        driver_t *drv;
    147134        /** The state of the device. */
    148135        device_state_t state;
    149         /**
    150          * Pointer to the previous and next device in the list of devices
    151          * owned by one driver.
    152          */
     136        /** Link to list of devices owned by driver (driver_t.devices) */
    153137        link_t driver_devices;
    154138       
    155         /** The list of device classes to which this device belongs. */
    156         link_t classes;
    157         /** Devmap handle if the device is registered by devmapper. */
    158         devmap_handle_t devmap_handle;
    159        
    160139        /**
    161140         * Used by the hash table of devices indexed by devman device handles.
    162141         */
    163         link_t devman_link;
    164        
    165         /**
    166          * Used by the hash table of devices indexed by devmap device handles.
    167          */
    168         link_t devmap_link;
    169 
     142        link_t devman_dev;
     143       
    170144        /**
    171145         * Whether this device was already passed to the driver.
     
    173147        bool passed_to_driver;
    174148};
     149
     150/** Function node in the device tree. */
     151struct fun_node {
     152        /** The global unique identifier of the function */
     153        devman_handle_t handle;
     154        /** Name of the function, assigned by the device driver */
     155        char *name;
     156       
     157        /** Full path and name of the device in device hierarchy */
     158        char *pathname;
     159       
     160        /** Device which this function belongs to */
     161        dev_node_t *dev;
     162       
     163        /** Link to list of functions in the device (ddf_dev_t.functions) */
     164        link_t dev_functions;
     165       
     166        /** Child device node (if any attached). */
     167        dev_node_t *child;
     168        /** List of device ids for device-to-driver matching. */
     169        match_id_list_t match_ids;
     170       
     171        /** The list of device classes to which this device function belongs. */
     172        link_t classes;
     173        /** Devmap handle if the device function is registered by devmap. */
     174        devmap_handle_t devmap_handle;
     175       
     176        /**
     177         * Used by the hash table of functions indexed by devman device handles.
     178         */
     179        link_t devman_fun;
     180       
     181        /**
     182         * Used by the hash table of functions indexed by devmap device handles.
     183         */
     184        link_t devmap_fun;
     185};
     186
    175187
    176188/** Represents device tree. */
    177189typedef struct dev_tree {
    178190        /** Root device node. */
    179         node_t *root_node;
     191        fun_node_t *root_node;
    180192       
    181193        /**
     
    191203        hash_table_t devman_devices;
    192204       
     205        /** Hash table of all devices indexed by devman handles. */
     206        hash_table_t devman_functions;
     207       
    193208        /**
    194209         * Hash table of devices registered by devmapper, indexed by devmap
    195210         * handles.
    196211         */
    197         hash_table_t devmap_devices;
     212        hash_table_t devmap_functions;
    198213} dev_tree_t;
    199214
     
    227242
    228243/**
    229  * Provides n-to-m mapping between device nodes and classes - each device may
    230  * be register to the arbitrary number of classes and each class may contain
    231  * the arbitrary number of devices.
     244 * Provides n-to-m mapping between function nodes and classes - each function
     245 * can register in an arbitrary number of classes and each class can contain
     246 * an arbitrary number of device functions.
    232247 */
    233248typedef struct dev_class_info {
     
    235250        dev_class_t *dev_class;
    236251        /** The device. */
    237         node_t *dev;
     252        fun_node_t *fun;
    238253       
    239254        /**
     
    249264        link_t dev_classes;
    250265       
    251         /** The name of the device within the class. */
     266        /** The name of the device function within the class. */
    252267        char *dev_name;
    253268        /** The handle of the device by device mapper in the class namespace. */
     
    270285         * indexed by devmap handles.
    271286         */
    272         hash_table_t devmap_devices;
     287        hash_table_t devmap_functions;
    273288       
    274289        /** Fibril mutex for list of classes. */
     
    278293/* Match ids and scores */
    279294
    280 extern int get_match_score(driver_t *, node_t *);
     295extern int get_match_score(driver_t *, dev_node_t *);
    281296
    282297extern bool parse_match_ids(char *, match_id_list_t *);
     
    292307extern int lookup_available_drivers(driver_list_t *, const char *);
    293308
    294 extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
    295 extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
     309extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *);
     310extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *);
    296311
    297312extern void add_driver(driver_list_t *, driver_t *);
    298 extern void attach_driver(node_t *, driver_t *);
    299 extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
     313extern void attach_driver(dev_node_t *, driver_t *);
     314extern void add_device(int, driver_t *, dev_node_t *, dev_tree_t *);
    300315extern bool start_driver(driver_t *);
    301316
     
    310325/* Device nodes */
    311326
    312 extern node_t *create_dev_node(void);
    313 extern void delete_dev_node(node_t *node);
    314 extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
     327extern dev_node_t *create_dev_node(void);
     328extern void delete_dev_node(dev_node_t *node);
     329extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
    315330    devman_handle_t handle);
    316 extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
    317 extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
    318 extern node_t *find_node_child(node_t *, const char *);
     331extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
     332extern dev_node_t *find_dev_function(dev_node_t *, const char *);
     333
     334extern fun_node_t *create_fun_node(void);
     335extern void delete_fun_node(fun_node_t *);
     336extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
     337    devman_handle_t handle);
     338extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
     339extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
    319340
    320341/* Device tree */
    321342
    322343extern bool init_device_tree(dev_tree_t *, driver_list_t *);
    323 extern bool create_root_node(dev_tree_t *);
    324 extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
     344extern bool create_root_nodes(dev_tree_t *);
     345extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
     346extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
    325347
    326348/* Device classes */
     
    330352extern size_t get_new_class_dev_idx(dev_class_t *);
    331353extern char *create_dev_name_for_class(dev_class_t *, const char *);
    332 extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
     354extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
    333355    const char *);
    334356
     
    341363/* Devmap devices */
    342364
    343 extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
    344 extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
    345 
    346 extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
    347 extern void tree_add_devmap_device(dev_tree_t *, node_t *);
     365extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
     366
     367extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
     368extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
     369
     370extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
     371extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
    348372
    349373#endif
  • uspace/srv/devman/main.c

    rdbe25f1 reb1a2f4  
    199199static int assign_driver_fibril(void *arg)
    200200{
    201         node_t *node = (node_t *) arg;
    202         assign_driver(node, &drivers_list, &device_tree);
     201        dev_node_t *dev_node = (dev_node_t *) arg;
     202        assign_driver(dev_node, &drivers_list, &device_tree);
    203203        return EOK;
    204204}
    205205
    206 /** Handle child device registration.
     206/** Handle function registration.
    207207 *
    208208 * Child devices are registered by their parent's device driver.
    209209 */
    210 static void devman_add_child(ipc_callid_t callid, ipc_call_t *call)
    211 {
    212         devman_handle_t parent_handle = IPC_GET_ARG1(*call);
    213         sysarg_t match_count = IPC_GET_ARG2(*call);
     210static void devman_add_function(ipc_callid_t callid, ipc_call_t *call)
     211{
     212        fun_type_t ftype = (fun_type_t) IPC_GET_ARG1(*call);
     213        devman_handle_t dev_handle = IPC_GET_ARG2(*call);
     214        sysarg_t match_count = IPC_GET_ARG3(*call);
    214215        dev_tree_t *tree = &device_tree;
    215216       
    216217        fibril_rwlock_write_lock(&tree->rwlock);
    217         node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle);
    218        
    219         if (parent == NULL) {
     218
     219        dev_node_t *dev = NULL;
     220        dev_node_t *pdev = find_dev_node_no_lock(&device_tree, dev_handle);
     221       
     222        if (pdev == NULL) {
    220223                fibril_rwlock_write_unlock(&tree->rwlock);
    221224                async_answer_0(callid, ENOENT);
     
    223226        }
    224227       
    225         char *dev_name = NULL;
    226         int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
     228        if (ftype != fun_inner && ftype != fun_exposed) {
     229                /* Unknown function type */
     230                printf(NAME ": Error, unknown function type provided by driver!\n");
     231
     232                fibril_rwlock_write_unlock(&tree->rwlock);
     233                async_answer_0(callid, EINVAL);
     234                return;
     235        }
     236       
     237        char *fun_name = NULL;
     238        int rc = async_data_write_accept((void **)&fun_name, true, 0, 0, 0, 0);
    227239        if (rc != EOK) {
    228240                fibril_rwlock_write_unlock(&tree->rwlock);
     
    231243        }
    232244       
    233         node_t *node = create_dev_node();
    234         if (!insert_dev_node(&device_tree, node, dev_name, parent)) {
     245        fun_node_t *fun = create_fun_node();
     246        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
    235247                fibril_rwlock_write_unlock(&tree->rwlock);
    236                 delete_dev_node(node);
     248                delete_fun_node(fun);
    237249                async_answer_0(callid, ENOMEM);
    238250                return;
    239251        }
    240252
     253        if (ftype == fun_inner) {
     254                dev = create_dev_node();
     255                if (dev == NULL) {
     256                        fibril_rwlock_write_unlock(&tree->rwlock);
     257                        delete_fun_node(fun);
     258                        async_answer_0(callid, ENOMEM);
     259                        return;
     260                }
     261
     262                insert_dev_node(tree, dev, fun);
     263        }
     264
    241265        fibril_rwlock_write_unlock(&tree->rwlock);
    242266       
    243         printf(NAME ": devman_add_child %s\n", node->pathname);
    244        
    245         devman_receive_match_ids(match_count, &node->match_ids);
    246 
    247         /*
    248          * Try to find a suitable driver and assign it to the device.  We do
    249          * not want to block the current fibril that is used for processing
    250          * incoming calls: we will launch a separate fibril to handle the
    251          * driver assigning. That is because assign_driver can actually include
    252          * task spawning which could take some time.
    253          */
    254         fid_t assign_fibril = fibril_create(assign_driver_fibril, node);
    255         if (assign_fibril == 0) {
     267        printf(NAME ": devman_add_function %s\n", fun->pathname);
     268       
     269        devman_receive_match_ids(match_count, &fun->match_ids);
     270
     271        if (ftype == fun_inner) {
     272                assert(dev != NULL);
    256273                /*
    257                  * Fallback in case we are out of memory.
    258                  * Probably not needed as we will die soon anyway ;-).
     274                 * Try to find a suitable driver and assign it to the device.  We do
     275                 * not want to block the current fibril that is used for processing
     276                 * incoming calls: we will launch a separate fibril to handle the
     277                 * driver assigning. That is because assign_driver can actually include
     278                 * task spawning which could take some time.
    259279                 */
    260                 (void) assign_driver_fibril(node);
     280                fid_t assign_fibril = fibril_create(assign_driver_fibril, dev);
     281                if (assign_fibril == 0) {
     282                        /*
     283                         * Fallback in case we are out of memory.
     284                         * Probably not needed as we will die soon anyway ;-).
     285                         */
     286                        (void) assign_driver_fibril(fun);
     287                } else {
     288                        fibril_add_ready(assign_fibril);
     289                }
    261290        } else {
    262                 fibril_add_ready(assign_fibril);
    263         }
    264 
     291                devmap_register_tree_function(fun, tree);
     292        }
     293       
    265294        /* Return device handle to parent's driver. */
    266         async_answer_1(callid, EOK, node->handle);
     295        async_answer_1(callid, EOK, fun->handle);
    267296}
    268297
     
    288317         * mapper.
    289318         */
    290         class_add_devmap_device(&class_list, cli);
     319        class_add_devmap_function(&class_list, cli);
    291320       
    292321        free(devmap_pathname);
    293322}
    294323
    295 static void devman_add_device_to_class(ipc_callid_t callid, ipc_call_t *call)
     324static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call)
    296325{
    297326        devman_handle_t handle = IPC_GET_ARG1(*call);
     
    306335        }       
    307336       
    308         node_t *dev = find_dev_node(&device_tree, handle);
    309         if (dev == NULL) {
     337        fun_node_t *fun = find_fun_node(&device_tree, handle);
     338        if (fun == NULL) {
    310339                async_answer_0(callid, ENOENT);
    311340                return;
     
    313342       
    314343        dev_class_t *cl = get_dev_class(&class_list, class_name);
    315         dev_class_info_t *class_info = add_device_to_class(dev, cl, NULL);
     344        dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
    316345       
    317346        /* Register the device's class alias by devmapper. */
    318347        devmap_register_class_dev(class_info);
    319348       
    320         printf(NAME ": device '%s' added to class '%s', class name '%s' was "
    321             "asigned to it\n", dev->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);
    322351
    323352        async_answer_0(callid, EOK);
     
    372401                        cont = false;
    373402                        continue;
    374                 case DEVMAN_ADD_CHILD_DEVICE:
    375                         devman_add_child(callid, &call);
     403                case DEVMAN_ADD_FUNCTION:
     404                        devman_add_function(callid, &call);
    376405                        break;
    377406                case DEVMAN_ADD_DEVICE_TO_CLASS:
    378                         devman_add_device_to_class(callid, &call);
     407                        devman_add_function_to_class(callid, &call);
    379408                        break;
    380409                default:
     
    387416/** Find handle for the device instance identified by the device's path in the
    388417 * device tree. */
    389 static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
     418static void devman_function_get_handle(ipc_callid_t iid, ipc_call_t *icall)
    390419{
    391420        char *pathname;
     
    397426        }
    398427       
    399         node_t * dev = find_dev_node_by_path(&device_tree, pathname);
     428        fun_node_t *fun = find_fun_node_by_path(&device_tree, pathname);
    400429       
    401430        free(pathname);
    402431
    403         if (dev == NULL) {
     432        if (fun == NULL) {
    404433                async_answer_0(iid, ENOENT);
    405434                return;
    406435        }
    407        
    408         async_answer_1(iid, EOK, dev->handle);
     436
     437        async_answer_1(iid, EOK, fun->handle);
    409438}
    410439
     
    426455                        continue;
    427456                case DEVMAN_DEVICE_GET_HANDLE:
    428                         devman_device_get_handle(callid, &call);
     457                        devman_function_get_handle(callid, &call);
    429458                        break;
    430459                default:
     
    438467{
    439468        devman_handle_t handle = IPC_GET_ARG2(*icall);
    440        
    441         node_t *dev = find_dev_node(&device_tree, handle);
    442         if (dev == NULL) {
    443                 printf(NAME ": devman_forward error - no device with handle %" PRIun
    444                     " was found.\n", handle);
     469        devman_handle_t fwd_h;
     470        fun_node_t *fun = NULL;
     471        dev_node_t *dev = NULL;
     472       
     473        fun = find_fun_node(&device_tree, handle);
     474        if (fun == NULL)
     475                dev = find_dev_node(&device_tree, handle);
     476        else
     477                dev = fun->dev;
     478
     479        if (fun == NULL && dev == NULL) {
     480                printf(NAME ": devman_forward error - no device or function with "
     481                    "handle %" PRIun " was found.\n", handle);
    445482                async_answer_0(iid, ENOENT);
    446483                return;
    447484        }
     485
     486        if (fun == NULL && !drv_to_parent) {
     487                printf(NAME ": devman_forward error - cannot connect to "
     488                    "handle %" PRIun ", refers to a device.\n", handle);
     489                async_answer_0(iid, ENOENT);
     490                return;
     491        }
    448492       
    449493        driver_t *driver = NULL;
    450494       
    451495        if (drv_to_parent) {
    452                 if (dev->parent != NULL)
    453                         driver = dev->parent->drv;
     496                /* Connect to parent function of a device (or device function). */
     497                if (dev->pfun->dev != NULL)
     498                        driver = dev->pfun->dev->drv;
     499                fwd_h = dev->pfun->handle;
    454500        } else if (dev->state == DEVICE_USABLE) {
     501                /* Connect to the specified function */
    455502                driver = dev->drv;
    456503                assert(driver != NULL);
     504
     505                fwd_h = handle;
    457506        }
    458507       
     
    460509                printf(NAME ": devman_forward error - the device %" PRIun \
    461510                    " (%s) is not in usable state.\n",
    462                     handle, dev->pathname);
     511                    handle, dev->pfun->pathname);
    463512                async_answer_0(iid, ENOENT);
    464513                return;
     
    479528        }
    480529
    481         printf(NAME ": devman_forward: forward connection to device %s to "
    482             "driver %s.\n", dev->pathname, driver->name);
    483         async_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
     530        if (fun != NULL) {
     531                printf(NAME ": devman_forward: forward connection to function %s to "
     532                    "driver %s.\n", fun->pathname, driver->name);
     533        } else {
     534                printf(NAME ": devman_forward: forward connection to device %s to "
     535                    "driver %s.\n", dev->pfun->pathname, driver->name);
     536        }
     537
     538        async_forward_fast(iid, driver->phone, method, fwd_h, 0, IPC_FF_NONE);
    484539}
    485540
     
    489544{
    490545        devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
    491         node_t *dev;
    492 
    493         dev = find_devmap_tree_device(&device_tree, devmap_handle);
    494         if (dev == NULL)
    495                 dev = find_devmap_class_device(&class_list, devmap_handle);
    496        
    497         if (dev == NULL || dev->drv == NULL) {
     546        fun_node_t *fun;
     547        dev_node_t *dev;
     548
     549        fun = find_devmap_tree_function(&device_tree, devmap_handle);
     550        if (fun == NULL)
     551                fun = find_devmap_class_function(&class_list, devmap_handle);
     552       
     553        if (fun == NULL || fun->dev->drv == NULL) {
    498554                async_answer_0(iid, ENOENT);
    499555                return;
    500556        }
     557       
     558        dev = fun->dev;
    501559       
    502560        if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     
    505563        }
    506564       
    507         async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
     565        async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
    508566            IPC_FF_NONE);
    509567        printf(NAME ": devman_connection_devmapper: forwarded connection to "
    510             "device %s to driver %s.\n", dev->pathname, dev->drv->name);
     568            "device %s to driver %s.\n", fun->pathname, dev->drv->name);
    511569}
    512570
  • uspace/srv/devman/match.c

    rdbe25f1 reb1a2f4  
    5757}
    5858
    59 int get_match_score(driver_t *drv, node_t *dev)
     59int get_match_score(driver_t *drv, dev_node_t *dev)
    6060{
    6161        link_t *drv_head = &drv->match_ids.ids;
    62         link_t *dev_head = &dev->match_ids.ids;
     62        link_t *dev_head = &dev->pfun->match_ids.ids;
    6363       
    6464        if (list_empty(drv_head) || list_empty(dev_head))
  • uspace/srv/fs/devfs/devfs_ops.c

    rdbe25f1 reb1a2f4  
    278278                                fibril_mutex_unlock(&devices_mutex);
    279279
    280                                 free(dev);
    281280                                return ENOENT;
    282281                        }
Note: See TracChangeset for help on using the changeset viewer.