mmz211
(George)
June 30, 2020, 4:56am
1
I see a function in freertos-8.2.3\Source\include\list.h line 386
"
void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;
"
what I have seen till now is like this way
"
void vListInitialise( List_t * const pxList );
"
what is the function of “PRIVILEGED_FUNCTION”.
I’m not familiar with this syntax, and do not know the key word if I want to search it.
anyone can explain it, thanks ahead.
rtel
(Richard Barry)
June 30, 2020, 5:11am
2
In ports that support memory protection and privilege and unprivileged modes (think user and kernel space, kind of) PRIVILEGED_FUNCTION and PRIVILEGED_DATA are #defined to place kernel function and kernel data in memory segments marked as privileged only. Ports that do not support privileged and unprivileged modes run everything privileged, in which case the macros are #defined to nothing.
See https://www.freertos.org/FreeRTOS-MPU-memory-protection-unit.html and https://www.freertos.org/2020/04/using-freertos-on-armv8-m-microcontrollers.html for more information.
1 Like
aggarg
(Gaurav Aggarwal)
June 30, 2020, 5:13am
3
It is used on MPU ports to place FreeRTOS kernel code in a separate protected privileged section.
For non-MPU ports PRIVILEGED_FUNCTION
is defined to nothing:
And so the function declaration will become what you expect after pre-processing:
void vListInitialise( List_t * const pxList );
For MPU ports, it is defined to __attribute__((section("privileged_functions")))
: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/include/mpu_wrappers.h#L172
So the function declaration becomes:
void vListInitialise( List_t * const pxList ) __attribute__((section("privileged_functions")));
Linker scripts are then used to place these FreeRTOS functions in a separate privileged section. One such example of a linker script is here: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_MPU_STM32L4_Discovery_GCC_IAR_Keil/Projects/GCC/STM32L475VGTX_FLASH.ld#L97
Thanks.
1 Like