18 #ifndef __CORE_FEATURE_CACHE_H__
19 #define __CORE_FEATURE_CACHE_H__
40 #include "core_feature_base.h"
43 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
70 typedef enum CCM_OP_FINFO {
81 typedef enum CCM_CMD {
99 typedef struct CacheInfo {
106 #if __riscv_xlen == 32
107 #define CCM_SUEN_SUEN_Msk (0xFFFFFFFFUL)
109 #define CCM_SUEN_SUEN_Msk (0xFFFFFFFFFFFFFFFFUL)
160 #if defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1)
246 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
266 if (csr_ccfg.
b.
lsize == 0) {
309 for (i = 0; i < cnt; i++) {
351 for (i = 0; i < cnt; i++) {
393 for (i = 0; i < cnt; i++) {
438 for (i = 0; i < cnt; i++) {
488 for (i = 0; i < cnt; i++) {
538 for (i = 0; i < cnt; i++) {
584 for (i = 0; i < cnt; i++) {
625 for (i = 0; i < cnt; i++) {
666 for (i = 0; i < cnt; i++) {
725 #if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1)
810 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
830 if (csr_ccfg.
b.
lsize == 0) {
873 for (i = 0; i < cnt; i++) {
915 for (i = 0; i < cnt; i++) {
957 for (i = 0; i < cnt; i++) {
998 for (i = 0; i < cnt; i++) {
1039 for (i = 0; i < cnt; i++) {
1080 for (i = 0; i < cnt; i++) {
1121 for (i = 0; i < cnt; i++) {
1162 for (i = 0; i < cnt; i++) {
1203 for (i = 0; i < cnt; i++) {
1248 for (i = 0; i < cnt; i++) {
1298 for (i = 0; i < cnt; i++) {
1348 for (i = 0; i < cnt; i++) {
1394 for (i = 0; i < cnt; i++) {
1435 for (i = 0; i < cnt; i++) {
1476 for (i = 0; i < cnt; i++) {
#define __RWMB()
Read & Write Memory barrier.
#define MCACHE_CTL_DC_ECC_EN
#define MCACHE_CTL_IC_ECC_EN
#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_CCM_MBEGINADDR
#define CSR_CCM_SBEGINADDR
#define CSR_CCM_UBEGINADDR
CCM_OP_FINFO_Type
Cache CCM Operation Fail Info.
__STATIC_FORCEINLINE void FlushPipeCCM(void)
Flush pipeline after CCM operation.
CCM_CMD_Type
Cache CCM Command Types.
__STATIC_FORCEINLINE void DisableSUCCM(void)
Disable CCM operation in Supervisor/User Mode.
#define CCM_SUEN_SUEN_Msk
CSR CCM_SUEN: SUEN Mask.
__STATIC_FORCEINLINE void EnableSUCCM(void)
Enable CCM operation in Supervisor/User Mode.
@ CCM_OP_REFILL_BUS_ERR
Refill has Bus Error.
@ CCM_OP_ECC_ERR
Deprecated, ECC Error, this error code is removed in later Nuclei CCM RTL design, please don't use it...
@ CCM_OP_PERM_CHECK_ERR
PMP/sPMP/Page-Table X(I-Cache)/R(D-Cache) permission check failed, or belong to Device/Non-Cacheable ...
@ CCM_OP_SUCCESS
Lock Succeed.
@ CCM_OP_EXCEED_ERR
Exceed the the number of lockable ways(N-Way I/D-Cache, lockable is N-1)
@ CCM_DC_WB
Flush the specific D-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_DC_INVAL
Unlock and invalidate D-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_DC_WBINVAL
Unlock, flush and invalidate the specific D-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_DC_LOCK
Lock the specific D-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_IC_INVAL
Unlock and invalidate I-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_IC_LOCK
Lock the specific I-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_DC_WB_ALL
Flush all the valid and dirty D-Cache lines.
@ CCM_DC_INVAL_ALL
Unlock and invalidate all the D-Cache lines.
@ CCM_IC_INVAL_ALL
Unlock and invalidate all the I-Cache lines.
@ CCM_DC_WBINVAL_ALL
Unlock and flush and invalidate all the valid and dirty D-Cache lines.
@ CCM_DC_UNLOCK
Unlock the specific D-Cache line specified by CSR CCM_XBEGINADDR.
@ CCM_IC_UNLOCK
Unlock the specific I-Cache line specified by CSR CCM_XBEGINADDR.
#define __STATIC_FORCEINLINE
Define a static function that should be always inlined by the compiler.
__STATIC_FORCEINLINE void UFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in U-Mode.
__STATIC_FORCEINLINE void UFlushDCache(void)
Flush all D-Cache lines in U-Mode.
__STATIC_FORCEINLINE void SInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void SInvalDCache(void)
Invalidate all D-Cache lines in S-Mode.
__STATIC_FORCEINLINE unsigned long SLockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void MInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void UUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE void MFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void UFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void UFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE unsigned long MLockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void MUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE unsigned long MLockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void SFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in S-Mode.
__STATIC_FORCEINLINE void SFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void SFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void EnableDCacheECC(void)
Enable DCache ECC.
__STATIC_FORCEINLINE void MFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE unsigned long ULockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE int32_t DCachePresent(void)
Check DCache Unit Present or Not.
__STATIC_FORCEINLINE void SFlushDCache(void)
Flush all D-Cache lines in S-Mode.
__STATIC_FORCEINLINE void MFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void SFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void MFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in M-Mode.
__STATIC_FORCEINLINE void SFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void MInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void DisableDCache(void)
Disable DCache.
__STATIC_FORCEINLINE void SUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void UFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void SUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void MFlushDCache(void)
Flush all D-Cache lines in M-Mode.
__STATIC_FORCEINLINE void SInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void DisableDCacheECC(void)
Disable DCache ECC.
__STATIC_FORCEINLINE void UFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE void UInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE int32_t GetDCacheInfo(CacheInfo_Type *info)
Get D-Cache Information.
__STATIC_FORCEINLINE unsigned long SLockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE unsigned long ULockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void MFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void MInvalDCache(void)
Invalidate all D-Cache lines in M-Mode.
__STATIC_FORCEINLINE void UInvalDCache(void)
Invalidate all D-Cache lines in U-Mode.
__STATIC_FORCEINLINE void UUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void UInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void MUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void EnableDCache(void)
Enable DCache.
__STATIC_FORCEINLINE void SInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void UUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE void SInvalICache(void)
Invalidate all I-Cache lines in S-Mode.
__STATIC_FORCEINLINE int32_t ICachePresent(void)
Check ICache Unit Present or Not.
__STATIC_FORCEINLINE void UInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE void UUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE void DisableICache(void)
Disable ICache.
__STATIC_FORCEINLINE void UInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE unsigned long MLockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void UInvalICache(void)
Invalidate all I-Cache lines in U-Mode.
__STATIC_FORCEINLINE int32_t GetICacheInfo(CacheInfo_Type *info)
Get I-Cache Information.
__STATIC_FORCEINLINE void MUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in M-Mode.
__STATIC_FORCEINLINE void SUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void EnableICache(void)
Enable ICache.
__STATIC_FORCEINLINE unsigned long ULockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in U-Mode.
__STATIC_FORCEINLINE unsigned long SLockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void SInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE void EnableICacheECC(void)
Enable ICache ECC.
__STATIC_FORCEINLINE unsigned long MLockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void DisableICacheECC(void)
Disable ICache ECC.
__STATIC_FORCEINLINE void MInvalICache(void)
Invalidate all I-Cache lines in M-Mode.
__STATIC_FORCEINLINE unsigned long SLockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in S-Mode.
__STATIC_FORCEINLINE void MUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void MInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in M-Mode.
__STATIC_FORCEINLINE void SUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in S-Mode.
__STATIC_FORCEINLINE unsigned long ULockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in U-Mode.
__STATIC_FORCEINLINE void MInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in M-Mode.
uint32_t setperway
Cache set per way.
uint32_t linesize
Cache Line size in bytes.
uint32_t size
Cache total size in bytes.
Union type to access MDCFG_INFO CSR register.
rv_csr_t set
bit: 0..3 D-Cache sets per way
rv_csr_t d
Type used for csr data access.
struct CSR_MDCFGINFO_Type::@15 b
Structure used for bit access.
rv_csr_t lsize
bit: 7..9 D-Cache line size
rv_csr_t way
bit: 4..6 D-Cache way
Union type to access MICFG_INFO CSR register.
rv_csr_t d
Type used for csr data access.
rv_csr_t set
bit: 0..3 I-Cache sets per way
struct CSR_MICFGINFO_Type::@14 b
Structure used for bit access.
rv_csr_t lsize
bit: 7..9 I-Cache line size
rv_csr_t way
bit: 4..6 I-Cache way