sl_mpu.c File Reference

MPU API implementation.

Version
1.0.0

License

(C) Copyright 2018 Silicon Labs, www.silabs.com

This file is licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file sl_mpu.c.

#include "em_device.h"
#include "em_common.h"
#include "em_core.h"
#include "sl_mpu.h"
#include <stdlib.h>
#include <math.h>

Macros

#define MPU_RAM_BACKGROUND_XN_REGION_NBR   0u
 
#define MPU_RAM_FUNCTION_REGION_NBR   1u
 
#define MPU_RBAR_VALUE   ARM_MPU_RBAR(0u, ARM_MPU_SH_OUTER, 0, 1, 1)
 
#define MPU_SUBREGION_NBR   8u
 
#define MPU_SUBREGION_USE_MIN_SIZE   256u
 
#define RAMFUNC_SECTION_BEGIN   (uint32_t) &__ram_func_section_start
 
#define RAMFUNC_SECTION_END   (uint32_t) &__ram_func_section_end
 
#define RAMFUNC_SECTION_SIZE   (RAMFUNC_SECTION_END - RAMFUNC_SECTION_BEGIN)
 

Functions

void MemManage_Handler (void)
 
static void mpu_compute_region_data (uint32_t section_begin, uint32_t section_end, uint32_t section_size, uint32_t *mpu_region_begin, uint32_t *mpu_region_end, uint32_t *mpu_region_size)
 
__WEAK void mpu_fault_handler (void)
 
static uint8_t mpu_region_size_encode (uint32_t region_size)
 
static uint32_t mpu_round_up_next_pwr2 (uint32_t nbr)
 
void sl_mpu_disable_execute (uint32_t address_begin, uint32_t address_end, uint32_t size)
 
void sl_mpu_disable_execute_from_ram (void)
 

Variables

uint32_t __ram_func_section_end
 
uint32_t __ram_func_section_start
 
static uint32_t region_nbr = 0
 

Function Documentation

static void mpu_compute_region_data ( uint32_t  section_begin,
uint32_t  section_end,
uint32_t  section_size,
uint32_t *  mpu_region_begin,
uint32_t *  mpu_region_end,
uint32_t *  mpu_region_size 
)
static

Compute region size.

Parameters
section_beginSection begin address.
section_endSection end address.
section_sizeSize of section.
mpu_region_beginPointer to a region begin variable.
mpu_region_endPointer to a region end variable.
mpu_region_sizePointer to a region size variable.

Definition at line 299 of file sl_mpu.c.

References mpu_round_up_next_pwr2().

Referenced by sl_mpu_disable_execute(), and sl_mpu_disable_execute_from_ram().

__WEAK void mpu_fault_handler ( void  )

MemManage default exception handler. Reset target.

Definition at line 333 of file sl_mpu.c.

Referenced by MemManage_Handler().

static uint8_t mpu_region_size_encode ( uint32_t  region_size)
static

Encode region size in RASR register REGION size field format.

Parameters
region_sizeSize of region.

Definition at line 277 of file sl_mpu.c.

Referenced by sl_mpu_disable_execute(), and sl_mpu_disable_execute_from_ram().

static uint32_t mpu_round_up_next_pwr2 ( uint32_t  nbr)
static

Rounds up given number to next power of 2.

Parameters
nbrNumber to round-up to next power of 2.

Definition at line 257 of file sl_mpu.c.

Referenced by mpu_compute_region_data().