next up previous contents
Next: Other Issues Up: Rtker's Device Driver Framework Previous: OSki't Device Driver Framework   Contents

rtker's Device Driver Framework

We have used the OSkit's Device Driver Framework for rtker. This means that we have provided implementation of all the functions of OSkit's Device Driver Framework. This includes functions like osenv_sleep() osenv_wakeup() and so on. Following is the implementation of osenv_sleep() and osenv_wakeup. These functions in turn call the rtker's functions for thread scnchronization.

void
osenv_sleep_init(osenv_sleeprec_t *sr) 
{
        osenv_assert(sr);

        sr->data[0] = OSENV_SLEEP_WAKEUP;   /* Return code for osenv_sleep() */
        sr->data[1] = sr;          /* Just a flag; anything non-null will do */
}

int
osenv_sleep(osenv_sleeprec_t *sr) 
{
  int i,j;
  volatile osenv_sleeprec_t *vsr = sr;
  /* Disable interrupts after saving old value */
  int was_enabled = osenv_intr_save_disable();
  osenv_assert(sr);
  if (vsr->data[0]==OSENV_SLEEP_INIT)
    {
      vsr->data[1]=thread_self();
      direct_cons_putchar('!');
      thread_suspend(vsr->data[1]);
    }

  if (was_enabled)
    osenv_intr_enable();
  
  return (int) vsr->data[0];
}

void
osenv_wakeup(osenv_sleeprec_t *sr, int wakeup_status) 
{
        osenv_assert(sr);
        sr->data[0] = (void *)wakeup_status;
        sr->data[1] = (void *)0;
}

Finally using the glue codes provided by OSkit, we can incorporate any Linux Device Driver into our RTOS without any change. We have used this framework to incorporate the ethernet device drivers from Linux to RTOS.



Soumyadeb Mitra 2002-08-07