Loading...
Searching...
No Matches
pmp.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Bennet Blischke <bennet.blischke@haw-hamburg.de>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
9#pragma once
10
23
24#include <assert.h>
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35#define PMP_NONE 0x00
36#define PMP_R 0x01
37#define PMP_W 0x02
38#define PMP_X 0x04
39
40#define PMP_A 0x18
41#define PMP_OFF 0x00
42#define PMP_TOR 0x08
43#define PMP_NA4 0x10
44#define PMP_NAPOT 0x18
45
46#define PMP_L 0x80
48
55static inline uint32_t make_napot(uint32_t addr, uint32_t size)
56{
57 assert(addr % size == 0);
58 return addr | ((size - 1) >> 1);
59}
60
67void write_pmpcfg(uint8_t reg_num, uint32_t value);
68
76uint32_t read_pmpcfg(uint8_t reg_num);
77
84void write_pmpaddr(uint8_t reg_num, uint32_t value);
85
93uint32_t read_pmpaddr(uint8_t reg_num);
94
102uint8_t get_pmpcfg(uint8_t entry);
103
110void set_pmpcfg(uint8_t entry, uint8_t value);
111
117void print_pmpcfg(uint8_t entry);
118
119#ifdef __cplusplus
120}
121#endif
122
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:55