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 <mazen@nestwave.com>
This commit is contained in:
Mazen NEIFER 2017-04-10 16:29:27 +02:00 committed by Andrew Boie
commit cc8ffbdb44
2 changed files with 5 additions and 8 deletions

View file

@ -82,8 +82,7 @@ void _new_thread(char *pStack, size_t stackSize,
int prio, unsigned int options) int prio, unsigned int options)
{ {
/* Align stack end to maximum alignment requirement. */ /* Align stack end to maximum alignment requirement. */
char *stackEnd = (char *)ROUND_DOWN(pStack + stackSize, char *stackEnd = (char *)ROUND_DOWN(pStack + stackSize, 16);
(XCHAL_TOTAL_SA_ALIGN < 16 ? 16 : XCHAL_TOTAL_SA_ALIGN));
/* k_thread is located at top of stack while frames are located at end /* k_thread is located at top of stack while frames are located at end
* of it * of it
*/ */
@ -101,7 +100,6 @@ void _new_thread(char *pStack, size_t stackSize,
#endif #endif
#if XCHAL_CP_NUM > 0 #if XCHAL_CP_NUM > 0
/* Coprocessor's stack is allocated just after the k_thread */ /* 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); cpSA = (uint32_t *)(thread->arch.preempCoprocReg.cpStack + XT_CP_ASA);
/* Coprocessor's save area alignment is at leat 16 bytes */ /* Coprocessor's save area alignment is at leat 16 bytes */
*cpSA = ROUND_UP(cpSA + 1, *cpSA = ROUND_UP(cpSA + 1,

View file

@ -103,19 +103,18 @@ typedef struct s_coopCoprocReg {
} tCoopCoprocReg; } tCoopCoprocReg;
/* /*
* The following structure defines the set of 'volatile' x87 FPU/MMX/SSE * The following structure defines the set of 'volatile' coprocessor
* registers. These registers need not be preserved by a called C function. * registers. These registers need not be preserved by a called C function.
* Given that they are not preserved across function calls, they must be * Given that they are not preserved across function calls, they must be
* save/restored (along with s_coopCoprocReg) when a preemptive context switch * save/restored (along with s_coopCoprocReg) when a preemptive context switch
* occurs. * occurs.
*/ */
typedef struct s_preempCoprocReg { typedef struct s_preempCoprocReg {
/* /*
* This structure intentionally left blank, as for now coprocessor's * This structure reserves coprocessor control and save area memory.
* stack is positioned at top of the stack.
*/ */
#if XCHAL_CP_NUM > 0 #if XCHAL_CP_NUM > 0
char *cpStack; char __aligned(4) cpStack[XT_CP_SIZE];
#endif #endif
} tPreempCoprocReg; } tPreempCoprocReg;