next up previous contents
Next: rtker's Device Driver Framework Up: Rtker's Device Driver Framework Previous: Rtker's Device Driver Framework   Contents

OSki't Device Driver Framework

Oskit's Device Driver Framework was designed, keeping in mind easy portability of already existing device drivers.

For this they have defined the notion of a glue code. A glue code is a piece of code for mapping the device driver framework of an existing Operating System like Linux to the OSkit's Device Driver Framework. I have illustrated the idea with the help of an example. Please refer to OSkit's documentation for a detailed description of this.

Consider the problem of Process Sysnchronization. Nearly all Device Drivers require functions to make a process sleep or wake up a process. Linux Device Driver Framework has functions like sleep_on, wake_up, for sleeping/waking up processes. In the OSkit's Device Driver, functions like osenv_sleep and osenv_wakeup have been defined for process synchronization.

Hence to port a Linux device driver to OSkit, one has to change all occurences of sleep_on to osenv_sleep, with appropriate parameter changes. This process requires a lot of work, particularly for complex device drivers.

The other option is to write a glue code that will map all Linux Device Driver fucntion calls to the appropriate OSkit calls, with appropriate parameters. With this glue code, any linux device driver can be easily ported to OSkit. Not only that, by defining glue codes for other OS's like freebsd, one can get their device drivers ported to OSkit.

The following glue code for mapping linux sleep_on to OSkit's osenv_sleep_on, illustrates the idea.

static void
__sleep_on(struct wait_queue **q, int interruptible)
{
        struct task_struct *cur = current;
        struct wait_queue wait = { cur, NULL };

        if (!q)
                return;

        osenv_sleep_init(&cur->sleeprec);
        add_wait_queue(q, &wait);

        osenv_sleep(&cur->sleeprec);
        current = cur;

        remove_wait_queue(q, &wait);
        current = cur;
}


void
sleep_on(struct wait_queue **q)
{
        __sleep_on(q, 0);
}


next up previous contents
Next: rtker's Device Driver Framework Up: Rtker's Device Driver Framework Previous: Rtker's Device Driver Framework   Contents
Soumyadeb Mitra 2002-08-07