change(freertos/idf): Remove xCoreID TCB member for single-core

This commit does the following:

- removes the xCoreID member from the TCB when building for single-core
- xCoreID is no longer hard set to 0 when calling "PinnedToCore" task creation
functions in single-core
- Tidy up or add missing xCoreID asserts for functions that take xCoreID as an
argument:
    - Functions that set/query a variable of a particular core will call
      taskVALID_CORE_ID() to ensure ) 0 <= xCoreID < configNUMBER_OF_CORES
    - Task creation functions that accept xCoreID also call taskVALID_CORE_ID()
      but also allow tskNO_AFFINITY.
- Fix TaskStatus_t
    - Remove xCoreID from TaskStatus_t if configTASKLIST_INCLUDE_COREID is not
      defined.
    - Set xCoreID to 0 when calling vTaskGetInfo() in single-core builds
This commit is contained in:
Darian Leung
2023-12-04 15:03:55 +08:00
parent 63fee6c23a
commit ee0ee4887f
10 changed files with 99 additions and 41 deletions
@@ -38,10 +38,19 @@
/* Macros used instead ofsetoff() for better performance of interrupt handler */
#define PORT_OFFSET_PX_STACK 0x30
#define PORT_OFFSET_PX_END_OF_STACK (PORT_OFFSET_PX_STACK + \
/* void * pxDummy6 */ 4 + \
/* uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ] */ CONFIG_FREERTOS_MAX_TASK_NAME_LEN + \
/* BaseType_t xDummyCoreID */ 4)
#if CONFIG_FREERTOS_UNICORE
#define CORE_ID_SIZE 0
#else
#define CORE_ID_SIZE 4
#endif
#define PORT_OFFSET_PX_END_OF_STACK ( \
PORT_OFFSET_PX_STACK \
+ 4 /* void * pxDummy6 */ \
+ CONFIG_FREERTOS_MAX_TASK_NAME_LEN /* uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ] */ \
+ CORE_ID_SIZE /* BaseType_t xDummyCoreID */ \
)
#ifndef __ASSEMBLER__
@@ -301,7 +301,11 @@ static void vPortCleanUpCoprocArea(void *pvTCB)
* If yes, reset the owner. */
if (sa->sa_enable != 0) {
/* Get the core the task is pinned on */
const BaseType_t coreID = task->xDummyCoreID;
#if ( configNUM_CORES > 1 )
const BaseType_t coreID = task->xDummyCoreID;
#else /* configNUM_CORES > 1 */
const BaseType_t coreID = 0;
#endif /* configNUM_CORES > 1 */
for (int i = 0; i < SOC_CPU_COPROC_NUM; i++) {
StaticTask_t** owner = &port_uxCoprocOwner[coreID][i];
@@ -767,11 +771,12 @@ void vPortTCBPreDeleteHook( void *pxTCB )
* are saved lazily, as soon as a task starts using one, it must always be scheduled on the core
* it is currently executing on.
*/
#if ( configNUM_CORES > 1 )
void vPortTaskPinToCore(StaticTask_t* task, int coreid)
{
task->xDummyCoreID = coreid;
}
#endif /* configNUM_CORES > 1 */
/**
* @brief Get coprocessor save area out of the given task. If the coprocessor area is not created,
@@ -185,10 +185,12 @@ rtos_save_fpu_coproc:
csrr a1, fcsr
sw a1, RV_FPU_FCSR(a0)
rtos_save_fpu_coproc_nosave:
#if ( configNUM_CORES > 1 )
/* Pin current task to current core */
mv a0, s1
csrr a1, mhartid
call vPortTaskPinToCore
#endif /* configNUM_CORES > 1 */
/* Check if we have to restore a previous FPU context from the current TCB */
mv a0, s1
call pxPortGetCoprocArea
@@ -618,8 +618,12 @@ static void vPortCleanUpCoprocArea(void *pvTCB)
uxCoprocArea = ( UBaseType_t ) ( ( ( StaticTask_t * ) pvTCB )->pxDummy8 ); /* Get TCB_t.pxEndOfStack */
uxCoprocArea = STACKPTR_ALIGN_DOWN(16, uxCoprocArea - XT_CP_SIZE);
/* Get xTargetCoreID from the TCB.xCoreID */
xTargetCoreID = ( ( StaticTask_t * ) pvTCB )->xDummyCoreID;
#if ( configNUMBER_OF_CORES > 1 )
/* Get xTargetCoreID from the TCB.xCoreID */
xTargetCoreID = ( ( StaticTask_t * ) pvTCB )->xDummyCoreID;
#else /* configNUMBER_OF_CORES > 1 */
xTargetCoreID = 0;
#endif /* configNUMBER_OF_CORES > 1 */
/* If task has live floating point registers somewhere, release them */
void _xt_coproc_release(volatile void *coproc_sa_base, BaseType_t xTargetCoreID);