Xtensa ESP32: Minor rearchitecting of how CPU interrupts are enabled. MOre to come.
This commit is contained in:
parent
cd3d414ba2
commit
d4ad5f04d3
@ -192,6 +192,20 @@ static const uint32_t g_priority[5] =
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_disable_all
|
||||
****************************************************************************/
|
||||
|
||||
static inline void xtensa_disable_all(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"movi a2, 0\n"
|
||||
"xsr a2, INTENABLE\n"
|
||||
: : : "a2"
|
||||
);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_alloc_cpuint
|
||||
*
|
||||
@ -279,6 +293,61 @@ int esp32_alloc_cpuint(uint32_t intmask)
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_cpuint_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize CPU interrupts
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned on
|
||||
* any failre.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_cpuint_initialize(void)
|
||||
{
|
||||
uintptr_t regaddr;
|
||||
#ifdef CONFIG_SMP
|
||||
int cpu;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* Which CPU are we initializing */
|
||||
|
||||
cpu = up_cpu_index();
|
||||
DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS);
|
||||
#endif
|
||||
|
||||
/* Disable all CPU interrupts on this CPU */
|
||||
|
||||
xtensa_disable_all();
|
||||
|
||||
/* Detach all peripheral sources PRO CPU interrupts */
|
||||
|
||||
for (i = 0; i < ESP32_NPERIPHERALS; i++)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
if (cpu != 0)
|
||||
{
|
||||
regaddr = DPORT_APP_MAP_REGADDR(i);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
regaddr = DPORT_PRO_MAP_REGADDR(i);
|
||||
}
|
||||
|
||||
putreg32(NO_CPUINT, regaddr);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_disable_irq
|
||||
*
|
||||
@ -442,8 +511,10 @@ void esp32_free_cpuint(int cpuint)
|
||||
*
|
||||
* Input Parameters:
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from ira.h to be assigned.
|
||||
* periphid - The peripheral number from ira.h to be assigned to
|
||||
* a CPU interrupt.
|
||||
* cpuint - The CPU interrupt to receive the peripheral interrupt
|
||||
* assignment.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@ -479,15 +550,18 @@ void esp32_attach_peripheral(int cpu, int periphid, int cpuint)
|
||||
* Detach a peripheral interupt from a CPU interrupt.
|
||||
*
|
||||
* Input Parameters:
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from ira.h to be assigned.
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from irq.h to be detached from the
|
||||
* CPU interrupt.
|
||||
* cpuint - The CPU interrupt from which the peripheral interrupt will
|
||||
* be detached.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void esp32_detach_peripheral(int cpu, int periphid)
|
||||
void esp32_detach_peripheral(int cpu, int periphid, int cpuint)
|
||||
{
|
||||
uintptr_t regaddr;
|
||||
|
||||
|
@ -46,6 +46,23 @@
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_cpuint_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize CPU interrupts
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned on
|
||||
* any failre.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_cpuint_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_alloc_levelint
|
||||
*
|
||||
@ -108,8 +125,10 @@ void esp32_free_cpuint(int cpuint);
|
||||
*
|
||||
* Input Parameters:
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from ira.h to be attached.
|
||||
* periphid - The peripheral number from ira.h to be assigned to
|
||||
* a CPU interrupt.
|
||||
* cpuint - The CPU interrupt to receive the peripheral interrupt
|
||||
* assignment.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@ -125,14 +144,17 @@ void esp32_attach_peripheral(int cpu, int periphid, int cpuint);
|
||||
* Detach a peripheral interupt from a CPU interrupt.
|
||||
*
|
||||
* Input Parameters:
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from ira.h to be detached.
|
||||
* cpu - The CPU to receive the interrupt 0=PRO CPU 1=APP CPU
|
||||
* periphid - The peripheral number from irq.h to be detached from the
|
||||
* CPU interrupt.
|
||||
* cpuint - The CPU interrupt from which the peripheral interrupt will
|
||||
* be detached.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void esp32_detach_peripheral(int cpu, int periphid);
|
||||
void esp32_detach_peripheral(int cpu, int periphid, int cpuint);
|
||||
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_CPUINT_H */
|
||||
|
@ -88,20 +88,6 @@ static inline void xtensa_registerdump(FAR struct tcb_s *tcb)
|
||||
# define xtensa_registerdump(tcb)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_disable_all
|
||||
****************************************************************************/
|
||||
|
||||
static inline void xtensa_disable_all(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"movi a2, 0\n"
|
||||
"xsr a2, INTENABLE\n"
|
||||
: : : "a2"
|
||||
);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_attach_fromcpu0_interrupt
|
||||
****************************************************************************/
|
||||
@ -154,7 +140,6 @@ static inline void xtensa_attach_fromcpu0_interrupt(void)
|
||||
int xtensa_start_handler(int irq, FAR void *context)
|
||||
{
|
||||
FAR struct tcb_s *tcb = this_task();
|
||||
int i;
|
||||
|
||||
sinfo("CPU%d Started\n", up_cpu_index());
|
||||
|
||||
@ -181,9 +166,9 @@ int xtensa_start_handler(int irq, FAR void *context)
|
||||
|
||||
esp32_region_protection();
|
||||
|
||||
/* Disable all PRO CPU interrupts */
|
||||
/* Initialize CPU interrupts */
|
||||
|
||||
xtensa_disable_all();
|
||||
(void)esp32_cpuint_initialize();
|
||||
|
||||
/* Attach and emable internal interrupts */
|
||||
|
||||
@ -193,13 +178,6 @@ int xtensa_start_handler(int irq, FAR void *context)
|
||||
xtensa_attach_fromcpu0_interrupt();
|
||||
#endif
|
||||
|
||||
/* Detach all peripheral sources APP CPU interrupts */
|
||||
|
||||
for (i = 0; i < ESP32_NPERIPHERALS; i++)
|
||||
{
|
||||
esp32_detach_peripheral(1, i);;
|
||||
}
|
||||
|
||||
#if 0 /* Does it make since to have co-processors enabled on the IDLE thread? */
|
||||
#if XTENSA_CP_ALLSET != 0
|
||||
/* Set initial co-processor state */
|
||||
|
@ -98,20 +98,6 @@ static void esp32_irq_dump(const char *msg, int irq)
|
||||
# define esp32_irq_dump(msg, irq)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_disable_all
|
||||
****************************************************************************/
|
||||
|
||||
static inline void xtensa_disable_all(void)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"movi a2, 0\n"
|
||||
"xsr a2, INTENABLE\n"
|
||||
: : : "a2"
|
||||
);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: xtensa_attach_fromcpu1_interrupt
|
||||
****************************************************************************/
|
||||
@ -151,18 +137,9 @@ static inline void xtensa_attach_fromcpu1_interrupt(void)
|
||||
|
||||
void xtensa_irq_initialize(void)
|
||||
{
|
||||
int i;
|
||||
/* Initialize CPU interrupts */
|
||||
|
||||
/* Disable all PRO CPU interrupts */
|
||||
|
||||
xtensa_disable_all();
|
||||
|
||||
/* Detach all peripheral sources PRO CPU interrupts */
|
||||
|
||||
for (i = 0; i < ESP32_NPERIPHERALS; i++)
|
||||
{
|
||||
esp32_detach_peripheral(0, i);
|
||||
}
|
||||
(void)esp32_cpuint_initialize();
|
||||
|
||||
#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
/* Colorize the interrupt stack for debug purposes */
|
||||
|
@ -716,7 +716,7 @@ static void esp32_detach(struct uart_dev_s *dev)
|
||||
cpu = 0;
|
||||
#endif
|
||||
|
||||
esp32_detach_peripheral(cpu, priv->config->periph);
|
||||
esp32_detach_peripheral(cpu, priv->config->periph, priv->cpuint);
|
||||
|
||||
/* And release the CPU interrupt */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user