Midnight Sun Firmware
Loading...
Searching...
No Matches
mpu.h
1#pragma once
2
3/************************************************************************************************
4 * @file mpu.h
5 *
6 * @brief MPU Library Header file
7 *
8 * @date 2024-11-03
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17
18/* Intra-component Headers */
19#include "status.h"
20
27typedef enum { MPU_REGION_0, MPU_REGION_1, MPU_REGION_2, MPU_REGION_3, MPU_REGION_4, MPU_REGION_5, MPU_REGION_6, MPU_REGION_7, NUM_MPU_REGIONS } MPURegionNumber;
28
29typedef enum {
30 MPU_ACCESS_NONE,
31 MPU_ACCESS_PRIV_RW,
32 MPU_ACCESS_PRIV_RW_URO,
33 MPU_ACCESS_FULL,
34 MPU_ACCESS_PRIV_RO = 0x05,
35 MPU_ACCESS_PRIV_RO_URO,
36} MPUAccessPerm;
37
38typedef struct {
39 bool enable;
40 MPURegionNumber number;
41 uint32_t base_address;
42 uint32_t size;
43} MPURegion;
44
45typedef struct {
46 MPUAccessPerm access_permission;
47 bool disable_code_exec;
48 bool is_cacheable;
49 bool is_bufferable;
51
60
67StatusCode mpu_enable_region(MPURegionNumber region_number);
68
75StatusCode mpu_disable_region(MPURegionNumber region_number);
76
82
StatusCode mpu_enable_region(MPURegionNumber region_number)
Enables given region.
Definition: mpu.c:80
StatusCode mpu_disable_region(MPURegionNumber region_number)
Disables given region.
Definition: mpu.c:90
StatusCode mpu_configure_region(MPURegion *region, MPURegionSettings *settings)
Configures MPU region with given settings.
Definition: mpu.c:53
StatusCode mpu_init(void)
Enables or Disables MPU with default memory access.
Definition: mpu.c:100
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Definition: mpu.h:45
Definition: mpu.h:38