mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add base priority get APIs (#818)
* Add base priority get APIs * Add MPU changes --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
631ae9e6e4
commit
7ffc6a7465
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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 */
|
||||
|
|
71
tasks.c
71
tasks.c
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue