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
22#ifndef PMP_H
23#define PMP_H
24
25#include <assert.h>
26#include <stdint.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36#define PMP_NONE 0x00
37#define PMP_R 0x01
38#define PMP_W 0x02
39#define PMP_X 0x04
41#define PMP_A 0x18
42#define PMP_OFF 0x00
43#define PMP_TOR 0x08
44#define PMP_NA4 0x10
45#define PMP_NAPOT 0x18
47#define PMP_L 0x80
56static inline uint32_t make_napot(uint32_t addr, uint32_t size)
57{
58 assert(addr % size == 0);
59 return addr | ((size - 1) >> 1);
60}
61
68void write_pmpcfg(uint8_t reg_num, uint32_t value);
69
77uint32_t read_pmpcfg(uint8_t reg_num);
78
85void write_pmpaddr(uint8_t reg_num, uint32_t value);
86
94uint32_t read_pmpaddr(uint8_t reg_num);
95
103uint8_t get_pmpcfg(uint8_t entry);
104
111void set_pmpcfg(uint8_t entry, uint8_t value);
112
118void print_pmpcfg(uint8_t entry);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* PMP_H */
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:136
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:56