GCC: MSP430F449: Fix pxPortInitialiseStack on EABI

According to the MSP430 EABI [1] section 3.3,

> Arguments are assigned, in declared order, to the first available
> register single, pair, or quad from the following list into which it
> fits (with the following special exceptions).
>
> For MSP430 and MSP430X, the argument registers are: R12, R13, R14, R15

Therefore, pvParameters should be passed in R12, as it is the first
argument, not R15. Keep passing the parameter in R15 for the COFF ABI,
if anyone is still using it.

[1] https://www.ti.com/lit/an/slaa534a/slaa534a.pdf
This commit is contained in:
Sean Anderson 2024-01-07 10:05:40 -05:00
parent b1ee2e6e14
commit 4c31a730f6

View file

@ -183,16 +183,23 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xbbbb;
pxTopOfStack--;
#ifdef __MSPGCC__
*pxTopOfStack = ( StackType_t ) 0xcccc;
#else
/* The MSP430 EABI expects the function parameter in R12. */
*pxTopOfStack = ( StackType_t ) pvParameters;
#endif
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xdddd;
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xeeee;
pxTopOfStack--;
/* When the task starts is will expect to find the function parameter in
* R15. */
#ifdef __MSPGCC__
/* The mspgcc ABI expects the function parameter in R15. */
*pxTopOfStack = ( StackType_t ) pvParameters;
#else
*pxTopOfStack = ( StackType_t ) 0xffff;
#endif
pxTopOfStack--;
/* The code generated by the mspgcc compiler does not maintain separate