Sfoglia il codice sorgente

System: move interrupt stack to .bss instead of .data section

The interrupt stack for Xtensa targets is now declared in C, automatically moving it to .bss section instead of .data section.

* Closes https://github.com/espressif/esp-idf/issues/9188
Omar Chebib 3 anni fa
parent
commit
bac62cfac8

+ 1 - 1
components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h

@@ -293,7 +293,7 @@ Default values for trace macros added by ESP-IDF and are not part of Vanilla Fre
 
 #ifndef __ASSEMBLER__
 #if CONFIG_APPTRACE_SV_ENABLE
-extern uint32_t port_switch_flag[];
+extern volatile uint32_t port_switch_flag[portNUM_PROCESSORS];
 #define os_task_switch_is_pended(_cpu_) (port_switch_flag[_cpu_])
 #else
 #define os_task_switch_is_pended(_cpu_) (false)

+ 10 - 0
components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c

@@ -75,6 +75,16 @@ Variables used by IDF critical sections only (SMP tracks critical nesting inside
 BaseType_t port_uxCriticalNestingIDF[portNUM_PROCESSORS] = {0};
 BaseType_t port_uxCriticalOldInterruptStateIDF[portNUM_PROCESSORS] = {0};
 
+/*
+*******************************************************************************
+* Interrupt stack. The size of the interrupt stack is determined by the config
+* parameter "configISR_STACK_SIZE" in FreeRTOSConfig.h
+*******************************************************************************
+*/
+volatile StackType_t DRAM_ATTR __attribute__((aligned(16))) port_IntStack[portNUM_PROCESSORS][configISR_STACK_SIZE];
+/* One flag for each individual CPU. */
+volatile uint32_t port_switch_flag[portNUM_PROCESSORS];
+
 BaseType_t xPortEnterCriticalTimeout(portMUX_TYPE *lock, BaseType_t timeout)
 {
     /* Interrupts may already be disabled (if this function is called in nested

+ 0 - 15
components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/portasm.S

@@ -61,23 +61,8 @@ Exit:
     and     \reg_A, \reg_A, \reg_B          /* Align CPSA pointer to 16 bytes */
     .endm
 
-/*
-*******************************************************************************
-* Interrupt stack. The size of the interrupt stack is determined by the config
-* parameter "configISR_STACK_SIZE" in FreeRTOSConfig.h
-*******************************************************************************
-*/
-    .data
-    .align      16
     .global     port_IntStack
     .global     port_switch_flag    //Required by sysview_tracing build
-port_IntStack:
-    .space      configISR_STACK_SIZE*portNUM_PROCESSORS     /* This allocates stacks for each individual CPU. */
-port_IntStackTop:
-    .word       0
-port_switch_flag:
-    .space      portNUM_PROCESSORS*4 /* One flag for each individual CPU. */
-
     .text
 
 /*

+ 1 - 1
components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h

@@ -752,7 +752,7 @@ bool xPortcheckValidStackMem(const void *ptr);
 // --------------------- App-Trace -------------------------
 
 #if CONFIG_APPTRACE_SV_ENABLE
-extern uint32_t port_switch_flag[];
+extern volatile uint32_t port_switch_flag[portNUM_PROCESSORS];
 #define os_task_switch_is_pended(_cpu_) (port_switch_flag[_cpu_])
 #else
 #define os_task_switch_is_pended(_cpu_) (false)

+ 9 - 0
components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c

@@ -89,6 +89,15 @@ unsigned port_interruptNesting[portNUM_PROCESSORS] = {0};  // Interrupt nesting
 BaseType_t port_uxCriticalNesting[portNUM_PROCESSORS] = {0};
 BaseType_t port_uxOldInterruptState[portNUM_PROCESSORS] = {0};
 
+/*
+*******************************************************************************
+* Interrupt stack. The size of the interrupt stack is determined by the config
+* parameter "configISR_STACK_SIZE" in FreeRTOSConfig.h
+*******************************************************************************
+*/
+volatile StackType_t DRAM_ATTR __attribute__((aligned(16))) port_IntStack[portNUM_PROCESSORS][configISR_STACK_SIZE];
+/* One flag for each individual CPU. */
+volatile uint32_t port_switch_flag[portNUM_PROCESSORS];
 
 /* ------------------------------------------------ FreeRTOS Portable --------------------------------------------------
  * - Provides implementation for functions required by FreeRTOS

+ 0 - 15
components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S

@@ -36,23 +36,8 @@
 
 .extern pxCurrentTCB
 
-/*
-*******************************************************************************
-* Interrupt stack. The size of the interrupt stack is determined by the config
-* parameter "configISR_STACK_SIZE" in FreeRTOSConfig.h
-*******************************************************************************
-*/
-    .data
-    .align      16
     .global     port_IntStack
     .global     port_switch_flag    //Required by sysview_tracing build
-port_IntStack:
-    .space      configISR_STACK_SIZE*portNUM_PROCESSORS     /* This allocates stacks for each individual CPU. */
-port_IntStackTop:
-    .word       0
-port_switch_flag:
-    .space      portNUM_PROCESSORS*4 /* One flag for each individual CPU. */
-
     .text
 
 /*