Formatting changes, move function declarations around to make the file flow a bit better

This commit is contained in:
Soren Ptak 2024-02-01 16:40:30 -05:00
parent ec1332e1f4
commit 56a51ff9f5
4 changed files with 246 additions and 257 deletions

View file

@ -202,29 +202,29 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
ulIndex--;
/* Next the General Purpose Registers */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x12121212; /* R12 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x12121212; /* R12 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x11111111; /* R11 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x11111111; /* R11 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x10101010; /* R10 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x10101010; /* R10 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x09090909; /* R9 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x09090909; /* R9 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x08080808; /* R8 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x08080808; /* R8 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x07070707; /* R7 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x07070707; /* R7 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x06060606; /* R6 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x06060606; /* R6 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x05050505; /* R5 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x05050505; /* R5 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x04040404; /* R4 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x04040404; /* R4 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x03030303; /* R3 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x03030303; /* R3 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x02020202; /* R2 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x02020202; /* R2 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x01010101; /* R1 */
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) 0x01010101; /* R1 */
ulIndex--;
xMPUSettings->ulContext[ ulIndex ] = ( StackType_t ) pvParameters; /* R0 */
ulIndex--;
@ -324,33 +324,7 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
return ( &xMPUSettings->ulContext[ ulIndex ] );
}
/*----------------------------------------------------------------------------*/
/* PRIVILEGED_FUNCTION */ static uint32_t prvGetMPURegionSizeSetting(
uint32_t ulActualSizeInBytes
)
{
uint32_t ulRegionSize, ulReturnValue = 4U;
/* 32 bytes is the smallest valid region for Cortex R4 and R5 CPUs */
for( ulRegionSize = 0x20UL; ulReturnValue < 0x1FUL; ( ulRegionSize <<= 1UL ) )
{
if( ulActualSizeInBytes <= ulRegionSize )
{
break;
}
else
{
ulReturnValue++;
}
}
/* Shift the code by one before returning so it can be written directly
* into the the correct bit position of the attribute register. */
return ulReturnValue << 1UL;
}
/*----------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */
/**
* @brief Stores a FreeRTOS Task's MPU Settings in its TCB.
@ -454,28 +428,116 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
if( 0x0UL != ulStackDepth )
{
/* Define the region that allows access to the stack. */
ulRegionStart = ( uint32_t ) pxBottomOfStack;
ulRegionAttr = portMPU_PRIV_RW_USER_RW_NOEXEC |
portMPU_NORMAL_OIWTNOWA_SHARED;
ulRegionLen = prvGetMPURegionSizeSetting( ulStackDepth << 2UL );
ulRegionLen |= portMPU_REGION_ENABLE;
ulRegionStart = ( uint32_t ) pxBottomOfStack;
ulRegionAttr = portMPU_PRIV_RW_USER_RW_NOEXEC |
portMPU_NORMAL_OIWTNOWA_SHARED;
ulRegionLen = prvGetMPURegionSizeSetting( ulStackDepth << 2UL );
ulRegionLen |= portMPU_REGION_ENABLE;
/* MPU Regions must be aligned to a power of 2 equal to length */
ulAlignment = 2UL << ( ulRegionLen >> 1UL );
configASSERT( 0U == ( ulRegionStart % 2UL ) );
configASSERT( 0U == ( ulRegionStart % ( ulAlignment ) ) );
/* MPU Regions must be aligned to a power of 2 equal to length */
ulAlignment = 2UL << ( ulRegionLen >> 1UL );
configASSERT( 0U == ( ulRegionStart % 2UL ) );
configASSERT( 0U == ( ulRegionStart % ( ulAlignment ) ) );
/* xRegion[portNUM_CONFIGURABLE_REGIONS] is the Task Stack */
ulIndex = portNUM_CONFIGURABLE_REGIONS;
/* xRegion[portNUM_CONFIGURABLE_REGIONS] is the Task Stack */
ulIndex = portNUM_CONFIGURABLE_REGIONS;
xMPUSettings->xRegion[ ulIndex ].ulRegionBaseAddress = ulRegionStart;
xMPUSettings->xRegion[ ulIndex ].ulRegionSize = ulRegionLen;
xMPUSettings->xRegion[ ulIndex ].ulRegionAttribute = ulRegionAttr;
xMPUSettings->xRegion[ ulIndex ].ulRegionBaseAddress = ulRegionStart;
xMPUSettings->xRegion[ ulIndex ].ulRegionSize = ulRegionLen;
xMPUSettings->xRegion[ ulIndex ].ulRegionAttribute = ulRegionAttr;
}
}
}
/*----------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */
/**
* @brief Determine if the FreeRTOS Task was created as a privileged task.
*
* @ingroup MPU Control
* @ingroup Task Context
*
* @return pdTRUE if the Task was created as a privileged task.
* pdFALSE if the task was not created as a privileged task.
*
*/
/* PRIVILEGED_FUNCTION */ BaseType_t xPortIsTaskPrivileged( void )
{
BaseType_t xTaskIsPrivileged = pdFALSE;
/* Calling task's MPU settings. */
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) ==
portTASK_IS_PRIVILEGED_FLAG )
{
xTaskIsPrivileged = pdTRUE;
}
return xTaskIsPrivileged;
}
/**
* @brief Start the System Tick Timer, starting the FreeRTOS-Kernel.
*
* @ingroup Scheduler
* @return BaseType_t This function is not meant to be returned from.
* If it does return it returns pdFALSE to mark that the scheduler
* could not be started.
*/
/* PRIVILEGED_FUNCTION */ BaseType_t xPortStartScheduler( void )
{
/* Start the timer that generates the tick ISR. */
configSETUP_TICK_INTERRUPT();
/* Reset the critical section nesting count read to execute the first task. */
ulCriticalNesting = 0UL;
/* Configure the regions in the MPU that are common to all tasks. */
prvSetupMPU();
/* Mark the port specific scheduler running variable as true */
prvPortSchedulerRunning = pdTRUE;
/* Load the context of the first task, starting the FreeRTOS-Scheduler's control. */
vPortStartFirstTask();
/* Will only get here if vTaskStartScheduler() was called with the CPU in
* a non-privileged mode or the binary point register was not set to its lowest
* possible value. prvTaskExitError() is referenced to prevent a compiler
* warning about it being defined but not referenced in the case that the user
* defines their own exit address. */
( void ) prvTaskExitError();
return pdFALSE;
}
/* ----------------------------------------------------------------------------------- */
/* PRIVILEGED_FUNCTION */ static uint32_t prvGetMPURegionSizeSetting(
uint32_t ulActualSizeInBytes
)
{
uint32_t ulRegionSize, ulReturnValue = 4U;
/* 32 bytes is the smallest valid region for Cortex R4 and R5 CPUs */
for( ulRegionSize = 0x20UL; ulReturnValue < 0x1FUL; ( ulRegionSize <<= 1UL ) )
{
if( ulActualSizeInBytes <= ulRegionSize )
{
break;
}
else
{
ulReturnValue++;
}
}
/* Shift the code by one before returning so it can be written directly
* into the the correct bit position of the attribute register. */
return ulReturnValue << 1UL;
}
/* ----------------------------------------------------------------------------------- */
/* PRIVILEGED_FUNCTION */ static void prvSetupMPU( void )
{
@ -616,7 +678,7 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
return xAccessGranted;
}
/* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------------- */
/* PRIVILEGED_FUNCTION */ BaseType_t xPortIsAuthorizedToAccessBuffer(
const void * pvBuffer,
@ -665,67 +727,7 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
return xAccessGranted;
}
/*---------------------------------------------------------------------------*/
/**
* @brief Determine if the FreeRTOS Task was created as a privileged task.
*
* @ingroup MPU Control
* @ingroup Task Context
*
* @return pdTRUE if the Task was created as a privileged task.
* pdFALSE if the task was not created as a privileged task.
*
*/
/* PRIVILEGED_FUNCTION */ BaseType_t xPortIsTaskPrivileged( void )
{
BaseType_t xTaskIsPrivileged = pdFALSE;
/* Calling task's MPU settings. */
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL );
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) ==
portTASK_IS_PRIVILEGED_FLAG )
{
xTaskIsPrivileged = pdTRUE;
}
return xTaskIsPrivileged;
}
/**
* @brief Start the System Tick Timer, starting the FreeRTOS-Kernel.
*
* @ingroup Scheduler
* @return BaseType_t This function is not meant to be returned from.
* If it does return it returns pdFALSE to mark that the scheduler could not be started.
*/
/* PRIVILEGED_FUNCTION */ BaseType_t xPortStartScheduler( void )
{
/* Start the timer that generates the tick ISR. */
configSETUP_TICK_INTERRUPT();
/* Reset the critical section nesting count read to execute the first task. */
ulCriticalNesting = 0UL;
/* Configure the regions in the MPU that are common to all tasks. */
prvSetupMPU();
/* Mark the port specific scheduler running variable as true */
prvPortSchedulerRunning = pdTRUE;
/* Load the context of the first task, starting the FreeRTOS-Scheduler's control. */
vPortStartFirstTask();
/* Will only get here if vTaskStartScheduler() was called with the CPU in
* a non-privileged mode or the binary point register was not set to its lowest
* possible value. prvTaskExitError() is referenced to prevent a compiler
* warning about it being defined but not referenced in the case that the user
* defines their own exit address. */
( void ) prvTaskExitError();
return pdFALSE;
}
/*---------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */
#if( configENABLE_ACCESS_CONTROL_LIST == 1 )
@ -747,7 +749,8 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
}
else
{
xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */
/* Calling task's MPU settings. */
xTaskMpuSettings = xTaskGetMPUSettings( NULL );
ulAccessControlListEntryIndex =
( ( uint32_t ) lInternalIndexOfKernelObject / portACL_ENTRY_SIZE_BITS );
@ -826,7 +829,7 @@ PRIVILEGED_FUNCTION static BaseType_t prvTaskCanAccessRegion(
#endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */
/*---------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */
void prvTaskExitError( void )
{
@ -843,12 +846,8 @@ void prvTaskExitError( void )
}
}
/*---------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */
/**
* @brief Function meant to end the FreeRTOS Scheduler, not implemented on this port.
* @ingroup Scheduler
*/
void vPortEndScheduler( void )
{
prvPortSchedulerRunning = pdFALSE;
@ -857,4 +856,4 @@ void vPortEndScheduler( void )
configASSERT( prvPortSchedulerRunning );
}
/*---------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------------- */

View file

@ -121,7 +121,7 @@
/* Load the first per-task MPU region into R5 */
MOV R5, #portFIRST_CONFIGURABLE_REGION
/* When creating a loop label in a macro it has to be a numeric label.
* For (R5 = portFIRST_CONFIGURABLE_REGION ; R5 <= portNUM_CONFIGURABLE_REGIONS ; R5++ ) */
* for( R5 = portFIRST_CONFIGURABLE_REGION ; R5 <= portNUM_CONFIGURABLE_REGIONS ; R5++ ) */
123:
/* Load values of struct MPU_REGION_REGISTERS into R2-R4 */
LDMIA R1!, { R2-R4 }
@ -217,7 +217,7 @@ FreeRTOS_SVC_Handler:
/* Push R11-R12 for scratch space */
PUSH { R11-R12 }
/* -------------------- Caller Flash Location Check -------------------- */
/* ------------------------- Caller Flash Location Check ------------------------- */
/* The address of the caller will be in the Link Register (LR), it will
* be the caller's Program Counter (PC). Check this address to ensure the
@ -234,7 +234,7 @@ FreeRTOS_SVC_Handler:
/* If the SVC was raised from outside FreeRTOS System Calls exit now */
BGE SVC_Handler_Exit
/* ----------------------- Get Caller SVC Number ----------------------- */
/* ---------------------------- Get Caller SVC Number ---------------------------- */
/* The SPSR will be the CPSR of the calling task, store it in R11 */
MRS R11, SPSR
@ -245,7 +245,7 @@ FreeRTOS_SVC_Handler:
/* Not in Thumb Mode, the instruction 0x4 before holds the SVC numebr */
LDRHEQ R11, [LR, #-0x4]
/* ---------------------------- SVC Routing ---------------------------- */
/* --------------------------------- SVC Routing --------------------------------- */
/* Determine if the SVC number is below #NUM_SYSTEM_CALLS */
CMP R11, #NUM_SYSTEM_CALLS

View file

@ -48,13 +48,13 @@ extern "C" {
/* Include stdint for integer types of specific bit widths */
#include <stdint.h>
/* ------------------------- FreeRTOS Config Check ------------------------- */
/* ------------------------------ FreeRTOS Config Check ------------------------------ */
/* Include the FreeRTOS Config file first to get the includes being used */
#include "FreeRTOSConfig.h"
#ifndef configENABLE_MPU
#define configENABLE_MPU 1
#define configENABLE_MPU 1
#elif( configENABLE_MPU != 1 )
#error "This port is only usable with configENABLE_MPU set to 1"
#endif /* configENABLE_MPU */
@ -64,11 +64,10 @@ extern "C" {
#endif /* configENABLE_ACCESS_CONTROL_LIST */
#ifndef configPROTECTED_KERNEL_OBJECT_POOL_SIZE
#error "Set configPROTECTED_KERNEL_OBJECT_POOL_SIZE to at least the number " \
"of FreeRTOS-Kernel Objects to be created"
#error "Set configPROTECTED_KERNEL_OBJECT_POOL_SIZE to at least the " \
"number of FreeRTOS-Kernel Objects to be created"
#endif /* configPROTECTED_KERNEL_OBJECT_POOL_SIZE */
/**
* @brief The size in Bytes that the Privileged System Call Stack should be.
*
@ -78,17 +77,17 @@ extern "C" {
* by an unprivileged task.
*/
#ifndef configSYSTEM_CALL_STACK_SIZE
#error "configSYSTEM_CALL_STACK_SIZE must be defined to a length, in bytes, " \
#error "Define configSYSTEM_CALL_STACK_SIZE to a length, in bytes, " \
"to use when an unprivileged task makes a FreeRTOS Kernel call. "
#endif /* configSYSTEM_CALL_STACK_SIZE */
/* ------------------------- FreeRTOS Config Check ------------------------- */
/* ------------------------------ FreeRTOS Config Check ------------------------------ */
#if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 )
/* Check the configuration. */
#if( configMAX_PRIORITIES > 32 )
#error "configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when " \
"configMAX_PRIORITIES is less than or equal to 32." \
"configMAX_PRIORITIES is less than or equal to 32. " \
"It is very rare that a system requires more than 10 to 15 difference " \
"priorities as tasks that share a priority will time slice."
#endif /* ( configMAX_PRIORITIES > 32 ) */
@ -129,20 +128,20 @@ extern "C" {
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
#ifndef configSETUP_TICK_INTERRUPT
#error configSETUP_TICK_INTERRUPT() must be defined in FreeRTOSConfig.h to call the function that sets up the tick interrupt.
#error "configSETUP_TICK_INTERRUPT() must be defined in FreeRTOSConfig.h " \
"to call the function that sets up the tick interrupt."
#endif /* configSETUP_TICK_INTERRUPT */
#ifndef configCLEAR_TICK_INTERRUPT
#error configCLEAR_TICK_INTERRUPT() must be defined in FreeRTOSConfig.h to clear which ever interrupt was used to generate the tick interrupt.
#error "configCLEAR_TICK_INTERRUPT() must be defined in FreeRTOSConfig.h " \
"to clear which ever interrupt was used to generate the tick interrupt."
#endif /* configCLEAR_TICK_INTERRUPT */
#ifdef configUSE_TICKLESS_IDLE
#if( configUSE_TICKLESS_IDLE != 0 )
#error This port does not support tickless idle
#endif /* ( configUSE_TICKLESS_IDLE != 0 ) */
#endif /* configUSE_TICKLESS_IDLE */
#if( configUSE_TICKLESS_IDLE != 0 )
#error This port does not support tickless idle
#endif /* ( configUSE_TICKLESS_IDLE != 0 ) */
/* ------------------------- Port Type Definitions ------------------------- */
/* ------------------------------ Port Type Definitions ------------------------------ */
#include "portmacro_asm.h"
@ -289,7 +288,7 @@ typedef uint32_t TickType_t;
*/
#define portMAX_DELAY ( TickType_t ) 0xFFFFFFFFUL
/* --------------------------- Port Assembly Handlers --------------------------- */
/* ----------------------------- Port Assembly Functions ----------------------------- */
/** @brief Assembly FreeRTOS Supervisor Call Handler. */
void FreeRTOS_SVC_Handler( void );
@ -297,8 +296,6 @@ void FreeRTOS_SVC_Handler( void );
/** @brief Assembly FreeRTOS Interrupt Handler */
void FreeRTOS_IRQ_Handler( void );
/* --------------------------- Port Assembly Functions --------------------------- */
/**
* @brief Make a Supervisor Call to swap the currently running task out.
*
@ -373,8 +370,8 @@ void vPortSystemCallExit( void );
*
* @ingroup Scheduler
*
* @note This is an assembly function implemented in portASM.s, it loads the context
* of the first task from pxCurrentTCB.
* @note This is an assembly function implemented in portASM.s, it loads the
* context of the first task from pxCurrentTCB.
*/
void vPortStartFirstTask( void );
@ -435,7 +432,7 @@ void vMPUSetRegion(
uint32_t ulRegionPermissions
);
/* ----------------------------- Port C Functions ----------------------------- */
/* ------------------------------- Port.c Declarations ------------------------------- */
/**
* @brief Checks whether or not the processor is privileged.
@ -517,7 +514,7 @@ void prvTaskExitError( void );
#endif /* configTASK_RETURN_ADDRESS */
/**
* @brief Address of function a task should execute if it exits its assigned function.
* @brief Function a task should execute if it exits its assigned function.
*
* @ingroup Task Context
*
@ -535,7 +532,13 @@ void prvTaskExitError( void );
*/
UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
/* ------------------------- Port MPU Definitions ------------------------- */
/**
* @brief Function meant to end the FreeRTOS Scheduler, not implemented on this port.
* @ingroup Scheduler
*/
void vPortEndScheduler( void );
/* --------------------------------- MPU Definitions --------------------------------- */
/**
* @brief Mark that this port utilizes the onboard ARM MPU.
@ -547,7 +550,7 @@ UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
* region information contained in xRegions.
*
*/
#define portUSING_MPU_WRAPPERS 1
#define portUSING_MPU_WRAPPERS 1
/**
* @brief Used to mark if a task should be created as a privileged task.
@ -559,14 +562,14 @@ UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
* For example, to create a privileged task at priority 2 the uxPriority
* parameter should be set to ( 2 | portPRIVILEGE_BIT ).
*/
#define portPRIVILEGE_BIT ( 0x80000000UL )
#define portPRIVILEGE_BIT ( 0x80000000UL )
/** @brief Size of the System Call Buffer in the TCB. */
#define portSYSTEM_CALL_STACK_SIZE configSYSTEM_CALL_STACK_SIZE
#define portSYSTEM_CALL_STACK_SIZE configSYSTEM_CALL_STACK_SIZE
/* Size of an Access Control List (ACL) entry in bits. */
#define portACL_ENTRY_SIZE_BITS ( 32UL )
/** @brief Size of an Access Control List (ACL) entry in bits. */
#define portACL_ENTRY_SIZE_BITS ( 32UL )
/**
* @brief Structure to hold the MPU Register Values.
@ -607,37 +610,33 @@ typedef struct MPU_REGION_REGISTERS
*
* @ingroup Port Privilege
*
* NOTE: Do not modify this structure. The ordering of this structure is expected to be
* this way in the assembly code of the port.
* NOTE: Do not modify this structure. The ordering of this structure is expected
* to be this way in the assembly code of the port.
*/
typedef struct SYSTEM_CALL_STACK_INFO
{
/**
* @brief Stack Pointer of the task when it made a FreeRTOS System Call.
* @note This will point to the start of ulSystemCallStackBuffer[]
* @struct xSYSTEM_CALL_STACK_INFO
* @ingroup Port Privilege
*/
uint32_t * pulTaskStackPointer;
/**
* @brief Link Register of the task when it made a FreeRTOS System Call.
* @struct xSYSTEM_CALL_STACK_INFO
* @ingroup Port Privilege
*/
uint32_t * pulLinkRegisterAtSystemCallEntry;
/**
* @brief Pre-Set Stack Pointer to use when making a FreeRTOS System Call.
* @struct xSYSTEM_CALL_STACK_INFO
* @ingroup Port Privilege
* @note This will point to the start of ulSystemCallStackBuffer[]
*/
uint32_t * pulSystemCallStackPointer;
/**
* @brief Pre-Set Link Register to exit a FreeRTOS System Call.
* @struct xSYSTEM_CALL_STACK_INFO
* @ingroup Port Privilege
* @note This value is set in pxPortInitialiseStack() to ensure after making
* a FreeRTOS System Call that the last LR jump is to vPortSystemCallExit()
*/
@ -646,7 +645,6 @@ typedef struct SYSTEM_CALL_STACK_INFO
/**
* @brief Buffer to be used when performing a FreeRTOS System Call.
* @struct xSYSTEM_CALL_STACK_INFO
* @ingroup Port Privilege
*/
uint32_t ulSystemCallStackBuffer[ configSYSTEM_CALL_STACK_SIZE ];
} xSYSTEM_CALL_STACK_INFO;
@ -667,32 +665,24 @@ typedef struct MPU_SETTINGS
/**
* @brief Array of Per-Task MPU Register Values. Loaded on Task Context Restore.
* @struct xMPU_SETTINGS
* @ingroup Task Context
* @ingroup Port Privilege
* @ingroup MPU Control
*/
xMPU_REGION_REGISTERS xRegion[ portTOTAL_NUM_REGIONS_IN_TCB ];
/**
* @brief Buffer that holds a Task's Context when being swapped out.
* @struct xMPU_SETTINGS
* @ingroup Task Context
*/
uint32_t ulContext[ MAX_CONTEXT_SIZE ];
/**
* @brief Variable to hold FreeRTOS Privilege Settings.
* @struct xMPU_SETTINGS
* @ingroup Task Context
* @ingroup MPU Control
*/
uint32_t ulTaskFlags;
/**
* @brief System Call Info structure that is stored in the TCB.
* @struct xMPU_SETTINGS
* @ingroup Task Context
* @ingroup Port Privilege
*/
xSYSTEM_CALL_STACK_INFO xSystemCallStackInfo;

View file

@ -62,55 +62,55 @@ extern "C" {
* @brief CPSR Mode bit field value for User Mode.
* @ingroup Port Privilege
*/
#define USER_MODE 0x10U
#define USER_MODE 0x10U
/**
* @brief CPSR Mode bit field value for Fast Interrupt Handler (FIQ) Mode.
* @ingroup Port Privilege
*/
#define FIQ_MODE 0x11U
#define FIQ_MODE 0x11U
/**
* @brief CPSR Mode bit field value for Interrupt Handler (IRQ) Mode.
* @ingroup Port Privilege
*/
#define IRQ_MODE 0x12U
#define IRQ_MODE 0x12U
/**
* @brief CPSR Mode bit field value for Supervisor (SVC) Mode.
* @ingroup Port Privilege
*/
#define SVC_MODE 0x13U
#define SVC_MODE 0x13U
/**
* @brief CPSR Mode bit field value for Monitor (MON) Mode.
* @ingroup Port Privilege
*/
#define MON_MODE 0x16U
#define MON_MODE 0x16U
/**
* @brief CPSR Mode bit field value for Abort (ABT) Mode.
* @ingroup Port Privilege
*/
#define ABT_MODE 0x17U
#define ABT_MODE 0x17U
/**
* @brief CPSR Mode bit field value for Hypervisor (HYP) Mode.
* @ingroup Port Privilege
*/
#define HYP_MODE 0x1AU
#define HYP_MODE 0x1AU
/**
* @brief CPSR Mode bit field value for Undefined (UND) Mode.
* @ingroup Port Privilege
*/
#define UND_MODE 0x1BU
#define UND_MODE 0x1BU
/**
* @brief CPSR Mode bit field value for System (SYS) Mode.
* @ingroup Port Privilege
*/
#define SYS_MODE 0x1FU
#define SYS_MODE 0x1FU
/**
* @brief Used to mark if a task should be created as a privileged task.
@ -122,27 +122,27 @@ extern "C" {
* For example, to create a privileged task at priority 2 the uxPriority
* parameter should be set to ( 2 | portPRIVILEGE_BIT ).
*/
#define portPRIVILEGE_BIT ( 0x80000000UL )
#define portPRIVILEGE_BIT ( 0x80000000UL )
/**
* @brief Flag uses to mark that a FreeRTOS Task is privileged.
* @ingroup Port Privilege
*/
#define portTASK_IS_PRIVILEGED_FLAG ( 1UL << 1UL )
#define portTASK_IS_PRIVILEGED_FLAG ( 1UL << 1UL )
/**
* @brief SVC Number to use when requesting a context swap.
* @ingroup Scheduler
* @note This value must not be in use in mpu_syscall_numbers.h
*/
#define portSVC_YIELD 0x0100
#define portSVC_YIELD 0x0100
/**
* @brief SVC Number to use when exiting a FreeRTOS System Call.
* @ingroup MPU Control
* @note This value must not be in use in mpu_syscall_numbers.h
*/
#define portSVC_SYSTEM_CALL_EXIT 0x0104
#define portSVC_SYSTEM_CALL_EXIT 0x0104
/**
* @addtogroup MPU Control
@ -153,73 +153,73 @@ extern "C" {
*/
/* MPU Sub Region settings */
#define portMPU_SUBREGION_0_DISABLE ( 0x1UL << 8UL )
#define portMPU_SUBREGION_1_DISABLE ( 0x1UL << 9UL )
#define portMPU_SUBREGION_2_DISABLE ( 0x1UL << 10UL )
#define portMPU_SUBREGION_3_DISABLE ( 0x1UL << 11UL )
#define portMPU_SUBREGION_4_DISABLE ( 0x1UL << 12UL )
#define portMPU_SUBREGION_5_DISABLE ( 0x1UL << 13UL )
#define portMPU_SUBREGION_6_DISABLE ( 0x1UL << 14UL )
#define portMPU_SUBREGION_7_DISABLE ( 0x1UL << 15UL )
#define portMPU_SUBREGION_0_DISABLE ( 0x1UL << 8UL )
#define portMPU_SUBREGION_1_DISABLE ( 0x1UL << 9UL )
#define portMPU_SUBREGION_2_DISABLE ( 0x1UL << 10UL )
#define portMPU_SUBREGION_3_DISABLE ( 0x1UL << 11UL )
#define portMPU_SUBREGION_4_DISABLE ( 0x1UL << 12UL )
#define portMPU_SUBREGION_5_DISABLE ( 0x1UL << 13UL )
#define portMPU_SUBREGION_6_DISABLE ( 0x1UL << 14UL )
#define portMPU_SUBREGION_7_DISABLE ( 0x1UL << 15UL )
/* Default MPU regions */
#define portFIRST_CONFIGURABLE_REGION ( 0 )
#define portLAST_CONFIGURABLE_REGION ( portMPU_TOTAL_REGIONS - 5UL )
#define portSTACK_REGION ( portMPU_TOTAL_REGIONS - 4UL )
#define portUNPRIVILEGED_FLASH_REGION ( portMPU_TOTAL_REGIONS - 3UL )
#define portPRIVILEGED_FLASH_REGION ( portMPU_TOTAL_REGIONS - 2UL )
#define portPRIVILEGED_RAM_REGION ( portMPU_TOTAL_REGIONS - 1UL )
#define portFIRST_CONFIGURABLE_REGION ( 0 )
#define portLAST_CONFIGURABLE_REGION ( portMPU_TOTAL_REGIONS - 5UL )
#define portSTACK_REGION ( portMPU_TOTAL_REGIONS - 4UL )
#define portUNPRIVILEGED_FLASH_REGION ( portMPU_TOTAL_REGIONS - 3UL )
#define portPRIVILEGED_FLASH_REGION ( portMPU_TOTAL_REGIONS - 2UL )
#define portPRIVILEGED_RAM_REGION ( portMPU_TOTAL_REGIONS - 1UL )
#define portNUM_CONFIGURABLE_REGIONS \
( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1UL )
/* Plus one to make space for the stack region*/
#define portTOTAL_NUM_REGIONS_IN_TCB ( portNUM_CONFIGURABLE_REGIONS + 1UL )
#define portTOTAL_NUM_REGIONS_IN_TCB ( portNUM_CONFIGURABLE_REGIONS + 1UL )
/* MPU region sizes */
#define portMPU_SIZE_32B ( 0x04UL << 1UL )
#define portMPU_SIZE_64B ( 0x05UL << 1UL )
#define portMPU_SIZE_128B ( 0x06UL << 1UL )
#define portMPU_SIZE_256B ( 0x07UL << 1UL )
#define portMPU_SIZE_512B ( 0x08UL << 1UL )
#define portMPU_SIZE_1KB ( 0x09UL << 1UL )
#define portMPU_SIZE_2KB ( 0x0AUL << 1UL )
#define portMPU_SIZE_4KB ( 0x0BUL << 1UL )
#define portMPU_SIZE_8KB ( 0x0CUL << 1UL )
#define portMPU_SIZE_16KB ( 0x0DUL << 1UL )
#define portMPU_SIZE_32KB ( 0x0EUL << 1UL )
#define portMPU_SIZE_64KB ( 0x0FUL << 1UL )
#define portMPU_SIZE_128KB ( 0x10UL << 1UL )
#define portMPU_SIZE_256KB ( 0x11UL << 1UL )
#define portMPU_SIZE_512KB ( 0x12UL << 1UL )
#define portMPU_SIZE_1MB ( 0x13UL << 1UL )
#define portMPU_SIZE_2MB ( 0x14UL << 1UL )
#define portMPU_SIZE_4MB ( 0x15UL << 1UL )
#define portMPU_SIZE_8MB ( 0x16UL << 1UL )
#define portMPU_SIZE_16MB ( 0x17UL << 1UL )
#define portMPU_SIZE_32MB ( 0x18UL << 1UL )
#define portMPU_SIZE_64MB ( 0x19UL << 1UL )
#define portMPU_SIZE_128MB ( 0x1AUL << 1UL )
#define portMPU_SIZE_256MB ( 0x1BUL << 1UL )
#define portMPU_SIZE_512MB ( 0x1CUL << 1UL )
#define portMPU_SIZE_1GB ( 0x1DUL << 1UL )
#define portMPU_SIZE_2GB ( 0x1EUL << 1UL )
#define portMPU_SIZE_4GB ( 0x1FUL << 1UL )
#define portMPU_SIZE_32B ( 0x04UL << 1UL )
#define portMPU_SIZE_64B ( 0x05UL << 1UL )
#define portMPU_SIZE_128B ( 0x06UL << 1UL )
#define portMPU_SIZE_256B ( 0x07UL << 1UL )
#define portMPU_SIZE_512B ( 0x08UL << 1UL )
#define portMPU_SIZE_1KB ( 0x09UL << 1UL )
#define portMPU_SIZE_2KB ( 0x0AUL << 1UL )
#define portMPU_SIZE_4KB ( 0x0BUL << 1UL )
#define portMPU_SIZE_8KB ( 0x0CUL << 1UL )
#define portMPU_SIZE_16KB ( 0x0DUL << 1UL )
#define portMPU_SIZE_32KB ( 0x0EUL << 1UL )
#define portMPU_SIZE_64KB ( 0x0FUL << 1UL )
#define portMPU_SIZE_128KB ( 0x10UL << 1UL )
#define portMPU_SIZE_256KB ( 0x11UL << 1UL )
#define portMPU_SIZE_512KB ( 0x12UL << 1UL )
#define portMPU_SIZE_1MB ( 0x13UL << 1UL )
#define portMPU_SIZE_2MB ( 0x14UL << 1UL )
#define portMPU_SIZE_4MB ( 0x15UL << 1UL )
#define portMPU_SIZE_8MB ( 0x16UL << 1UL )
#define portMPU_SIZE_16MB ( 0x17UL << 1UL )
#define portMPU_SIZE_32MB ( 0x18UL << 1UL )
#define portMPU_SIZE_64MB ( 0x19UL << 1UL )
#define portMPU_SIZE_128MB ( 0x1AUL << 1UL )
#define portMPU_SIZE_256MB ( 0x1BUL << 1UL )
#define portMPU_SIZE_512MB ( 0x1CUL << 1UL )
#define portMPU_SIZE_1GB ( 0x1DUL << 1UL )
#define portMPU_SIZE_2GB ( 0x1EUL << 1UL )
#define portMPU_SIZE_4GB ( 0x1FUL << 1UL )
/* MPU Device Memory Types */
#define portMPU_REGION_STRONGLY_ORDERED ( 0x00UL )
#define portMPU_REGION_DEVICE ( 0x01UL )
#define portMPU_REGION_CACHEABLE_BUFFERABLE ( 0x03UL )
#define portMPU_REGION_EXECUTE_NEVER ( 0x01UL << 12UL )
#define portMPU_STRONGLYORDERED_SHAREABLE ( 0x0000UL )
#define portMPU_DEVICE_SHAREABLE ( 0x0001UL )
#define portMPU_DEVICE_NONSHAREABLE ( 0x0010UL )
#define portMPU_NORMAL_OIWTNOWA_NONSHARED ( 0x0002UL )
#define portMPU_NORMAL_OIWBNOWA_NONSHARED ( 0x0003UL )
#define portMPU_NORMAL_OIWTNOWA_SHARED ( 0x0006UL )
#define portMPU_NORMAL_OIWBNOWA_SHARED ( 0x0007UL )
#define portMPU_NORMAL_OINC_NONSHARED ( 0x0008UL )
#define portMPU_NORMAL_OIWBWA_NONSHARED ( 0x000BUL )
#define portMPU_NORMAL_OINC_SHARED ( 0x000CUL )
#define portMPU_NORMAL_OIWBWA_SHARED ( 0x000FUL )
#define portMPU_REGION_STRONGLY_ORDERED ( 0x00UL )
#define portMPU_REGION_DEVICE ( 0x01UL )
#define portMPU_REGION_CACHEABLE_BUFFERABLE ( 0x03UL )
#define portMPU_REGION_EXECUTE_NEVER ( 0x01UL << 12UL )
#define portMPU_STRONGLYORDERED_SHAREABLE ( 0x0000UL )
#define portMPU_DEVICE_SHAREABLE ( 0x0001UL )
#define portMPU_DEVICE_NONSHAREABLE ( 0x0010UL )
#define portMPU_NORMAL_OIWTNOWA_NONSHARED ( 0x0002UL )
#define portMPU_NORMAL_OIWBNOWA_NONSHARED ( 0x0003UL )
#define portMPU_NORMAL_OIWTNOWA_SHARED ( 0x0006UL )
#define portMPU_NORMAL_OIWBNOWA_SHARED ( 0x0007UL )
#define portMPU_NORMAL_OINC_NONSHARED ( 0x0008UL )
#define portMPU_NORMAL_OIWBWA_NONSHARED ( 0x000BUL )
#define portMPU_NORMAL_OINC_SHARED ( 0x000CUL )
#define portMPU_NORMAL_OIWBWA_SHARED ( 0x000FUL )
/**
* @brief MPU_CTRL value for: No Access and No Execute
@ -230,7 +230,7 @@ extern "C" {
* No Access in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_NA_USER_NA_NOEXEC ( 0x1000UL )
#define portMPU_PRIV_NA_USER_NA_NOEXEC ( 0x1000UL )
/**
* @brief MPU_CTRL value for Privileged Read and Exec
@ -241,7 +241,7 @@ extern "C" {
* No Read/Write Access in User Mode
* Allowed to Execute Code from this region
*/
#define portMPU_PRIV_RO_USER_NA_EXEC ( 0x0500UL )
#define portMPU_PRIV_RO_USER_NA_EXEC ( 0x0500UL )
/**
* @brief MPU_CTRL value for Privileged Read, Write, and Exec
@ -252,7 +252,7 @@ extern "C" {
* No Access in User Mode
* Allowed to Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_NA_EXEC ( 0x0100UL )
#define portMPU_PRIV_RW_USER_NA_EXEC ( 0x0100UL )
/**
* @brief MPU_CTRL value for Read Only and Execute
@ -263,7 +263,7 @@ extern "C" {
* Read Only in User Mode
* Allowed to Execute Code from this region
* */
#define portMPU_PRIV_RO_USER_RO_EXEC ( 0x0600UL )
#define portMPU_PRIV_RO_USER_RO_EXEC ( 0x0600UL )
/**
* @brief MPU_CTRL value for: Read, Execute, and Privileged Write
@ -274,7 +274,7 @@ extern "C" {
* Read Only in User Mode
* Allowed to Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_RO_EXEC ( 0x0200UL )
#define portMPU_PRIV_RW_USER_RO_EXEC ( 0x0200UL )
/**
* @brief MPU_CTRL value for: Read, Write, and Execute
@ -285,7 +285,7 @@ extern "C" {
* Read/write in User Mode
* Allowed to Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_RW_EXEC ( 0x0300UL )
#define portMPU_PRIV_RW_USER_RW_EXEC ( 0x0300UL )
/**
* @brief MPU_CTRL value for: Privileged Read, Write Only, no Execute
@ -296,7 +296,7 @@ extern "C" {
* No Access in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_NA_NOEXEC ( 0x1100UL )
#define portMPU_PRIV_RW_USER_NA_NOEXEC ( 0x1100UL )
/**
* @brief MPU_CTRL value for: All Read, Privileged Write, no Execute
@ -307,7 +307,7 @@ extern "C" {
* Read Only in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_RO_NOEXEC ( 0x1200UL )
#define portMPU_PRIV_RW_USER_RO_NOEXEC ( 0x1200UL )
/**
* @brief MPU_CTRL value for: Read, Write, no Execute
@ -318,7 +318,7 @@ extern "C" {
* Read/Write in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_RW_USER_RW_NOEXEC ( 0x1300UL )
#define portMPU_PRIV_RW_USER_RW_NOEXEC ( 0x1300UL )
/**
* @brief MPU_CTRL value for: Privileged Read Only, No Execute
@ -329,7 +329,7 @@ extern "C" {
* No Access in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_RO_USER_NA_NOEXEC ( 0x1500UL )
#define portMPU_PRIV_RO_USER_NA_NOEXEC ( 0x1500UL )
/**
* @brief MPU_CTRL value for: Read Only, No Execute
@ -340,13 +340,13 @@ extern "C" {
* Read Only in User Mode
* Cannot Execute Code from this region
*/
#define portMPU_PRIV_RO_USER_RO_NOEXEC ( 0x1600UL )
#define portMPU_PRIV_RO_USER_RO_NOEXEC ( 0x1600UL )
/**
* @brief MPU_CTRL value to enable an MPU Region
* @ingroup MPU Control
*/
#define portMPU_REGION_ENABLE ( 0x01UL )
#define portMPU_REGION_ENABLE ( 0x01UL )
/** This following section is used to create the proper size for the ulContext array.
* This array is where all registers related to a task's context are saved.
@ -384,7 +384,7 @@ extern "C" {
* @note There are 13 GPRs, R0-R12, the SP, and the LR. Each are 32 bits,
* which leads to the 15 registers * 4 in length.
*/
#define portREGISTER_LENGTH ( 15U * 4U )
#define portREGISTER_LENGTH ( 15U * 4U )
/**
* If you KNOW that your system will not utilize the FPU in any capacity