Changeset 7bdcc45 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-12-16T16:38:49Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7837101
Parents:
8e58f94 (diff), eb221e5 (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

    r8e58f94 r7bdcc45  
    3636 */
    3737
     38#include <inttypes.h>
    3839#include <assert.h>
    3940#include <ipc/services.h>
     
    7374       
    7475        iid = async_get_call(&icall);
    75         if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
     76        if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) {
    7677                ipc_answer_0(iid, EREFUSED);
    7778                return NULL;
     
    108109        ipc_call_t call;
    109110        ipc_callid_t callid = async_get_call(&call);
    110         if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
     111        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
    111112                ipc_answer_0(callid, ENOTSUP);
    112113                ipc_answer_0(iid, ENOTSUP);
     
    140141       
    141142        callid = async_get_call(&call);
    142         if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
     143        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    143144                printf(NAME ": ERROR: devman_receive_match_id - invalid "
    144145                    "protocol.\n");
     
    183184 * @return              Zero on success, negative error code otherwise.
    184185 */
    185 static int devman_receive_match_ids(ipcarg_t match_count,
     186static int devman_receive_match_ids(sysarg_t match_count,
    186187    match_id_list_t *match_ids)
    187188{
     
    196197}
    197198
     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
    198206/** Handle child device registration.
    199207 *
     
    203211{
    204212        devman_handle_t parent_handle = IPC_GET_ARG1(*call);
    205         ipcarg_t match_count = IPC_GET_ARG2(*call);
     213        sysarg_t match_count = IPC_GET_ARG2(*call);
    206214        dev_tree_t *tree = &device_tree;
    207215       
     
    236244       
    237245        devman_receive_match_ids(match_count, &node->match_ids);
    238        
     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
    239265        /* Return device handle to parent's driver. */
    240266        ipc_answer_1(callid, EOK, node->handle);
    241        
    242         /* Try to find suitable driver and assign it to the device. */
    243         assign_driver(node, &drivers_list, &device_tree);
    244267}
    245268
     
    296319        printf(NAME ": device '%s' added to class '%s', class name '%s' was "
    297320            "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
    298        
     321
    299322        ipc_answer_0(callid, EOK);
    300323}
     
    344367                callid = async_get_call(&call);
    345368               
    346                 switch (IPC_GET_METHOD(call)) {
     369                switch (IPC_GET_IMETHOD(call)) {
    347370                case IPC_M_PHONE_HUNGUP:
    348371                        cont = false;
     
    397420                ipc_callid_t callid = async_get_call(&call);
    398421               
    399                 switch (IPC_GET_METHOD(call)) {
     422                switch (IPC_GET_IMETHOD(call)) {
    400423                case IPC_M_PHONE_HUNGUP:
    401424                        cont = false;
     
    405428                        break;
    406429                default:
    407                         if (!(callid & IPC_CALLID_NOTIFICATION))
    408                                 ipc_answer_0(callid, ENOENT);
     430                        ipc_answer_0(callid, ENOENT);
    409431                }
    410432        }
     
    418440        node_t *dev = find_dev_node(&device_tree, handle);
    419441        if (dev == NULL) {
    420                 printf(NAME ": devman_forward error - no device with handle %x "
    421                     "was found.\n", handle);
     442                printf(NAME ": devman_forward error - no device with handle %" PRIun
     443                    " was found.\n", handle);
    422444                ipc_answer_0(iid, ENOENT);
    423445                return;
     
    435457       
    436458        if (driver == NULL) {
    437                 printf(NAME ": devman_forward error - the device is not in "
    438                     "usable state.\n", handle);
     459                printf(NAME ": devman_forward error - the device is not in %" PRIun
     460                    " usable state.\n", handle);
    439461                ipc_answer_0(iid, ENOENT);
    440462                return;
     
    450472                printf(NAME ": devman_forward: cound not forward to driver %s ",
    451473                    driver->name);
    452                 printf("the driver's phone is %x).\n", driver->phone);
     474                printf("the driver's phone is %" PRIun ").\n", driver->phone);
    453475                ipc_answer_0(iid, EINVAL);
    454476                return;
     
    464486static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
    465487{
    466         devmap_handle_t devmap_handle = IPC_GET_METHOD(*icall);
     488        devmap_handle_t devmap_handle = IPC_GET_IMETHOD(*icall);
    467489        node_t *dev;
    468490
     
    499521         * passes device handle to the driver as an ipc method.)
    500522         */
    501         if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
     523        if (IPC_GET_IMETHOD(*icall) != IPC_M_CONNECT_ME_TO)
    502524                devman_connection_devmapper(iid, icall);
    503525
     
    509531       
    510532        /* Select interface. */
    511         switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
     533        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
    512534        case DEVMAN_DRIVER:
    513535                devman_connection_driver(iid, icall);
     
    577599
    578600        /* Register device manager at naming service. */
    579         ipcarg_t phonead;
     601        sysarg_t phonead;
    580602        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
    581603                return -1;
Note: See TracChangeset for help on using the changeset viewer.