Loading...
Searching...
No Matches
pmp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Bennet Blischke <bennet.blischke@haw-hamburg.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#include <assert.h>
22#include <stdint.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
32#define PMP_NONE 0x00
33#define PMP_R 0x01
34#define PMP_W 0x02
35#define PMP_X 0x04
36
37#define PMP_A 0x18
38#define PMP_OFF 0x00
39#define PMP_TOR 0x08
40#define PMP_NA4 0x10
41#define PMP_NAPOT 0x18
42
43#define PMP_L 0x80
45
52static inline uint32_t make_napot(uint32_t addr, uint32_t size)
53{
54 assert(addr % size == 0);
55 return addr | ((size - 1) >> 1);
56}
57
64void write_pmpcfg(uint8_t reg_num, uint32_t value);
65
73uint32_t read_pmpcfg(uint8_t reg_num);
74
81void write_pmpaddr(uint8_t reg_num, uint32_t value);
82
90uint32_t read_pmpaddr(uint8_t reg_num);
91
99uint8_t get_pmpcfg(uint8_t entry);
100
107void set_pmpcfg(uint8_t entry, uint8_t value);
108
114void print_pmpcfg(uint8_t entry);
115
116#ifdef __cplusplus
117}
118#endif
119
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:146
uint32_t read_pmpaddr(uint8_t reg_num)
Read a complete pmpaddr register.
void set_pmpcfg(uint8_t entry, uint8_t value)
Set's a single pmpcfg sub-register.
void print_pmpcfg(uint8_t entry)
Prints a single pmpcfg sub-register human readable.
uint8_t get_pmpcfg(uint8_t entry)
Read a single pmpcfg sub-register.
void write_pmpcfg(uint8_t reg_num, uint32_t value)
Writes a complete pmpcfg register.
void write_pmpaddr(uint8_t reg_num, uint32_t value)
Writes a complete pmpaddr register.
uint32_t read_pmpcfg(uint8_t reg_num)
Read a complete pmpcfg register.
static uint32_t make_napot(uint32_t addr, uint32_t size)
Create a NAPOT formatted address.
Definition pmp.h:52