Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ae73a00
arch: cxd56xx: Introduce cxd56_cpuindex.h
masayuki2009 Oct 6, 2020
4cde353
arch: cxd56xx: Add interrupt stack for SMP
masayuki2009 Oct 6, 2020
36f5ce6
arch: imx6: Fix style warnings in chip.h
masayuki2009 Oct 19, 2020
fc3e7fe
arch: arm: Fix interrupt stack handlings for SMP
masayuki2009 Oct 19, 2020
78cefc6
boards: lc823450-xgevk: Update rndis/defconfig
masayuki2009 Oct 20, 2020
81880a6
boards: sabre-6quad: Update smp/defconfig
masayuki2009 Oct 20, 2020
7cb3593
arch: armv7-a: Fix style warnings in smp.h
masayuki2009 Oct 22, 2020
7663761
arch: armv7-a: Fix style warnings in arm_cpuidlestack.c
masayuki2009 Oct 23, 2020
56cccf5
arch: armv7-a: Fix CPUx IDLE stack top for SMP
masayuki2009 Oct 22, 2020
481dfc6
boards: sabre-6quad: Update nsh/defconfig
masayuki2009 Oct 22, 2020
07e6a6a
armv7-a, imx6: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
887b6e7
arm, c5471: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
a72873a
arch: armv7-r: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
617e765
boards: stm32f4discovery: Update wifi/defconfig
masayuki2009 Oct 22, 2020
aef92e3
armv7-m, cxd56xx, lc823450: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
f9653cc
arch: armv8-m: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
69f1ba0
arch: armv6-m: Refactor interrupt stack related code
masayuki2009 Oct 22, 2020
36d1437
arm: armv7-a: Fix kernel stack dump in arm_assert.c
masayuki2009 Oct 23, 2020
6598907
sched: irq: Fix enter_critical_section() in an irq handler for SMP
masayuki2009 Nov 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions arch/arm/src/arm/arm_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,30 @@ static void up_dumpstate(void)
* stack?
*/

if (sp <= istackbase && sp > istackbase - istacksize)
if (sp < istackbase && sp > istackbase - istacksize)
{
/* Yes.. dump the interrupt stack */

_alert("Interrupt Stack\n", sp);
up_stackdump(sp, istackbase);

/* Extract the user stack pointer which should lie
* at the base of the interrupt stack.
*/

sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}

/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
* pointer (and the above range check should have failed).
*/

if (CURRENT_REGS)
{
sp = CURRENT_REGS[REG_R13];
_alert("User sp: %08x\n", sp);
}

/* Show user stack info */

_alert("User stack:\n");
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/arm/arm_vectors.S
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ arm_vectorirq:

#if CONFIG_ARCH_INTERRUPTSTACK > 3
ldr sp, .Lirqstackbase /* SP = interrupt stack base */
str r0, [sp] /* Save the user stack pointer */
str r0, [sp, #-4]! /* Save the xcp address at SP-4 then update SP */
bl arm_decodeirq /* Call the handler */
ldr sp, [sp] /* Restore the user stack pointer */
#else
Expand Down Expand Up @@ -432,13 +432,13 @@ arm_vectorfiq:

#if CONFIG_ARCH_INTERRUPTSTACK > 3
.bss
.align 4
.balign 4
.globl g_intstackalloc
.type g_intstackalloc, object
.globl g_intstackbase
.type g_intstackbase, object
g_intstackalloc:
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4)
.skip (CONFIG_ARCH_INTERRUPTSTACK & ~3)
g_intstackbase:
.skip 4
.size g_intstackbase, 4
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/arm_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static void up_dumpstate(void)
* stack?
*/

