Xtensa ESP32: A few fixes for APP CPU start-up
This commit is contained in:
parent
404925d93e
commit
6d5a718b98
@ -88,7 +88,7 @@ CHIP_CSRCS += esp32_timerisr.c
|
||||
# Configuration-dependent ESP32 files
|
||||
|
||||
ifeq ($(CONFIG_SMP),y)
|
||||
CHIP_ASRCS = esp32_cpuhead.S esp32_cpuindex.S
|
||||
CHIP_ASRCS = esp32_cpuindex.S
|
||||
CMN_CSRCS += esp32_cpuidlestack.c esp32_cpustart.c esp32_intercpu_interrupt.c
|
||||
endif
|
||||
|
||||
|
@ -1,153 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/src/esp32/esp32_cpuhead.S
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
.file "esp32_cpuhead.S"
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/xtensa/xtensa_corebits.h>
|
||||
#include <arch/esp32/core-isa.h>
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
.section .noinit, "aw"
|
||||
.global g_cpu1_idlestack
|
||||
.type g_cpu1_idlestack, @object
|
||||
.align 16
|
||||
|
||||
g_cpu1_idlestack:
|
||||
.space (CONFIG_SMP_IDLETHREAD_STACKSIZE & ~15)
|
||||
.Lcpu1_stacktop:
|
||||
.size g_cpu1_idlestack, . - g_cpu1_idlestack
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
.text
|
||||
|
||||
/****************************************************************************
|
||||
* Name: __cpu[n]_start
|
||||
*
|
||||
* Description:
|
||||
* Boot functions for each CPU (other than CPU0). These functions set up
|
||||
* the ARM operating mode, the initial stack, and configure co-processor
|
||||
* registers. At the end of the boot, esp32_cpu_boot() is called.
|
||||
*
|
||||
* These functions are provided by the common ARMv7-A logic.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Do not return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
.global __cpu1_start
|
||||
.type __cpu1_start, @function
|
||||
|
||||
.align 4
|
||||
|
||||
.Lcpu1_bottomofstack:
|
||||
.long .Lcpu1_stacktop
|
||||
.size .Lcpu1_bottomofstack, . - .Lcpu1_bottomofstack
|
||||
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
.Lcpu1_bottomofstack:
|
||||
.long .Lcpu1_stacktop
|
||||
.size .Lcpu1_bottomofstack, . - .Lcpu1_bottomofstack
|
||||
|
||||
.Lcpu1_stackcolor:
|
||||
.long STACK_COLOR
|
||||
.size .Lcpu1_stackcolor, . - .Lcpu1_stackcolor
|
||||
#endif
|
||||
|
||||
.align 4
|
||||
|
||||
__cpu1_start:
|
||||
|
||||
/* Set up the stack pointer and the CPU index */
|
||||
|
||||
l32r sp, .Lcpu1_bottomofstack
|
||||
|
||||
/* REVIST: Does it make since to have co-processors enabled on the IDLE thread? */
|
||||
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
/* Write a known value to the IDLE thread stack to support stack
|
||||
* monitoring logic
|
||||
*/
|
||||
|
||||
mov a0, sp
|
||||
l32r a1, .Lcpu1_bottomofstack
|
||||
l32r a2, .Lcpu1_stackcolor
|
||||
|
||||
1:
|
||||
s32i a2, a1, 0
|
||||
addi a2, a2, 4
|
||||
bne a1, a2, 1b
|
||||
#endif
|
||||
|
||||
/* Set up the intiali PS */
|
||||
|
||||
#ifdef __XTENSA_CALL0_ABI__
|
||||
movi a0, (PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_EXCM)
|
||||
#else
|
||||
movi a0, (PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_EXCM | PS_WOE | PS_CALLINC(1))
|
||||
#endif
|
||||
wsr a0, PS
|
||||
|
||||
/* Finish initialization in C */
|
||||
|
||||
#ifdef __XTENSA_CALL0_ABI__
|
||||
movi a2, 1 /* Argument 1: CPU ID */
|
||||
call0 xtensa_start_handler
|
||||
#else
|
||||
movi a6, 1 /* Argument 1: CPU ID */
|
||||
call4 xtensa_start_handler
|
||||
#endif
|
||||
|
||||
/* xtensa_start_handler() does not return */
|
||||
|
||||
2: j 2b
|
||||
.size __cpu1_start, . - __cpu1_start
|
||||
#endif /* CONFIG_SMP */
|
@ -36,6 +36,16 @@
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Address of the CPU0 IDLE thread */
|
||||
|
||||
uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]
|
||||
__attribute__((aligned(16) section(".noinit")));
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -129,24 +129,34 @@ static inline void xtensa_attach_fromcpu0_interrupt(void)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_start_handler
|
||||
* Name: xtensa_appcpu_start
|
||||
*
|
||||
* Description:
|
||||
* This is the handler for SGI1. This handler simply returns from the
|
||||
* interrupt, restoring the state of the new task at the head of the ready
|
||||
* to run list.
|
||||
* This is the entry point used with the APP CPU was started via
|
||||
* up_cpu_start(). The actually start-up logic in in ROM and we boot up
|
||||
* in C code.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Standard interrupt handling
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
* None, does not return
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int xtensa_start_handler(int irq, FAR void *context)
|
||||
void xtensa_appcpu_start(void)
|
||||
{
|
||||
FAR struct tcb_s *tcb = this_task();
|
||||
register uint32_t sp;
|
||||
|
||||
/* Move to the stack assigned to us by up_smp_start immediately. Although
|
||||
* we were give a stack pointer at start-up, we don't know where that stack
|
||||
* pointer is positioned respect to our memory map. The only safe option
|
||||
* is to switch to a well-known IDLE thread stack.
|
||||
*/
|
||||
|
||||
sp = (uint32_t)tcb->adj_stack_ptr;
|
||||
__asm__ __volatile__("mov sp, %0\n" : : "r"(sp));
|
||||
|
||||
sinfo("CPU%d Started\n", up_cpu_index());
|
||||
|
||||
@ -209,7 +219,6 @@ int xtensa_start_handler(int irq, FAR void *context)
|
||||
*/
|
||||
|
||||
xtensa_context_restore(tcb->xcp.regs);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -302,7 +311,7 @@ int up_cpu_start(int cpu)
|
||||
|
||||
/* Set the CPU1 start address */
|
||||
|
||||
ets_set_appcpu_boot_addr((uint32_t)__cpu1_start);
|
||||
ets_set_appcpu_boot_addr((uint32_t)xtensa_appcpu_start);
|
||||
|
||||
/* And wait for the initial task to run on CPU1 */
|
||||
|
||||
|
@ -44,6 +44,20 @@
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-procesor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* An IDLE thread stack size for CPU0 must be defined */
|
||||
|
||||
#if !defined(CONFIG_SMP_IDLETHREAD_STACKSIZE)
|
||||
# error CONFIG_SMP_IDLETHREAD_STACKSIZE is not defined
|
||||
#elif CONFIG_SMP_IDLETHREAD_STACKSIZE < 16
|
||||
# error CONFIG_SMP_IDLETHREAD_STACKSIZE is to small
|
||||
#endif
|
||||
|
||||
#define CPU1_IDLETHREAD_STACKSIZE ((CONFIG_SMP_IDLETHREAD_STACKSIZE + 15) & ~15)
|
||||
#define CPU1_IDLETHREAD_STACKWORDS (CPU1_IDLETHREAD_STACKSIZE >> 2)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -51,8 +65,7 @@
|
||||
|
||||
/* This is the CPU1 IDLE stack */
|
||||
|
||||
#define CPU1_IDLETHREAD_STACKSIZE (CONFIG_SMP_IDLETHREAD_STACKSIZE & ~15)
|
||||
extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKSIZE / 34];
|
||||
extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
Loading…
Reference in New Issue
Block a user