Просмотр исходного кода

Merge branch 'bugfix/dport_in_single_core' into 'master'

esp32: exclude DPORT-related code in single core mode

See merge request !1304

Ivan Grokhotkov 8 лет назад
Родитель
Сommit
d50aca62c3
2 измененных файлов с 17 добавлено и 9 удалено
  1. 13 9
      components/esp32/dport_access.c
  2. 4 0
      components/esp32/dport_panic_highint_hdl.S

+ 13 - 9
components/esp32/dport_access.c

@@ -41,6 +41,7 @@
 
 
 #include "xtensa/core-macros.h"
 #include "xtensa/core-macros.h"
 
 
+#ifndef CONFIG_FREERTOS_UNICORE
 static portMUX_TYPE g_dport_mux = portMUX_INITIALIZER_UNLOCKED;
 static portMUX_TYPE g_dport_mux = portMUX_INITIALIZER_UNLOCKED;
 
 
 #define DPORT_CORE_STATE_IDLE        0
 #define DPORT_CORE_STATE_IDLE        0
@@ -61,9 +62,9 @@ static uint32_t ccount_margin[portNUM_PROCESSORS][DPORT_ACCESS_BENCHMARK_STORE_N
 static uint32_t ccount_margin_cnt;
 static uint32_t ccount_margin_cnt;
 #endif
 #endif
 
 
-#ifndef CONFIG_FREERTOS_UNICORE
+
 static BaseType_t oldInterruptLevel[2];
 static BaseType_t oldInterruptLevel[2];
-#endif
+#endif // CONFIG_FREERTOS_UNICORE
 
 
 /* stall other cpu that this cpu is pending to access dport register start */
 /* stall other cpu that this cpu is pending to access dport register start */
 void IRAM_ATTR esp_dport_access_stall_other_cpu_start(void)
 void IRAM_ATTR esp_dport_access_stall_other_cpu_start(void)
@@ -153,17 +154,17 @@ void IRAM_ATTR esp_dport_access_stall_other_cpu_end_wrap(void)
     DPORT_STALL_OTHER_CPU_END();
     DPORT_STALL_OTHER_CPU_END();
 }
 }
 
 
+#ifndef CONFIG_FREERTOS_UNICORE
 static void dport_access_init_core(void *arg)
 static void dport_access_init_core(void *arg)
 {
 {
     int core_id = 0;
     int core_id = 0;
     uint32_t intr_source = ETS_FROM_CPU_INTR2_SOURCE;
     uint32_t intr_source = ETS_FROM_CPU_INTR2_SOURCE;
 
 
-#ifndef CONFIG_FREERTOS_UNICORE
+
     core_id = xPortGetCoreID();
     core_id = xPortGetCoreID();
     if (core_id == 1) {
     if (core_id == 1) {
         intr_source = ETS_FROM_CPU_INTR3_SOURCE;
         intr_source = ETS_FROM_CPU_INTR3_SOURCE;
     }
     }
-#endif
 
 
     ESP_INTR_DISABLE(ETS_DPORT_INUM);
     ESP_INTR_DISABLE(ETS_DPORT_INUM);
     intr_matrix_set(core_id, intr_source, ETS_DPORT_INUM);
     intr_matrix_set(core_id, intr_source, ETS_DPORT_INUM);
@@ -176,40 +177,43 @@ static void dport_access_init_core(void *arg)
 
 
     vTaskDelete(NULL);
     vTaskDelete(NULL);
 }
 }