if (sp <= istackbase && sp > istackbase - istacksize)
if (sp < istackbase && sp > istackbase - istacksize)
{
/* Yes.. dump the interrupt stack */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/arm_exception.S
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ exception_common:
.bss
.global g_intstackalloc
.global g_intstackbase
.align 4
.balign 4
g_intstackalloc:
.skip (CONFIG_ARCH_INTERRUPTSTACK & ~3)
g_intstackbase:
Expand Down
27 changes: 12 additions & 15 deletions arch/arm/src/armv7-a/arm_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void up_dumpstate(void)
if (rtcb->xcp.kstack)
{
kstackbase = (uint32_t)rtcb->xcp.kstack +
CONFIG_ARCH_KERNEL_STACKSIZE - 4;
CONFIG_ARCH_KERNEL_STACKSIZE;

_alert("Kernel stack:\n");
_alert(" base: %08x\n", kstackbase);
Expand All @@ -265,24 +265,10 @@ static void up_dumpstate(void)

if (sp > istackbase - istacksize && sp < istackbase)
{
uint32_t *stackbase;

/* Yes.. dump the interrupt stack */

_alert("Interrupt Stack\n", sp);
up_stackdump(sp, istackbase);

/* Extract the user stack pointer which should lie
* at the base of the interrupt stack.
*/

#ifdef CONFIG_SMP
stackbase = (uint32_t *)arm_intstack_base();
#else
stackbase = (uint32_t *)&g_intstackbase;
#endif
sp = *stackbase;
_alert("User sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
Expand All @@ -291,6 +277,17 @@ static void up_dumpstate(void)
}
#endif

/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
* pointer (and the above range check should have failed).
*/

if (CURRENT_REGS)
{
sp = CURRENT_REGS[REG_R13];
_alert("User sp: %08x\n", sp);
}

/* Dump the user stack if the stack pointer lies within the allocated user
* stack memory.
*/
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/src/armv7-a/arm_cpuidlestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size)

/* Get the top of the stack */


stack_alloc = (uintptr_t)g_cpu_stackalloc[cpu];
DEBUGASSERT(stack_alloc != 0 && STACK_ISALIGNED(stack_alloc));
top_of_stack = stack_alloc + SMP_STACK_TOP;
top_of_stack = stack_alloc + SMP_STACK_SIZE;

tcb->adj_stack_size = SMP_STACK_SIZE;
tcb->stack_alloc_ptr = (FAR uint32_t *)stack_alloc;
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/armv7-a/arm_vectors.S
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ arm_vectorirq:
/* Call arm_decodeirq() on the interrupt stack */

setirqstack r1, r3 /* SP = IRQ stack top */
str r0, [sp] /* Save the user stack pointer */
str r0, [sp, #-4]! /* Save the xcp address at SP-4 then update SP */
mov r4, sp /* Save the SP in a preserved register */
bic sp, sp, #7 /* Force 8-byte alignment */
bl arm_decodeirq /* Call the handler */
Expand Down Expand Up @@ -1004,7 +1004,7 @@ arm_vectorfiq:

#if CONFIG_ARCH_INTERRUPTSTACK > 7
setfiqstack r1, r4 /* SP = FIQ stack top */
str r0, [sp] /* Save the user stack pointer */
str r0, [sp, #-4]! /* Save the xcp address at SP-4 then update SP */
mov r4, sp /* Save the SP in a preserved register */
bic sp, sp, #7 /* Force 8-byte alignment */
bl arm_decodefiq /* Call the handler */
Expand Down Expand Up @@ -1072,15 +1072,15 @@ arm_vectorfiq:

#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7
.bss
.align 4
.balign 8

.globl g_intstackalloc
.type g_intstackalloc, object
.globl g_intstackbase
.type g_intstackbase, object

g_intstackalloc:
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~7) - 4)
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
.skip 4
.size g_intstackbase, 4
Expand All @@ -1096,7 +1096,7 @@ g_intstackbase:
.type g_fiqstackbase, object

g_fiqstackalloc:
.skip ((CONFIG_ARCH_INTERRUPTSTACK & ~7) - 4)
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_fiqstackbase:
.skip 4
.size g_fiqstackbase, 4
Expand Down
7 changes: 3 additions & 4 deletions arch/arm/src/armv7-a/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#define SMP_STACK_MASK 7
#define SMP_STACK_SIZE ((CONFIG_SMP_IDLETHREAD_STACKSIZE + 7) & ~7)
#define SMP_STACK_WORDS (SMP_STACK_SIZE >> 2)
#define SMP_STACK_TOP (SMP_STACK_SIZE - 8)

/****************************************************************************
* Public Data
Expand Down Expand Up @@ -122,9 +121,9 @@ void __cpu3_start(void);
*
* Description:
* Continues the C-level initialization started by the assembly language
* __cpu[n]_start function. At a minimum, this function needs to initialize
* interrupt handling and, perhaps, wait on WFI for arm_cpu_start() to
* issue an SGI.
* __cpu[n]_start function. At a minimum, this function needs to
* initialize interrupt handling and, perhaps, wait on WFI for
* arm_cpu_start() to issue an SGI.
*
* This function must be provided by the each ARMv7-A MCU and implement
* MCU-specific initialization logic.
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-m/arm_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void up_dumpstate(void)
* stack?
*/

if (sp <= istackbase && sp > istackbase - istacksize)
if (sp < istackbase && sp > istackbase - istacksize)
{
/* Yes.. dump the interrupt stack */

Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/armv7-m/gnu/arm_exception.S
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* no privileged task has run.
*/

# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 4
# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif

Expand Down Expand Up @@ -197,7 +197,7 @@ exception_common:
* here prohibits nested interrupts without some additional logic!
*/

setintstack r2, r3
setintstack r2, r3 /* SP = IRQ stack top */

#else
/* Otherwise, we will re-use the interrupted thread's stack. That may
Expand Down Expand Up @@ -321,7 +321,7 @@ exception_common:
.bss
.global g_intstackalloc
.global g_intstackbase
.align 8
.balign 8
g_intstackalloc:
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/armv7-m/gnu/arm_lazyexception.S
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* nested interrupt, the interrupt stack if no privileged task has run.
*/

# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 4
# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8
# error Interrupt stack must be used with high priority interrupts in kernel mode
# endif

Expand Down Expand Up @@ -192,7 +192,7 @@ exception_common:
* here prohibits nested interrupts without some additional logic!
*/

setintstack r2, r3
setintstack r2, r3 /* SP = IRQ stack top */

#else
/* Otherwise, we will re-use the interrupted thread's stack. That may
Expand Down Expand Up @@ -340,7 +340,7 @@ exception_common:
.bss
.global g_intstackalloc
.global g_intstackbase
.align 8
.balign 8
g_intstackalloc:
.skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7)
g_intstackbase:
Expand Down
26 changes: 15 additions & 11 deletions arch/arm/src/armv7-r/arm_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static void up_dumpstate(void)
uint32_t sp = arm_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 7
uint32_t istackbase;
uint32_t istacksize;
#endif
Expand All @@ -214,11 +214,11 @@ static void up_dumpstate(void)

_alert("Current sp: %08x\n", sp);

#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 7
/* Get the limits on the interrupt stack memory */

istackbase = (uint32_t)&g_intstackbase;
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3);
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~7);

/* Show interrupt stack info */

Expand Down Expand Up @@ -253,7 +253,7 @@ static void up_dumpstate(void)
}
#endif

#if CONFIG_ARCH_INTERRUPTSTACK > 3
#if CONFIG_ARCH_INTERRUPTSTACK > 7
/* Does the current stack pointer lie within the interrupt stack? */

if (sp > istackbase - istacksize && sp < istackbase)
Expand All @@ -262,13 +262,6 @@ static void up_dumpstate(void)

_alert("Interrupt Stack\n", sp);
up_stackdump(sp, istackbase);

/* Extract the user stack pointer which should lie
* at the base of the interrupt stack.
*/

sp = g_intstackbase;
_alert("User sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
Expand All @@ -277,6 +270,17 @@ static void up_dumpstate(void)
}
#endif

/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
* pointer (and the above range check should have failed).
*/

if (CURRENT_REGS)
{
sp = CURRENT_REGS[REG_R13];
_alert("User sp: %08x\n", sp);
}

/* Dump the user stack if the stack pointer lies within the allocated user
* stack memory.
*/
Expand Down
Loading