fix(esp32p4): Fixed interrupt handling to use the CLIC controller
This commit is contained in:
@@ -14,6 +14,7 @@ SECTIONS
|
||||
_iram_start = ABSOLUTE(.);
|
||||
/* Vectors go to start of IRAM */
|
||||
ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
|
||||
KEEP(*(.exception_vectors_table.text));
|
||||
KEEP(*(.exception_vectors.text));
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ SECTIONS
|
||||
_iram_start = ABSOLUTE(.);
|
||||
/* Vectors go to start of IRAM */
|
||||
ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
|
||||
KEEP(*(.exception_vectors_table.text));
|
||||
KEEP(*(.exception_vectors.text));
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ SECTIONS
|
||||
_iram_start = ABSOLUTE(.);
|
||||
/* Vectors go to start of IRAM */
|
||||
ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
|
||||
KEEP(*(.exception_vectors_table.text));
|
||||
KEEP(*(.exception_vectors.text));
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ SECTIONS
|
||||
_iram_start = ABSOLUTE(.);
|
||||
/* Vectors go to start of IRAM */
|
||||
ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
|
||||
KEEP(*(.exception_vectors_table.text));
|
||||
KEEP(*(.exception_vectors.text));
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
@@ -167,7 +167,8 @@ SECTIONS
|
||||
{
|
||||
_iram_start = ABSOLUTE(.);
|
||||
/* Vectors go to start of IRAM */
|
||||
ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
|
||||
ASSERT(ABSOLUTE(.) % 0x40 == 0, "vector address must be 64 byte aligned");
|
||||
KEEP(*(.exception_vectors_table.text));
|
||||
KEEP(*(.exception_vectors.text));
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
@@ -150,14 +150,22 @@ static void core_intr_matrix_clear(void)
|
||||
for (int i = 0; i < ETS_MAX_INTR_SOURCE; i++) {
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
if (core_id == 0) {
|
||||
REG_WRITE(INTERRUPT_CORE0_LP_RTC_INT_MAP_REG + 4 * i, 0);
|
||||
REG_WRITE(INTERRUPT_CORE0_LP_RTC_INT_MAP_REG + 4 * i, ETS_INVALID_INUM);
|
||||
} else {
|
||||
REG_WRITE(INTERRUPT_CORE1_LP_RTC_INT_MAP_REG + 4 * i, 0);
|
||||
REG_WRITE(INTERRUPT_CORE1_LP_RTC_INT_MAP_REG + 4 * i, ETS_INVALID_INUM);
|
||||
}
|
||||
#else
|
||||
esp_rom_route_intr_matrix(core_id, i, ETS_INVALID_INUM);
|
||||
#endif
|
||||
#endif // CONFIG_IDF_TARGET_ESP32P4
|
||||
}
|
||||
|
||||
#if SOC_INT_CLIC_SUPPORTED
|
||||
for (int i = 0; i < 32; i++) {
|
||||
/* Set all the CPU interrupt lines to vectored by default, as it is on other RISC-V targets */
|
||||
esprv_intc_int_set_vectored(i, true);
|
||||
}
|
||||
#endif // SOC_INT_CLIC_SUPPORTED
|
||||
|
||||
}
|
||||
|
||||
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include "sdkconfig.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -35,24 +36,99 @@ uint32_t esp_hw_stack_guard_get_pc(void);
|
||||
#define ASSIST_DEBUG_CORE_0_SP_MIN_OFFSET (ASSIST_DEBUG_CORE_0_SP_MIN_REG - ASSIST_DEBUG_CORE_0_INTR_ENA_REG)
|
||||
#define ASSIST_DEBUG_CORE_0_SP_MAX_OFFSET (ASSIST_DEBUG_CORE_0_SP_MAX_REG - ASSIST_DEBUG_CORE_0_INTR_ENA_REG)
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_SET_BOUNDS_CPU0
|
||||
lui t0, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
sw a0, ASSIST_DEBUG_CORE_0_SP_MIN_OFFSET(t0)
|
||||
sw a1, ASSIST_DEBUG_CORE_0_SP_MAX_OFFSET(t0)
|
||||
.macro ESP_HW_STACK_GUARD_SET_BOUNDS_CPU0 reg1
|
||||
lui \reg1, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
sw a0, ASSIST_DEBUG_CORE_0_SP_MIN_OFFSET(\reg1)
|
||||
sw a1, ASSIST_DEBUG_CORE_0_SP_MAX_OFFSET(\reg1)
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_STOP_CPU0
|
||||
lui t0, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
lw t1, 0(t0)
|
||||
andi t1, t1, ~ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw t1, 0(t0)
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_STOP_CPU0 reg1 reg2
|
||||
lui \reg1, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
lw \reg2, 0(\reg1)
|
||||
andi \reg2, \reg2, ~ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw \reg2, 0(\reg1)
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_START_CPU0
|
||||
lui t0, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
lw t1, 0(t0)
|
||||
ori t1, t1, ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw t1, 0(t0)
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_START_CPU0 reg1 reg2
|
||||
lui \reg1, ASSIST_DEBUG_CORE_0_INTR_ENA_REG_IMM
|
||||
lw \reg2, 0(\reg1)
|
||||
ori \reg2, \reg2, ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw \reg2, 0(\reg1)
|
||||
.endm
|
||||
|
||||
|
||||
#if SOC_CPU_CORES_NUM > 1
|
||||
|
||||
#define ASSIST_DEBUG_CORE_1_INTR_ENA_REG_IMM (ASSIST_DEBUG_CORE_1_INTR_ENA_REG >> 12)
|
||||
#define ASSIST_DEBUG_CORE_1_SP_MIN_OFFSET (ASSIST_DEBUG_CORE_1_SP_MIN_REG - ASSIST_DEBUG_CORE_1_INTR_ENA_REG)
|
||||
#define ASSIST_DEBUG_CORE_1_SP_MAX_OFFSET (ASSIST_DEBUG_CORE_1_SP_MAX_REG - ASSIST_DEBUG_CORE_1_INTR_ENA_REG)
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_SET_BOUNDS_CPU1 reg1
|
||||
lui \reg1, ASSIST_DEBUG_CORE_1_INTR_ENA_REG_IMM
|
||||
sw a0, ASSIST_DEBUG_CORE_1_SP_MIN_OFFSET(\reg1)
|
||||
sw a1, ASSIST_DEBUG_CORE_1_SP_MAX_OFFSET(\reg1)
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_STOP_CPU1 reg1 reg2
|
||||
lui \reg1, ASSIST_DEBUG_CORE_1_INTR_ENA_REG_IMM
|
||||
lw \reg2, 0(\reg1)
|
||||
andi \reg2, \reg2, ~ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw \reg2, 0(\reg1)
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_START_CPU1 reg1 reg2
|
||||
lui \reg1, ASSIST_DEBUG_CORE_1_INTR_ENA_REG_IMM
|
||||
lw \reg2, 0(\reg1)
|
||||
ori \reg2, \reg2, ASSIST_DEBUG_SP_SPILL_BITS
|
||||
sw \reg2, 0(\reg1)
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_SET_BOUNDS_CUR_CORE reg1
|
||||
/* Check the current core ID */
|
||||
csrr \reg1, mhartid
|
||||
beqz \reg1, @1f
|
||||
/* Core 1 */
|
||||
ESP_HW_STACK_GUARD_SET_BOUNDS_CPU1 \reg1
|
||||
j 2f
|
||||
1:
|
||||
/* Core 0 */
|
||||
ESP_HW_STACK_GUARD_SET_BOUNDS_CPU0 \reg1
|
||||
2:
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_START_CUR_CORE reg1 reg2
|
||||
/* Check the current core ID */
|
||||
csrr \reg1, mhartid
|
||||
beqz \reg1, @1f
|
||||
/* Core 1 */
|
||||
ESP_HW_STACK_GUARD_MONITOR_START_CPU1 \reg1 \reg2
|
||||
j 2f
|
||||
1:
|
||||
/* Core 0 */
|
||||
ESP_HW_STACK_GUARD_MONITOR_START_CPU0 \reg1 \reg2
|
||||
2:
|
||||
.endm
|
||||
|
||||
.macro ESP_HW_STACK_GUARD_MONITOR_STOP_CUR_CORE reg1 reg2
|
||||
/* Check the current core ID */
|
||||
csrr \reg1, mhartid
|
||||
beqz \reg1, @1f
|
||||
/* Core 1 */
|
||||
ESP_HW_STACK_GUARD_MONITOR_STOP_CPU1 \reg1 \reg2
|
||||
j 2f
|
||||
1:
|
||||
/* Core 0 */
|
||||
ESP_HW_STACK_GUARD_MONITOR_STOP_CPU0 \reg1 \reg2
|
||||
2:
|
||||
.endm
|
||||
|
||||
#else // SOC_CPU_CORES_NUM <= 1
|
||||
|
||||
#define ESP_HW_STACK_GUARD_SET_BOUNDS_CUR_CORE ESP_HW_STACK_GUARD_SET_BOUNDS_CPU0
|
||||
#define ESP_HW_STACK_GUARD_MONITOR_START_CUR_CORE ESP_HW_STACK_GUARD_MONITOR_START_CPU0
|
||||
#define ESP_HW_STACK_GUARD_MONITOR_STOP_CUR_CORE ESP_HW_STACK_GUARD_MONITOR_STOP_CPU0
|
||||
|
||||
#endif // SOC_CPU_CORES_NUM > 1
|
||||
|
||||
|
||||
#endif // __ASSEMBLER__
|
||||
|
||||
Reference in New Issue
Block a user