mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
nRF52: support stack coloration
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
3620728db2
commit
5fc34a6e8c
@@ -81,6 +81,11 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STACK_COLORATION
|
||||||
|
static void go_nx_start(void *pv, unsigned int nbytes)
|
||||||
|
__attribute__ ((naked, no_instrument_function, noreturn));
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nrf52_fpuconfig
|
* Name: nrf52_fpuconfig
|
||||||
*
|
*
|
||||||
@@ -168,6 +173,47 @@ static inline void nrf52_fpuconfig(void)
|
|||||||
# define nrf52_fpuconfig()
|
# define nrf52_fpuconfig()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: go_nx_start
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the IDLE stack to the coloration value and jump into nx_start()
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_STACK_COLORATION
|
||||||
|
static void go_nx_start(void *pv, unsigned int nbytes)
|
||||||
|
{
|
||||||
|
/* Set the IDLE stack to the stack coloration value then jump to
|
||||||
|
* nx_start(). We take extreme care here because were currently
|
||||||
|
* executing on this stack.
|
||||||
|
*
|
||||||
|
* We want to avoid sneak stack access generated by the compiler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
__asm__ __volatile__
|
||||||
|
(
|
||||||
|
"\tmovs r1, r1, lsr #2\n" /* R1 = nwords = nbytes >> 2 */
|
||||||
|
"\tcmp r1, #0\n" /* Check (nwords == 0) */
|
||||||
|
"\tbeq 2f\n" /* (should not happen) */
|
||||||
|
|
||||||
|
"\tbic r0, r0, #3\n" /* R0 = Aligned stackptr */
|
||||||
|
"\tmovw r2, #0xbeef\n" /* R2 = STACK_COLOR = 0xdeadbeef */
|
||||||
|
"\tmovt r2, #0xdead\n"
|
||||||
|
|
||||||
|
"1:\n" /* Top of the loop */
|
||||||
|
"\tsub r1, r1, #1\n" /* R1 nwords-- */
|
||||||
|
"\tcmp r1, #0\n" /* Check (nwords == 0) */
|
||||||
|
"\tstr r2, [r0], #4\n" /* Save stack color word, increment stackptr */
|
||||||
|
"\tbne 1b\n" /* Bottom of the loop */
|
||||||
|
|
||||||
|
"2:\n"
|
||||||
|
"\tmov r14, #0\n" /* LR = return address (none) */
|
||||||
|
"\tb nx_start\n" /* Branch to nx_start */
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -266,9 +312,16 @@ void __start(void)
|
|||||||
|
|
||||||
showprogress('\r');
|
showprogress('\r');
|
||||||
showprogress('\n');
|
showprogress('\n');
|
||||||
|
|
||||||
|
#ifdef CONFIG_STACK_COLORATION
|
||||||
|
/* Set the IDLE stack to the coloration value and jump into nx_start() */
|
||||||
|
|
||||||
|
go_nx_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE);
|
||||||
|
#else
|
||||||
nx_start();
|
nx_start();
|
||||||
|
|
||||||
/* Shouldn't get here */
|
/* Shouldn't get here */
|
||||||
|
|
||||||
for (; ; );
|
for (; ; );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user