Skip to content

Commit

Permalink
Merge branch 'main' into pr_625_final
Browse files Browse the repository at this point in the history
  • Loading branch information
aggarg authored Oct 17, 2023
2 parents 3df0cba + 7ffc6a7 commit 3d8e07e
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,22 @@
#define traceRETURN_uxTaskPriorityGetFromISR( uxReturn )
#endif

#ifndef traceENTER_uxTaskBasePriorityGet
#define traceENTER_uxTaskBasePriorityGet( xTask )
#endif

#ifndef traceRETURN_uxTaskBasePriorityGet
#define traceRETURN_uxTaskBasePriorityGet( uxReturn )
#endif

#ifndef traceENTER_uxTaskBasePriorityGetFromISR
#define traceENTER_uxTaskBasePriorityGetFromISR( xTask )
#endif

#ifndef traceRETURN_uxTaskBasePriorityGetFromISR
#define traceRETURN_uxTaskBasePriorityGetFromISR( uxReturn )
#endif

#ifndef traceENTER_vTaskPrioritySet
#define traceENTER_vTaskPrioritySet( xTask, uxNewPriority )
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/mpu_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask,
StackType_t ** ppuxStackBuffer,
StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
UBaseType_t MPU_uxTaskBasePriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
UBaseType_t MPU_uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
Expand Down
2 changes: 2 additions & 0 deletions include/mpu_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
#define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
#define xTaskGetStaticBuffers MPU_xTaskGetStaticBuffers
#define uxTaskPriorityGetFromISR MPU_uxTaskPriorityGetFromISR
#define uxTaskBasePriorityGet MPU_uxTaskBasePriorityGet
#define uxTaskBasePriorityGetFromISR MPU_uxTaskBasePriorityGetFromISR
#define xTaskResumeFromISR MPU_xTaskResumeFromISR
#define xTaskGetApplicationTaskTagFromISR MPU_xTaskGetApplicationTaskTagFromISR
#define xTaskGenericNotifyFromISR MPU_xTaskGenericNotifyFromISR
Expand Down
31 changes: 31 additions & 0 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,37 @@ UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
*/
UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;

/**
* task. h
* @code{c}
* UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask );
* @endcode
*
* INCLUDE_uxTaskPriorityGet and configUSE_MUTEXES must be defined as 1 for this
* function to be available. See the configuration section for more information.
*
* Obtain the base priority of any task.
*
* @param xTask Handle of the task to be queried. Passing a NULL
* handle results in the base priority of the calling task being returned.
*
* @return The base priority of xTask.
*
* \defgroup uxTaskPriorityGet uxTaskBasePriorityGet
* \ingroup TaskCtrl
*/
UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;

/**
* task. h
* @code{c}
* UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask );
* @endcode
*
* A version of uxTaskBasePriorityGet() that can be used from an ISR.
*/
UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;

/**
* task. h
* @code{c}
Expand Down
66 changes: 66 additions & 0 deletions portable/Common/mpu_wrappers_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,72 @@
#endif /* #if ( INCLUDE_uxTaskPriorityGet == 1 ) */
/*-----------------------------------------------------------*/

#if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )

UBaseType_t MPU_uxTaskBasePriorityGet( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
{
UBaseType_t uxReturn = configMAX_PRIORITIES;
int32_t lIndex;
TaskHandle_t xInternalTaskHandle = NULL;

if( xTask == NULL )
{
uxReturn = uxTaskBasePriorityGet( xTask );
}
else
{
lIndex = ( int32_t ) xTask;

if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );

if( xInternalTaskHandle != NULL )
{
uxReturn = uxTaskBasePriorityGet( xInternalTaskHandle );
}
}
}

return uxReturn;
}

#endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )

UBaseType_t MPU_uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
{
UBaseType_t uxReturn = configMAX_PRIORITIES;
int32_t lIndex;
TaskHandle_t xInternalTaskHandle = NULL;

if( xTask == NULL )
{
uxReturn = uxTaskBasePriorityGetFromISR( xTask );
}
else
{
lIndex = ( int32_t ) xTask;

if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );

if( xInternalTaskHandle != NULL )
{
uxReturn = uxTaskBasePriorityGetFromISR( xInternalTaskHandle );
}
}
}

return uxReturn;
}

#endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )

BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) /* PRIVILEGED_FUNCTION */
Expand Down
71 changes: 71 additions & 0 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,77 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
#endif /* INCLUDE_uxTaskPriorityGet */
/*-----------------------------------------------------------*/

#if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )

UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask )
{
TCB_t const * pxTCB;
UBaseType_t uxReturn;

traceENTER_uxTaskBasePriorityGet( xTask );

taskENTER_CRITICAL();
{
/* If null is passed in here then it is the base priority of the task
* that called uxTaskBasePriorityGet() that is being queried. */
pxTCB = prvGetTCBFromHandle( xTask );
uxReturn = pxTCB->uxBasePriority;
}
taskEXIT_CRITICAL();

traceRETURN_uxTaskBasePriorityGet( uxReturn );

return uxReturn;
}

#endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )

UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask )
{
TCB_t const * pxTCB;
UBaseType_t uxReturn;
UBaseType_t uxSavedInterruptStatus;

traceENTER_uxTaskBasePriorityGetFromISR( xTask );

/* RTOS ports that support interrupt nesting have the concept of a
* maximum system call (or maximum API call) interrupt priority.
* Interrupts that are above the maximum system call priority are keep
* permanently enabled, even when the RTOS kernel is in a critical section,
* but cannot make any calls to FreeRTOS API functions. If configASSERT()
* is defined in FreeRTOSConfig.h then
* portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
* failure if a FreeRTOS API function is called from an interrupt that has
* been assigned a priority above the configured maximum system call
* priority. Only FreeRTOS functions that end in FromISR can be called
* from interrupts that have been assigned a priority at or (logically)
* below the maximum system call interrupt priority. FreeRTOS maintains a
* separate interrupt safe API to ensure interrupt entry is as fast and as
* simple as possible. More information (albeit Cortex-M specific) is
* provided on the following link:
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();

uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
{
/* If null is passed in here then it is the base priority of the calling
* task that is being queried. */
pxTCB = prvGetTCBFromHandle( xTask );
uxReturn = pxTCB->uxBasePriority;
}
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );

traceRETURN_uxTaskBasePriorityGetFromISR( uxReturn );

return uxReturn;
}

#endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( INCLUDE_vTaskPrioritySet == 1 )

void vTaskPrioritySet( TaskHandle_t xTask,
Expand Down

0 comments on commit 3d8e07e

Please sign in to comment.