diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-27 08:42:48 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-29 10:04:37 +0200 |
commit | 04698ebd49f1d9eacccdcdfcff823d0d0966f7f5 (patch) | |
tree | 1b2e9abbe124603c479108c4ac9fd2a666e84a3a /cpukit/score/cpu/riscv/riscv-context-initialize.c | |
parent | riscv: Do not clear thread context (diff) | |
download | rtems-04698ebd49f1d9eacccdcdfcff823d0d0966f7f5.tar.bz2 |
riscv: Properly align the thread stack
Update #3433.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/cpu/riscv/riscv-context-initialize.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cpukit/score/cpu/riscv/riscv-context-initialize.c b/cpukit/score/cpu/riscv/riscv-context-initialize.c index f558fbd591..609c683a03 100644 --- a/cpukit/score/cpu/riscv/riscv-context-initialize.c +++ b/cpukit/score/cpu/riscv/riscv-context-initialize.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 2018 embedded brains GmbH * * Copyright (c) 2015 University of York. * Hesham Almatary <hesham@alumni.york.ac.uk> @@ -33,6 +34,7 @@ #endif #include <rtems/score/cpu.h> +#include <rtems/score/address.h> #include <rtems/score/riscv-utility.h> void _CPU_Context_Initialize( @@ -45,12 +47,14 @@ void _CPU_Context_Initialize( void *tls_area ) { - uintptr_t stack = ((uintptr_t) stack_area_begin); + void *stack; - uintptr_t stack_high = stack + stack_area_size; + stack = _Addresses_Add_offset( stack_area_begin, stack_area_size ); + stack = _Addresses_Align_down( stack, CPU_STACK_ALIGNMENT ); /* Stack Pointer - sp/x2 */ - context->x[2] = stack_high; + context->x[2] = (uintptr_t) stack; + /* Frame Pointer - fp/x8 */ context->x[8] = stack_high; /* Return Address - ra/x1 */ |