Changeset ea28272 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-12-30T13:43:27Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d770deb
Parents:
d70d80ed (diff), f418e51 (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.

File:
1 edited

Legend:

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

    rd70d80ed rea28272  
    7474       
    7575        iid = async_get_call(&icall);
    76         if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
     76        if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) {
    7777                ipc_answer_0(iid, EREFUSED);
    7878                return NULL;
     
    109109        ipc_call_t call;
    110110        ipc_callid_t callid = async_get_call(&call);
    111         if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
     111        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
    112112                ipc_answer_0(callid, ENOTSUP);
    113113                ipc_answer_0(iid, ENOTSUP);
     
    141141       
    142142        callid = async_get_call(&call);
    143         if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
     143        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    144144                printf(NAME ": ERROR: devman_receive_match_id - invalid "
    145145                    "protocol.\n");
     
    184184 * @return              Zero on success, negative error code otherwise.
    185185 */
    186 static int devman_receive_match_ids(ipcarg_t match_count,
     186static int devman_receive_match_ids(sysarg_t match_count,
    187187    match_id_list_t *match_ids)
    188188{
     
    197197}
    198198
     199static int assign_driver_fibril(void *arg)
     200{
     201        node_t *node = (node_t *) arg;
     202        assign_driver(node, &drivers_list, &device_tree);
     203        return EOK;
     204}
     205
    199206/** Handle child device registration.
    200207 *
     
    204211{
    205212        devman_handle_t parent_handle = IPC_GET_ARG1(*call);
    206         ipcarg_t match_count = IPC_GET_ARG2(*call);
     213        sysarg_t match_count = IPC_GET_ARG2(*call);
    207214        dev_tree_t *tree = &device_tree;
    208215       
     
    237244       
    238245        devman_receive_match_ids(match_count, &node->match_ids);
    239        
     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) {
     256                /*
     257                 * Fallback in case we are out of memory.
     258                 * Probably not needed as we will die soon anyway ;-).
     259                 */
     260                (void) assign_driver_fibril(node);
     261        } else {
     262                fibril_add_ready(assign_fibril);
     263        }
     264
    240265        /* Return device handle to parent's driver. */
    241266        ipc_answer_1(callid, EOK, node->handle);
    242        
    243         /* Try to find suitable driver and assign it to the device. */
    244         assign_driver(node, &drivers_list, &device_tree);
    245267}
    246268
     
    259281         * handle.
    260282         */
    261         devmap_device_register(devmap_pathname, &cli->devmap_handle);
     283        devmap_device_register_with_iface(devmap_pathname,
     284            &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    262285       
    263286        /*
     
    297320        printf(NAME ": device '%s' added to class '%s', class name '%s' was "
    298321            "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
    299        
     322
    300323        ipc_answer_0(callid, EOK);
    301324}
     
    345368                callid = async_get_call(&call);
    346369               
    347                 switch (IPC_GET_METHOD(call)) {
     370                switch (IPC_GET_IMETHOD(call)) {
    348371                case IPC_M_PHONE_HUNGUP:
    349372                        cont = false;
     
    398421                ipc_callid_t callid = async_get_call(&call);
    399422               
    400                 switch (IPC_GET_METHOD(call)) {
     423                switch (IPC_GET_IMETHOD(call)) {
    401424                case IPC_M_PHONE_HUNGUP:
    402425                        cont = false;
     
    464487static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
    465488{
    466         devmap_handle_t devmap_handle = IPC_GET_METHOD(*icall);
     489        devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
    467490        node_t *dev;
    468491
     
    481504        }
    482505       
    483         printf(NAME ": devman_connection_devmapper: forward connection to "
    484             "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    485506        ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
    486507            IPC_FF_NONE);
     508        printf(NAME ": devman_connection_devmapper: forwarded connection to "
     509            "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    487510}
    488511
     
    490513static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
    491514{
    492         /*
    493          * Silly hack to enable the device manager to register as a driver by
    494          * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this
    495          * is not the forwarded connection from naming service, so it must be a
    496          * connection from the devmapper which thinks this is a devmapper-style
    497          * driver. So pretend this is a devmapper-style driver. (This does not
    498          * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper
    499          * passes device handle to the driver as an ipc method.)
    500          */
    501         if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
    502                 devman_connection_devmapper(iid, icall);
    503 
    504         /*
    505          * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection
    506          * from naming service by which we registered as device manager, so be
    507          * device manager.
    508          */
    509        
    510515        /* Select interface. */
    511         switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
     516        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
    512517        case DEVMAN_DRIVER:
    513518                devman_connection_driver(iid, icall);
     
    520525                devman_forward(iid, icall, false);
    521526                break;
     527        case DEVMAN_CONNECT_FROM_DEVMAP:
     528                /* Someone connected through devmap node. */
     529                devman_connection_devmapper(iid, icall);
     530                break;
    522531        case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
    523532                /* Connect client to selected device. */
     
    577586
    578587        /* Register device manager at naming service. */
    579         ipcarg_t phonead;
     588        sysarg_t phonead;
    580589        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
    581590                return -1;
Note: See TracChangeset for help on using the changeset viewer.