arch/risc-v: Fix interrupt stack alignment

This commit is contained in:
Gustavo Henrique Nihei 2021-04-29 14:50:30 -03:00 committed by Xiang Xiao
parent f8a36f10c3
commit e0da0bf6bd
16 changed files with 30 additions and 30 deletions

View File

@ -85,7 +85,7 @@ exception_common:
mv a1, sp /* context = sp */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
/* Switch to interrupt stack */
lui sp, %hi(g_intstacktop)

View File

@ -78,10 +78,10 @@ void up_irqinitialize(void)
up_irq_save();
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
/* Colorize the interrupt stack for debug purposes */
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
riscv_stack_color((FAR void *)&g_intstackalloc, intstack_size);
#endif

View File

@ -191,7 +191,7 @@ exception_common:
mv a1, sp /* context = sp */
#if CONFIG_ARCH_INTERRUPTSTACK > 7
#if CONFIG_ARCH_INTERRUPTSTACK > 15
/* Load mhartid (cpuid) */
csrr s0, mhartid
@ -203,7 +203,7 @@ exception_common:
j 4f
3:
la sp, g_intstacktop
addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~7)
addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~15)
4:
#endif

View File

@ -72,8 +72,8 @@ void up_irqinitialize(void)
/* Colorize the interrupt stack for debug purposes */
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7);
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
riscv_stack_color((FAR void *)&g_intstackalloc, intstack_size);
#endif

View File

@ -176,16 +176,16 @@ ssize_t up_check_stack_remain(void)
return up_check_tcbstack_remain(this_task());
}
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
size_t up_check_intstack(void)
{
return do_stackcheck((uintptr_t)&g_intstackalloc,
(CONFIG_ARCH_INTERRUPTSTACK & ~3));
(CONFIG_ARCH_INTERRUPTSTACK & ~15));
}
size_t up_check_intstack_remain(void)
{
return (CONFIG_ARCH_INTERRUPTSTACK & ~3) - up_check_intstack();
return (CONFIG_ARCH_INTERRUPTSTACK & ~15) - up_check_intstack();
}
#endif

View File

@ -53,13 +53,13 @@
*
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
static inline void up_color_intstack(void)
{
uint32_t *ptr = (uint32_t *)&g_intstackalloc;
ssize_t size;
for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
size > 0;
size -= sizeof(uint32_t))
{

View File

@ -113,7 +113,7 @@ EXTERN uint32_t g_idle_topstack;
/* Address of the saved user stack pointer */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
EXTERN uint32_t g_intstackalloc; /* Allocated stack base */
EXTERN uint32_t g_intstacktop; /* Initial top of interrupt stack */
#endif

View File

@ -115,7 +115,7 @@ _interrupt_handler:
csrr a0, mcause /* Handler arg0: Exception cause */
mv a1, sp /* Handler arg1: Context (saved registers on stack) */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
lui sp, %hi(g_intstacktop)
addi sp, sp, %lo(g_intstacktop)
#endif

View File

@ -139,7 +139,7 @@ exception_common:
mv a1, sp /* context = sp */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
/* Switch to interrupt stack */
lui sp, %hi(g_intstacktop)

View File

@ -59,8 +59,8 @@ void up_irqinitialize(void)
/* Colorize the interrupt stack for debug purposes */
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
riscv_stack_color((FAR void *)&g_intstackalloc, intstack_size);
#endif

View File

@ -170,7 +170,7 @@ normal_irq:
mv a1, sp /* context = sp */
#if CONFIG_ARCH_INTERRUPTSTACK > 7
#if CONFIG_ARCH_INTERRUPTSTACK > 15
/* Load mhartid (cpuid) */
csrr s0, mhartid
@ -182,7 +182,7 @@ normal_irq:
j 4f
3:
la sp, g_intstacktop
addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~7)
addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~15)
4:
#endif

View File

@ -80,8 +80,8 @@ void up_irqinitialize(void)
/* Colorize the interrupt stack for debug purposes */
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7);
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
riscv_stack_color((FAR void *)&g_intstackalloc, intstack_size);
#endif

View File

@ -126,7 +126,7 @@ exception_common:
mv a1, sp /* context = sp */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
/* Switch to interrupt stack */
lui sp, %hi(g_intstacktop)

View File

@ -58,8 +58,8 @@ void up_irqinitialize(void)
/* Colorize the interrupt stack for debug purposes */
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 15
size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
riscv_stack_color((FAR void *)&g_intstackalloc, intstack_size);
#endif

View File

@ -173,7 +173,7 @@ static void riscv_dumpstate(void)
uint32_t sp = riscv_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
uint32_t istackbase;
uint32_t istacksize;
#endif
@ -189,9 +189,9 @@ static void riscv_dumpstate(void)
/* Get the limits on the interrupt stack memory */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 15
istackbase = (uint32_t)&g_intstackalloc;
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
/* Show interrupt stack info */

View File

@ -184,7 +184,7 @@ static void up_dumpstate(void)
uint64_t sp = riscv_getsp();
uintptr_t ustackbase;
uintptr_t ustacksize;
#if CONFIG_ARCH_INTERRUPTSTACK > 7
#if CONFIG_ARCH_INTERRUPTSTACK > 15
uintptr_t istackbase;
uintptr_t istacksize;
#endif
@ -200,9 +200,9 @@ static void up_dumpstate(void)
/* Get the limits on the interrupt stack memory */
#if CONFIG_ARCH_INTERRUPTSTACK > 7
#if CONFIG_ARCH_INTERRUPTSTACK > 15
istackbase = (uintptr_t)&g_intstackalloc;
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~7);
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
/* Show interrupt stack info */