Ignore:
File:
1 edited

Legend:

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

    r4ae90f9 r01b87dc5  
    123123static devmap_handle_t last_handle = 0;
    124124static devmap_device_t *null_devices[NULL_DEVICES];
    125 
    126 /*
    127  * Dummy list for null devices. This is necessary so that null devices can
    128  * be used just as any other devices, e.g. in devmap_device_unregister_core().
    129  */
    130 static LIST_INITIALIZE(dummy_null_driver_devices);
    131125
    132126static devmap_handle_t devmap_create_handle(void)
     
    380374       
    381375        if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
    382                 async_answer_0(iid, EREFUSED);
     376                ipc_answer_0(iid, EREFUSED);
    383377                return NULL;
    384378        }
     
    387381            (devmap_driver_t *) malloc(sizeof(devmap_driver_t));
    388382        if (driver == NULL) {
    389                 async_answer_0(iid, ENOMEM);
     383                ipc_answer_0(iid, ENOMEM);
    390384                return NULL;
    391385        }
     
    398392        if (rc != EOK) {
    399393                free(driver);
    400                 async_answer_0(iid, rc);
     394                ipc_answer_0(iid, rc);
    401395                return NULL;
    402396        }
     
    411405                free(driver->name);
    412406                free(driver);
    413                 async_answer_0(callid, ENOTSUP);
    414                 async_answer_0(iid, ENOTSUP);
     407                ipc_answer_0(callid, ENOTSUP);
     408                ipc_answer_0(iid, ENOTSUP);
    415409                return NULL;
    416410        }
    417411       
    418412        driver->phone = IPC_GET_ARG5(call);
    419         async_answer_0(callid, EOK);
     413        ipc_answer_0(callid, EOK);
    420414       
    421415        /*
     
    429423         */
    430424        list_initialize(&driver->devices);
    431 
    432         link_initialize(&driver->drivers);
     425        list_initialize(&(driver->drivers));
    433426       
    434427        fibril_mutex_lock(&drivers_list_mutex);
     
    445438        fibril_mutex_unlock(&drivers_list_mutex);
    446439       
    447         async_answer_0(iid, EOK);
     440        ipc_answer_0(iid, EOK);
    448441       
    449442        return driver;
     
    463456       
    464457        if (driver->phone != 0)
    465                 async_hangup(driver->phone);
     458                ipc_hangup(driver->phone);
    466459       
    467460        /* Remove it from list of drivers */
     
    498491{
    499492        if (driver == NULL) {
    500                 async_answer_0(iid, EREFUSED);
     493                ipc_answer_0(iid, EREFUSED);
    501494                return;
    502495        }
     
    506499            (devmap_device_t *) malloc(sizeof(devmap_device_t));
    507500        if (device == NULL) {
    508                 async_answer_0(iid, ENOMEM);
     501                ipc_answer_0(iid, ENOMEM);
    509502                return;
    510503        }
     
    519512        if (rc != EOK) {
    520513                free(device);
    521                 async_answer_0(iid, rc);
     514                ipc_answer_0(iid, rc);
    522515                return;
    523516        }
     
    527520                free(fqdn);
    528521                free(device);
    529                 async_answer_0(iid, EINVAL);
     522                ipc_answer_0(iid, EINVAL);
    530523                return;
    531524        }
     
    541534                free(device->name);
    542535                free(device);
    543                 async_answer_0(iid, ENOMEM);
    544                 return;
    545         }
    546        
    547         link_initialize(&device->devices);
    548         link_initialize(&device->driver_devices);
     536                ipc_answer_0(iid, ENOMEM);
     537                return;
     538        }
     539       
     540        list_initialize(&(device->devices));
     541        list_initialize(&(device->driver_devices));
    549542       
    550543        /* Check that device is not already registered */
    551544        if (devmap_device_find_name(namespace->name, device->name) != NULL) {
    552545                printf("%s: Device '%s/%s' already registered\n", NAME,
    553                     namespace->name, device->name);
     546                    device->namespace->name, device->name);
    554547                devmap_namespace_destroy(namespace);
    555548                fibril_mutex_unlock(&devices_list_mutex);
    556549                free(device->name);
    557550                free(device);
    558                 async_answer_0(iid, EEXISTS);
     551                ipc_answer_0(iid, EEXISTS);
    559552                return;
    560553        }
     
    578571        fibril_mutex_unlock(&devices_list_mutex);
    579572       
    580         async_answer_1(iid, EOK, device->handle);
     573        ipc_answer_1(iid, EOK, device->handle);
    581574}
    582575
     
    609602        if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) {
    610603                fibril_mutex_unlock(&devices_list_mutex);
    611                 async_answer_0(callid, ENOENT);
     604                ipc_answer_0(callid, ENOENT);
    612605                return;
    613606        }
    614607       
    615608        if (dev->forward_interface == 0) {
    616                 async_forward_fast(callid, dev->driver->phone,
     609                ipc_forward_fast(callid, dev->driver->phone,
    617610                    dev->handle, 0, 0,
    618611                    IPC_FF_NONE);
    619612        } else {
    620                 async_forward_fast(callid, dev->driver->phone,
     613                ipc_forward_fast(callid, dev->driver->phone,
    621614                    dev->forward_interface, dev->handle, 0,
    622615                    IPC_FF_NONE);
     
    640633            DEVMAP_NAME_MAXLEN, 0, NULL);
    641634        if (rc != EOK) {
    642                 async_answer_0(iid, rc);
     635                ipc_answer_0(iid, rc);
    643636                return;
    644637        }
     
    648641        if (!devmap_fqdn_split(fqdn, &ns_name, &name)) {
    649642                free(fqdn);
    650                 async_answer_0(iid, EINVAL);
     643                ipc_answer_0(iid, EINVAL);
    651644                return;
    652645        }
     
    675668                }
    676669               
    677                 async_answer_0(iid, ENOENT);
     670                ipc_answer_0(iid, ENOENT);
    678671                free(ns_name);
    679672                free(name);
     
    682675        }
    683676       
    684         async_answer_1(iid, EOK, dev->handle);
     677        ipc_answer_1(iid, EOK, dev->handle);
    685678       
    686679        fibril_mutex_unlock(&devices_list_mutex);
     
    703696            DEVMAP_NAME_MAXLEN, 0, NULL);
    704697        if (rc != EOK) {
    705                 async_answer_0(iid, rc);
     698                ipc_answer_0(iid, rc);
    706699                return;
    707700        }
     
    728721                }
    729722               
    730                 async_answer_0(iid, ENOENT);
     723                ipc_answer_0(iid, ENOENT);
    731724                free(name);
    732725                fibril_mutex_unlock(&devices_list_mutex);
     
    734727        }
    735728       
    736         async_answer_1(iid, EOK, namespace->handle);
     729        ipc_answer_1(iid, EOK, namespace->handle);
    737730       
    738731        fibril_mutex_unlock(&devices_list_mutex);
     
    750743                    devmap_device_find_handle(IPC_GET_ARG1(*icall));
    751744                if (dev == NULL)
    752                         async_answer_1(iid, EOK, DEV_HANDLE_NONE);
     745                        ipc_answer_1(iid, EOK, DEV_HANDLE_NONE);
    753746                else
    754                         async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
     747                        ipc_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
    755748        } else
    756                 async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
     749                ipc_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
    757750       
    758751        fibril_mutex_unlock(&devices_list_mutex);
     
    762755{
    763756        fibril_mutex_lock(&devices_list_mutex);
    764         async_answer_1(iid, EOK, list_count(&namespaces_list));
     757        ipc_answer_1(iid, EOK, list_count(&namespaces_list));
    765758        fibril_mutex_unlock(&devices_list_mutex);
    766759}
     
    773766            devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
    774767        if (namespace == NULL)
    775                 async_answer_0(iid, EEXISTS);
     768                ipc_answer_0(iid, EEXISTS);
    776769        else
    777                 async_answer_1(iid, EOK, namespace->refcnt);
     770                ipc_answer_1(iid, EOK, namespace->refcnt);
    778771       
    779772        fibril_mutex_unlock(&devices_list_mutex);
     
    785778        size_t size;
    786779        if (!async_data_read_receive(&callid, &size)) {
    787                 async_answer_0(callid, EREFUSED);
    788                 async_answer_0(iid, EREFUSED);
     780                ipc_answer_0(callid, EREFUSED);
     781                ipc_answer_0(iid, EREFUSED);
    789782                return;
    790783        }
    791784       
    792785        if ((size % sizeof(dev_desc_t)) != 0) {
    793                 async_answer_0(callid, EINVAL);
    794                 async_answer_0(iid, EINVAL);
     786                ipc_answer_0(callid, EINVAL);
     787                ipc_answer_0(iid, EINVAL);
    795788                return;
    796789        }
     
    801794        if (count != list_count(&namespaces_list)) {
    802795                fibril_mutex_unlock(&devices_list_mutex);
    803                 async_answer_0(callid, EOVERFLOW);
    804                 async_answer_0(iid, EOVERFLOW);
     796                ipc_answer_0(callid, EOVERFLOW);
     797                ipc_answer_0(iid, EOVERFLOW);
    805798                return;
    806799        }
     
    809802        if (desc == NULL) {
    810803                fibril_mutex_unlock(&devices_list_mutex);
    811                 async_answer_0(callid, ENOMEM);
    812                 async_answer_0(iid, ENOMEM);
     804                ipc_answer_0(callid, ENOMEM);
     805                ipc_answer_0(iid, ENOMEM);
    813806                return;
    814807        }
     
    831824        fibril_mutex_unlock(&devices_list_mutex);
    832825       
    833         async_answer_0(iid, retval);
     826        ipc_answer_0(iid, retval);
    834827}
    835828
     
    842835        size_t size;
    843836        if (!async_data_read_receive(&callid, &size)) {
    844                 async_answer_0(callid, EREFUSED);
    845                 async_answer_0(iid, EREFUSED);
     837                ipc_answer_0(callid, EREFUSED);
     838                ipc_answer_0(iid, EREFUSED);
    846839                return;
    847840        }
    848841       
    849842        if ((size % sizeof(dev_desc_t)) != 0) {
    850                 async_answer_0(callid, EINVAL);
    851                 async_answer_0(iid, EINVAL);
     843                ipc_answer_0(callid, EINVAL);
     844                ipc_answer_0(iid, EINVAL);
    852845                return;
    853846        }
     
    859852        if (namespace == NULL) {
    860853                fibril_mutex_unlock(&devices_list_mutex);
    861                 async_answer_0(callid, ENOENT);
    862                 async_answer_0(iid, ENOENT);
     854                ipc_answer_0(callid, ENOENT);
     855                ipc_answer_0(iid, ENOENT);
    863856                return;
    864857        }
     
    867860        if (count != namespace->refcnt) {
    868861                fibril_mutex_unlock(&devices_list_mutex);
    869                 async_answer_0(callid, EOVERFLOW);
    870                 async_answer_0(iid, EOVERFLOW);
     862                ipc_answer_0(callid, EOVERFLOW);
     863                ipc_answer_0(iid, EOVERFLOW);
    871864                return;
    872865        }
     
    875868        if (desc == NULL) {
    876869                fibril_mutex_unlock(&devices_list_mutex);
    877                 async_answer_0(callid, ENOMEM);
    878                 async_answer_0(iid, EREFUSED);
     870                ipc_answer_0(callid, ENOMEM);
     871                ipc_answer_0(iid, EREFUSED);
    879872                return;
    880873        }
     
    898891        fibril_mutex_unlock(&devices_list_mutex);
    899892       
    900         async_answer_0(iid, retval);
     893        ipc_answer_0(iid, retval);
    901894}
    902895
     
    917910        if (!fnd) {
    918911                fibril_mutex_unlock(&null_devices_mutex);
    919                 async_answer_0(iid, ENOMEM);
     912                ipc_answer_0(iid, ENOMEM);
    920913                return;
    921914        }
     
    927920        if (dev_name == NULL) {
    928921                fibril_mutex_unlock(&null_devices_mutex);
    929                 async_answer_0(iid, ENOMEM);
     922                ipc_answer_0(iid, ENOMEM);
    930923                return;
    931924        }
     
    935928        if (device == NULL) {
    936929                fibril_mutex_unlock(&null_devices_mutex);
    937                 async_answer_0(iid, ENOMEM);
     930                ipc_answer_0(iid, ENOMEM);
    938931                return;
    939932        }
     
    945938                fibril_mutex_lock(&devices_list_mutex);
    946939                fibril_mutex_unlock(&null_devices_mutex);
    947                 async_answer_0(iid, ENOMEM);
    948                 return;
    949         }
    950        
    951         link_initialize(&device->devices);
    952         link_initialize(&device->driver_devices);
     940                ipc_answer_0(iid, ENOMEM);
     941                return;
     942        }
     943       
     944        list_initialize(&(device->devices));
     945        list_initialize(&(device->driver_devices));
    953946       
    954947        /* Get unique device handle */
     
    959952        device->name = dev_name;
    960953       
    961         /*
    962          * Insert device into list of all devices and into null devices array.
    963          * Insert device into a dummy list of null driver's devices so that it
    964          * can be safely removed later.
    965          */
     954        /* Insert device into list of all devices
     955           and into null devices array */
    966956        list_append(&device->devices, &devices_list);
    967         list_append(&device->driver_devices, &dummy_null_driver_devices);
    968957        null_devices[i] = device;
    969958       
     
    971960        fibril_mutex_unlock(&null_devices_mutex);
    972961       
    973         async_answer_1(iid, EOK, (sysarg_t) i);
     962        ipc_answer_1(iid, EOK, (sysarg_t) i);
    974963}
    975964
     
    978967        sysarg_t i = IPC_GET_ARG1(*icall);
    979968        if (i >= NULL_DEVICES) {
    980                 async_answer_0(iid, ELIMIT);
     969                ipc_answer_0(iid, ELIMIT);
    981970                return;
    982971        }
     
    986975        if (null_devices[i] == NULL) {
    987976                fibril_mutex_unlock(&null_devices_mutex);
    988                 async_answer_0(iid, ENOENT);
     977                ipc_answer_0(iid, ENOENT);
    989978                return;
    990979        }
     
    997986       
    998987        fibril_mutex_unlock(&null_devices_mutex);
    999         async_answer_0(iid, EOK);
     988        ipc_answer_0(iid, EOK);
    1000989}
    1001990
     
    10231012{
    10241013        /* Accept connection */
    1025         async_answer_0(iid, EOK);
     1014        ipc_answer_0(iid, EOK);
    10261015       
    10271016        devmap_driver_t *driver = devmap_driver_register();
     
    10401029                case DEVMAP_DRIVER_UNREGISTER:
    10411030                        if (NULL == driver)
    1042                                 async_answer_0(callid, ENOENT);
     1031                                ipc_answer_0(callid, ENOENT);
    10431032                        else
    1044                                 async_answer_0(callid, EOK);
     1033                                ipc_answer_0(callid, EOK);
    10451034                        break;
    10461035                case DEVMAP_DEVICE_REGISTER:
     
    10591048                        break;
    10601049                default:
    1061                         async_answer_0(callid, ENOENT);
     1050                        ipc_answer_0(callid, ENOENT);
    10621051                }
    10631052        }
     
    10781067{
    10791068        /* Accept connection */
    1080         async_answer_0(iid, EOK);
     1069        ipc_answer_0(iid, EOK);
    10811070       
    10821071        bool cont = true;
     
    11171106                        break;
    11181107                default:
    1119                         async_answer_0(callid, ENOENT);
     1108                        ipc_answer_0(callid, ENOENT);
    11201109                }
    11211110        }
     
    11411130        default:
    11421131                /* No such interface */
    1143                 async_answer_0(iid, ENOENT);
     1132                ipc_answer_0(iid, ENOENT);
    11441133        }
    11451134}
     
    11611150       
    11621151        /* Register device mapper at naming service */
    1163         if (service_register(SERVICE_DEVMAP) != EOK)
     1152        sysarg_t phonead;
     1153        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0)
    11641154                return -1;
    11651155       
Note: See TracChangeset for help on using the changeset viewer.