1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include <mod_armv7m_mpu.h>
9 
10 #include <fwk_assert.h>
11 #include <fwk_id.h>
12 #include <fwk_module.h>
13 #include <fwk_status.h>
14 
15 #include <fmw_cmsis.h>
16 
armv7m_mpu_init(fwk_id_t module_id,unsigned int element_count,const void * data)17 static int armv7m_mpu_init(
18     fwk_id_t module_id,
19     unsigned int element_count,
20     const void *data)
21 {
22     const struct mod_armv7m_mpu_config *config;
23 
24     fwk_assert(element_count == 0);
25     fwk_assert(data != NULL);
26 
27     config = data;
28 
29     ARM_MPU_Disable();
30     ARM_MPU_Load(config->regions, config->region_count);
31     ARM_MPU_Enable(MPU_CTRL_HFNMIENA_Msk);
32 
33     return FWK_SUCCESS;
34 }
35 
36 /* Module description */
37 const struct fwk_module module_armv7m_mpu = {
38     .type = FWK_MODULE_TYPE_DRIVER,
39     .init = armv7m_mpu_init,
40 };
41