soc: arm: beetle: Add Initial MPU Support

This patch adds initial MPU support to ARM Beetle.
The boot configuration prevents the following security issues:
* Prevent to read at an address that is reserved in the memory map.
* Prevent to write into the boot Flash/ROM.
* Prevent from running code located in SRAM.

Change-Id: I64f1001369896fffb0647de6be605a95161c4695
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
Vincenzo Frascino 2017-03-08 10:05:15 +00:00 committed by Kumar Gala
commit b125767fdb
5 changed files with 51 additions and 0 deletions

View file

@ -9,6 +9,7 @@
config ARM_MPU
bool "ARM MPU Support"
depends on CPU_HAS_MPU
depends on SOC_FAMILY_ARM || SOC_FAMILY_STM32
default n
help
MCU has ARM MPU

View file

@ -13,5 +13,6 @@ config SOC_SERIES_BEETLE
select CPU_CORTEX_M3
select SOC_FAMILY_ARM
select CPU_HAS_SYSTICK
select CPU_HAS_MPU
help
Enable support for Beetle MCU Series

View file

@ -14,3 +14,11 @@ config SOC_BEETLE_R0
bool "ARM BEETLE R0"
endchoice
config ARM_MPU_ENABLE
bool "Enable MPU"
depends on CPU_HAS_MPU
select ARM_MPU
default n
help
Enable MPU

View file

@ -7,3 +7,4 @@
#
obj-y += soc.o power.o
obj-$(CONFIG_ARM_MPU_ENABLE) += arm_mpu_regions.o

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2017 Linaro Limited.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <soc.h>
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
static struct arm_mpu_region mpu_regions[] = {
/* Region 0 */
MPU_REGION_ENTRY("FLASH_0",
CONFIG_FLASH_BASE_ADDRESS,
REGION_FLASH_ATTR(REGION_256K)),
/* Region 1 */
MPU_REGION_ENTRY("RAM_0",
CONFIG_SRAM_BASE_ADDRESS,
REGION_RAM_ATTR(REGION_128K)),
/* Region 2 */
MPU_REGION_ENTRY("APB_0",
_BEETLE_APB_BASE,
REGION_IO_ATTR(REGION_64K)),
/* Region 3 */
MPU_REGION_ENTRY("AHB_0",
_BEETLE_AHB_BASE,
REGION_IO_ATTR(REGION_64K)),
/* Region 4 */
MPU_REGION_ENTRY("BITBAND_0",
_BEETLE_BITBAND_BASE,
REGION_IO_ATTR(REGION_32M)),
/* Region 5 */
MPU_REGION_ENTRY("PPB_0",
_BEETLE_PPB_BASE,
REGION_PPB_ATTR(REGION_1M)),
};
struct arm_mpu_config mpu_config = {
.num_regions = ARRAY_SIZE(mpu_regions),
.mpu_regions = mpu_regions,
};