Exemplo n.º 1
0
void nOS_SwitchContext(void)
{
    SAVE_CONTEXT();
    nOS_runningThread = nOS_highPrioThread;
    RESTORE_CONTEXT();
    asm volatile ("ret");
}
Exemplo n.º 2
0
void
segv_handler(HANDLER_ARGS)
{
    os_context_t *os_context = (os_context_t *) context;
    
    caddr_t addr = code->si_addr;

    SAVE_CONTEXT();

#ifdef RED_ZONE_HIT
    if (os_control_stack_overflow(addr, context))
	return;
#endif

    if (gc_write_barrier(code->si_addr))
	 return;

    /*
     * Could be a C stack overflow.  Let's check
     */

    {
	struct rlimit rlimit;

	if (getrlimit(RLIMIT_STACK, &rlimit) == 0) {
	    /* The stack top here is based on the notes in sparc-validate.h */
	    char *stack_top = (char *) 0xffbf0000;
	    char *stack_bottom;

	    stack_bottom = stack_top - rlimit.rlim_cur;

	    /*
	     * Add a fudge factor.  Don't know why, but we get the signal
	     * sometime after the bottom of the stack, as computed above,
	     * has been reached.  (It seems to be 8K, so we use something
	     * larger.)
	     */

	    stack_bottom -= 16384;

	    if ((stack_bottom <= addr) && (addr <= stack_top)) {
		fprintf(stderr,
			"\nsegv_handler:  C stack overflow.  Try increasing stack limit (%ld).\n",
			rlimit.rlim_cur);

		segv_handle_now(signal, code, context);
	    }
	} else {
	    perror("getrlimit");
	}
    }

    /* a *real* protection fault */
    fprintf(stderr, "segv_handler: Real protection violation: %p, PC = %p\n",
            addr,
            os_context->uc_mcontext.gregs[1]);
    real_segv_handler(signal, code, context);
}
void port_reschedule(void)
{
    SAVE_CONTEXT();
    log_line(running_task->name);
    log_string(" --> ");
    reschedule();
    timer_tick = RR_TIMEOUT_MS;
    log_string(running_task->name);
    RESTORE_CONTEXT();
    /* The RETI instruction enables interrupts. */
    __asm__ __volatile__ ("reti \n\t");
}
ISR(TIMER0_COMP_vect, ISR_NAKED) {
    SAVE_CONTEXT();
    /* Decide if a task change shall occur. We know that
    running_task is in the ready list. */
    if (0 == timer_tick) {
        list_remove_node((Node *) running_task);
        list_enqueue(&ready_tasks, (Node *) running_task);
        reschedule();
        timer_tick = RR_TIMEOUT_MS;
    } else {
        timer_tick--;
    }
    RESTORE_CONTEXT();
    __asm__ __volatile__ ("reti \n\t");
}
Exemplo n.º 5
0
void
segv_handler(HANDLER_ARGS)
{
    caddr_t addr = code->si_addr;

    SAVE_CONTEXT();

#ifdef RED_ZONE_HIT
    if (os_control_stack_overflow(addr, context))
	return;
#endif

    if (!interrupt_maybe_gc(signal, code, context)) {
	/* a *real* protection fault */
	fprintf(stderr, "segv_handler: Real protection violation: 0x%08x\n",
		addr);
	interrupt_handle_now(signal, code, context);
    }
}
Exemplo n.º 6
0
void p_pos_softContextSwitch(void) {
        SAVE_CONTEXT();
        posCurrentTask_g->stackptr = (void*)SP;

        asm volatile("jmp    p_pos_intContextSwitch");
}