AVR: Fix warnings from pointer casts and prototype

There was broken logic around serial initialization function
prototype.  Pointers were also being cast directly to uint32
without first being cast to uintptr.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
This commit is contained in:
Brennan Ashton 2020-07-19 16:06:19 +00:00 committed by Alan Carvalho de Assis
parent 871613f271
commit ff6e2e7b7d
3 changed files with 27 additions and 28 deletions

View File

@ -85,12 +85,12 @@ void up_initial_state(struct tcb_s *tcb)
/* Save the task entry point */ /* Save the task entry point */
#if !defined(REG_PC2) #if !defined(REG_PC2)
xcp->regs[REG_PC0] = (uint8_t)((uint16_t)tcb->start >> 8); xcp->regs[REG_PC0] = (uint8_t)((uintptr_t)tcb->start >> 8);
xcp->regs[REG_PC1] = (uint8_t)((uint16_t)tcb->start & 0xff); xcp->regs[REG_PC1] = (uint8_t)((uintptr_t)tcb->start & 0xff);
#else #else
xcp->regs[REG_PC0] = (uint8_t)((uint32_t)tcb->start >> 16); xcp->regs[REG_PC0] = (uint8_t)((uint32_t)(uintptr_t)tcb->start >> 16);
xcp->regs[REG_PC1] = (uint8_t)((uint32_t)tcb->start >> 8); xcp->regs[REG_PC1] = (uint8_t)((uintptr_t)tcb->start >> 8);
xcp->regs[REG_PC2] = (uint8_t)((uint32_t)tcb->start & 0xff); xcp->regs[REG_PC2] = (uint8_t)((uintptr_t)tcb->start & 0xff);
#endif #endif
/* Enable or disable interrupts, based on user configuration */ /* Enable or disable interrupts, based on user configuration */

View File

@ -91,6 +91,7 @@
void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
{ {
irqstate_t flags; irqstate_t flags;
uintptr_t reg_ptr = (uintptr_t)up_sigdeliver;
sinfo("tcb=0x%p sigdeliver=0x%p\n", tcb, 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 else
{ {
/* Save registers that must be protected while the signal handler /* Save registers that must be protected while the signal
* runs. These will be restored by the signal trampoline after * handler runs. These will be restored by the signal
* the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver; 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 /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
*/ */
#if !defined(REG_PC2) #if !defined(REG_PC2)
g_current_regs[REG_PC0] = (uint16_t)up_sigdeliver >> 8; g_current_regs[REG_PC0] = (uint16_t)reg_ptr >> 8;
g_current_regs[REG_PC1] = (uint16_t)up_sigdeliver & 0xff; g_current_regs[REG_PC1] = (uint16_t)reg_ptr & 0xff;
#else #else
g_current_regs[REG_PC0] = (uint32_t)up_sigdeliver >> 16; g_current_regs[REG_PC0] = (uint32_t)reg_ptr >> 16;
g_current_regs[REG_PC1] = (uint32_t)up_sigdeliver >> 8; g_current_regs[REG_PC1] = (uint32_t)reg_ptr >> 8;
g_current_regs[REG_PC2] = (uint32_t)up_sigdeliver & 0xff; g_current_regs[REG_PC2] = (uint32_t)reg_ptr & 0xff;
#endif #endif
g_current_regs[REG_SREG] &= ~(1 << SREG_I); 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) #if !defined(REG_PC2)
tcb->xcp.regs[REG_PC0] = (uint16_t)up_sigdeliver >> 8; tcb->xcp.regs[REG_PC0] = (uint16_t)reg_ptr >> 8;
tcb->xcp.regs[REG_PC1] = (uint16_t)up_sigdeliver & 0xff; tcb->xcp.regs[REG_PC1] = (uint16_t)reg_ptr & 0xff;
#else #else
tcb->xcp.regs[REG_PC0] = (uint32_t)up_sigdeliver >> 16; tcb->xcp.regs[REG_PC0] = (uint32_t)reg_ptr >> 16;
tcb->xcp.regs[REG_PC1] = (uint32_t)up_sigdeliver >> 8; tcb->xcp.regs[REG_PC1] = (uint32_t)reg_ptr >> 8;
tcb->xcp.regs[REG_PC2] = (uint32_t)up_sigdeliver & 0xff; tcb->xcp.regs[REG_PC2] = (uint32_t)reg_ptr & 0xff;
#endif #endif
tcb->xcp.regs[REG_SREG] &= ~(1 << SREG_I); tcb->xcp.regs[REG_SREG] &= ~(1 << SREG_I);

View File

@ -89,14 +89,14 @@ typedef void (*up_vector_t)(void);
extern void g_intstackbase; extern void g_intstackbase;
#endif #endif
/* These 'addresses' of these values are setup by the linker script. They are /* These 'addresses' of these values are setup by the linker script. They
* not actual uint32_t storage locations! They are only used meaningfully in the * are not actual uint32_t storage locations! They are only used meaningfully
* following way: * in the following way:
* *
* - The linker script defines, for example, the symbol_sdata. * - The linker script defines, for example, the symbol_sdata.
* - The declareion extern uint32_t _sdata; makes C happy. C will believe * - 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 * that the value _sdata is the address of a uint32_t variable _data
* not!). * (it is not!).
* - We can recoved the linker value then by simply taking the address of * - We can recoved the linker value then by simply taking the address of
* of _data. like: uint32_t *pdata = &_sdata; * 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__ #ifndef __ASSEMBLY__
@ -150,11 +150,8 @@ void up_lowinit(void);
/* Defined in chip/xxx_serial.c */ /* Defined in chip/xxx_serial.c */
#ifdef USE_EARLYSERIALINIT #ifdef CONFIG_DEV_CONSOLE
void up_earlyserialinit(void); void up_earlyserialinit(void);
#endif
#ifdef USE_SERIALDRIVER
void up_serialinit(void); void up_serialinit(void);
#endif #endif