mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Add option to keep the main stack intact on CM7
I was surprised by that behaviour, and apparently I'm not the only one: https://forums.freertos.org/t/silently-breaking-compiler-standards-by-corrupting-main-stack/11165 https://forums.freertos.org/t/main-stack-pointer-reset-when-starting-the-scheduler/5227 Add an option to disable that. My use case is that I initialize some stuff before the OS and give it to the tasks. No global variable, because I want to reduce the visibility.
This commit is contained in:
parent
fffed5e809
commit
b5149c0141
|
@ -272,15 +272,19 @@ void vPortSVCHandler( void )
|
|||
|
||||
static void prvPortStartFirstTask( void )
|
||||
{
|
||||
/* Start the first task. This also clears the bit that indicates the FPU is
|
||||
* in use in case the FPU was used before the scheduler was started - which
|
||||
* would otherwise result in the unnecessary leaving of space in the SVC stack
|
||||
* for lazy saving of FPU registers. */
|
||||
#ifndef configKEEP_MAIN_STACK
|
||||
__asm volatile (
|
||||
" ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
|
||||
" ldr r0, [r0] \n"
|
||||
" ldr r0, [r0] \n"
|
||||
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
|
||||
);
|
||||
#endif
|
||||
/* Start the first task. This also clears the bit that indicates the FPU is
|
||||
* in use in case the FPU was used before the scheduler was started - which
|
||||
* would otherwise result in the unnecessary leaving of space in the SVC stack
|
||||
* for lazy saving of FPU registers. */
|
||||
__asm volatile (
|
||||
" mov r0, #0 \n" /* Clear the bit that indicates the FPU is in use, see comment above. */
|
||||
" msr control, r0 \n"
|
||||
" cpsie i \n" /* Globally enable interrupts. */
|
||||
|
|
Loading…
Reference in a new issue