diff --git a/arch/avr/src/avr/up_initialstate.c b/arch/avr/src/avr/up_initialstate.c index 6780866a9e8..5c63f239e00 100644 --- a/arch/avr/src/avr/up_initialstate.c +++ b/arch/avr/src/avr/up_initialstate.c @@ -85,12 +85,12 @@ void up_initial_state(struct tcb_s *tcb) /* Save the task entry point */ #if !defined(REG_PC2) - xcp->regs[REG_PC0] = (uint8_t)((uint16_t)tcb->start >> 8); - xcp->regs[REG_PC1] = (uint8_t)((uint16_t)tcb->start & 0xff); + xcp->regs[REG_PC0] = (uint8_t)((uintptr_t)tcb->start >> 8); + xcp->regs[REG_PC1] = (uint8_t)((uintptr_t)tcb->start & 0xff); #else - xcp->regs[REG_PC0] = (uint8_t)((uint32_t)tcb->start >> 16); - xcp->regs[REG_PC1] = (uint8_t)((uint32_t)tcb->start >> 8); - xcp->regs[REG_PC2] = (uint8_t)((uint32_t)tcb->start & 0xff); + xcp->regs[REG_PC0] = (uint8_t)((uint32_t)(uintptr_t)tcb->start >> 16); + xcp->regs[REG_PC1] = (uint8_t)((uintptr_t)tcb->start >> 8); + xcp->regs[REG_PC2] = (uint8_t)((uintptr_t)tcb->start & 0xff); #endif /* Enable or disable interrupts, based on user configuration */ diff --git a/arch/avr/src/avr/up_schedulesigaction.c b/arch/avr/src/avr/up_schedulesigaction.c index 955606d7822..f0d4f45ab36 100644 --- a/arch/avr/src/avr/up_schedulesigaction.c +++ b/arch/avr/src/avr/up_schedulesigaction.c @@ -91,6 +91,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) { irqstate_t flags; + uintptr_t reg_ptr = (uintptr_t)up_sigdeliver; sinfo("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver); @@ -136,9 +137,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) else { - /* Save registers that must be protected while the signal handler - * runs. These will be restored by the signal trampoline after - * the signal(s) have been delivered. + /* Save registers that must be protected while the signal + * handler runs. These will be restored by the signal + * trampoline after the signal(s) have been delivered. */ tcb->xcp.sigdeliver = sigdeliver; @@ -152,13 +153,14 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Then set up to vector to the trampoline with interrupts * disabled */ + #if !defined(REG_PC2) - g_current_regs[REG_PC0] = (uint16_t)up_sigdeliver >> 8; - g_current_regs[REG_PC1] = (uint16_t)up_sigdeliver & 0xff; + g_current_regs[REG_PC0] = (uint16_t)reg_ptr >> 8; + g_current_regs[REG_PC1] = (uint16_t)reg_ptr & 0xff; #else - g_current_regs[REG_PC0] = (uint32_t)up_sigdeliver >> 16; - g_current_regs[REG_PC1] = (uint32_t)up_sigdeliver >> 8; - g_current_regs[REG_PC2] = (uint32_t)up_sigdeliver & 0xff; + g_current_regs[REG_PC0] = (uint32_t)reg_ptr >> 16; + g_current_regs[REG_PC1] = (uint32_t)reg_ptr >> 8; + g_current_regs[REG_PC2] = (uint32_t)reg_ptr & 0xff; #endif g_current_regs[REG_SREG] &= ~(1 << SREG_I); @@ -196,12 +198,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) */ #if !defined(REG_PC2) - tcb->xcp.regs[REG_PC0] = (uint16_t)up_sigdeliver >> 8; - tcb->xcp.regs[REG_PC1] = (uint16_t)up_sigdeliver & 0xff; + tcb->xcp.regs[REG_PC0] = (uint16_t)reg_ptr >> 8; + tcb->xcp.regs[REG_PC1] = (uint16_t)reg_ptr & 0xff; #else - tcb->xcp.regs[REG_PC0] = (uint32_t)up_sigdeliver >> 16; - tcb->xcp.regs[REG_PC1] = (uint32_t)up_sigdeliver >> 8; - tcb->xcp.regs[REG_PC2] = (uint32_t)up_sigdeliver & 0xff; + tcb->xcp.regs[REG_PC0] = (uint32_t)reg_ptr >> 16; + tcb->xcp.regs[REG_PC1] = (uint32_t)reg_ptr >> 8; + tcb->xcp.regs[REG_PC2] = (uint32_t)reg_ptr & 0xff; #endif tcb->xcp.regs[REG_SREG] &= ~(1 << SREG_I); diff --git a/arch/avr/src/common/up_internal.h b/arch/avr/src/common/up_internal.h index ae89d5457c4..c8538152c7e 100644 --- a/arch/avr/src/common/up_internal.h +++ b/arch/avr/src/common/up_internal.h @@ -89,14 +89,14 @@ typedef void (*up_vector_t)(void); extern void g_intstackbase; #endif -/* These 'addresses' of these values are setup by the linker script. They are - * not actual uint32_t storage locations! They are only used meaningfully in the - * following way: +/* These 'addresses' of these values are setup by the linker script. They + * are not actual uint32_t storage locations! They are only used meaningfully + * in the following way: * * - The linker script defines, for example, the symbol_sdata. * - The declareion extern uint32_t _sdata; makes C happy. C will believe - * that the value _sdata is the address of a uint32_t variable _data (it is - * not!). + * that the value _sdata is the address of a uint32_t variable _data + * (it is not!). * - We can recoved the linker value then by simply taking the address of * of _data. like: uint32_t *pdata = &_sdata; */ @@ -116,7 +116,7 @@ extern uint32_t _ebss; /* End+1 of .bss */ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ #ifndef __ASSEMBLY__ @@ -150,11 +150,8 @@ void up_lowinit(void); /* Defined in chip/xxx_serial.c */ -#ifdef USE_EARLYSERIALINIT +#ifdef CONFIG_DEV_CONSOLE void up_earlyserialinit(void); -#endif - -#ifdef USE_SERIALDRIVER void up_serialinit(void); #endif