18 #ifndef __CORE_FEATURE_PMA_H__
19 #define __CORE_FEATURE_PMA_H__
29 #include "core_compatiable.h"
31 #if defined(__PMA_PRESENT) && (__PMA_PRESENT==1)
53 #define PMA_REGION_TYPE_SECSHARE (1UL << 3)
54 #define PMA_REGION_TYPE_NC (1UL << 2)
55 #define PMA_REGION_TYPE_DEV (1UL << 1)
56 #define PMA_REGION_TYPE_CA (0)
57 #define PMA_REGION_ENA (1UL << 0)
58 #define PMA_REGION_DIS (0)
60 typedef struct PMA_CONFIG {
102 unsigned long size = (pma_cfg->
region_size >> 12) << 12;
103 unsigned long base_addr = (pma_cfg->
region_base >> 12) << 12;
105 if ((entry_idx + 1) > __PMA_CSR_NUM) {
109 rv_csr_t mask = (
unsigned long)(~(size - 1));
142 uint32_t mpasize = *(uint32_t *)__IINFO_MPASIZE_ADDR;
144 if ((entry_idx + 1) > __PMA_CSR_NUM) {
160 pma_cfg->
region_type = (
unsigned long)(base & 0x0E);
161 pma_cfg->
region_base = (
unsigned long)((base >> 12) << 12);
162 pma_cfg->
region_size = (
unsigned long)(1UL << (mask == 0 ? mpasize :
__CTZ(mask)));
184 unsigned long size = (pma_cfg->
region_size >> 12) << 12;
185 unsigned long base_addr = (pma_cfg->
region_base >> 12) << 12;
187 if ((entry_idx + 1) > __PMA_SEC_CSR_NUM) {
191 rv_csr_t mask = (
unsigned long)(~(size - 1));
222 uint32_t mpasize = *(uint32_t *)__IINFO_MPASIZE_ADDR;
224 if ((entry_idx + 1) > __PMA_SEC_CSR_NUM) {
240 pma_cfg->
region_base = (
unsigned long)((base >> 12) << 12);
241 pma_cfg->
region_size = (
unsigned long)(1UL << (mask == 0 ? mpasize :
__CTZ(mask)));
247 #if defined(__PMA_MACRO_PRESENT) && (__PMA_MACRO_PRESENT == 1)
__STATIC_FORCEINLINE unsigned long __CTZ(unsigned long data)
Count tailing zero.
#define __RV_CSR_CLEAR(csr, val)
CSR operation Macro for csrc instruction.
#define __RV_CSR_READ(csr)
CSR operation Macro for csrr instruction.
#define __RV_CSR_WRITE(csr, val)
CSR operation Macro for csrw instruction.
#define __RV_CSR_SET(csr, val)
CSR operation Macro for csrs instruction.
#define CSR_MMACRO_DEV_EN
#define CSR_MMACRO_NOC_EN
#define __STATIC_FORCEINLINE
Define a static function that should be always inlined by the compiler.
__STATIC_FORCEINLINE void PMA_EnableHwNCRegion(unsigned long entry_idx)
Enable hardware defined Non-Cacheable regions.
__STATIC_FORCEINLINE void PMA_DisableHwNCRegion(unsigned long entry_idx)
Disable hardware defined Non-Cacheable regions.
__STATIC_FORCEINLINE void PMA_DisableHwCARegion(unsigned long entry_idx)
Disable hardware defined Cacheable regions.
__STATIC_FORCEINLINE long PMA_GetRegion_S(unsigned long entry_idx, pma_config *pma_cfg)
Get the region info of Secure S-Mode world sharing with Non-Secure S-Mode world.
__STATIC_FORCEINLINE void PMA_EnableHwDevRegion(unsigned long entry_idx)
Enable hardware defined Device regions.
__STATIC_FORCEINLINE long PMA_SetRegion(unsigned long entry_idx, pma_config *pma_cfg)
Configure one region in machine mode.
__STATIC_FORCEINLINE void PMA_EnableHwCARegion(unsigned long entry_idx)
Enable hardware defined Cacheable regions.
__STATIC_FORCEINLINE long PMA_GetRegion(unsigned long entry_idx, pma_config *pma_cfg)
Get the region info in machine mode.
__STATIC_FORCEINLINE void PMA_DisableHwDevRegion(unsigned long entry_idx)
Disable hardware defined Device regions.
__STATIC_FORCEINLINE long PMA_SetRegion_S(unsigned long entry_idx, pma_config *pma_cfg)
Configure one region for Secure S-Mode world to share with Non-Secure S-Mode world.
unsigned long rv_csr_t
Type of Control and Status Register(CSR), depends on the XLEN defined in RISC-V.
unsigned long region_base
Base physical address, which needs to be 4K byte aligned.
uint16_t region_type
Type could be PMA_REGION_TYPE_SECSHARE, PMA_REGION_TYPE_NC, PMA_REGION_TYPE_DEV, PMA_REGION_TYPE_CA P...
uint16_t region_enable
Enable or disable the region, could be PMA_REGION_ENA, PMA_REGION_DIS.
unsigned long region_size
Region size, which needs to be 4K byte aligned; the region_base should be integer multiples of region...