Commit Graph

3565 Commits (main)
 

Author SHA1 Message Date
chinglee-iot 97d48ba94a
Add more comment for core affinity in prvSelectHighestPriorityTask (#801)
* Add more comment for core affinity in prvSelectHighestPriorityTask

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

---------

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>
1 year ago
chinglee-iot 317bc0c89c
Move trace macro after declaration (#820)
* Move trace macro after declaration to comply with ISO C90
1 year ago
chinglee-iot 30e13dac2b
Implement prvYieldCore with macro (#785)
* Implement prvYieldCore with macro for performance and memory
* Remove the portCHECK_IF_IN_ISR macro check. It is not required in SMP
  now

Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
chinglee-iot 830533d49e
Add taskYIELD_WITHIN_API macro (#782)
Add taskYIELD_WITHIN_API macro for readability improvement.
1 year ago
Joseph Julicher 5cdb1bc4e1
removed the copyright and license header for select files (#815)
* removed the copyright and license header for files expected to be copied by users

* fixed a bug in the kernel checker.  temporarily restored the copyright in the sample config to allow this PR to pass the checks.

* Uncrustify: triggered by comment.

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Michael Fairman 57f9eed00d
bugfix: correct computation of stack size on Mac Posix port (#816)
Aligns the stack end to a page boundary before computing its
size, since the size depends on both the start and end.

The original change which introduced stack alignment (#674)
only worked for cases where the round + trunc operation would
wind up within the same area, but would lead to segfaults in
other cases.

Also adds a typecast to the `mach_vm_round_page()` call, as
it is actually a macro which casts to `mach_vm_offset_t` and
the result here is used as a `StackType_t` pointer.

Tested on ARM64 and Intel MacOS, as well as ARM64 and Intel
Linux.  The test code included a single-task case, as well
as a case with two tasks passing queue messages.
1 year ago
Joseph Julicher 5a9d7c8388
Sample FreeRTOSConfig.h and template port (#812)
* config file experiments

* adding a config file for an example

* Added a template port and updated the CMakeLists

* template and default configuration build

* finalising the sample FreeRTOSConfig.h header file

* removed .config hidden file

* further reductions in the template port

* Uncrustify: triggered by comment.

* Uncrustify: triggered by comment.

* minor readme updates

* fixed spelling error in HTTP

* fixed a type and added a link to the sample readme

* uncrustified FreeRTOSConfig.h

* Uncrustify: triggered by comment.

* Revert "Uncrustify: triggered by comment."

This reverts commit e534f46f2d.

* Revert "Revert "Uncrustify: triggered by comment.""

This reverts commit c9058dd383.

* excluding the FreeRTOSConfig.h from copyright+license check because this file is intended to be incorporated into user code

* Removed the copyright and license from the template files

* put license copy in the template and sample files

* Uncrustify: triggered by comment.

---------

Co-authored-by: GitHub Action <action@github.com>
1 year ago
Devaraj Ranganna 9d2571d2ed
Cortex-M23: Do not use PSPLIM_NS (#791)
According to Armv8-M technical reference manual, if the main extension
is not implemented then PSPLIM_NS is RES0. Update the cortex-M23
port to not use the reserved PSPLIM_NS.
1 year ago
Soren Ptak a695b671aa
Apply formatting bot fix (#806) 1 year ago
Gaurav-Aggarwal-AWS 96d6190b61
Replace sprintf with snprintf (#802)
This change necessitates the introduction of 2 new APIs:

void vTaskListTasks( char * pcWriteBuffer, size_t uxBufferLength );
void vTaskGetRunTimeStatistics( char * pcWriteBuffer, size_t uxBufferLength );

These 2 APIs behave exactly as vTaskList and vTaskGetRunTimeStats
except the fact that they take the length of the pcWriteBuffer as the
second argument to ensure that we do not write past the buffer.

vTaskList and vTaskGetRunTimeStats assume that the length of the
buffer is configSTATS_BUFFER_MAX_LENGTH which defaults to 0xFFFF.
This is done to ensure that the existing applications do not break.
New applications should use the new APIs to avoid memory corruption.
1 year ago
Soren Ptak 84bdb05bd2
Fix portSWITCH_TO_USER_MODE() on Armv7-M MPU ports (#803)
A task's privilege level is stored in ulTaskFlag member in the TCB. Current
implementation of portSWITCH_TO_USER_MODE() does not update this
flag but just lowers the processor's privilege level. This results in many
APIs incorrectly determining task's privilege level and access permissions -

- xPortIsAuthorizedToAccessBuffer
- xPortIsTaskPrivileged
- xPortIsAuthorizedToAccessKernelObject

This PR fixes the portSWITCH_TO_USER_MODE() implementation to correctly
update the ulTaskFlag member in the TCB before lowering the processor's
privilege level.
1 year ago
kar-rahul-aws ac5deb155d
Remove unwanted variable portACL_ENTRY_SIZE_BYTES (#810) 1 year ago
Moral-Hao 2f25cb94f5
Reduce memory usage of ACL. (#809)
Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com>
1 year ago
chinglee-iot 2bc6188be3
Update pxMutexHolder is NULL check description (#800) 1 year ago
Boris van der Meer d43062ba78
Add trace hook macro for most ports (#794)
Add trace hook macro for most ports

In pull request #659 we introduced better support for tracing
tools like systemview. This patchset adds support for more
ports as requested in the original pull request.
1 year ago
Sebastian Brosch 83861f5b1d
Add Trace Hook Macros to all API calls (#786)
This pull-request adds out-of-the-box support for different tracing
tools. New trace hook macros have been added for all public API
functions, one for each function entry and one for each exit. There are
no functional changes, as the macros are by default empty.

For more information see following forum post:
https://forums.freertos.org/t/add-tracing-functionality-for-all-api-calls/18007.
1 year ago
Robert Berger 15e0364968
xQueueSendToFromFromISR --> xQueueSendToFrontFromISR (#795)
Co-authored-by: Robert Berger <Robert.Berger@ReliableEmbeddedSystems.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
Robert Berger c59ce22c8f
Fix xQueueSendToFront code comment (#796)
Co-authored-by: Robert Berger <Robert.Berger@ReliableEmbeddedSystems.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
kar-rahul-aws c6ec8295e8
Remove CORTEX_M3_MPS2_QEMU_GCC Demo from kernel demos yaml file (#798) 1 year ago
Mehdi 7cd201c290
Add default implementations of vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory (#790)
This PR introduces configKERNEL_PROVIDED_STATIC_MEMORY option
which the application can set to 1 to use the default implementations
of vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory
functions.

If the application enables static allocation (i.e. sets
configUSE_STATIC_ALLOCATION to 1) and does not provide the above 2
functions, it will result in linker error. The application has two options:

1. Set configKERNEL_PROVIDED_STATIC_MEMORY to 1 to use the default
    implementations of these functions.
2. Provide implementations of these 2 functions.

Note that default definitions are only available for non-MPU ports. The
reason is that the stack alignment requirements vary for different
architectures.
1 year ago
Gaurav-Aggarwal-AWS c3ece08119
Fix prototype in mpu_prototypes.h (#797)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Soren Ptak 596292f874
Add the formatting bot action to FreeRTOS-Kernel (#787) 1 year ago
kar-rahul-aws 170a291d4d
Add Access Control List to MPU ports (#765)
This PR adds Access Control to kernel objects on a per task basis to MPU
ports. The following needs to be defined in the `FreeRTOSConfig.h` to
enable this feature:

```c
#define configUSE_MPU_WRAPPERS_V1 0
#define configENABLE_ACCESS_CONTROL_LIST 1
```

This PR adds the following new APIs:

```c
void vGrantAccessToTask( TaskHandle_t xTask,
                         TaskHandle_t xTaskToGrantAccess );
void vRevokeAccessToTask( TaskHandle_t xTask,
                          TaskHandle_t xTaskToRevokeAccess );

void vGrantAccessToSemaphore( TaskHandle_t xTask,
                              SemaphoreHandle_t xSemaphoreToGrantAccess );
void vRevokeAccessToSemaphore( TaskHandle_t xTask,
                               SemaphoreHandle_t xSemaphoreToRevokeAccess );

void vGrantAccessToQueue( TaskHandle_t xTask,
                          QueueHandle_t xQueueToGrantAccess );
void vRevokeAccessToQueue( TaskHandle_t xTask,
                           QueueHandle_t xQueueToRevokeAccess );

void vGrantAccessToQueueSet( TaskHandle_t xTask,
                             QueueSetHandle_t xQueueSetToGrantAccess );
void vRevokeAccessToQueueSet( TaskHandle_t xTask,
                              QueueSetHandle_t xQueueSetToRevokeAccess );

void vGrantAccessToEventGroup( TaskHandle_t xTask,
                               EventGroupHandle_t xEventGroupToGrantAccess );
void vRevokeAccessToEventGroup( TaskHandle_t xTask,
                                EventGroupHandle_t xEventGroupToRevokeAccess );

void vGrantAccessToStreamBuffer( TaskHandle_t xTask,
                                 StreamBufferHandle_t xStreamBufferToGrantAccess );
void vRevokeAccessToStreamBuffer( TaskHandle_t xTask,
                                  StreamBufferHandle_t xStreamBufferToRevokeAccess );

void vGrantAccessToMessageBuffer( TaskHandle_t xTask,
                                  MessageBufferHandle_t xMessageBufferToGrantAccess );
void vRevokeAccessToMessageBuffer( TaskHandle_t xTask,
                                   MessageBufferHandle_t xMessageBufferToRevokeAccess );

void vGrantAccessToTimer( TaskHandle_t xTask,
                          TimerHandle_t xTimerToGrantAccess );
void vRevokeAccessToTimer( TaskHandle_t xTask,
                           TimerHandle_t xTimerToRevokeAccess );
```

An unprivileged task by default has access to itself only and no other
kernel object. The application writer needs to explicitly grant an
unprivileged task access to all the kernel objects it needs. The best
place to do that is before starting the scheduler when all the kernel
objects are created. 

For example, let's say an unprivileged tasks needs access to a queue and
an event group, the application writer needs to do the following:

```c
vGrantAccessToQueue( xUnprivilegedTaskHandle, xQueue );
vGrantAccessToEventGroup( xUnprivilegedTaskHandle, xEventGroup );
```

The application writer MUST revoke all the accesses before deleting a
task. Failing to do so will result in undefined behavior. In the above
example, the application writer needs to make the following 2 calls
before deleting the task:

```c
vRevokeAccessToQueue( xUnprivilegedTaskHandle, xQueue );
vRevokeAccessToEventGroup( xUnprivilegedTaskHandle, xEventGroup );

```
1 year ago
chinglee-iot 7db0e87af1
Update taskYIELD_IF_USING_PREEMPTION macro (#769)
* Add taskYIELD_TASK_CORE_IF_USING_PREEMPTION and taskYIELD_ANY_CORE_IF_USING_PREEMPTION to align task yield behavior for single core and SMP.
---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
kar-rahul-aws 26c48dec46
Fix xStreamBufferCreateStatic() API for buffer size 1 (#793) 1 year ago
Boris van der Meer 2f94b181a2
Add Trace Hook Macros and function that returns the start of the stack. (#659)
* Add Trace Hook Macros and function that returns the start of the stack.

* Remove obsolete functions.

---------

Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Rahul Kar <karahulx@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
chinglee-iot f13ad7789b
Add macro taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD (#780)
* Add macro taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD macro to align single core and SMP
* Update for explicit precedence in vTaskDelete
* Update comment when deleting a running task
1 year ago
chinglee-iot f7565c2d5e
Add configUSE_CORE_AFFINITY bits check (#776)
* Add core affinity bits check
* Add taskBITS_PER_BYTES
1 year ago
chinglee-iot c93d3865f7
Update task running state type and related macros (#770)
* Remove unnecessary type TaskRunning_t
* Rename taskTASK_YIELD to taskTASK_SCHEDULED_TO_YIELD
---------
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
chinglee-iot 53229b1537
Assert if prvCheckForRunStateChange is called in ISR (#779)
* Assert if prvCheckForRunStateChange is called in ISR
1 year ago
chinglee-iot 288d143357
Update taskSELECT_HIGHEST_PRIORITY_TASK macro for SMP (#777)
* Move the configUSE_PORT_OPTIMISED_TASK_SELECTION check to FreeRTOS.h
* SMP also use taskSELECT_HIGHEST_PRIORITY_TASK macro
---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
Soren Ptak 5fb9b50da8
CI-CD Updates (#768)
* Use new version of CI-CD Actions
* Use cSpell spell check, and use ubuntu-20.04 for formatting check
* Format and spell check all files in the portable directory
* Remove the https:// from #errors and #warnings as uncrustify attempts to change it to /*
* Use checkout@v3 instead of checkout@v2 on all jobs
---------
1 year ago
Gaurav-Aggarwal-AWS d6bccb1f4c
Fix heap address calculation issue (#781)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
kar-rahul-aws 231278eded
Fix cast alignment warning in heap_4.c and heap_5.c (#771)
* Fix cast alignment warning
---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
chinglee-iot 1aaa318f1c
Update INFINITE_LOOP control (#775)
* Use for loop instead of while loop for INFINITE_LOOP control
1 year ago
chinglee-iot 80a390cbbb
Update block validate macro in heap_5 (#774)
* Update block validate macro in heap_5, and update for readability
* Don't validate block pointer when configENABLE_HEAP_PROTECTOR is not set to 1
1 year ago
Jordan Williams af2904b01c
Fix typo in the include directory for the the GCC_ARM_CM55_TFM port (#764)
Should be CM55 not CM85.
1 year ago
oliverlavery 0d9649ca45
Heap protect (#747)
Setting configENABLE_HEAP_PROTECTOR to 1 obfuscates heap
block pointers by XORing them with an application supplied
canary value. This obfuscation helps to catch heap corruption
should a heap buffer overflow occur.

This PR also adds heap bounds checking to heap_4 and heap_5.

This PR also adds some additional integer underflow checks.
1 year ago
Gaurav-Aggarwal-AWS b9f488a713
Fix remarks emitted by IAR compiler (#763)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Moral-Hao 7372519cba
Use the bigger priority whenever possible. (#760)
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
kar-rahul-aws cdd3678c29
Add runtime parameter checks (#761)
* Add runtime parameter checks

This commit adds runtime checks for function parameters to mpu_wrappers_v2 file. The same checks are performed
in the API implementation using asserts.

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
1 year ago
kar-rahul-aws cd87a39736
Update version number in manifest.yml (#755)
* Add automation to update version number in manifest.yml

* Make updater file executable
1 year ago
Chien Wong b1a85116bd
Add missing stack alignment adjustment if stack grows upwards (#751)
Signed-off-by: Chien Wong <m@xv97.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Moral-Hao bd720c316a
Bring the heap_4 improvements to secure_heap (#749)
This includes improvements like addition overflow checks,
readability improvements.
1 year ago
Moral-Hao bcd6dbd772
Move size calculation out of critical section (#748)
The size calculation in pvPortMalloc uses only parameters and read
only constants and therefore, can be moved out of critical section
to make the critical section as small as possible.
1 year ago
kar-rahul-aws 6f3586516a
fix MPU wrapper for vTaskDelete for calling task deletion (#745) 2 years ago
bebebib-rs b5f670f826
Fix pxTopOfStack calculation in configINIT_TLS_BLOCK for picolib (#739)
The pxTopOfStack calculation in configINIT_TLS_BLOCK for picolib needs
to decrement pxTopOfStack in order to meet the expectation of
 pxPortInitialiseStack function.
2 years ago
kar-rahul-aws 05d93e0990
Fix API for NULL task parameter (#741)
* Fix API for NULL task parameter

* Fix uncrustify

---------

Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
2 years ago
Leonardo de Araujo 4689d8ff86
fix: typos in README.md (#744)
Co-authored-by: ActoryOu <jay2002824@gmail.com>
2 years ago
Moral-Hao ee0a82be1b
Fix bug of heap_2 introduced by pr738. (#743)
* Fix bug of heap_2 introduced by pr738.
* Fix formatting check

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

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: moral-hao <405197809@qq.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
2 years ago