void up_initial_state(_TCB *tcb) { struct xcptcontext *xcp = &tcb->xcp; /* Initialize the initial exception register context structure. Zeroing * all registers is a good debug helper, but should not be necessary. */ memset(xcp, 0, sizeof(struct xcptcontext)); /* Set the initial stack pointer to the "base" of the allocated stack */ xcp->regs[REG_SPH] = (uint8_t)((uint16_t)tcb->adj_stack_ptr >> 8); xcp->regs[REG_SPL] = (uint8_t)((uint16_t)tcb->adj_stack_ptr & 0xff); /* Save the task entry point */ xcp->regs[REG_PCH] = (uint8_t)((uint16_t)tcb->start >> 8); xcp->regs[REG_PCL] = (uint8_t)((uint16_t)tcb->start & 0xff); /* Enable or disable interrupts, based on user configuration */ #ifdef CONFIG_SUPPRESS_INTERRUPTS xcp->regs[REG_SREG] = getsreg() & ~(1 << SREG_I); #else xcp->regs[REG_SREG] = getsreg() | (1 << SREG_I); #endif }
void up_irqinitialize(void) { /* currents_regs is non-NULL only while processing an interrupt */ g_current_regs = NULL; /* Initialize GPIO interrupt facilities */ #ifdef CONFIG_AVR32_GPIOIRQ #ifdef CONFIG_HAVE_WEAKFUNCTIONS if (gpio_irqinitialize != NULL) #endif { gpio_irqinitialize(); } #endif /* And finally, enable interrupts */ #ifndef CONFIG_SUPPRESS_INTERRUPTS up_irq_restore(getsreg() | (1 << SREG_I)); #endif }