arm: core: mpu: Add core MPU implementation
This patch adds the arm core MPU implementation. This implementation currently supports the thread stack guard feature. Change-Id: I8b3795ebaf1ebad38aaddc2ed2f05535ead2c09a Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
parent
b94c5b16fe
commit
726c7b545f
2 changed files with 32 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
obj-$(CONFIG_ARM_CORE_MPU) += arm_core_mpu.o
|
||||
obj-$(CONFIG_ARM_MPU) += arm_mpu.o
|
||||
obj-$(CONFIG_NXP_MPU) += nxp_mpu.o
|
||||
|
|
31
arch/arm/core/cortex_m/mpu/arm_core_mpu.c
Normal file
31
arch/arm/core/cortex_m/mpu/arm_core_mpu.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Linaro Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <kernel.h>
|
||||
#include <soc.h>
|
||||
#include <arch/arm/cortex_m/cmsis.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_core_mpu.h>
|
||||
|
||||
#if defined(CONFIG_MPU_STACK_GUARD)
|
||||
/*
|
||||
* @brief Configure MPU stack guard
|
||||
*
|
||||
* This function configures per thread stack guards reprogramming the MPU.
|
||||
* The functionality is meant to be used during context switch.
|
||||
*
|
||||
* @param thread thread info data structure.
|
||||
*/
|
||||
void configure_mpu_stack_guard(struct k_thread *thread)
|
||||
{
|
||||
arm_core_mpu_disable();
|
||||
arm_core_mpu_configure(THREAD_STACK_GUARD_REGION,
|
||||
thread->stack_info.start,
|
||||
thread->stack_info.size);
|
||||
arm_core_mpu_enable();
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue