Ignore:
File:
1 edited

Legend:

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

    r01b87dc5 r991f645  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
    48 #include <assert.h>
    4948
    5049#define NAME          "devmap"
     
    6261        link_t devices;
    6362        /** Phone asociated with this driver */
    64         sysarg_t phone;
     63        ipcarg_t phone;
    6564        /** Device driver name */
    6665        char *name;
     
    10099        /** Device driver handling this device */
    101100        devmap_driver_t *driver;
    102         /** Use this interface when forwarding to driver. */
    103         sysarg_t forward_interface;
    104101} devmap_device_t;
    105102
     
    209206}
    210207
    211 /** Find namespace with given name. */
     208/** Find namespace with given name.
     209 *
     210 * The devices_list_mutex should be already held when
     211 * calling this function.
     212 *
     213 */
    212214static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    213215{
    214216        link_t *item;
    215        
    216         assert(fibril_mutex_is_locked(&devices_list_mutex));
    217        
    218217        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    219218                devmap_namespace_t *namespace =
     
    228227/** Find namespace with given handle.
    229228 *
     229 * The devices_list_mutex should be already held when
     230 * calling this function.
     231 *
    230232 * @todo: use hash table
    231233 *
     
    234236{
    235237        link_t *item;
    236        
    237         assert(fibril_mutex_is_locked(&devices_list_mutex));
    238        
    239238        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    240239                devmap_namespace_t *namespace =
     
    247246}
    248247
    249 /** Find device with given name. */
     248/** Find device with given name.
     249 *
     250 * The devices_list_mutex should be already held when
     251 * calling this function.
     252 *
     253 */
    250254static devmap_device_t *devmap_device_find_name(const char *ns_name,
    251255    const char *name)
    252256{
    253257        link_t *item;
    254        
    255         assert(fibril_mutex_is_locked(&devices_list_mutex));
    256        
    257258        for (item = devices_list.next; item != &devices_list; item = item->next) {
    258259                devmap_device_t *device =
     
    268269/** Find device with given handle.
    269270 *
     271 * The devices_list_mutex should be already held when
     272 * calling this function.
     273 *
    270274 * @todo: use hash table
    271275 *
     
    274278{
    275279        link_t *item;
    276        
    277         assert(fibril_mutex_is_locked(&devices_list_mutex));
    278        
    279280        for (item = devices_list.next; item != &devices_list; item = item->next) {
    280281                devmap_device_t *device =
     
    287288}
    288289
    289 /** Create a namespace (if not already present). */
     290/** Create a namespace (if not already present)
     291 *
     292 * The devices_list_mutex should be already held when
     293 * calling this function.
     294 *
     295 */
    290296static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    291297{
    292         devmap_namespace_t *namespace;
    293        
    294         assert(fibril_mutex_is_locked(&devices_list_mutex));
    295        
    296         namespace = devmap_namespace_find_name(ns_name);
     298        devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
    297299        if (namespace != NULL)
    298300                return namespace;
     
    319321}
    320322
    321 /** Destroy a namespace (if it is no longer needed). */
     323/** Destroy a namespace (if it is no longer needed)
     324 *
     325 * The devices_list_mutex should be already held when
     326 * calling this function.
     327 *
     328 */
    322329static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    323330{
    324         assert(fibril_mutex_is_locked(&devices_list_mutex));
    325 
    326331        if (namespace->refcnt == 0) {
    327332                list_remove(&(namespace->namespaces));
     
    332337}
    333338
    334 /** Increase namespace reference count by including device. */
     339/** Increase namespace reference count by including device
     340 *
     341 * The devices_list_mutex should be already held when
     342 * calling this function.
     343 *
     344 */
    335345static void devmap_namespace_addref(devmap_namespace_t *namespace,
    336346    devmap_device_t *device)
    337347{
    338         assert(fibril_mutex_is_locked(&devices_list_mutex));
    339 
    340348        device->namespace = namespace;
    341349        namespace->refcnt++;
    342350}
    343351
    344 /** Decrease namespace reference count. */
     352/** Decrease namespace reference count
     353 *
     354 * The devices_list_mutex should be already held when
     355 * calling this function.
     356 *
     357 */
    345358static void devmap_namespace_delref(devmap_namespace_t *namespace)
    346359{
    347         assert(fibril_mutex_is_locked(&devices_list_mutex));
    348 
    349360        namespace->refcnt--;
    350361        devmap_namespace_destroy(namespace);
    351362}
    352363
    353 /** Unregister device and free it. */
     364/** Unregister device and free it
     365 *
     366 * The devices_list_mutex should be already held when
     367 * calling this function.
     368 *
     369 */
    354370static void devmap_device_unregister_core(devmap_device_t *device)
    355371{
    356         assert(fibril_mutex_is_locked(&devices_list_mutex));
    357 
    358372        devmap_namespace_delref(device->namespace);
    359373        list_remove(&(device->devices));
     
    373387        ipc_callid_t iid = async_get_call(&icall);
    374388       
    375         if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
     389        if (IPC_GET_METHOD(icall) != DEVMAP_DRIVER_REGISTER) {
    376390                ipc_answer_0(iid, EREFUSED);
    377391                return NULL;
     
    402416        ipc_callid_t callid = async_get_call(&call);
    403417       
    404         if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     418        if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
    405419                free(driver->name);
    406420                free(driver);
     
    503517        }
    504518       
    505         /* Set the interface, if any. */
    506         device->forward_interface = IPC_GET_ARG1(*icall);
    507 
    508519        /* Get fqdn */
    509520        char *fqdn;
     
    544555        if (devmap_device_find_name(namespace->name, device->name) != NULL) {
    545556                printf("%s: Device '%s/%s' already registered\n", NAME,
    546                     device->namespace->name, device->name);
     557                    device->namespace, device->name);
    547558                devmap_namespace_destroy(namespace);
    548559                fibril_mutex_unlock(&devices_list_mutex);
     
    555566        /* Get unique device handle */
    556567        device->handle = devmap_create_handle();
    557 
     568       
    558569        devmap_namespace_addref(namespace, device);
    559570        device->driver = driver;
     
    606617        }
    607618       
    608         if (dev->forward_interface == 0) {
    609                 ipc_forward_fast(callid, dev->driver->phone,
    610                     dev->handle, 0, 0,
    611                     IPC_FF_NONE);
    612         } else {
    613                 ipc_forward_fast(callid, dev->driver->phone,
    614                     dev->forward_interface, dev->handle, 0,
    615                     IPC_FF_NONE);
    616         }
     619        ipc_forward_fast(callid, dev->driver->phone, dev->handle,
     620            IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
    617621       
    618622        fibril_mutex_unlock(&devices_list_mutex);
     
    819823        }
    820824       
    821         sysarg_t retval = async_data_read_finalize(callid, desc, size);
     825        ipcarg_t retval = async_data_read_finalize(callid, desc, size);
    822826       
    823827        free(desc);
     
    886890        }
    887891       
    888         sysarg_t retval = async_data_read_finalize(callid, desc, size);
     892        ipcarg_t retval = async_data_read_finalize(callid, desc, size);
    889893       
    890894        free(desc);
     
    960964        fibril_mutex_unlock(&null_devices_mutex);
    961965       
    962         ipc_answer_1(iid, EOK, (sysarg_t) i);
     966        ipc_answer_1(iid, EOK, (ipcarg_t) i);
    963967}
    964968
    965969static void devmap_null_destroy(ipc_callid_t iid, ipc_call_t *icall)
    966970{
    967         sysarg_t i = IPC_GET_ARG1(*icall);
     971        ipcarg_t i = IPC_GET_ARG1(*icall);
    968972        if (i >= NULL_DEVICES) {
    969973                ipc_answer_0(iid, ELIMIT);
     
    10231027                ipc_callid_t callid = async_get_call(&call);
    10241028               
    1025                 switch (IPC_GET_IMETHOD(call)) {
     1029                switch (IPC_GET_METHOD(call)) {
    10261030                case IPC_M_PHONE_HUNGUP:
    10271031                        cont = false;
     
    10481052                        break;
    10491053                default:
    1050                         ipc_answer_0(callid, ENOENT);
     1054                        if (!(callid & IPC_CALLID_NOTIFICATION))
     1055                                ipc_answer_0(callid, ENOENT);
    10511056                }
    10521057        }
     
    10741079                ipc_callid_t callid = async_get_call(&call);
    10751080               
    1076                 switch (IPC_GET_IMETHOD(call)) {
     1081                switch (IPC_GET_METHOD(call)) {
    10771082                case IPC_M_PHONE_HUNGUP:
    10781083                        cont = false;
     
    11061111                        break;
    11071112                default:
    1108                         ipc_answer_0(callid, ENOENT);
     1113                        if (!(callid & IPC_CALLID_NOTIFICATION))
     1114                                ipc_answer_0(callid, ENOENT);
    11091115                }
    11101116        }
     
    11171123{
    11181124        /* Select interface */
    1119         switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
     1125        switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
    11201126        case DEVMAP_DRIVER:
    11211127                devmap_connection_driver(iid, icall);
     
    11501156       
    11511157        /* Register device mapper at naming service */
    1152         sysarg_t phonead;
     1158        ipcarg_t phonead;
    11531159        if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0)
    11541160                return -1;
Note: See TracChangeset for help on using the changeset viewer.