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

add mpu_stack_guard pseudomodule (just Cortex-M for now)

triggers an exception during stack overflow,
but at a cost of 32-63 bytes of RAM per thread.
This commit is contained in:
Ian Martin 2016-10-24 12:40:44 -04:00
parent 28a7ddc9a8
commit 22b5de86a5
2 changed files with 20 additions and 0 deletions

View File

@ -34,6 +34,7 @@ PSEUDOMODULES += lwip_stats
PSEUDOMODULES += lwip_tcp
PSEUDOMODULES += lwip_udp
PSEUDOMODULES += lwip_udplite
PSEUDOMODULES += mpu_stack_guard
PSEUDOMODULES += netdev_default
PSEUDOMODULES += netif
PSEUDOMODULES += netstats

View File

@ -28,9 +28,14 @@
#include "cpu.h"
#include "kernel_init.h"
#include "board.h"
#include "mpu.h"
#include "panic.h"
#include "vectors_cortexm.h"
#ifndef SRAM_BASE
#define SRAM_BASE 0
#endif
/**
* @brief Memory markers, defined in the linker script
* @{
@ -48,6 +53,8 @@ extern uint32_t _sram;
extern uint32_t _eram;
/** @} */
static const uintptr_t stack_base = (uintptr_t)&_sstack;
/**
* @brief Allocation of the interrupt stack
*/
@ -94,6 +101,18 @@ void reset_handler_default(void)
*(dst++) = 0;
}
#ifdef MODULE_MPU_STACK_GUARD
if (stack_base != SRAM_BASE) {
mpu_configure(
0, /* MPU region 0 */
stack_base + 31, /* Base Address (rounded up) */
MPU_ATTR(1, AP_RO_RO, 0, 1, 0, 1, MPU_SIZE_32B) /* Attributes and Size */
);
mpu_enable();
}
#endif
post_startup();
/* initialize the board (which also initiates CPU initialization) */