Skip to content

Commit

Permalink
Merge branch 'main' into armv8-1-m-add-pacbti-support
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedIsmail02 authored Oct 22, 2024
2 parents 9e24b0f + a49c35b commit bdc4b61
Show file tree
Hide file tree
Showing 50 changed files with 275 additions and 6,503 deletions.
2 changes: 1 addition & 1 deletion .github/third_party_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ team.
| Tool | Website | Getting Started |
|------|---------|-----------------|
| Code Sonar | [Link](https://codesecure.com/our-products/codesonar/) | [Link](https://github.com/CodeSecure-SE/FreeRTOS-Kernel/blob/main/examples/codesonar/README.md) |
| Coverity | [Link](https://www.synopsys.com/software-integrity/security-testing/static-analysis-sast.html) | [Link](../examples/coverity/README.md) |
| Coverity | [Link](https://www.blackduck.com/static-analysis-tools-sast/coverity.html) | [Link](../examples/coverity/README.md) |
2 changes: 1 addition & 1 deletion examples/coverity/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MISRA Compliance for FreeRTOS-Kernel
FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to
run [Synopsys Coverity](https://www.synopsys.com/software-integrity/security-testing/static-analysis-sast.html)
run [Synopsys Coverity](https://www.blackduck.com/static-analysis-tools-sast/coverity.html)
for checking MISRA compliance.

> **Note**
Expand Down
215 changes: 156 additions & 59 deletions include/mpu_prototypes.h

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion include/mpu_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
/* Privileged only wrappers for Task APIs. These are needed so that
* the application can use opaque handles maintained in mpu_wrappers.c
* with all the APIs. */
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )

/* These are not needed in v2 because they do not take a task
* handle and therefore, no lookup is needed. Needed in v1 because
* these are available as system calls in v1. */
#define vTaskGetRunTimeStatistics MPU_vTaskGetRunTimeStatistics
#define vTaskListTasks MPU_vTaskListTasks
#define vTaskSuspendAll MPU_vTaskSuspendAll
#define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
#define xTaskResumeAll MPU_xTaskResumeAll
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */

#define xTaskCreate MPU_xTaskCreate
#define xTaskCreateStatic MPU_xTaskCreateStatic
#define vTaskDelete MPU_vTaskDelete
Expand Down Expand Up @@ -165,11 +177,14 @@
#define xTimerGetPeriod MPU_xTimerGetPeriod
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime

#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */

/* Privileged only wrappers for Timer APIs. These are needed so that
* the application can use opaque handles maintained in mpu_wrappers.c
* with all the APIs. */
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
#define xTimerCreate MPU_xTimerCreate
#define xTimerCreateStatic MPU_xTimerCreateStatic
#define xTimerGetStaticBuffer MPU_xTimerGetStaticBuffer
Expand Down
8 changes: 8 additions & 0 deletions include/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
#define portARCH_NAME NULL
#endif

#ifndef portBASE_TYPE_ENTER_CRITICAL
#define portBASE_TYPE_ENTER_CRITICAL() taskENTER_CRITICAL()
#endif

#ifndef portBASE_TYPE_EXIT_CRITICAL
#define portBASE_TYPE_EXIT_CRITICAL() taskEXIT_CRITICAL()
#endif

#ifndef configSTACK_DEPTH_TYPE
#define configSTACK_DEPTH_TYPE StackType_t
#endif
Expand Down
5 changes: 0 additions & 5 deletions portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@
#define portDONT_DISCARD __root
/*-----------------------------------------------------------*/

#if ( configTOTAL_MPU_REGIONS == 16 )
#error 16 MPU regions are not yet supported for this port.
#endif
/*-----------------------------------------------------------*/

/* ARMv8-M common port configurations. */
#include "portmacrocommon.h"
/*-----------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,11 @@
#include "portmacrocommon.h"
/*-----------------------------------------------------------*/

#if ( configTOTAL_MPU_REGIONS == 16 )
#error 16 MPU regions are not yet supported for this port.
#endif

#ifndef configENABLE_MVE
#define configENABLE_MVE 0
#elif( configENABLE_MVE != 0 )
#error configENABLE_MVE must be left undefined, or defined to 0 for the Cortex-M33.
#endif

/*-----------------------------------------------------------*/

/**
Expand Down
4 changes: 0 additions & 4 deletions portable/ARMv8M/non_secure/portable/IAR/ARM_CM35P/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
#include "portmacrocommon.h"
/*-----------------------------------------------------------*/

#if ( configTOTAL_MPU_REGIONS == 16 )
#error 16 MPU regions are not yet supported for this port.
#endif

#ifndef configENABLE_MVE
#define configENABLE_MVE 0
#elif( configENABLE_MVE != 0 )
Expand Down
5 changes: 0 additions & 5 deletions portable/ARMv8M/non_secure/portable/IAR/ARM_CM55/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
#include "portmacrocommon.h"
/*-----------------------------------------------------------*/

#if ( configTOTAL_MPU_REGIONS == 16 )
#error 16 MPU regions are not yet supported for this port.
#endif
/*-----------------------------------------------------------*/

/**
* @brief Critical section management.
*/
Expand Down
5 changes: 0 additions & 5 deletions portable/ARMv8M/non_secure/portable/IAR/ARM_CM85/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
#include "portmacrocommon.h"
/*-----------------------------------------------------------*/

#if ( configTOTAL_MPU_REGIONS == 16 )
#error 16 MPU regions are not yet supported for this port.
#endif
/*-----------------------------------------------------------*/

/**
* @brief Critical section management.
*/
Expand Down
14 changes: 8 additions & 6 deletions portable/Common/mpu_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,44 +508,46 @@
/*-----------------------------------------------------------*/

#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
void MPU_vTaskList( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
void MPU_vTaskListTasks( char * pcWriteBuffer,
size_t uxBufferLength ) /* FREERTOS_SYSTEM_CALL */
{
if( portIS_PRIVILEGED() == pdFALSE )
{
portRAISE_PRIVILEGE();
portMEMORY_BARRIER();

vTaskList( pcWriteBuffer );
vTaskListTasks( pcWriteBuffer, uxBufferLength );
portMEMORY_BARRIER();

portRESET_PRIVILEGE();
portMEMORY_BARRIER();
}
else
{
vTaskList( pcWriteBuffer );
vTaskListTasks( pcWriteBuffer, uxBufferLength );
}
}
#endif /* if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
void MPU_vTaskGetRunTimeStatistics( char * pcWriteBuffer,
size_t uxBufferLength ) /* FREERTOS_SYSTEM_CALL */
{
if( portIS_PRIVILEGED() == pdFALSE )
{
portRAISE_PRIVILEGE();
portMEMORY_BARRIER();

vTaskGetRunTimeStats( pcWriteBuffer );
vTaskGetRunTimeStatistics( pcWriteBuffer, uxBufferLength );
portMEMORY_BARRIER();

portRESET_PRIVILEGE();
portMEMORY_BARRIER();
}
else
{
vTaskGetRunTimeStats( pcWriteBuffer );
vTaskGetRunTimeStatistics( pcWriteBuffer, uxBufferLength );
}
}
#endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
Expand Down
12 changes: 5 additions & 7 deletions portable/GCC/ARM_CM3/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ static void prvTaskExitError( void )
void vPortSVCHandler( void )
{
__asm volatile (
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
" ldr r3, =pxCurrentTCB \n" /* Restore the context. */
" ldr r1, [r3] \n" /* Get the pxCurrentTCB address. */
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
" ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
" msr psp, r0 \n" /* Restore the task stack pointer. */
Expand All @@ -239,8 +239,7 @@ void vPortSVCHandler( void )
" orr r14, #0xd \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
" .ltorg \n"
);
}
/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -462,7 +461,7 @@ void xPortPendSVHandler( void )
" mrs r0, psp \n"
" isb \n"
" \n"
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
" ldr r2, [r3] \n"
" \n"
" stmdb r0!, {r4-r11} \n" /* Save the remaining registers. */
Expand All @@ -483,8 +482,7 @@ void xPortPendSVHandler( void )
" isb \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst: .word pxCurrentTCB \n"
" .ltorg \n"
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}
Expand Down
16 changes: 5 additions & 11 deletions portable/GCC/ARM_CM3_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static void prvRestoreContextOfFirstTask( void )
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
" \n"
/*------------ Program MPU. ------------ */
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
" \n"
Expand All @@ -716,7 +716,7 @@ static void prvRestoreContextOfFirstTask( void )
" dsb \n" /* Force memory writes before continuing. */
" \n"
/*---------- Restore Context. ---------- */
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
" \n"
Expand All @@ -732,8 +732,6 @@ static void prvRestoreContextOfFirstTask( void )
" bx lr \n"
" \n"
" .ltorg \n" /* Assemble current literal pool to avoid offset-out-of-bound errors with lto. */
" .align 4 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
);
}
/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -988,7 +986,7 @@ void xPortPendSVHandler( void )

__asm volatile
(
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
" ldr r1, [r2] \n" /* r1 = Location where the context should be saved. */
" \n"
Expand All @@ -1012,7 +1010,7 @@ void xPortPendSVHandler( void )
" msr basepri, r0 \n"
" \n"
/*------------ Program MPU. ------------ */
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
" \n"
Expand All @@ -1033,7 +1031,7 @@ void xPortPendSVHandler( void )
" dsb \n" /* Force memory writes before continuing. */
" \n"
/*---------- Restore Context. ---------- */
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
" \n"
Expand All @@ -1047,8 +1045,6 @@ void xPortPendSVHandler( void )
" bx lr \n"
" \n"
" .ltorg \n" /* Assemble current literal pool to avoid offset-out-of-bound errors with lto. */
" .align 4 \n"
"pxCurrentTCBConst: .word pxCurrentTCB \n"
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}
Expand Down Expand Up @@ -1207,8 +1203,6 @@ BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */
" movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */
" moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */
" bx lr \n" /* Return. */
" \n"
" .align 4 \n"
::: "r0", "memory"
);
}
Expand Down
12 changes: 5 additions & 7 deletions portable/GCC/ARM_CM4F/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ static void prvTaskExitError( void )
void vPortSVCHandler( void )
{
__asm volatile (
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
" ldr r3, =pxCurrentTCB \n" /* Restore the context. */
" ldr r1, [r3] \n" /* Get the pxCurrentTCB address. */
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
" ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
" msr psp, r0 \n" /* Restore the task stack pointer. */
Expand All @@ -270,8 +270,7 @@ void vPortSVCHandler( void )
" msr basepri, r0 \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
" .ltorg \n"
);
}
/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -511,7 +510,7 @@ void xPortPendSVHandler( void )
" mrs r0, psp \n"
" isb \n"
" \n"
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
" ldr r2, [r3] \n"
" \n"
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
Expand Down Expand Up @@ -552,8 +551,7 @@ void xPortPendSVHandler( void )
" \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst: .word pxCurrentTCB \n"
" .ltorg \n"
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}
Expand Down
Loading

0 comments on commit bdc4b61

Please sign in to comment.