Ignore:
File:
1 edited

Legend:

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

    r7beb220 rb927375  
    3939#include <assert.h>
    4040#include <ipc/services.h>
    41 #include <ns.h>
     41#include <ipc/ns.h>
    4242#include <async.h>
    4343#include <stdio.h>
    4444#include <errno.h>
    45 #include <str_error.h>
    4645#include <bool.h>
    4746#include <fibril_synch.h>
     
    5251#include <sys/stat.h>
    5352#include <ctype.h>
    54 #include <io/log.h>
    5553#include <ipc/devman.h>
    5654#include <ipc/driver.h>
    5755#include <thread.h>
    58 #include <loc.h>
     56#include <devmap.h>
    5957
    6058#include "devman.h"
     
    6462static driver_list_t drivers_list;
    6563static dev_tree_t device_tree;
     64static class_list_t class_list;
    6665
    6766/** Register running driver. */
     
    7271        driver_t *driver = NULL;
    7372
    74         log_msg(LVL_DEBUG, "devman_driver_register");
     73        printf(NAME ": devman_driver_register \n");
    7574       
    7675        iid = async_get_call(&icall);
     
    8988        }
    9089
    91         log_msg(LVL_DEBUG, "The `%s' driver is trying to register.",
     90        printf(NAME ": the %s driver is trying to register by the service.\n",
    9291            drv_name);
    9392       
    9493        /* Find driver structure. */
    9594        driver = find_driver(&drivers_list, drv_name);
     95       
    9696        if (driver == NULL) {
    97                 log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);
     97                printf(NAME ": no driver named %s was found.\n", drv_name);
    9898                free(drv_name);
    9999                drv_name = NULL;
     
    105105        drv_name = NULL;
    106106       
    107         fibril_mutex_lock(&driver->driver_mutex);
    108        
    109         if (driver->sess) {
    110                 /* We already have a connection to the driver. */
    111                 log_msg(LVL_ERROR, "Driver '%s' already started.\n",
    112                     driver->name);
    113                 fibril_mutex_unlock(&driver->driver_mutex);
    114                 async_answer_0(iid, EEXISTS);
    115                 return NULL;
    116         }
    117        
    118         switch (driver->state) {
    119         case DRIVER_NOT_STARTED:
    120                 /* Somebody started the driver manually. */
    121                 log_msg(LVL_NOTE, "Driver '%s' started manually.\n",
    122                     driver->name);
    123                 driver->state = DRIVER_STARTING;
    124                 break;
    125         case DRIVER_STARTING:
    126                 /* The expected case */
    127                 break;
    128         case DRIVER_RUNNING:
    129                 /* Should not happen since we do not have a connected session */
    130                 assert(false);
    131         }
    132        
    133107        /* Create connection to the driver. */
    134         log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.",
    135             driver->name);
    136         driver->sess = async_callback_receive(EXCHANGE_SERIALIZE);
    137         if (!driver->sess) {
    138                 fibril_mutex_unlock(&driver->driver_mutex);
     108        printf(NAME ":  creating connection to the %s driver.\n", driver->name);
     109        ipc_call_t call;
     110        ipc_callid_t callid = async_get_call(&call);
     111        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     112                async_answer_0(callid, ENOTSUP);
    139113                async_answer_0(iid, ENOTSUP);
    140114                return NULL;
    141115        }
    142116       
    143         fibril_mutex_unlock(&driver->driver_mutex);
    144        
    145         log_msg(LVL_NOTE,
    146             "The `%s' driver was successfully registered as running.",
     117        /* Remember driver's phone. */
     118        set_driver_phone(driver, IPC_GET_ARG5(call));
     119       
     120        printf(NAME ": the %s driver was successfully registered as running.\n",
    147121            driver->name);
    148122       
     123        async_answer_0(callid, EOK);
    149124        async_answer_0(iid, EOK);
    150125       
     
    167142        callid = async_get_call(&call);
    168143        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    169                 log_msg(LVL_ERROR,
    170                     "Invalid protocol when trying to receive match id.");
     144                printf(NAME ": ERROR: devman_receive_match_id - invalid "
     145                    "protocol.\n");
    171146                async_answer_0(callid, EINVAL);
    172147                delete_match_id(match_id);
     
    175150       
    176151        if (match_id == NULL) {
    177                 log_msg(LVL_ERROR, "Failed to allocate match id.");
     152                printf(NAME ": ERROR: devman_receive_match_id - failed to "
     153                    "allocate match id.\n");
    178154                async_answer_0(callid, ENOMEM);
    179155                return ENOMEM;
     
    189165        if (rc != EOK) {
    190166                delete_match_id(match_id);
    191                 log_msg(LVL_ERROR, "Failed to receive match id string: %s.",
    192                     str_error(rc));
     167                printf(NAME ": devman_receive_match_id - failed to receive "
     168                    "match id string.\n");
    193169                return rc;
    194170        }
     
    196172        list_append(&match_id->link, &match_ids->ids);
    197173       
    198         log_msg(LVL_DEBUG, "Received match id `%s', score %d.",
     174        printf(NAME ": received match id '%s', score = %d \n",
    199175            match_id->id, match_id->score);
    200176        return rc;
     
    252228        if (ftype != fun_inner && ftype != fun_exposed) {
    253229                /* Unknown function type */
    254                 log_msg(LVL_ERROR,
    255                     "Unknown function type %d provided by driver.",
    256                     (int) ftype);
     230                printf(NAME ": Error, unknown function type provided by driver!\n");
    257231
    258232                fibril_rwlock_write_unlock(&tree->rwlock);
     
    269243        }
    270244       
    271         /* Check that function with same name is not there already. */
    272         if (find_fun_node_in_device(pdev, fun_name) != NULL) {
    273                 fibril_rwlock_write_unlock(&tree->rwlock);
    274                 async_answer_0(callid, EEXISTS);
    275                 printf(NAME ": Warning, driver tried to register `%s' twice.\n",
    276                     fun_name);
    277                 free(fun_name);
    278                 return;
    279         }
    280        
    281245        fun_node_t *fun = create_fun_node();
    282         fun->ftype = ftype;
    283        
    284246        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
    285247                fibril_rwlock_write_unlock(&tree->rwlock);
     
    303265        fibril_rwlock_write_unlock(&tree->rwlock);
    304266       
    305         log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")", fun->pathname);
     267        printf(NAME ": devman_add_function %s\n", fun->pathname);
    306268       
    307269        devman_receive_match_ids(match_count, &fun->match_ids);
     
    327289                }
    328290        } else {
    329                 loc_register_tree_function(fun, tree);
     291                devmap_register_tree_function(fun, tree);
    330292        }
    331293       
     
    334296}
    335297
    336 static void devman_add_function_to_cat(ipc_callid_t callid, ipc_call_t *call)
     298static void devmap_register_class_dev(dev_class_info_t *cli)
     299{
     300        /* Create devmap path and name for the device. */
     301        char *devmap_pathname = NULL;
     302
     303        asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
     304            cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
     305        if (devmap_pathname == NULL)
     306                return;
     307       
     308        /*
     309         * Register the device by the device mapper and remember its devmap
     310         * handle.
     311         */
     312        devmap_device_register_with_iface(devmap_pathname,
     313            &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
     314       
     315        /*
     316         * Add device to the hash map of class devices registered by device
     317         * mapper.
     318         */
     319        class_add_devmap_function(&class_list, cli);
     320       
     321        free(devmap_pathname);
     322}
     323
     324static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call)
    337325{
    338326        devman_handle_t handle = IPC_GET_ARG1(*call);
    339         category_id_t cat_id;
    340         int rc;
    341        
    342         /* Get category name. */
    343         char *cat_name;
    344         rc = async_data_write_accept((void **) &cat_name, true,
     327       
     328        /* Get class name. */
     329        char *class_name;
     330        int rc = async_data_write_accept((void **) &class_name, true,
    345331            0, 0, 0, 0);
    346332        if (rc != EOK) {
     
    355341        }
    356342       
    357         rc = loc_category_get_id(cat_name, &cat_id, IPC_FLAG_BLOCKING);
    358         if (rc == EOK) {
    359                 loc_service_add_to_cat(fun->service_id, cat_id);
    360         } else {
    361                 log_msg(LVL_ERROR, "Failed adding function `%s' to category "
    362                     "`%s'.", fun->pathname, cat_name);
    363         }
    364        
    365         log_msg(LVL_NOTE, "Function `%s' added to category `%s'.",
    366             fun->pathname, cat_name);
    367 
    368         async_answer_0(callid, EOK);
    369 }
    370 
    371 /** Remove function. */
    372 static void devman_remove_function(ipc_callid_t callid, ipc_call_t *call)
    373 {
    374         devman_handle_t fun_handle = IPC_GET_ARG1(*call);
    375         dev_tree_t *tree = &device_tree;
    376         int rc;
    377        
    378         fibril_rwlock_write_lock(&tree->rwlock);
    379        
    380         fun_node_t *fun = find_fun_node_no_lock(&device_tree, fun_handle);
    381         if (fun == NULL) {
    382                 fibril_rwlock_write_unlock(&tree->rwlock);
    383                 async_answer_0(callid, ENOENT);
    384                 return;
    385         }
    386        
    387         log_msg(LVL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname);
    388        
    389         if (fun->ftype == fun_inner) {
    390                 /* Handle possible descendants */
    391                 /* TODO */
    392                 log_msg(LVL_WARN, "devman_remove_function(): not handling "
    393                     "descendants\n");
    394         } else {
    395                 /* Unregister from location service */
    396                 rc = loc_service_unregister(fun->service_id);
    397                 if (rc != EOK) {
    398                         log_msg(LVL_ERROR, "Failed unregistering tree service.");
    399                         fibril_rwlock_write_unlock(&tree->rwlock);
    400                         async_answer_0(callid, EIO);
    401                         return;
    402                 }
    403         }
    404        
    405         remove_fun_node(&device_tree, fun);
    406         fibril_rwlock_write_unlock(&tree->rwlock);
    407         delete_fun_node(fun);
    408        
    409         log_msg(LVL_DEBUG, "devman_remove_function() succeeded.");
     343        dev_class_t *cl = get_dev_class(&class_list, class_name);
     344        dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
     345       
     346        /* Register the device's class alias by devmapper. */
     347        devmap_register_class_dev(class_info);
     348       
     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);
     351
    410352        async_answer_0(callid, EOK);
    411353}
     
    421363       
    422364        initialize_running_driver(driver, &device_tree);
    423         log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.",
     365        printf(NAME ": the %s driver was successfully initialized. \n",
    424366            driver->name);
    425367        return 0;
     
    443385        fid_t fid = fibril_create(init_running_drv, driver);
    444386        if (fid == 0) {
    445                 log_msg(LVL_ERROR, "Failed to create initialization fibril " \
    446                     "for driver `%s'.", driver->name);
     387                printf(NAME ": Error creating fibril for the initialization of "
     388                    "the newly registered running driver.\n");
    447389                return;
    448390        }
    449391        fibril_add_ready(fid);
    450392       
    451         while (true) {
    452                 ipc_call_t call;
    453                 ipc_callid_t callid = async_get_call(&call);
    454                
    455                 if (!IPC_GET_IMETHOD(call))
    456                         break;
     393        ipc_callid_t callid;
     394        ipc_call_t call;
     395        bool cont = true;
     396        while (cont) {
     397                callid = async_get_call(&call);
    457398               
    458399                switch (IPC_GET_IMETHOD(call)) {
     400                case IPC_M_PHONE_HUNGUP:
     401                        cont = false;
     402                        continue;
    459403                case DEVMAN_ADD_FUNCTION:
    460404                        devman_add_function(callid, &call);
    461405                        break;
    462                 case DEVMAN_ADD_DEVICE_TO_CATEGORY:
    463                         devman_add_function_to_cat(callid, &call);
    464                         break;
    465                 case DEVMAN_REMOVE_FUNCTION:
    466                         devman_remove_function(callid, &call);
     406                case DEVMAN_ADD_DEVICE_TO_CLASS:
     407                        devman_add_function_to_class(callid, &call);
    467408                        break;
    468409                default:
     
    497438}
    498439
    499 /** Get device name. */
    500 static void devman_fun_get_name(ipc_callid_t iid, ipc_call_t *icall)
    501 {
    502         devman_handle_t handle = IPC_GET_ARG1(*icall);
    503 
    504         fun_node_t *fun = find_fun_node(&device_tree, handle);
    505         if (fun == NULL) {
    506                 async_answer_0(iid, ENOMEM);
    507                 return;
    508         }
    509 
    510         ipc_callid_t data_callid;
    511         size_t data_len;
    512         if (!async_data_read_receive(&data_callid, &data_len)) {
    513                 async_answer_0(iid, EINVAL);
    514                 return;
    515         }
    516 
    517         void *buffer = malloc(data_len);
    518         if (buffer == NULL) {
    519                 async_answer_0(data_callid, ENOMEM);
    520                 async_answer_0(iid, ENOMEM);
    521                 return;
    522         }
    523 
    524         size_t sent_length = str_size(fun->name);
    525         if (sent_length > data_len) {
    526                 sent_length = data_len;
    527         }
    528 
    529         async_data_read_finalize(data_callid, fun->name, sent_length);
    530         async_answer_0(iid, EOK);
    531 
    532         free(buffer);
    533 }
    534 
    535 
    536 /** Get device path. */
    537 static void devman_fun_get_path(ipc_callid_t iid, ipc_call_t *icall)
    538 {
    539         devman_handle_t handle = IPC_GET_ARG1(*icall);
    540 
    541         fun_node_t *fun = find_fun_node(&device_tree, handle);
    542         if (fun == NULL) {
    543                 async_answer_0(iid, ENOMEM);
    544                 return;
    545         }
    546 
    547         ipc_callid_t data_callid;
    548         size_t data_len;
    549         if (!async_data_read_receive(&data_callid, &data_len)) {
    550                 async_answer_0(iid, EINVAL);
    551                 return;
    552         }
    553 
    554         void *buffer = malloc(data_len);
    555         if (buffer == NULL) {
    556                 async_answer_0(data_callid, ENOMEM);
    557                 async_answer_0(iid, ENOMEM);
    558                 return;
    559         }
    560 
    561         size_t sent_length = str_size(fun->pathname);
    562         if (sent_length > data_len) {
    563                 sent_length = data_len;
    564         }
    565 
    566         async_data_read_finalize(data_callid, fun->pathname, sent_length);
    567         async_answer_0(iid, EOK);
    568 
    569         free(buffer);
    570 }
    571 
    572 static void devman_dev_get_functions(ipc_callid_t iid, ipc_call_t *icall)
    573 {
    574         ipc_callid_t callid;
    575         size_t size;
    576         size_t act_size;
    577         int rc;
    578        
    579         if (!async_data_read_receive(&callid, &size)) {
    580                 async_answer_0(callid, EREFUSED);
    581                 async_answer_0(iid, EREFUSED);
    582                 return;
    583         }
    584        
    585         fibril_rwlock_read_lock(&device_tree.rwlock);
    586        
    587         dev_node_t *dev = find_dev_node_no_lock(&device_tree,
    588             IPC_GET_ARG1(*icall));
    589         if (dev == NULL) {
    590                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    591                 async_answer_0(callid, ENOENT);
    592                 async_answer_0(iid, ENOENT);
    593                 return;
    594         }
    595        
    596         devman_handle_t *hdl_buf = (devman_handle_t *) malloc(size);
    597         if (hdl_buf == NULL) {
    598                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    599                 async_answer_0(callid, ENOMEM);
    600                 async_answer_0(iid, ENOMEM);
    601                 return;
    602         }
    603        
    604         rc = dev_get_functions(&device_tree, dev, hdl_buf, size, &act_size);
    605         if (rc != EOK) {
    606                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    607                 async_answer_0(callid, rc);
    608                 async_answer_0(iid, rc);
    609                 return;
    610         }
    611        
    612         fibril_rwlock_read_unlock(&device_tree.rwlock);
    613        
    614         sysarg_t retval = async_data_read_finalize(callid, hdl_buf, size);
    615         free(hdl_buf);
    616        
    617         async_answer_1(iid, retval, act_size);
    618 }
    619 
    620 
    621 /** Get handle for child device of a function. */
    622 static void devman_fun_get_child(ipc_callid_t iid, ipc_call_t *icall)
    623 {
    624         fun_node_t *fun;
    625        
    626         fibril_rwlock_read_lock(&device_tree.rwlock);
    627        
    628         fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall));
    629         if (fun == NULL) {
    630                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    631                 async_answer_0(iid, ENOENT);
    632                 return;
    633         }
    634        
    635         if (fun->child == NULL) {
    636                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    637                 async_answer_0(iid, ENOENT);
    638                 return;
    639         }
    640        
    641         async_answer_1(iid, EOK, fun->child->handle);
    642        
    643         fibril_rwlock_read_unlock(&device_tree.rwlock);
    644 }
    645 
    646 /** Find handle for the function instance identified by its service ID. */
    647 static void devman_fun_sid_to_handle(ipc_callid_t iid, ipc_call_t *icall)
    648 {
    649         fun_node_t *fun;
    650 
    651         fun = find_loc_tree_function(&device_tree, IPC_GET_ARG1(*icall));
    652        
    653         if (fun == NULL) {
    654                 async_answer_0(iid, ENOENT);
    655                 return;
    656         }
    657 
    658         async_answer_1(iid, EOK, fun->handle);
    659 }
    660440
    661441/** Function for handling connections from a client to the device manager. */
     
    665445        async_answer_0(iid, EOK);
    666446       
    667         while (true) {
     447        bool cont = true;
     448        while (cont) {
    668449                ipc_call_t call;
    669450                ipc_callid_t callid = async_get_call(&call);
    670451               
    671                 if (!IPC_GET_IMETHOD(call))
    672                         break;
    673                
    674452                switch (IPC_GET_IMETHOD(call)) {
     453                case IPC_M_PHONE_HUNGUP:
     454                        cont = false;
     455                        continue;
    675456                case DEVMAN_DEVICE_GET_HANDLE:
    676457                        devman_function_get_handle(callid, &call);
    677                         break;
    678                 case DEVMAN_DEV_GET_FUNCTIONS:
    679                         devman_dev_get_functions(callid, &call);
    680                         break;
    681                 case DEVMAN_FUN_GET_CHILD:
    682                         devman_fun_get_child(callid, &call);
    683                         break;
    684                 case DEVMAN_FUN_GET_NAME:
    685                         devman_fun_get_name(callid, &call);
    686                         break;
    687                 case DEVMAN_FUN_GET_PATH:
    688                         devman_fun_get_path(callid, &call);
    689                         break;
    690                 case DEVMAN_FUN_SID_TO_HANDLE:
    691                         devman_fun_sid_to_handle(callid, &call);
    692458                        break;
    693459                default:
     
    711477                dev = fun->dev;
    712478
    713         /*
    714          * For a valid function to connect to we need a device. The root
    715          * function, for example, has no device and cannot be connected to.
    716          * This means @c dev needs to be valid regardless whether we are
    717          * connecting to a device or to a function.
    718          */
    719         if (dev == NULL) {
    720                 log_msg(LVL_ERROR, "IPC forwarding failed - no device or "
    721                     "function with handle %" PRIun " was found.", handle);
     479        if (fun == NULL && dev == NULL) {
     480                printf(NAME ": devman_forward error - no device or function with "
     481                    "handle %" PRIun " was found.\n", handle);
    722482                async_answer_0(iid, ENOENT);
    723483                return;
     
    725485
    726486        if (fun == NULL && !drv_to_parent) {
    727                 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot "
    728                     "connect to handle %" PRIun ", refers to a device.",
    729                     handle);
     487                printf(NAME ": devman_forward error - cannot connect to "
     488                    "handle %" PRIun ", refers to a device.\n", handle);
    730489                async_answer_0(iid, ENOENT);
    731490                return;
     
    748507       
    749508        if (driver == NULL) {
    750                 log_msg(LVL_ERROR, "IPC forwarding refused - " \
    751                     "the device %" PRIun " is not in usable state.", handle);
     509                printf(NAME ": devman_forward error - the device is not in %" PRIun
     510                    " usable state.\n", handle);
    752511                async_answer_0(iid, ENOENT);
    753512                return;
     
    760519                method = DRIVER_CLIENT;
    761520       
    762         if (!driver->sess) {
    763                 log_msg(LVL_ERROR,
    764                     "Could not forward to driver `%s'.", driver->name);
     521        if (driver->phone <= 0) {
     522                printf(NAME ": devman_forward: cound not forward to driver %s ",
     523                    driver->name);
     524                printf("the driver's phone is %" PRIun ").\n", driver->phone);
    765525                async_answer_0(iid, EINVAL);
    766526                return;
     
    768528
    769529        if (fun != NULL) {
    770                 log_msg(LVL_DEBUG,
    771                     "Forwarding request for `%s' function to driver `%s'.",
    772                     fun->pathname, driver->name);
     530                printf(NAME ": devman_forward: forward connection to function %s to "
     531                    "driver %s.\n", fun->pathname, driver->name);
    773532        } else {
    774                 log_msg(LVL_DEBUG,
    775                     "Forwarding request for `%s' device to driver `%s'.",
    776                     dev->pfun->pathname, driver->name);
    777         }
    778        
    779         async_exch_t *exch = async_exchange_begin(driver->sess);
    780         async_forward_fast(iid, exch, method, fwd_h, 0, IPC_FF_NONE);
    781         async_exchange_end(exch);
    782 }
    783 
    784 /** Function for handling connections from a client forwarded by the location
    785  * service to the device manager. */
    786 static void devman_connection_loc(ipc_callid_t iid, ipc_call_t *icall)
    787 {
    788         service_id_t service_id = IPC_GET_ARG2(*icall);
     533                printf(NAME ": devman_forward: forward connection to device %s to "
     534                    "driver %s.\n", dev->pfun->pathname, driver->name);
     535        }
     536
     537        async_forward_fast(iid, driver->phone, method, fwd_h, 0, IPC_FF_NONE);
     538}
     539
     540/** Function for handling connections from a client forwarded by the device
     541 * mapper to the device manager. */
     542static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
     543{
     544        devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
    789545        fun_node_t *fun;
    790546        dev_node_t *dev;
    791547
    792         fun = find_loc_tree_function(&device_tree, service_id);
     548        fun = find_devmap_tree_function(&device_tree, devmap_handle);
     549        if (fun == NULL)
     550                fun = find_devmap_class_function(&class_list, devmap_handle);
    793551       
    794552        if (fun == NULL || fun->dev->drv == NULL) {
    795                 log_msg(LVL_WARN, "devman_connection_loc(): function "
    796                     "not found.\n");
    797553                async_answer_0(iid, ENOENT);
    798554                return;
     
    801557        dev = fun->dev;
    802558       
    803         async_exch_t *exch = async_exchange_begin(dev->drv->sess);
    804         async_forward_fast(iid, exch, DRIVER_CLIENT, fun->handle, 0,
     559        if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     560                async_answer_0(iid, EINVAL);
     561                return;
     562        }
     563       
     564        async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
    805565            IPC_FF_NONE);
    806         async_exchange_end(exch);
    807        
    808         log_msg(LVL_DEBUG,
    809             "Forwarding loc service request for `%s' function to driver `%s'.",
    810             fun->pathname, dev->drv->name);
     566        printf(NAME ": devman_connection_devmapper: forwarded connection to "
     567            "device %s to driver %s.\n", fun->pathname, dev->drv->name);
    811568}
    812569
    813570/** Function for handling connections to device manager. */
    814 static void devman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     571static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
    815572{
    816573        /* Select interface. */
     
    826583                devman_forward(iid, icall, false);
    827584                break;
    828         case DEVMAN_CONNECT_FROM_LOC:
    829                 /* Someone connected through loc node. */
    830                 devman_connection_loc(iid, icall);
     585        case DEVMAN_CONNECT_FROM_DEVMAP:
     586                /* Someone connected through devmap node. */
     587                devman_connection_devmapper(iid, icall);
    831588                break;
    832589        case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
     
    843600static bool devman_init(void)
    844601{
    845         log_msg(LVL_DEBUG, "devman_init - looking for available drivers.");
     602        printf(NAME ": devman_init - looking for available drivers.\n");
    846603       
    847604        /* Initialize list of available drivers. */
     
    849606        if (lookup_available_drivers(&drivers_list,
    850607            DRIVER_DEFAULT_STORE) == 0) {
    851                 log_msg(LVL_FATAL, "No drivers found.");
     608                printf(NAME " no drivers found.");
    852609                return false;
    853610        }
    854611
    855         log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.");
     612        printf(NAME ": devman_init  - list of drivers has been initialized.\n");
    856613
    857614        /* Create root device node. */
    858615        if (!init_device_tree(&device_tree, &drivers_list)) {
    859                 log_msg(LVL_FATAL, "Failed to initialize device tree.");
     616                printf(NAME " failed to initialize device tree.");
    860617                return false;
    861618        }
    862619
     620        init_class_list(&class_list);
     621       
    863622        /*
    864          * !!! devman_connection ... as the device manager is not a real loc
     623         * !!! devman_connection ... as the device manager is not a real devmap
    865624         * driver (it uses a completely different ipc protocol than an ordinary
    866          * loc driver) forwarding a connection from client to the devman by
    867          * location service would not work.
     625         * devmap driver) forwarding a connection from client to the devman by
     626         * devmapper would not work.
    868627         */
    869         loc_server_register(NAME, devman_connection);
     628        devmap_driver_register(NAME, devman_connection);
    870629       
    871630        return true;
     
    876635        printf(NAME ": HelenOS Device Manager\n");
    877636
    878         if (log_init(NAME, LVL_WARN) != EOK) {
    879                 printf(NAME ": Error initializing logging subsystem.\n");
    880                 return -1;
    881         }
    882 
    883637        if (!devman_init()) {
    884                 log_msg(LVL_ERROR, "Error while initializing service.");
     638                printf(NAME ": Error while initializing service\n");
    885639                return -1;
    886640        }
     
    890644
    891645        /* Register device manager at naming service. */
    892         if (service_register(SERVICE_DEVMAN) != EOK) {
    893                 log_msg(LVL_ERROR, "Failed registering as a service.");
     646        if (service_register(SERVICE_DEVMAN) != EOK)
    894647                return -1;
    895         }
    896 
    897         printf(NAME ": Accepting connections.\n");
    898         task_retval(0);
     648
     649        printf(NAME ": Accepting connections\n");
    899650        async_manager();
    900651
Note: See TracChangeset for help on using the changeset viewer.