void NORETURN __enter_thread_mode(void)
{
    irq_enable();
    __context_restore();
    __asm__ volatile("ret");

    UNREACHABLE();
}
Ejemplo n.º 2
0
int __init main()
{
    /* keep the calling order below because of dependencies */
    sys_init();
    mm_init();
    fs_init();
    device_init();
    systick_init();
    scheduler_init();
    console_init();

    make_init_task();
    load_user_task(); /* that are registered statically */

    softirq_init();
#ifdef CONFIG_TIMER
    timer_init();
#endif

#ifndef DEFSTR
#define DEFMKSTR(x)	#x
#define DEFSTR(x)	DEFMKSTR(x)
#endif
    /* a banner */
    printk("yaos %s %s\n", DEFSTR(VERSION), DEFSTR(MACHINE));

    /* switch from boot stack memory to new one */
    set_user_sp(init.mm.sp);
    set_kernel_sp(init.mm.kernel.sp);

    /* everything ready now */
#ifndef ARMv7A
    sei();
#endif
    resched();

    /* it doesn't really reach up to this point. init task becomes idle as
     * its context is already set to idle */
    __context_restore(current);
    __ret_from_exc(0);
    freeze();

    return 0;
}
// Use this interrupt to perform all context switches
ISR(AVR_CONTEXT_SWAP_INTERRUPT_VECT, ISR_NAKED) {
    __context_save();
    sched_run();
    __context_restore();
    __asm__ volatile("reti");
}