Changeset b2d06fa in mainline for uspace/srv/devmap/devmap.c


Ignore:
Timestamp:
2010-12-25T17:14:36Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
092e4f1
Parents:
59e9398b (diff), 3ac66f69 (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/devmap/devmap.c

    r59e9398b rb2d06fa  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
     48#include <assert.h>
    4849
    4950#define NAME          "devmap"
     
    99100        /** Device driver handling this device */
    100101        devmap_driver_t *driver;
     102        /** Use this interface when forwarding to driver. */
     103        sysarg_t forward_interface;
    101104} devmap_device_t;
    102105
     
    206209}
    207210
    208 /** Find namespace with given name.
    209  *
    210  * The devices_list_mutex should be already held when
    211  * calling this function.
    212  *
    213  */
     211/** Find namespace with given name. */
    214212static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    215213{
    216214        link_t *item;
     215       
     216        assert(fibril_mutex_is_locked(&devices_list_mutex));
     217       
    217218        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    218219                devmap_namespace_t *namespace =
     
    227228/** Find namespace with given handle.
    228229 *
    229  * The devices_list_mutex should be already held when
    230  * calling this function.
    231  *
    232230 * @todo: use hash table
    233231 *
     
    236234{
    237235        link_t *item;
     236       
     237        assert(fibril_mutex_is_locked(&devices_list_mutex));
     238       
    238239        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    239240                devmap_namespace_t *namespace =
     
    246247}
    247248
    248 /** Find device with given name.
    249  *
    250  * The devices_list_mutex should be already held when
    251  * calling this function.
    252  *
    253  */
     249/** Find device with given name. */
    254250static devmap_device_t *devmap_device_find_name(const char *ns_name,
    255251    const char *name)
    256252{
    257253        link_t *item;
     254       
     255        assert(fibril_mutex_is_locked(&devices_list_mutex));
     256       
    258257        for (item = devices_list.next; item != &devices_list; item = item->next) {
    259258                devmap_device_t *device =
     
    269268/** Find device with given handle.
    270269 *
    271  * The devices_list_mutex should be already held when
    272  * calling this function.
    273  *
    274270 * @todo: use hash table
    275271 *
     
    278274{
    279275        link_t *item;
     276       
     277        assert(fibril_mutex_is_locked(&devices_list_mutex));
     278       
    280279        for (item = devices_list.next; item != &devices_list; item = item->next) {
    281280                devmap_device_t *device =
     
    288287}
    289288
    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  */
     289/** Create a namespace (if not already present). */
    296290static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    297291{
    298         devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
     292        devmap_namespace_t *namespace;
     293       
     294        assert(fibril_mutex_is_locked(&devices_list_mutex));
     295       
     296        namespace = devmap_namespace_find_name(ns_name);
    299297        if (namespace != NULL)
    300298                return namespace;
     
    321319}
    322320
    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  */
     321/** Destroy a namespace (if it is no longer needed). */
    329322static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    330323{
     324        assert(fibril_mutex_is_locked(&devices_list_mutex));
     325
    331326        if (namespace->refcnt == 0) {
    332327                list_remove(&(namespace->namespaces));
     
    337332}
    338333
    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  */
     334/** Increase namespace reference count by including device. */
    345335static void devmap_namespace_addref(devmap_namespace_t *namespace,
    346336    devmap_device_t *device)
    347337{
     338        assert(fibril_mutex_is_locked(&devices_list_mutex));
     339
    348340        device->namespace = namespace;
    349341        namespace->refcnt++;
    350342}
    351343
    352 /** Decrease namespace reference count
    353  *
    354  * The devices_list_mutex should be already held when
    355  * calling this function.
    356  *
    357  */
     344/** Decrease namespace reference count. */
    358345static void devmap_namespace_delref(devmap_namespace_t *namespace)
    359346{
     347        assert(fibril_mutex_is_locked(&devices_list_mutex));
     348
    360349        namespace->refcnt--;
    361350        devmap_namespace_destroy(namespace);
    362351}
    363352
    364 /** Unregister device and free it
    365  *
    366  * The devices_list_mutex should be already held when
    367  * calling this function.
    368  *
    369  */
     353/** Unregister device and free it. */
    370354static void devmap_device_unregister_core(devmap_device_t *device)
    371355{
     356        assert(fibril_mutex_is_locked(&devices_list_mutex));
     357
    372358        devmap_namespace_delref(device->namespace);
    373359        list_remove(&(device->devices));
     
    517503        }
    518504       
     505        /* Set the interface, if any. */
     506        device->forward_interface = IPC_GET_ARG1(*icall);
     507
    519508        /* Get fqdn */
    520509        char *fqdn;
     
    566555        /* Get unique device handle */
    567556        device->handle = devmap_create_handle();
    568        
     557
    569558        devmap_namespace_addref(namespace, device);
    570559        device->driver = driver;
     
    617606        }
    618607       
    619         ipc_forward_fast(callid, dev->driver->phone, dev->handle,
    620             IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
     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        }
    621617       
    622618        fibril_mutex_unlock(&devices_list_mutex);
Note: See TracChangeset for help on using the changeset viewer.