arch: arm: Remove redundant check and fix rounding

This patch removes the redundant stack alignment check being done.  The
stack definition macros enforce the alignment requirements via the
__align() directives.

In addition, fix the rounding down of the psp to be correct.  The
actual initial stack pointer is the end of the stack minus the size of
the __esf structure.  Rounding down after the subtraction will get us
to the correct offset.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
This commit is contained in:
Andy Gross 2017-08-30 16:12:03 -05:00 committed by Kumar Gala
commit 85481d997b

View file

@ -58,18 +58,14 @@ void _new_thread(struct k_thread *thread, k_thread_stack_t stack,
_ASSERT_VALID_PRIO(priority, pEntry);
__ASSERT(!((u32_t)pStackMem & (STACK_ALIGN - 1)),
"stack is not aligned properly\n"
"%d-byte alignment required\n", STACK_ALIGN);
char *stackEnd = pStackMem + stackSize;
struct __esf *pInitCtx;
_new_thread_init(thread, pStackMem, stackSize, priority, options);
/* carve the thread entry struct from the "base" of the stack */
pInitCtx = (struct __esf *)(STACK_ROUND_DOWN(stackEnd) -
sizeof(struct __esf));
pInitCtx = (struct __esf *)(STACK_ROUND_DOWN(stackEnd -
sizeof(struct __esf)));
pInitCtx->pc = ((u32_t)_thread_entry) & 0xfffffffe;
pInitCtx->a1 = (u32_t)pEntry;