blob: 24d7948143b3cb0276707bcc629d10b00b94b983 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "config.h"
#include "mpu.h"
#include "logging/log.h"
#include <arch/arm/aarch32/cortex_m/cmsis.h>
#include <arch/cpu.h>
#include <init.h>
LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR);
void mpu_enable(void)
{
for (int index = 0; index < mpu_config.num_regions; index++) {
MPU->RNR = index;
MPU->RASR |= MPU_RASR_ENABLE_Msk;
LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
}
}
static int mpu_disable_fixed_regions(const struct device *dev)
{
/* MPU is configured and enabled by the Zephyr init code, disable the
* fixed sections by default.
*/
for (int index = 0; index < mpu_config.num_regions; index++) {
MPU->RNR = index;
MPU->RASR &= ~MPU_RASR_ENABLE_Msk;
LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
}
return 0;
}
SYS_INIT(mpu_disable_fixed_regions, PRE_KERNEL_1, 50);
|