1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core: save the stack_start in the thread context for mpu_stack_guard

This commit is contained in:
Ian Martin 2016-10-24 12:36:15 -04:00
parent b7bd6b3479
commit 28a7ddc9a8
4 changed files with 17 additions and 3 deletions

View File

@ -189,7 +189,7 @@ struct _thread {
msg_t *msg_array; /**< memory holding messages */
#endif
#if defined DEVELHELP || defined(SCHED_TEST_STACK)
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
char *stack_start; /**< thread's stack start address */
#endif
#ifdef DEVELHELP

View File

@ -29,6 +29,10 @@
#include "irq.h"
#include "log.h"
#ifdef MODULE_MPU_STACK_GUARD
#include "mpu.h"
#endif
#ifdef MODULE_SCHEDSTATISTICS
#include "xtimer.h"
#endif
@ -115,6 +119,16 @@ int __attribute__((used)) sched_run(void)
sched_active_pid = next_thread->pid;
sched_active_thread = (volatile thread_t *) next_thread;
#ifdef MODULE_MPU_STACK_GUARD
mpu_configure(
1, /* MPU region 1 */
(uintptr_t)sched_active_thread->stack_start + 31, /* Base Address (rounded up) */
MPU_ATTR(1, AP_RO_RO, 0, 1, 0, 1, MPU_SIZE_32B) /* Attributes and Size */
);
mpu_enable();
#endif
DEBUG("sched_run: done, changed sched_active_thread.\n");
return 1;

View File

@ -211,7 +211,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
cb->pid = pid;
cb->sp = thread_stack_init(function, arg, stack, stacksize);
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK)
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
cb->stack_start = stack;
#endif

View File

@ -48,7 +48,7 @@ int main(void)
#ifdef DEVELHELP
P(name);
#endif
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK)
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
P(stack_start);
#endif