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.