Changeset 15f3c3f in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-06-22T22:00:52Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86ffa27f
Parents:
ef09a7a
Message:

Rename devmap to loc, devfs to locfs.

File:
1 edited

Legend:

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

    ref09a7a r15f3c3f  
    3737#include <ipc/driver.h>
    3838#include <ipc/devman.h>
    39 #include <devmap.h>
     39#include <loc.h>
    4040#include <str_error.h>
    4141#include <stdio.h>
     
    6666}
    6767
    68 static int devmap_functions_compare(unsigned long key[], hash_count_t keys,
     68static int loc_functions_compare(unsigned long key[], hash_count_t keys,
    6969    link_t *item)
    7070{
    71         fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devmap_fun);
    72         return (fun->devmap_handle == (devmap_handle_t) key[0]);
    73 }
    74 
    75 static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys,
     71        fun_node_t *fun = hash_table_get_instance(item, fun_node_t, loc_fun);
     72        return (fun->service_id == (service_id_t) key[0]);
     73}
     74
     75static int loc_devices_class_compare(unsigned long key[], hash_count_t keys,
    7676    link_t *item)
    7777{
    7878        dev_class_info_t *class_info
    79             = hash_table_get_instance(item, dev_class_info_t, devmap_link);
     79            = hash_table_get_instance(item, dev_class_info_t, loc_link);
    8080        assert(class_info != NULL);
    8181
    82         return (class_info->devmap_handle == (devmap_handle_t) key[0]);
     82        return (class_info->service_id == (service_id_t) key[0]);
    8383}
    8484
     
    9999};
    100100
    101 static hash_table_operations_t devmap_devices_ops = {
     101static hash_table_operations_t loc_devices_ops = {
    102102        .hash = devices_hash,
    103         .compare = devmap_functions_compare,
     103        .compare = loc_functions_compare,
    104104        .remove_callback = devices_remove_callback
    105105};
    106106
    107 static hash_table_operations_t devmap_devices_class_ops = {
     107static hash_table_operations_t loc_devices_class_ops = {
    108108        .hash = devices_hash,
    109         .compare = devmap_devices_class_compare,
     109        .compare = loc_devices_class_compare,
    110110        .remove_callback = devices_remove_callback
    111111};
     
    700700}
    701701
    702 /** Create devmap path and name for the function. */
    703 void devmap_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
    704 {
    705         char *devmap_pathname = NULL;
    706         char *devmap_name = NULL;
    707        
    708         asprintf(&devmap_name, "%s", fun->pathname);
    709         if (devmap_name == NULL)
     702/** Create loc path and name for the function. */
     703void loc_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
     704{
     705        char *loc_pathname = NULL;
     706        char *loc_name = NULL;
     707       
     708        asprintf(&loc_name, "%s", fun->pathname);
     709        if (loc_name == NULL)
    710710                return;
    711711       
    712         replace_char(devmap_name, '/', DEVMAP_SEPARATOR);
    713        
    714         asprintf(&devmap_pathname, "%s/%s", DEVMAP_DEVICE_NAMESPACE,
    715             devmap_name);
    716         if (devmap_pathname == NULL) {
    717                 free(devmap_name);
     712        replace_char(loc_name, '/', LOC_SEPARATOR);
     713       
     714        asprintf(&loc_pathname, "%s/%s", LOC_DEVICE_NAMESPACE,
     715            loc_name);
     716        if (loc_pathname == NULL) {
     717                free(loc_name);
    718718                return;
    719719        }
    720720       
    721         devmap_device_register_with_iface(devmap_pathname,
    722             &fun->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    723        
    724         tree_add_devmap_function(tree, fun);
    725        
    726         free(devmap_name);
    727         free(devmap_pathname);
     721        loc_service_register_with_iface(loc_pathname,
     722            &fun->service_id, DEVMAN_CONNECT_FROM_LOC);
     723       
     724        tree_add_loc_function(tree, fun);
     725       
     726        free(loc_name);
     727        free(loc_pathname);
    728728}
    729729
     
    855855        hash_table_create(&tree->devman_functions, DEVICE_BUCKETS, 1,
    856856            &devman_functions_ops);
    857         hash_table_create(&tree->devmap_functions, DEVICE_BUCKETS, 1,
    858             &devmap_devices_ops);
     857        hash_table_create(&tree->loc_functions, DEVICE_BUCKETS, 1,
     858            &loc_devices_ops);
    859859       
    860860        fibril_rwlock_initialize(&tree->rwlock);
     
    951951                list_initialize(&res->classes);
    952952                link_initialize(&res->devman_fun);
    953                 link_initialize(&res->devmap_fun);
     953                link_initialize(&res->loc_fun);
    954954        }
    955955       
     
    12671267                memset(info, 0, sizeof(dev_class_info_t));
    12681268                link_initialize(&info->dev_classes);
    1269                 link_initialize(&info->devmap_link);
     1269                link_initialize(&info->loc_link);
    12701270                link_initialize(&info->link);
    12711271        }
     
    14131413        list_initialize(&class_list->classes);
    14141414        fibril_rwlock_initialize(&class_list->rwlock);
    1415         hash_table_create(&class_list->devmap_functions, DEVICE_BUCKETS, 1,
    1416             &devmap_devices_class_ops);
    1417 }
    1418 
    1419 
    1420 /* Devmap devices */
    1421 
    1422 fun_node_t *find_devmap_tree_function(dev_tree_t *tree, devmap_handle_t devmap_handle)
     1415        hash_table_create(&class_list->loc_functions, DEVICE_BUCKETS, 1,
     1416            &loc_devices_class_ops);
     1417}
     1418
     1419
     1420/* loc devices */
     1421
     1422fun_node_t *find_loc_tree_function(dev_tree_t *tree, service_id_t service_id)
    14231423{
    14241424        fun_node_t *fun = NULL;
    14251425        link_t *link;
    1426         unsigned long key = (unsigned long) devmap_handle;
     1426        unsigned long key = (unsigned long) service_id;
    14271427       
    14281428        fibril_rwlock_read_lock(&tree->rwlock);
    1429         link = hash_table_find(&tree->devmap_functions, &key);
     1429        link = hash_table_find(&tree->loc_functions, &key);
    14301430        if (link != NULL)
    1431                 fun = hash_table_get_instance(link, fun_node_t, devmap_fun);
     1431                fun = hash_table_get_instance(link, fun_node_t, loc_fun);
    14321432        fibril_rwlock_read_unlock(&tree->rwlock);
    14331433       
     
    14351435}
    14361436
    1437 fun_node_t *find_devmap_class_function(class_list_t *classes,
    1438     devmap_handle_t devmap_handle)
     1437fun_node_t *find_loc_class_function(class_list_t *classes,
     1438    service_id_t service_id)
    14391439{
    14401440        fun_node_t *fun = NULL;
    14411441        dev_class_info_t *cli;
    14421442        link_t *link;
    1443         unsigned long key = (unsigned long)devmap_handle;
     1443        unsigned long key = (unsigned long)service_id;
    14441444       
    14451445        fibril_rwlock_read_lock(&classes->rwlock);
    1446         link = hash_table_find(&classes->devmap_functions, &key);
     1446        link = hash_table_find(&classes->loc_functions, &key);
    14471447        if (link != NULL) {
    14481448                cli = hash_table_get_instance(link, dev_class_info_t,
    1449                     devmap_link);
     1449                    loc_link);
    14501450                fun = cli->fun;
    14511451        }
     
    14551455}
    14561456
    1457 void class_add_devmap_function(class_list_t *class_list, dev_class_info_t *cli)
    1458 {
    1459         unsigned long key = (unsigned long) cli->devmap_handle;
     1457void class_add_loc_function(class_list_t *class_list, dev_class_info_t *cli)
     1458{
     1459        unsigned long key = (unsigned long) cli->service_id;
    14601460       
    14611461        fibril_rwlock_write_lock(&class_list->rwlock);
    1462         hash_table_insert(&class_list->devmap_functions, &key, &cli->devmap_link);
     1462        hash_table_insert(&class_list->loc_functions, &key, &cli->loc_link);
    14631463        fibril_rwlock_write_unlock(&class_list->rwlock);
    14641464
    1465         assert(find_devmap_class_function(class_list, cli->devmap_handle) != NULL);
    1466 }
    1467 
    1468 void tree_add_devmap_function(dev_tree_t *tree, fun_node_t *fun)
    1469 {
    1470         unsigned long key = (unsigned long) fun->devmap_handle;
     1465        assert(find_loc_class_function(class_list, cli->service_id) != NULL);
     1466}
     1467
     1468void tree_add_loc_function(dev_tree_t *tree, fun_node_t *fun)
     1469{
     1470        unsigned long key = (unsigned long) fun->service_id;
    14711471        fibril_rwlock_write_lock(&tree->rwlock);
    1472         hash_table_insert(&tree->devmap_functions, &key, &fun->devmap_fun);
     1472        hash_table_insert(&tree->loc_functions, &key, &fun->loc_fun);
    14731473        fibril_rwlock_write_unlock(&tree->rwlock);
    14741474}
Note: See TracChangeset for help on using the changeset viewer.