+#endif
 
 
 /*  Defer initialisation until after scheduler is running */
 /*  Defer initialisation until after scheduler is running */
 void esp_dport_access_int_init(void)
 void esp_dport_access_int_init(void)
 {
 {
+#ifndef CONFIG_FREERTOS_UNICORE
     portBASE_TYPE res = xTaskCreatePinnedToCore(&dport_access_init_core, "dport", configMINIMAL_STACK_SIZE, NULL, 5, NULL, xPortGetCoreID());
     portBASE_TYPE res = xTaskCreatePinnedToCore(&dport_access_init_core, "dport", configMINIMAL_STACK_SIZE, NULL, 5, NULL, xPortGetCoreID());
     assert(res == pdTRUE);
     assert(res == pdTRUE);
+#endif
 }
 }
 
 
 void IRAM_ATTR esp_dport_access_int_pause(void)
 void IRAM_ATTR esp_dport_access_int_pause(void)
 {
 {
+#ifndef CONFIG_FREERTOS_UNICORE
     portENTER_CRITICAL_ISR(&g_dport_mux);
     portENTER_CRITICAL_ISR(&g_dport_mux);
     dport_core_state[0] = DPORT_CORE_STATE_IDLE;
     dport_core_state[0] = DPORT_CORE_STATE_IDLE;
-#ifndef CONFIG_FREERTOS_UNICORE
     dport_core_state[1] = DPORT_CORE_STATE_IDLE;
     dport_core_state[1] = DPORT_CORE_STATE_IDLE;
-#endif
     portEXIT_CRITICAL_ISR(&g_dport_mux);
     portEXIT_CRITICAL_ISR(&g_dport_mux);
+#endif
 }
 }
 
 
 //Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux.
 //Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux.
 void IRAM_ATTR esp_dport_access_int_abort(void)
 void IRAM_ATTR esp_dport_access_int_abort(void)
 {
 {
-    dport_core_state[0] = DPORT_CORE_STATE_IDLE;
 #ifndef CONFIG_FREERTOS_UNICORE
 #ifndef CONFIG_FREERTOS_UNICORE
+    dport_core_state[0] = DPORT_CORE_STATE_IDLE;
     dport_core_state[1] = DPORT_CORE_STATE_IDLE;
     dport_core_state[1] = DPORT_CORE_STATE_IDLE;
 #endif
 #endif
 }
 }
 
 
 void IRAM_ATTR esp_dport_access_int_resume(void)
 void IRAM_ATTR esp_dport_access_int_resume(void)
 {
 {
+#ifndef CONFIG_FREERTOS_UNICORE
     portENTER_CRITICAL_ISR(&g_dport_mux);
     portENTER_CRITICAL_ISR(&g_dport_mux);
     dport_core_state[0] = DPORT_CORE_STATE_RUNNING;
     dport_core_state[0] = DPORT_CORE_STATE_RUNNING;
-#ifndef CONFIG_FREERTOS_UNICORE
     dport_core_state[1] = DPORT_CORE_STATE_RUNNING;
     dport_core_state[1] = DPORT_CORE_STATE_RUNNING;
-#endif
     portEXIT_CRITICAL_ISR(&g_dport_mux);
     portEXIT_CRITICAL_ISR(&g_dport_mux);
+#endif
 }
 }
 
 

+ 4 - 0
components/esp32/dport_panic_highint_hdl.S

@@ -45,10 +45,12 @@ _l4_intr_stack:
     .align      4
     .align      4
 xt_highint4:
 xt_highint4:
 
 
+#ifndef CONFIG_FREERTOS_UNICORE
     /* See if we're here for the dport access interrupt */
     /* See if we're here for the dport access interrupt */
     rsr     a0, INTERRUPT
     rsr     a0, INTERRUPT
     extui   a0, a0, ETS_DPORT_INUM, 1
     extui   a0, a0, ETS_DPORT_INUM, 1
     bnez    a0, .handle_dport_access_int
     bnez    a0, .handle_dport_access_int
+#endif // CONFIG_FREERTOS_UNICORE
 
 
     /* Allocate exception frame and save minimal context. */
     /* Allocate exception frame and save minimal context. */
     mov     a0, sp
     mov     a0, sp
@@ -129,6 +131,7 @@ xt_highint4:
 
 
 
 
 
 
+#ifndef CONFIG_FREERTOS_UNICORE
 
 
     .align      4
     .align      4
 .handle_dport_access_int:
 .handle_dport_access_int:
@@ -187,6 +190,7 @@ xt_highint4:
     rsr     a0, EXCSAVE_4                   /* restore a0 */
     rsr     a0, EXCSAVE_4                   /* restore a0 */
     rfi     4
     rfi     4
 
 
+#endif // CONFIG_FREERTOS_UNICORE
 
 
 /* The linker has no reason to link in this file; all symbols it exports are already defined
 /* The linker has no reason to link in this file; all symbols it exports are already defined
    (weakly!) in the default int handler. Define a symbol here so we can use it to have the 
    (weakly!) in the default int handler. Define a symbol here so we can use it to have the