Loading...
Searching...
No Matches
pmp.h File Reference

RISC-V PMP configuration options. More...

Detailed Description

RISC-V PMP configuration options.

RISCV implementations using this peripheral must define the NUM_PMP_ENTRIES NUM_PMP_ENTRIES must be 16 or 64.

Author
Bennet Blischke

Definition in file pmp.h.

#include <assert.h>
#include <stdint.h>
+ Include dependency graph for pmp.h:

Go to the source code of this file.

Functions

static uint32_t make_napot (uint32_t addr, uint32_t size)
 Create a NAPOT formatted address.
 
void write_pmpcfg (uint8_t reg_num, uint32_t value)
 Writes a complete pmpcfg register.
 
uint32_t read_pmpcfg (uint8_t reg_num)
 Read a complete pmpcfg register.
 
void write_pmpaddr (uint8_t reg_num, uint32_t value)
 Writes a complete pmpaddr register.
 
uint32_t read_pmpaddr (uint8_t reg_num)
 Read a complete pmpaddr register.
 
uint8_t get_pmpcfg (uint8_t entry)
 Read a single pmpcfg sub-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.
 

Bit masks for the PMP configuration register

#define PMP_NONE   0x00
 No access allowed at all.
 
#define PMP_R   0x01
 Allow read access.
 
#define PMP_W   0x02
 Allow write access.
 
#define PMP_X   0x04
 Allow execution.
 
#define PMP_A   0x18
 Addressing mode mask.
 
#define PMP_OFF   0x00
 Disable this pmp entry.
 
#define PMP_TOR   0x08
 Top-of-range addressing mode.
 
#define PMP_NA4   0x10
 Naturally aligned four-byte region.
 
#define PMP_NAPOT   0x18
 Naturally aligned power-of-two region, ≥8 bytes.
 
#define PMP_L   0x80
 Lock; read-only config & applies to machine-mode.
 

Macro Definition Documentation

◆ PMP_A

#define PMP_A   0x18

Addressing mode mask.

Definition at line 41 of file pmp.h.

◆ PMP_L

#define PMP_L   0x80

Lock; read-only config & applies to machine-mode.

Definition at line 47 of file pmp.h.

◆ PMP_NA4

#define PMP_NA4   0x10

Naturally aligned four-byte region.

Definition at line 44 of file pmp.h.

◆ PMP_NAPOT

#define PMP_NAPOT   0x18

Naturally aligned power-of-two region, ≥8 bytes.

Definition at line 45 of file pmp.h.

◆ PMP_NONE

#define PMP_NONE   0x00

No access allowed at all.

Definition at line 36 of file pmp.h.

◆ PMP_OFF

#define PMP_OFF   0x00

Disable this pmp entry.

Definition at line 42 of file pmp.h.

◆ PMP_R

#define PMP_R   0x01

Allow read access.

Definition at line 37 of file pmp.h.

◆ PMP_TOR

#define PMP_TOR   0x08

Top-of-range addressing mode.

Definition at line 43 of file pmp.h.

◆ PMP_W

#define PMP_W   0x02

Allow write access.

Definition at line 38 of file pmp.h.

◆ PMP_X

#define PMP_X   0x04

Allow execution.

Definition at line 39 of file pmp.h.

Function Documentation

◆ get_pmpcfg()

uint8_t get_pmpcfg ( uint8_t  entry)

Read a single pmpcfg sub-register.

Parameters
[in]entrySub-register number
Returns
Contents of the specified sub-register

◆ make_napot()

static uint32_t make_napot ( uint32_t  addr,
uint32_t  size 
)
inlinestatic

Create a NAPOT formatted address.

Parameters
addrBase address, must be aligned to the size of the region
sizeSize of the region in bytes

Definition at line 56 of file pmp.h.

◆ print_pmpcfg()

void print_pmpcfg ( uint8_t  entry)

Prints a single pmpcfg sub-register human readable.

Parameters
entryRegister number to print

◆ read_pmpaddr()

uint32_t read_pmpaddr ( uint8_t  reg_num)

Read a complete pmpaddr register.

Parameters
[in]reg_numRegister number
Returns
Contents of the specified register

◆ read_pmpcfg()

uint32_t read_pmpcfg ( uint8_t  reg_num)

Read a complete pmpcfg register.

Parameters
[in]reg_numRegister number
Returns
Contents of the specified register

◆ set_pmpcfg()

void set_pmpcfg ( uint8_t  entry,
uint8_t  value 
)

Set's a single pmpcfg sub-register.

Parameters
entrySub-register number
valueValue to write

◆ write_pmpaddr()

void write_pmpaddr ( uint8_t  reg_num,
uint32_t  value 
)

Writes a complete pmpaddr register.

Parameters
reg_numRegister number
valueValue to write

◆ write_pmpcfg()

void write_pmpcfg ( uint8_t  reg_num,
uint32_t  value 
)

Writes a complete pmpcfg register.

Parameters
reg_numRegister number
valueValue to write