Commit Graph

442 Commits (main)

Author SHA1 Message Date
superroc 190906aeaf
Add portMEMORY_BARRIER defination to fix over-optimization in xTaskResumeAll. (#1116)
Co-authored-by: owen <owen@freqchip.com>
6 months ago
Trong Nguyen da3c35aa48
Add CC-RH port for Renesas F1Kx devices (#1100)
Add CC-RH port for Renesas F1Kx devices
6 months ago
Rahul Kar c963d24001
Add support for vApplicationFPUSafeIRQHandler (#1113)
This PR adds support for vApplicationFPUSafeIRQHandler. The application
writer needs to name their IRQ handler as:
1. vApplicationIRQHandler if the IRQ handler does not use FPU registers.
2. vApplicationFPUSafeIRQHandler is the IRQ handler uses FPU registers.

When the application uses vApplicationFPUSafeIRQHandler, a default
implementation of vApplicationIRQHandler is used which stores FPU
registers and then calls vApplicationFPUSafeIRQHandler.
6 months ago
Rahul Kar 3d935e86d9
Update broken links in readme and comments (#1110)
Update broken links in readme and comments
6 months ago
Gaurav-Aggarwal-AWS d844312131
Fix POSIX port to respect configUSE_TIME_SLICING (#1103)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
6 months ago
Rahul Kar 5588ae68c8
Update ARM_CRx_No_GIC port (#1101)
This PR makes the following improvements to the ARM_CRx_No_GIC port-

1. Remove inline assembly and move all the assembly code to the portASM.S
    file.

2. Add support for configUSE_TASK_FPU_SUPPORT -
   - When configUSE_TASK_FPU_SUPPORT is defined to 1, tasks are created
      without floating point context. Tasks that want to use floating point, need
      to call portTASK_USES_FLOATING_POINT(). This is the current behavior.
   - When configUSE_TASK_FPU_SUPPORT is defined to 2, each task is created
      with a floating point context.
  If left undefined, configUSE_TASK_FPU_SUPPORT defaults to 1 for backward compatibility.

3. The application writer can now implement vApplicationSVCHandler to handle the
    SVC calls raised within the application. SVC 0 is used for the yield kernel operation
    and the application can use all the SVC calls other than 0.

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
6 months ago
Florian La Roche f4f2e1596b
Fix gcc warning in posix port (#1098)
Fix warning from "gcc -Wsign-compare" in the file
portable/ThirdParty/GCC/Posix/port.c since PTHREAD_STACK_MIN
is used from system headers.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
7 months ago
Florian La Roche 646881e7f9
fix typo gab -> gap and adjust indentation level (#1097)
Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
7 months ago
Angel Cascarino 17dfd0f808
Update XMOS xcore.ai port to be compatible with v11.x (#1096)
* Fix kexcept function

* Create dummy pxCurrentTCBs for xcore.ai port

* Additional commentary

* Add a layer of indirection to cope with singlecore

* Clarify use of _DoException
7 months ago
Eric Dawe 9e838293c2
Update README.md (#1094)
Fix spelling of the word 'the' ('thw') in line 29
7 months ago
Ahmed Ismail 31419bfcee
FreeRTOS MPU: Add Privileged eXecute Never MPU attribute support (#1092)
FreeRTOS MPU: Add privileged execute never MPU attribute

A new MPU region attribute Privileged eXecute Never (PXN)
is introduced in Armv8.1-M architecture, where if an MPU
region has PXN attribute set and the processor attempts
to execute the code inside with privileged level,
the Memory Management Fault exception would be triggered,
with IACCVIOL bit in MemManage Fault State Register set
to 1. The PXN feature allows privileged software to ensure
specific application tasks (threads) to execute in
unprivileged level only.

Signed-off-by: Ahmed Ismail <Ahmed.Ismail@arm.com>
8 months ago
耀眼的大神 76eb443821
Fix traceMALLOC() allocated bytes (#1089)
* Fix traceMALLOC() memory count is inaccurate. (#1078)

Modify xWantedSize to the size of a free block when not split blocks.

Ensure that the sizes within traceMALLOC() and traceFREE() macros are equal.

* Create a new variable xAllocatedBlockSize for traceMALLOC()

---------

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
8 months ago
haydenridd 28b6a141ea
- Changed macro __VFP_FP__ to __ARM_FP for ports GCC/ARM_CM7, GCC/ARM_CM4_MPU, and GCC/ARM_CM4F to accurately reflect if floating point hardware support is enabled (#1088)
Co-authored-by: Hayden Riddiford <hayden@terrakaffe.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
8 months ago
maxiao bee9037c46
Fix compilation warning about undelcared pthread_setname_np (#1079)
Use _GNU_SOURCE macro instead of __USE_GNU and define it before
including portmacro.h. The reason is that portmacro.h includes limits.h
which in-turn includes features.h - this results in __USE_GNU getting
incorrectly undefined.
8 months ago
Florian La Roche c431b358c8
event_create(): check malloc() return value to be non-NULL (#1084)
* event_create(): check malloc() to be non-NULL

Check malloc() to return non-NULL before writing data
in the function event_create().

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>

* Code review suggestion

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
8 months ago
Ethan Slattery 65e6297b68 Add missing Extern "C" to MSVC portmacro.h 8 months ago
wdfk-prog 9f22177c02
Readability enhancements in heap_1.c (#1074)
* Remove  that Heap_1.c unnecessary judgment and code logic

* Remove useless alignment calculations and increase heap usage size

* Revert "Remove useless alignment calculations and increase heap usage size"

This reverts commit 7832a4bc11.

* Readability improvements

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: huangly <huangly@milesight.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
8 months ago
Rahul Kar 0801c91bc6
Add Noreturn attribute in template port for static analysis (#1060)
* Add _Noreturn attribute in the template function to fix MISRA 17.11 advisory warnings

* Add _Noreturn attribute in function declaration

* Code review suggestions
9 months ago
Gaurav-Aggarwal-AWS 2e0c623351
Fix race in prvProcessSimulatedInterrupts (#1055)
Earlier the code was suspending the current thread after calling
vTaskSwitchContext. This left a gap where the current thread could
access incorrect pxCurrentTCB after it was changed by
vTaskSwitchContext.

This commit addresses the problem by suspending the current thread
before calling vTaskSwitchContext.

It was reported here - https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/1054.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
9 months ago
StefanBalt 55eceb2203
Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (#1048)
* Add configUSE_TASK_FPU_SUPPORT to AARCH64 port

NEON SIMD is required by standard AARCH64 and its registers are
frequently utilized by standard functions such as memcpy().
This means that even simple tasks that do not use any floating point
arithmetics may still alter the contents of the FPU registers.

For this reason it makes sense to add support for
configUSE_TASK_FPU_SUPPORT to be able to enforce FPU register saving and
restoring globally.

The implementation was largely adopted from the ARM_CA9 port. However,
the FPU registers must be placed on the stack before the critical
nesting count to match the AARCH64 portASM.S.
9 months ago
chinglee-iot 067d04e44e
Add vPortGenerateSimulatedInterruptFromWindowsThread in MSVC port (#1044)
Add vPortGenerateSimulatedInterruptFromWindowsThread  in MSVC port
to enable native windows threads to notify FreeRTOS tasks.
9 months ago
Gaurav-Aggarwal-AWS 78c8bbde0e
Update xPortRunning before resuming first task (#1049)
The variable `xPortRunning` is now updated before starting the first
task.

It fixes the following issue -
https://forums.freertos.org/t/possible-bug-in-the-way-prvtimertask-thread-function-is-started-in-win32-port/19959/

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
9 months ago
0mhu 30afc1a2c0
Fix wrong source file list in CMake of GCC_ARM_CM0 port. (#1045)
Add GCC/ARM_CM0/mpu_wrappers_v2_asm.c and GCC/ARM_CM0/portasm.c as source files to 'freertos_kernel_port' library.
This fixes the FREERTOS_PORT "GCC_ARM_CM0" CMake configuration.
9 months ago
chinglee-iot c02a347880
Use suffix "U" for unsigned constant (#1041)
* Fix the constant suffix to U

* Fix more unsigned contant suffix

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal>
10 months ago
chinglee-iot 2a014ce0b3
Update submodule pointer (#1040) 10 months ago
Devaraj Ranganna 8d280217cd
armv8-m: Remove redundant constant pools (#1035)
Currently in Armv8-M GCC/ArmClang ports, constant pool is used to
define literals needed for `ldr` instructions. However, those
constant pools are defined with `.align 4` which increases code size.
Instead of defining the constant pool with `.align 4`, let the
compiler hanlde the constant pool and the required alignment.

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
10 months ago
Rahul Kar bbc058967b
Fix cmake example errors (#1037)
Add typecasts to prevent compiler warnings. Remove ULL suffix to adhere
to C90.
10 months ago
Devaraj Ranganna e143832ad4
tf-m: Update tf-m to TF-Mv2.0.0 release (#1038)
The `portable/ThirdParty/GCC/ARM_TFM/README.md` and
`portable/ThirdParty/GCC/ARM_TFM/os_wrapper_freertos.c` are updated to
support `TF-Mv2.0.0` of trusted-firmware-m release.

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
10 months ago
Caleb Perkinson f69b1db45c
Add Stream Batching Buffer (#916)
The difference between a stream buffer and a stream batching buffer is when
a task performs read on a non-empty buffer:
- The task reading from a non-empty stream buffer returns immediately
   regardless of the amount of data in the buffer.
- The task reading from a non-empty steam batching buffer blocks until the
   amount of data in the buffer exceeds the trigger level or the block time
   expires.
10 months ago
Rahul Kar 5a72344c9a
Add MPU wrapper from xStreamBufferResetFromISR (#1034)
* Add MPU wrapper from xStreamBufferResetFromISR in V10.6.x

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
10 months ago
Soren Ptak 6de0d7a737
Fix the pxTopcOfStack typo in the RISC-V ports. (#1030)
* Fix the pxTopcOfStack typo in the RISC-V ports.

* Add a missing o to to
10 months ago
Florian La Roche 6270e2aebf
Update the memory alignment within the Cortex-R5 port asm code (#1023)
Update alignment in ARM_CR5 port.

This is the same patch as 553caa18ce
provided by Richard Barry for issue #426 (ARM_CA9).

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
10 months ago
Rahul Kar f0ff3834bc
Fix spelling in comment (#1024)
Co-authored-by: ActoryOu <jay2002824@gmail.com>
10 months ago
Florian La Roche 8afb3a5b82
fix typos in comments: interace -> interface, swtich -> switch (#1022)
Fix typos in comments: interace -> interface, swtich -> switch.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
10 months ago
Kody Stribrny 8c49c54987
Fix TFM about link (#1021)
This page does not look to
exist anymore which is
failing our link verifier
check.
10 months ago
Rahul Kar e8289dfee6
Add config option for event groups and stream buffers (#994)
* Add configUSE_EVENT_GROUPS in source files

* Add configUSE_EVENT_GROUPS macro in MPU wrapper files

* Add configUSE_EVENT_GROUPS macro in MPU port files for GCC and RVDS compilers

* Fix Formatting

* Add configUSE_STREAM_BUFFERS in source files

* Add configUSE_STREAM_BUFFERS  macro in MPU wrapper files

* Add configUSE_STREAM_BUFFERS macro in MPU port files for GCC and RVDS compilers

* Update FreeRTOS.h post latest commit

* Update the ARM_CRx_MPU Port to account for the new configuration changes

* Formatting suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

* Code review suggestions

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: joshzarr <joshzarr@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
10 months ago
Rahul Kar 39dbff7204
Allow xPortIsAuthorizedToAccessBuffer() API call only from mpu_wrappers_v2 (#992)
* Add support to call xPortxPortIsAuthorizedToAccessBuffer function only when using latest MPU wrappers

* Fix build issue in ARM CM3 MPU port

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
10 months ago
Soren Ptak a455b86bd3
Add removed unprivileged access check to ARM_CRx_MPU xPortIsAuthorizedToAccessBuffer() (#1016)
* Add in a removed check for if a task is attempting to read a variable from a location it has write access to in xPortIsAuthorizedToAccessBuffer.

* Add in a portDONT_DISCARD symbol as well.
10 months ago
Soren Ptak 345a86d49b
ARM CM0+ MPU Port (#1005)
* Add MPU Support to the ARM CM0+ GCC Port.
* Co-authored by @aggarg
10 months ago
Soren Ptak 625b24a104
Remove duplicate pop from MPU Wrappers ASM Files (#1008)
* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/mpu_wrappers_v2_asm.S

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/mpu_wrappers_v2_asm.S

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/mpu_wrappers_v2_asm.S

* Remove duplicate pop instruction from portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/mpu_wrappers_v2_asm.S

* Run the copy_files.py script to update the ARMv8M ports to remove the duplicate pop instruction in mpu_wrappers_v2_asm

* Remove duplicate pop instruction from portable/GCC/ARM_CM3_MPU/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/GCC/ARM_CM4_MPU/mpu_wrappers_v2_asm.c

* Remove duplicate pop instruction from portable/IAR/ARM_CM4F_MPU/mpu_wrappers_v2_asm.S

* Remove duplicate pop instruction from portable/RVDS/ARM_CM4_MPU/mpu_wrappers_v2_asm.c

---------

Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
11 months ago
wat 6dcce92490
Improvement for 64bit Windows port (#1011)
* 64bit TickType_t is supported on Windows port.(MSVC and MinGW)
Especially it is introduced for 64bit compiler.(x64 platform on MSVC and MinGW-w64)

* Unnecessary compiler warning for the cast operation is disabled locally.(MinGW-w64 only)

* Modify the condition for ignoring compiler warning for the cast operation.

Before modification: Compiler warning was ignored only on MinGW64
After modification: Compiler warning is ignored on MinGW32 and MinGW64
Reason of modification: The cast warning here is unavoidable not only on MinGW64 but also on MinGW32.
"__GNUC__" macro is used because MSVC does not recognize this #pragma directive.
11 months ago
chinglee-iot d95451d924
Define portNOP in RP2040 port (#1003) 11 months ago
Soren Ptak 61111b1460
Add ARMv7-R MPU Port (#938)
* Apply git review patch created by @aggargr
* Add necessary changes to the CMakeLists.txt file to build the port
11 months ago
Soren Ptak 839ccb719b
Use Regex for Copyright Year in Header Check (#1002) 11 months ago
Aniruddha Kanhere 2fcb0f48b1
Fix small bugs in Kernel (#998)
* Fix small bugs

* Cast sizeof to BaseType_t

* Test removing assert to fix UT

* Revert change to tasks.c

Since configIDLE_TASK_NAME must be defined as a string according to
the documentation, the macro will always be NULL terminated. Which
means that the check `if( cIdleName[ xIdleTaskNameIndex ] == ( char ) 0x00 )`
will catch the end of string.

* Update coverity config; Add coverity version; Update pvPortMalloc declaration to match the definitions.

* Add port files to sed command

* Remove warnings about unused parameters in port code

---------

Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
12 months ago
chinglee-iot 1a500f1a74
Support reset kernel state for restarting scheduler (#944)
* Adding the following functions to reset kernel state. These functions are only required for application which 
needs to restart the scheduler.
 - void vTaskResetState( void )
 - void vTimerResetState( void )
 - void vPortHeapResetState( void )
 - void vCoRoutineResetState( void )

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Chris Morgan <cmorgan@boston-engineering.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
12 months ago
Paul Bartell 23afc48fc3
Update version number (#983)
* Update version number to 11.0.1+ in task.h

* Update Third Party Port version to <DEVELOPMENT BRANCH>

* Update version to 11.0.1 in manifest.yml
12 months ago
Eric Jackson 938ec0f7bf
Correct ARM port folder capitalization (#981)
* Rename Arm_AARCH64 to ARM_AARCH64

* Rename Arm_AARCH64_SRE to ARM_AARCH64_SRE

* Update cmake for ARM port folder capitalization

* Update in portable/CmakeLists.txt
* Use capitalization name in port README.md

---------

Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
1 year ago
bradleysmith23 1065389c4e
Fix MISRA C 2012 Rule 10.4 Violations (#972)
Fixes for violations of MISRA rule 10.4
1 year ago
bradleysmith23 1189198a5e
Fix MISRA C 2012 Rule 20.7 Violations (#971)
* Initial set of SA fixes

* Revert function parameter name changes

* Reverted parameter name for Static version of function by mistake

* Update mpu_wrappers_v2.c to only include 20.7 fixes

* Update queue.c to remove non-20.7 fixes

* Update tasks.c to remove non-20.7 fixes

---------

Co-authored-by: bjbsmith <bjbsmith@uafeb6a6bcdce55.ant.amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
Rahul Kar b4da9e301f
Fix MISRA directive 4.7 warning (#977) 1 year ago
bradleysmith23 d94db2d11d
Fix MISRA C 2012 Rule 10.3 Violations (#974)
* Resolve violations for MISRA Rule 10.3-b2

* Formatting fix

---------

Co-authored-by: bjbsmith <bjbsmith@uafeb6a6bcdce55.ant.amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
bradleysmith23 cd8c6c1f22
Fix MISRA C 2012 Rule 9.3 violations (#973)
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
bradleysmith23 edd35e8f6e
Fix MISRA Rule 10.1 violations (#976)
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
chinglee-iot 1de764ba87
Delete kernel created task in vTaskEndScheduler (#962)
* Update vTaskDelete() to delete a task directly when scheduler is stopped instead of putting it on the xTasksWaitingTermination list.
* Delete the idle tasks and timer task in vTaskEndScheduler().
* Reclaim resources for all the tasks on the xTasksWaitingTermination list in vTaskEndScheduler().
* Update POSIX to no longer delete FreeRTOS tasks in the port.

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
barnatahmed c565fd45c1
Cmake: Create a single static library including port
Modify portable/CMakeLists.txt to create only one static library containing both the common kernel code and kernel port.

Change the freertos_kernel_port target from a STATIC library to an OBJECT library and introduce a new freertos_kernel_port_headers  INTERFACE library target.

---------

Co-authored-by: ABARNAT <ahmed.barnat@actia-engineering.tn>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Phillip Stevens 8622bd5f49
Fix ThirdParty/GCC/ATmega formatting (#965)
Unnecessary white space was introduced in PR #768
which affected the formatting of assembly code. This PR
returns the correct formatting. No functional change.
1 year ago
Gaurav-Aggarwal-AWS 04cb022e44
Add a check for configENABLE_MVE to M23, M33 ports (#968)
Add a check for configENABLE_MVE to M23, M33 ports

configENABLE_MVE is only applicable to Cortex-M55 and Cortex-M85 ports.
It must not be defined to 1 for other ARMv8_m ports.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Gaurav-Aggarwal-AWS 5a2237a1e2
Remove configTOTAL_MPU_REGIONS from M3 MPU port (#966)
The number of MPU regions is not configurable for Cortex-M3 port and
therefore, it is misleading to have configTOTAL_MPU_REGIONS in
portmacro.h.

It was added in PR #952.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
José Simões 722596eaae
Add code to allow building for x64 in MSVC (#924)
* Add code to allow building for x64 in MSVC

- Add code for x64 arch.
- Add initial value for local otherwise it won't get proper value in x64.

* Moving init local to portGET_HIGHEST_PRIORITY

- From code review.

* More changes following review

* Another style fix from review

* Update formatting

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Forty-Bot 1860c9ad09
GCC: MSP430F449: Fix pxPortInitialiseStack on EABI (#947)
According to the MSP430 EABI [1] section 3.3,

Arguments are assigned, in declared order, to the first available
register single, pair, or quad from the following list into which it
fits (with the following special exceptions). For MSP430 and
MSP430X, the argument registers are: R12, R13, R14, R15

Therefore, pvParameters should be passed in R12, as it is the first
argument, not R15. Keep passing the parameter in R15 for the
MSP430 EABI, if anyone is still using it.

[1] https://www.ti.com/lit/an/slaa534a/slaa534a.pdf
1 year ago
Soren Ptak b1ee2e6e14
Fix MacOS Posix port (#957)
PR #914 caused Posix Port to fail to build on MacOS. This PR fixes
teh build failure.

This PR also adds a Matrix configuration to the GitHub kernel-demo
workflow to build the Posix Demos on MacOS.
---------

Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Phillip Stevens 14dd5b503a
use configSTACK_DEPTH_TYPE consequently (updated for 11.0.x) (#942)
* use configSTACK_DEPTH_TYPE consequently

* update default to uint32_t

* Update FreeRTOS.h

Revert for backwards compatibility

* Update portable.h

* configSTACK_DEPTH_TYPE - unify stack variable naming

* update lexicon.txt

* update typo lexicon.txt

* Update task.h

* Update timers.h

* fix merge typo

* fix stack type

* fix timer stack type

* fix timer stack more

* fix affinity set stack

* adjust ports to use configSTACK_DEPTH_TYPE

* fix vTaskListTasks

* set default stack depth type in portable.h

* fix History.txt

* update affinityset

* resolve reviewer comments

* fix prvTaskCheckFreeStackSpace for variable stack size type

* restore CoRoutine defines

* remove obsolete stack ttype casts

* fix (attempt) for format portable.h

* Formatting fixes

* prvTaskCheckFreeStackSpace make variable naming compliant

* Update portable/GCC/ARM_CM33/non_secure/port.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Update portable/GCC/ARM_CM23/non_secure/port.c

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Apply suggestions from code review

Update ulStackDepth to uxStackDepth

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

* Correct uxStackDepth in port.c

Also add uint32_t cast prvGetMPURegionSizeSetting.

* Update ARM CM3 MPU port.c

Revert casting of ( uint32_t ) pxBottomOfStack

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Mubin Sayyed 5040a67939
Sync up MicroblazeV9 port with Xilinx tree (#220)
* MicroblazeV9: Add support for 64 bit microblaze
* MicroblazeV9: Add support for generation of run time task stats
* MicroblazeV9: Add default implementation for callback functions
---------
Signed-off-by: Mubin Usman Sayyed <mubin.usman.sayyed@xilinx.com>
1 year ago
Soren Ptak 8e664fc984
Add check for if the scheduler is running to ARMv8M MPU ports (#960)
* Allow access to any buffer in xPortIsAuthorizedToAccessBuffer if xSchedulerRunning is set to pdFALSE

* Allow access to any buffer in xPortIsAuthorizedToAccessBuffer if xSchedulerRunning is set to pdFALSE in the copied ARMv8M Port Files
1 year ago
Soren Ptak 4d9f6522e5
Add check for if the scheduler is running to MPU ports (#954)
* In the ARM_CM3_MPU and ARM_CM4_MPU Port function xPortIsAuthorizedToAccessBuffer() grant access to the buffer if xSchedulerRunning is false.
1 year ago
Mikhail Paulyshka e6f6d0ecf4
Posix port - set name for threads (#950)
Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
1 year ago
IsaacDynamo 52ab3d0f22
MPU assert for ARM_CM3_MPU (#952)
* Add runtime check to see if the target even has a MPU

* Add missing extern symbols for __ARMCC_VERSION support

* Add default for configTOTAL_MPU_REGIONS and change a runtime assert to compile time error

* Simplify check and link to reference documentation

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>

---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
1 year ago
IsaacDynamo c083af972a
Add mpu_wrappers_v2_asm.c to MPU ports (#951)
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
Tony Josi c053ffeacc
Fix -Werror=unused-parameter in GCC posix prvTimerTickHandler() (#949) 1 year ago
Chris Morgan 3baa3dd98b POSIX port - Switch from allowing the user to specify the stack memory itself, to allowing them to specify the stack size
Change from pthread_attr_setstack() to pthread_attr_setstacksize(), and automatically adjust the stack size
to be at least PTHREAD_STACK_MIN if it wasn't already, removing the size warning.

This permits the user to increase the pthread stack size beyond the PTHREAD_STACK_MIN default of 16384 if
desired, without producing a warning in the typical case where stacks are minimized for RAM limited targets.

Continue to store thread paramters on the provided stack, for consistency with the MCU targets.

Previously pthread_attr_setstack() was used to enable user defined stacks.

Note that:

1. The stack size can still be specified by the user.

2. pxPortInitialiseStack(), and pthread_addr_setstack() was failing on stacks of typical size, as
   these are smaller than PTHREAD_STACK_MIN (16384) bytes, and printing out a series of warnings.
   Improve usability by having the posix port automatically increase the stack size to be
   at least PTHREAD_STACK_MIN as posix platforms have enough memory for this not to be a concern.

3. Reuse of stack memory will also result in valgrind 'invalid write' errors to what is demonstrably
   valid memory. Root cause is that Valgrind is tracking a stack pointer as the stack is used.
   Reuse of a stack buffer results in the stack being used at its start, in an area that Valgrind thinks
   is far away from the start of the stack. There are ways to notify Valgrind of these changes
   however this would require linking against and calling Valgrind functions from the FreeRTOS application using
   the posix port, https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq.

   Also, apparently it isn't permitted by posix to reuse stack memory once its been used in a pthread via pthread_attr_setstack(),
   see https://stackoverflow.com/a/5422134
1 year ago
Ching-Hsin Lee 62220666ba Revert pthread_attr_setstacksize 1 year ago
Ching-Hsin,Lee b6c0c51cbe Revert timer tick function 1 year ago
Ching-Hsin,Lee 5ed9c7022b Add back event signal 1 year ago
Ching-Hsin,Lee 14903c380e Remove redundent cancellation point 1 year ago
Ching-Hsin,Lee a7d39c3e3a format and header file 1 year ago
Ching-Hsin,Lee 0fac0859af Add back heap setup code 1 year ago
Ching-Hsin,Lee 3dade5b5a5 UPdate format 1 year ago
Ching-Hsin Lee 7ba4124c78 Add back the pthread stack fit 1 year ago
Ching-Hsin,Lee 6b698ff6bc Fix potential race condition 1 year ago
Chris Morgan 88d3540b54 POSIX port - Cancel and join all FreeRTOS managed pthreads upon shutdown
For a clean shutdown where memory is freed, it is necessary for all pthreads to be joined
at shutdown.

Previously there was explicit cancellation of the idle task and timer daemon task, however
there may be a number of other tasks in the system, both system created and user created,
and those tasks/threads were being left at shutdown.

This change calls pthread_cancel()/pthread_join() on all FreeRTOS managed pthreads upon
shutdown.
1 year ago
Chris Morgan ddc89fa985 POSIX - Switch from posix timers to a timer thread to fix signal handling with non-FreeRTOS pthreads
Improve upon the elegant approach of using signals to cause task/pthreads
suspension and scheduler execution by using directed signals.

This fixes:
- Deadlocks in non-FreeRTOS pthreads
- Multiple FreeRTOS tasks(pthreads) incorrectly running at the same time

By directing the signals using pthread_kill() the signal handler in the presently running
FreeRTOS task/pthread will be called, ensuring that the scheduler runs both in the context
of a FreeRTOS task/pthread and from the presently executing FreeRTOS task/pthread.

Details
==============

The POSIX port uses signals to preempt FreeRTOS tasks (implemented as pthreads), a very neat and elegant
approach to forcing tasks/pthreads to suspend and run the scheduler.

Signal handlers are process global.

Posix timers generate signals when the timer expires, and the signal is sent to the currently
running pthread.

In systems where there are pthreads that are NOT a result of creating FreeRTOS tasks, such as the
entry point thread that calls main(), or user created pthreads, this poses a serious issue.

While the POSIX port only allows a single FreeRTOS pthread to run at once, by causing all suspended
threads to not be scheduled due to their waiting on a pthread condition variable,
this isn't the case with non-FreeRTOS pthreads.

Thus it is possible that a non-FreeRTOS pthread is running when the timer expires and the signal
is generated. This results in the signal handler running in the non-FreeRTOS thread.

The sequence of events results in these events from signal handler context:
- vPortSystemTickHandler() being called
- The scheduler running
- Selecting another FreeRTOS task to run and switching the active task
- The newly selected task released from suspension by pthread_cond_signal()
- The presently active thread calling event_wait()
- The pthread calling pthread_cond_wait(), suspending the thread and allowing the host OS scheduler
  to schedule another thread to run.

If this occurs from a non-FreeRTOS thread this results in:
- The active FreeRTOS pthread (Task A/Thread A) continuing to run (as the signal handler that calls
  event_wait() ran instead in a non-FreeRTOS pthread.
- The pthread where the signal handler did run (Thread B) will call event_wait() and pthread_cond_wait(),
  but on the condition variable of the previously active FreeRTOS task, oops. This causes the
  non-FreeRTOS pthread to block unexpectedly relative to what the developer might have expected.
- The newly selected FreeRTOS Task (Task C/Thread C) will resume and start running.

At this point Task A/Thread A is running concurrently with Task C/Thread C. While this may not
necessarily be an issue, it does not replicate the expected behavior of a single Task running at
once.

Note that Thread B will resume if/when Task A/ThreadA is switched to. However, this could be delayed
by an arbitrary amount of time, or could never occur.

Also note that if there are multiple non-FreeRTOS pthreads that Thread D, E, F...etc could suffer the
same fate as Thread B, if the scheduler were to suspend Task C/Thread C and resume Task E/Thread E.

Implementation
==============

Timer details
-------------
A standalone pthread for the signal generation thread was chosen, rather than using
a posix timer_settime() handler function because the latter creates a temporary
pthread for each handler callback. This makes debugging much more difficult due to
gdb detecting the creation and destruction of these temporary threads.

Signal delivery
--------------
While signal handlers are per-thread, it is possible for pthreads to selectively block
signals, rather than using thread directed signals. However, the approach of blocking
signals in non-FreeRTOS pthreads adds complexity to each of these non-FreeRTOS pthreads
including ensuring that these signals are blocked at thread creation, prior to the thread
starting up. Directed signals removes the requirement for non-FreeRTOS pthreads to be aware
of and take action to protect against these signals, reducing complexity.
1 year ago
Soren Ptak 529de5606e
Revert #768 on the XCC/Xtensa portable files (#948) 1 year ago
chinglee-iot be880a1fc8
Fix portSET_INTERRUPT_MASK_FROM_ISR definition for atomic operation (#940)
* Introduce portHAS_NESTED_INTERRUPTS to identify if port has nested interrupt or not.
* Update atomic.h to use portHAS_NESTED_INTERRUPTS instead of portSET_INTERRUPT_MASK_FROM_ISR definition.

---------

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: ActoryOu <jay2002824@gmail.com>
1 year ago
dps.lwk 75c4044b7e
RP2040: Fix removal of idle_task_static_memory.c (#935)
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
1 year ago
Jeff Tenney 5544c78299
Fix build error for MSP430 and Cortex A with IAR (#937)
* fix whitespace in asm macros

* Revert formatting ARM_CA5_No_GIC and ARM_CA9
1 year ago
dps.lwk 93380c02a1
RP2040: FreeRTOS-Kernel-Static use configKERNEL_PROVIDED_STATIC_MEMORY (#934)
Remove the idle_task_static_memory.c and use the new default implementations
to allows for FreeRTOS-Kernel-Static to be used with configNUMBER_OF_CORES > 1
1 year ago
Forty-Bot ec93432a59
Fix build with modern GCC (#933)
* GCC: MSP430F449: Add missing attributes

Apparently at some point in the past, GCC (or TI's GCC) used to define
these attributes. Define them ourselves so that we can compile the demo
application.

* GCC: MSP430F449: Make interrupts return void

If a return type of a function is not specified, it defaults to int. Set
the return type of interrupts to void to avoid warnings.

* GCC: MSP430F449: Define portPOINTER_SIZE_TYPE

portPOINTER_SIZE_TYPE defaults to uint32_t if undefined. Define it to
uint16_t, which is correct for this port.
1 year ago
Jeff Tenney 30e6b8a5ea
Detect more startup config errors on Cortex M (#832)
Verify that the application has correctly installed PendSV
and SVCall handlers. The application can choose to
disable these checks by setting configCHECK_HANDLER_INSTALLATION
to 0 in their FreeRTOSConfig.h.
1 year ago
RichardBarry 553caa18ce
Update the memory alignment within the Cortex-A9 port asm code (#426)
Update alignment in ARM_CA9 port.
1 year ago
Soren Ptak ac7fc396a0
Revert Portable/BCC formatting (#828)
Revert Portable/BCC formatting
1 year ago
Soren Ptak bcf7bdaa13
Revert Portable/oWatcom formatting (#829)
Revert the formatting on oWatcom ports
1 year ago
Soren Ptak 0debe8c669
Revert Portable/Paradigm formatting (#830)
Revert the formatting on Paradigm ports
1 year ago
Soren Ptak db5df4bfde
Revert Portable/CodeWarrior formatting (#831)
Revert the formatting on CodeWarrior ports
1 year ago
chinglee-iot de2c0c1a95
Update partner and community supported port submodule pointer (#919) 1 year ago
chinglee-iot c0ce725293
Add SMP template port and example (#900)
* Add SMP template port and example
* Add readme file for smp configuration
* Update SMP build flow and add CI build

---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
1 year ago
Rahul Kar f8ef5f605b
Fix prototype of MPU_vTimerSetReloadMode (#913) 1 year ago
Legend 592bfe0e01
Fix typo in comment (#910)
Co-authored-by: Tony Josi <tonyjosi@amazon.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com>
1 year ago
Soren Ptak 6a9f5a244a
Add portMEMORY_BARRIER() to RX MCU ports (#864)
* Add portMEMORY_BARRIER() to RX MCU ports

* Remove the memory barrier from the SH2A_FPU portable directory

---------

Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
1 year ago
Soren Ptak 6a41432498
Upgrade msvc port to winsock2 (#895)
* Add the changes needed to the MSVC windows port to get it to build with winsock2.h
* Rely upon the WIN32_LEAN_AND_MEAN define to include winsock2.h
1 year ago