mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
feat(freertos): Introduced new Kconfig option CONFIG_FREERTOS_NUMBER_OF_CORES
This commit replaces the use of portNUM_PROCESSORS and configNUM_CORES macros in all of ESP-IDF. These macros are needed to realize an SMP scenario by fetching the number of active cores FreeRTOS is running on. Instead, a new Kconfig option, CONFIG_FREERTOS_NUMBER_OF_CORES, has been added as a proxy for the FreeRTOS config option, configNUMBER_OF_CORES. This new commit is now used to realize an SMP scenario in various places in ESP-IDF. [Sudeep Mohanty: Added new Kconfig option CONFIG_FREERTOS_NUMBER_OF_CORES] Signed-off-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -25,14 +26,14 @@
|
||||
#define IPC_STACK_SIZE (CONFIG_ESP_IPC_TASK_STACK_SIZE)
|
||||
#endif //CONFIG_COMPILER_OPTIMIZATION_NONE
|
||||
|
||||
static DRAM_ATTR StaticSemaphore_t s_ipc_mutex_buffer[portNUM_PROCESSORS];
|
||||
static DRAM_ATTR StaticSemaphore_t s_ipc_ack_buffer[portNUM_PROCESSORS];
|
||||
static DRAM_ATTR StaticSemaphore_t s_ipc_mutex_buffer[CONFIG_FREERTOS_NUMBER_OF_CORES];
|
||||
static DRAM_ATTR StaticSemaphore_t s_ipc_ack_buffer[CONFIG_FREERTOS_NUMBER_OF_CORES];
|
||||
|
||||
static TaskHandle_t s_ipc_task_handle[portNUM_PROCESSORS];
|
||||
static SemaphoreHandle_t s_ipc_mutex[portNUM_PROCESSORS]; // This mutex is used as a global lock for esp_ipc_* APIs
|
||||
static SemaphoreHandle_t s_ipc_ack[portNUM_PROCESSORS]; // Semaphore used to acknowledge that task was woken up,
|
||||
static volatile esp_ipc_func_t s_func[portNUM_PROCESSORS] = { 0 }; // Function which should be called by high priority task
|
||||
static void * volatile s_func_arg[portNUM_PROCESSORS]; // Argument to pass into s_func
|
||||
static TaskHandle_t s_ipc_task_handle[CONFIG_FREERTOS_NUMBER_OF_CORES];
|
||||
static SemaphoreHandle_t s_ipc_mutex[CONFIG_FREERTOS_NUMBER_OF_CORES]; // This mutex is used as a global lock for esp_ipc_* APIs
|
||||
static SemaphoreHandle_t s_ipc_ack[CONFIG_FREERTOS_NUMBER_OF_CORES]; // Semaphore used to acknowledge that task was woken up,
|
||||
static volatile esp_ipc_func_t s_func[CONFIG_FREERTOS_NUMBER_OF_CORES] = { 0 }; // Function which should be called by high priority task
|
||||
static void * volatile s_func_arg[CONFIG_FREERTOS_NUMBER_OF_CORES]; // Argument to pass into s_func
|
||||
typedef enum {
|
||||
IPC_WAIT_NO = 0,
|
||||
IPC_WAIT_FOR_START,
|
||||
@@ -114,7 +115,7 @@ static void esp_ipc_init(void)
|
||||
{
|
||||
char task_name[] = "ipcX"; // up to 10 ipc tasks/cores (0-9)
|
||||
|
||||
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
|
||||
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
|
||||
task_name[3] = i + (char)'0';
|
||||
s_ipc_mutex[i] = xSemaphoreCreateMutexStatic(&s_ipc_mutex_buffer[i]);
|
||||
s_ipc_ack[i] = xSemaphoreCreateBinaryStatic(&s_ipc_ack_buffer[i]);
|
||||
@@ -127,7 +128,7 @@ static void esp_ipc_init(void)
|
||||
|
||||
static esp_err_t esp_ipc_call_and_wait(uint32_t cpu_id, esp_ipc_func_t func, void* arg, esp_ipc_wait_t wait_for)
|
||||
{
|
||||
if (cpu_id >= portNUM_PROCESSORS) {
|
||||
if (cpu_id >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (s_ipc_task_handle[cpu_id] == NULL) {
|
||||
|
Reference in New Issue
Block a user