arch/risc-v: Fix interrupt stack alignment
This commit is contained in:
parent
f8a36f10c3
commit
e0da0bf6bd
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user