From cc8ffbdb4450ca25cf8612485e06f4b31e112d1f Mon Sep 17 00:00:00 2001 From: Mazen NEIFER Date: Mon, 10 Apr 2017 16:29:27 +0200 Subject: [PATCH] Xtensa port: Moved coporcessor context area inside struct _k_thread The CP context area was before on the bottom of the stack just after the thread descriptor. Now it is moved inside the thread descriptor to support some kind of memory protection. Change-Id: Id3ebeaecfd9c2475899713fdc8da583a1f9121f9 Signed-off-by: Mazen NEIFER --- arch/xtensa/core/thread.c | 4 +--- arch/xtensa/include/kernel_arch_data.h | 9 ++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/xtensa/core/thread.c b/arch/xtensa/core/thread.c index eac97bc9f41..f48a9d8c10d 100644 --- a/arch/xtensa/core/thread.c +++ b/arch/xtensa/core/thread.c @@ -82,8 +82,7 @@ void _new_thread(char *pStack, size_t stackSize, int prio, unsigned int options) { /* Align stack end to maximum alignment requirement. */ - char *stackEnd = (char *)ROUND_DOWN(pStack + stackSize, - (XCHAL_TOTAL_SA_ALIGN < 16 ? 16 : XCHAL_TOTAL_SA_ALIGN)); + char *stackEnd = (char *)ROUND_DOWN(pStack + stackSize, 16); /* k_thread is located at top of stack while frames are located at end * of it */ @@ -101,7 +100,6 @@ void _new_thread(char *pStack, size_t stackSize, #endif #if XCHAL_CP_NUM > 0 /* Coprocessor's stack is allocated just after the k_thread */ - thread->arch.preempCoprocReg.cpStack = pStack + sizeof(struct k_thread); cpSA = (uint32_t *)(thread->arch.preempCoprocReg.cpStack + XT_CP_ASA); /* Coprocessor's save area alignment is at leat 16 bytes */ *cpSA = ROUND_UP(cpSA + 1, diff --git a/arch/xtensa/include/kernel_arch_data.h b/arch/xtensa/include/kernel_arch_data.h index 87d9539e7e8..4c2eb884ac9 100644 --- a/arch/xtensa/include/kernel_arch_data.h +++ b/arch/xtensa/include/kernel_arch_data.h @@ -103,19 +103,18 @@ typedef struct s_coopCoprocReg { } tCoopCoprocReg; /* - * The following structure defines the set of 'volatile' x87 FPU/MMX/SSE - * registers. These registers need not be preserved by a called C function. + * The following structure defines the set of 'volatile' coprocessor + * registers. These registers need not be preserved by a called C function. * Given that they are not preserved across function calls, they must be * save/restored (along with s_coopCoprocReg) when a preemptive context switch * occurs. */ typedef struct s_preempCoprocReg { /* - * This structure intentionally left blank, as for now coprocessor's - * stack is positioned at top of the stack. + * This structure reserves coprocessor control and save area memory. */ #if XCHAL_CP_NUM > 0 - char *cpStack; + char __aligned(4) cpStack[XT_CP_SIZE]; #endif } tPreempCoprocReg;