Go to the source code of this file.
Data Structures | |
| struct | pmp_entry_struct |
| PMP Entry structure. More... | |
| struct | pmp_attribute_struct |
| PMP attribute structure. More... | |
| struct | pma_attribute_struct |
| PMA Attribute structure. More... | |
Macros | |
| #define | READ_EN (1U) |
| PMP Configuration definitions. More... | |
| #define | READ_DIS (0U) |
| #define | WRITE_EN (1U) |
| #define | WRITE_DIS (0U) |
| #define | EXECUTE_EN (1U) |
| #define | EXECUTE_DIS (0U) |
| #define | ADDR_MATCH_MODE_OFF (0U) |
| #define | ADDR_MATCH_TOR (1U) |
| #define | ADDR_MATCH_NAPOT (3U) |
| #define | REG_LOCK (1U) |
| #define | REG_UNLOCK (0U) |
| #define | PMP_REG_LOCK_MASK (1UL << 7) |
| #define | MEM_TYPE_DEV_NON_BUF (0U) |
| PMA Configuration definitions. More... | |
| #define | MEM_TYPE_DEV_BUF (1U) |
| #define | MEM_TYPE_MEM_NON_CACHE_NON_BUF (2U) |
| #define | MEM_TYPE_MEM_NON_CACHE_BUF (3U) |
| #define | MEM_TYPE_MEM_WT_NO_ALLOC (4U) |
| #define | MEM_TYPE_MEM_WT_READ_ALLOC (5U) |
| #define | MEM_TYPE_MEM_WB_NO_ALLOC (8U) |
| #define | MEM_TYPE_MEM_WB_READ_ALLOC (9U) |
| #define | MEM_TYPE_MEM_WB_WRITE_ALLOC (10U) |
| #define | MEM_TYPE_MEM_WB_READ_WRITE_ALLOC (11U) |
| #define | MEM_TYPE_EMPTY_HOLE (15U) |
| #define | AMO_EN (0U) |
| #define | AMO_DIS (1U) |
| #define | PMP_CFG(r, w, x, m, l) ((r) | ((w) << 1) | ((x) << 2) | ((m) << 3) | ((l) << 7)) |
| PMP Configuration. More... | |
| #define | PMA_CFG(m, t, n) ((m) | ((t) << 2) | ((n) << 6)) |
| PMA Configuration. More... | |
| #define | PMP_TOR_ADDR(addr) ((addr) >> 2) |
| Format Top Address Region. More... | |
| #define | PMP_NAPOT_ADDR(x, n) (((uint32_t)(x) + (((uint32_t)(n)) >> 1) - 1U) >> 2) |
| Format PMP Natural Aligned Region. More... | |
| #define | PMA_NAPOT_ADDR(x, n) (((uint32_t)(x) + (((uint32_t)(n)) >> 1) - 1U) >> 2) |
| Format PMA Natural Aligned Region. More... | |
Typedefs | |
| typedef struct pmp_entry_struct | pmp_entry_t |
| PMP Entry structure. More... | |
| typedef struct pmp_attribute_struct | pmp_attr_t |
| PMP attribute structure. More... | |
| typedef struct pma_attribute_struct | pma_attr_t |
| PMA Attribute structure. More... | |
Functions | |
| void | write_pmp_cfg (uint32_t value, uint32_t idx) |
| Write PMP Configuration to corresponding PMP_CFG register. More... | |
| uint32_t | read_pmp_cfg (uint32_t idx) |
| Read PMP configuration. More... | |
| void | write_pmp_addr (uint32_t value, uint32_t idx) |
| Write PMP address to corresponding PMP_ADDR register. More... | |
| uint32_t | read_pmp_addr (uint32_t idx) |
| Read PMP address entry. More... | |
| hpm_stat_t | pmp_config_attributes (const pmp_attr_t *attrs, uint32_t num_of_entries) |
| Configure PMP Attributes (including PMPi_CFG and PMPADDRi) More... | |
| hpm_stat_t | pmp_lock_pmp_entry (uint32_t pmp_index) |
| Lock the specified PMP entry. More... | |
| uint32_t | read_pma_cfg (uint32_t idx) |
| Read PMA configuration. More... | |
| void | write_pma_cfg (uint32_t value, uint32_t idx) |
| Write PMA Configuration to corresponding PMA_CFG register. More... | |
| void | write_pma_addr (uint32_t value, uint32_t idx) |
| Write PMA address to corresponding PMA_ADDR register. More... | |
| uint32_t | read_pma_addr (uint32_t idx) |
| Read PMA address entry. More... | |
| hpm_stat_t | pma_config_attributes (const pma_attr_t *attrs, uint32_t num_of_entries) |
| Configure PMA Attributes (including PMAiCFG and PMAADDRi) More... | |
| hpm_stat_t | pmp_config_entry (const pmp_entry_t *entry, uint32_t entry_index) |
| Configure PMP and PMA for specified PMP/PMA entry. More... | |
| hpm_stat_t | pmp_config (const pmp_entry_t *entry, uint32_t num_of_entries) |
| Configure PMP and PMA based on the PMP entry list. More... | |
| uint32_t | pmp_get_aligned_len (uint32_t len) |
| Get the aligned length of the PMP/PMA entry, the length is round up to next power of 2. More... | |
| void | pmp_disable (void) |
| Disable PMP and PMA. More... | |
| #define ADDR_MATCH_MODE_OFF (0U) |
| #define ADDR_MATCH_NAPOT (3U) |
| #define ADDR_MATCH_TOR (1U) |
| #define AMO_DIS (1U) |
| #define AMO_EN (0U) |
| #define EXECUTE_DIS (0U) |
| #define EXECUTE_EN (1U) |
| #define MEM_TYPE_DEV_BUF (1U) |
| #define MEM_TYPE_DEV_NON_BUF (0U) |
PMA Configuration definitions.
| #define MEM_TYPE_EMPTY_HOLE (15U) |
| #define MEM_TYPE_MEM_NON_CACHE_BUF (3U) |
| #define MEM_TYPE_MEM_NON_CACHE_NON_BUF (2U) |
| #define MEM_TYPE_MEM_WB_NO_ALLOC (8U) |
| #define MEM_TYPE_MEM_WB_READ_ALLOC (9U) |
| #define MEM_TYPE_MEM_WB_READ_WRITE_ALLOC (11U) |
| #define MEM_TYPE_MEM_WB_WRITE_ALLOC (10U) |
| #define MEM_TYPE_MEM_WT_NO_ALLOC (4U) |
| #define MEM_TYPE_MEM_WT_READ_ALLOC (5U) |
| #define PMA_CFG | ( | m, | |
| t, | |||
| n | |||
| ) | ((m) | ((t) << 2) | ((n) << 6)) |
PMA Configuration.
| [in] | m | - Entry address matching mode, valid value: ADDR_MATCH_MODE_OFF - This PMA entry is disabled ADDR_MATCH_NAPOT - Naturally aligned power-of-2 region, the granularity is 4K bytes |
| [in] | t | - Memory type attributes, valid value: MEM_TYPE_DEV_NON_BUF - Device, Non-bufferable MEM_TYPE_DEV_BUF - Device, bufferable MEM_TYPE_MEM_NON_CACHE_NON_BUF - Memory, Non-cacheable, Non-bufferable MEM_TYPE_MEM_NON_CACHE_BUF - Memory, Non-cacheable, bufferable MEM_TYPE_MEM_WT_NO_ALLOC - Memory, Write-through, No-allocate MEM_TYPE_MEM_WT_READ_ALLOC - Memory, Write-through, read-allocate MEM_TYPE_MEM_WB_NO_ALLOC - Memory, Write-back, No-allocate MEM_TYPE_MEM_WB_READ_ALLOC - Memory, Write-back, Read-allocate MEM_TYPE_MEM_WB_READ_WRITE_ALLOC - Memory, Write-back, Write-Allocate, Read-Allocate MEM_TYPE_EMPTY_HOLE - Empty hole, nothing exists |
| [in] | n | - Indicate whether Atomic Memory Operation instructions are supported in this region, valid value: AMO_EN - Atomic Memory Operations are supported AMO_DIS - Atomic Memory Operations are not supported |
| #define PMA_NAPOT_ADDR | ( | x, | |
| n | |||
| ) | (((uint32_t)(x) + (((uint32_t)(n)) >> 1) - 1U) >> 2) |
Format PMA Natural Aligned Region.
| [in] | x | - start address (must be aligned to n) |
| [in] | n | - power-of-2 aligned length (minimum 8 bytes) |
| #define PMP_CFG | ( | r, | |
| w, | |||
| x, | |||
| m, | |||
| l | |||
| ) | ((r) | ((w) << 1) | ((x) << 2) | ((m) << 3) | ((l) << 7)) |
PMP Configuration.
| [in] | r | - READ Access control, valid value: READ_EN, READ_DIS |
| [in] | w | - Write access control, valid value: WRITE_EN, WRITE_DIS |
| [in] | x | - Instruction Execution control, valid value: EXECUTE_EN, EXECUTE_DIS |
| [in] | m | - Address matching mode, valid value: ADDR_MATCH_MODE_OFF - Null region (disabled) ADDR_MATCH_TOR - Top of range. For pmp_addr0, any address < pmp_addr0 matches, for other regions, any address which meets ( pmp_addr[i-1] <= addr < pmp_addr) matches. ADDR_MATCH_NAPOT - Naturally aligned power-of-2 region, minimal size must be 8 bytes |
| [in] | l | - Write lock and permission enforcement bit for Machine mode, valid value: REG_LOCK, REG_UNLOCK If set to REG_LOCK, the PMP entry is locked and cannot be modified by software until system reset. If set to REG_UNLOCK, the PMP entry can be modified by software. |
| #define PMP_NAPOT_ADDR | ( | x, | |
| n | |||
| ) | (((uint32_t)(x) + (((uint32_t)(n)) >> 1) - 1U) >> 2) |
Format PMP Natural Aligned Region.
| [in] | x | - start address (must be aligned to n) |
| [in] | n | - power-of-2 aligned length (minimum 8 bytes) |
| #define PMP_REG_LOCK_MASK (1UL << 7) |
| #define PMP_TOR_ADDR | ( | addr | ) | ((addr) >> 2) |
Format Top Address Region.
| #define READ_DIS (0U) |
| #define READ_EN (1U) |
PMP Configuration definitions.
| #define REG_LOCK (1U) |
| #define REG_UNLOCK (0U) |
| #define WRITE_DIS (0U) |
| #define WRITE_EN (1U) |
| typedef struct pma_attribute_struct pma_attr_t |
PMA Attribute structure.
| typedef struct pmp_attribute_struct pmp_attr_t |
PMP attribute structure.
| typedef struct pmp_entry_struct pmp_entry_t |
PMP Entry structure.
| hpm_stat_t pma_config_attributes | ( | const pma_attr_t * | attrs, |
| uint32_t | num_of_entries | ||
| ) |
Configure PMA Attributes (including PMAiCFG and PMAADDRi)
| attrs | pointer to the array of PMA attributes |
| num_of_entries | Number of entries in PMA attribute array |
| status_success | if no errors happened |
| status_invalid_argument | Invalid argument(s) detected |
| hpm_stat_t pmp_config | ( | const pmp_entry_t * | entry, |
| uint32_t | num_of_entries | ||
| ) |
Configure PMP and PMA based on the PMP entry list.
| entry | start of the PMP entry list |
| num_of_entries | Number of entries in the PMP entry list |
| status_invalid_argument | Invalid Arguments were detected |
| status_success | Configuration completed without errors |
| hpm_stat_t pmp_config_attributes | ( | const pmp_attr_t * | attrs, |
| uint32_t | num_of_entries | ||
| ) |
Configure PMP Attributes (including PMPi_CFG and PMPADDRi)
| [in] | attrs | pointer to the array of PMP attributes |
| [in] | num_of_entries | Number of entries in PMP attribute array |
| status_success | if no errors happened |
| status_invalid_argument | Invalid argument(s) detected |
| hpm_stat_t pmp_config_entry | ( | const pmp_entry_t * | entry, |
| uint32_t | entry_index | ||
| ) |
Configure PMP and PMA for specified PMP/PMA entry.
| [in] | entry | PMP entry |
| [in] | entry_index | PMP/PMA entry index |
| status_invalid_argument | Invalid Arguments were detected |
| status_success | Configuration completed without errors |
| void pmp_disable | ( | void | ) |
Disable PMP and PMA.
| uint32_t pmp_get_aligned_len | ( | uint32_t | len | ) |
Get the aligned length of the PMP/PMA entry, the length is round up to next power of 2.
| [in] | len | The length of the PMP/PMA entry |
| hpm_stat_t pmp_lock_pmp_entry | ( | uint32_t | pmp_index | ) |
Lock the specified PMP entry.
| [in] | pmp_index | PMP index |
| status_success | No error happened |
| status_fail | PMP entry has been locked already |
| status_invalid_argument | the pmp_index is out of range |
| uint32_t read_pma_addr | ( | uint32_t | idx | ) |
Read PMA address entry.
| [in] | idx | PMA address entry index, valid value is 0-15 |
| uint32_t read_pma_cfg | ( | uint32_t | idx | ) |
Read PMA configuration.
| [in] | idx | PMA entry index |
| uint32_t read_pmp_addr | ( | uint32_t | idx | ) |
Read PMP address entry.
| [in] | idx | PMP address entry index |
| uint32_t read_pmp_cfg | ( | uint32_t | idx | ) |
Read PMP configuration.
| [in] | idx | PMP entry index |
| void write_pma_addr | ( | uint32_t | value, |
| uint32_t | idx | ||
| ) |
Write PMA address to corresponding PMA_ADDR register.
| [in] | value | PMA address |
| [in] | idx | PMA address entry index, valid value is 0-15 |
| void write_pma_cfg | ( | uint32_t | value, |
| uint32_t | idx | ||
| ) |
Write PMA Configuration to corresponding PMA_CFG register.
| [in] | value | PMA configuration |
| [in] | idx | PMA entry index, valid value is 0-15 |
| void write_pmp_addr | ( | uint32_t | value, |
| uint32_t | idx | ||
| ) |
Write PMP address to corresponding PMP_ADDR register.
| [in] | value | PMP address |
| [in] | idx | PMP address entry index, valid value is 0-15 |
| void write_pmp_cfg | ( | uint32_t | value, |
| uint32_t | idx | ||
| ) |
Write PMP Configuration to corresponding PMP_CFG register.
| [in] | value | PMP configuration |
| [in] | idx | PMP entry index, valid value is 0-15 |