NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
Cache Functions

Functions that configure Instruction and Data Cache. More...

Modules

 I-Cache Functions
 Functions that configure Instruction Cache.
 
 D-Cache Functions
 Functions that configure Data Cache.
 

Data Structures

struct  CacheInfo
 Cache Information Type. More...
 

Macros

#define CCM_SUEN_SUEN_Msk   (0xFFFFFFFFFFFFFFFFUL)
 CSR CCM_SUEN: SUEN Mask. More...
 

Enumerations

enum  CCM_OP_FINFO {
  CCM_OP_SUCCESS = 0x0,
  CCM_OP_EXCEED_ERR = 0x1,
  CCM_OP_PERM_CHECK_ERR = 0x2,
  CCM_OP_REFILL_BUS_ERR = 0x3,
  CCM_OP_ECC_ERR = 0x4
}
 Cache CCM Operation Fail Info. More...
 
enum  CCM_CMD {
  CCM_DC_INVAL = 0x0,
  CCM_DC_WB = 0x1,
  CCM_DC_WBINVAL = 0x2,
  CCM_DC_LOCK = 0x3,
  CCM_DC_UNLOCK = 0x4,
  CCM_DC_WBINVAL_ALL = 0x6,
  CCM_DC_WB_ALL = 0x7,
  CCM_DC_INVAL_ALL = 0x17,
  CCM_IC_INVAL = 0x8,
  CCM_IC_LOCK = 0xb,
  CCM_IC_UNLOCK = 0xc,
  CCM_IC_INVAL_ALL = 0xd
}
 Cache CCM Command Types. More...
 

Functions

__STATIC_FORCEINLINE void EnableSUCCM (void)
 Enable CCM operation in Supervisor/User Mode. More...
 
__STATIC_FORCEINLINE void DisableSUCCM (void)
 Disable CCM operation in Supervisor/User Mode. More...
 
__STATIC_FORCEINLINE void FlushPipeCCM (void)
 Flush pipeline after CCM operation. More...
 

Detailed Description

Functions that configure Instruction and Data Cache.

Nuclei provide Cache Control and Maintainence(CCM) for software to control and maintain the internal L1 I/D Cache of the RISC-V Core, software can manage the cache flexibly to meet the actual application scenarios.

The CCM operations have 3 types: by single address, by all and flush pipeline. The CCM operations are done via CSR registers, M/S/U mode has its own CSR registers to do CCM operations. By default, CCM operations are not allowed in S/U mode, you can execute EnableSUCCM in M-Mode to enable it.

Macro Definition Documentation

◆ CCM_SUEN_SUEN_Msk

#define CCM_SUEN_SUEN_Msk   (0xFFFFFFFFFFFFFFFFUL)

CSR CCM_SUEN: SUEN Mask.

Definition at line 109 of file core_feature_cache.h.

Enumeration Type Documentation

◆ CCM_CMD

enum CCM_CMD

Cache CCM Command Types.

Enumerator
CCM_DC_INVAL 

Unlock and invalidate D-Cache line specified by CSR CCM_XBEGINADDR.

CCM_DC_WB 

Flush the specific 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_DC_UNLOCK 

Unlock the specific D-Cache line specified by CSR CCM_XBEGINADDR.

CCM_DC_WBINVAL_ALL 

Unlock and flush and invalidate all the valid and dirty D-Cache lines.

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 

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_IC_UNLOCK 

Unlock the specific I-Cache line specified by CSR CCM_XBEGINADDR.

CCM_IC_INVAL_ALL 

Unlock and invalidate all the I-Cache lines.

Definition at line 81 of file core_feature_cache.h.

81  {
82  CCM_DC_INVAL = 0x0,
83  CCM_DC_WB = 0x1,
84  CCM_DC_WBINVAL = 0x2,
85  CCM_DC_LOCK = 0x3,
86  CCM_DC_UNLOCK = 0x4,
87  CCM_DC_WBINVAL_ALL = 0x6,
88  CCM_DC_WB_ALL = 0x7,
89  CCM_DC_INVAL_ALL = 0x17,
90  CCM_IC_INVAL = 0x8,
91  CCM_IC_LOCK = 0xb,
92  CCM_IC_UNLOCK = 0xc,
93  CCM_IC_INVAL_ALL = 0xd
94 } CCM_CMD_Type;

◆ CCM_OP_FINFO

Cache CCM Operation Fail Info.

Enumerator
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_OP_PERM_CHECK_ERR 

PMP/sPMP/Page-Table X(I-Cache)/R(D-Cache) permission check failed, or belong to Device/Non-Cacheable address range.

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.

Definition at line 70 of file core_feature_cache.h.

70  {
71  CCM_OP_SUCCESS = 0x0,
72  CCM_OP_EXCEED_ERR = 0x1,
73  CCM_OP_PERM_CHECK_ERR = 0x2,
74  CCM_OP_REFILL_BUS_ERR = 0x3,
75  CCM_OP_ECC_ERR = 0x4
76 } CCM_OP_FINFO_Type;

Function Documentation

◆ DisableSUCCM()

__STATIC_FORCEINLINE void DisableSUCCM ( void  )

Disable CCM operation in Supervisor/User Mode.

This function disable CCM operation in Supervisor/User Mode. If not enabled, CCM operations in supervisor/user mode will trigger a illegal intruction exception.

Remarks
  • This function can be called in M-Mode only.
See also

Definition at line 139 of file core_feature_cache.h.

References __RV_CSR_CLEAR, CCM_SUEN_SUEN_Msk, and CSR_CCM_SUEN.

◆ EnableSUCCM()

__STATIC_FORCEINLINE void EnableSUCCM ( void  )

Enable CCM operation in Supervisor/User Mode.

This function enable CCM operation in Supervisor/User Mode. If enabled, CCM operations in supervisor/user mode will be allowed.

Remarks
  • This function can be called in M-Mode only.
See also

Definition at line 123 of file core_feature_cache.h.

References __RV_CSR_SET, CCM_SUEN_SUEN_Msk, and CSR_CCM_SUEN.

◆ FlushPipeCCM()

__STATIC_FORCEINLINE void FlushPipeCCM ( void  )

Flush pipeline after CCM operation.

This function is used to flush pipeline after CCM operations on Cache, it will ensure latest instructions or data can be seen by pipeline.

Remarks
  • This function can be called in M/S/U-Mode only.

Definition at line 153 of file core_feature_cache.h.

154 {
156 }

References __RV_CSR_WRITE, and CSR_CCM_FPIPE.

CSR_CCM_SUEN
#define CSR_CCM_SUEN
Definition: riscv_encoding.h:984
CCM_IC_INVAL_ALL
@ CCM_IC_INVAL_ALL
Unlock and invalidate all the I-Cache lines.
Definition: core_feature_cache.h:93
__RV_CSR_CLEAR
#define __RV_CSR_CLEAR(csr, val)
CSR operation Macro for csrc instruction.
Definition: core_feature_base.h:573
CCM_DC_LOCK
@ CCM_DC_LOCK
Lock the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:85
CCM_OP_REFILL_BUS_ERR
@ CCM_OP_REFILL_BUS_ERR
Refill has Bus Error.
Definition: core_feature_cache.h:74
CCM_OP_ECC_ERR
@ CCM_OP_ECC_ERR
Deprecated, ECC Error, this error code is removed in later Nuclei CCM RTL design, please don't use it...
Definition: core_feature_cache.h:75
__RV_CSR_WRITE
#define __RV_CSR_WRITE(csr, val)
CSR operation Macro for csrw instruction.
Definition: core_feature_base.h:499
CCM_SUEN_SUEN_Msk
#define CCM_SUEN_SUEN_Msk
CSR CCM_SUEN: SUEN Mask.
Definition: core_feature_cache.h:109
CCM_DC_WBINVAL_ALL
@ CCM_DC_WBINVAL_ALL
Unlock and flush and invalidate all the valid and dirty D-Cache lines.
Definition: core_feature_cache.h:87
CCM_OP_SUCCESS
@ CCM_OP_SUCCESS
Lock Succeed.
Definition: core_feature_cache.h:71
CCM_IC_INVAL
@ CCM_IC_INVAL
Unlock and invalidate I-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:90
CSR_CCM_FPIPE
#define CSR_CCM_FPIPE
Definition: riscv_encoding.h:991
CCM_DC_UNLOCK
@ CCM_DC_UNLOCK
Unlock the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:86
CCM_DC_WB_ALL
@ CCM_DC_WB_ALL
Flush all the valid and dirty D-Cache lines.
Definition: core_feature_cache.h:88
CCM_OP_PERM_CHECK_ERR
@ CCM_OP_PERM_CHECK_ERR
PMP/sPMP/Page-Table X(I-Cache)/R(D-Cache) permission check failed, or belong to Device/Non-Cacheable ...
Definition: core_feature_cache.h:73
CCM_DC_WB
@ CCM_DC_WB
Flush the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:83
__RV_CSR_SET
#define __RV_CSR_SET(csr, val)
CSR operation Macro for csrs instruction.
Definition: core_feature_base.h:536
CCM_DC_INVAL_ALL
@ CCM_DC_INVAL_ALL
Unlock and invalidate all the D-Cache lines.
Definition: core_feature_cache.h:89
CCM_DC_WBINVAL
@ CCM_DC_WBINVAL
Unlock, flush and invalidate the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:84
CCM_DC_INVAL
@ CCM_DC_INVAL
Unlock and invalidate D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:82
CCM_OP_EXCEED_ERR
@ CCM_OP_EXCEED_ERR
Exceed the the number of lockable ways(N-Way I/D-Cache, lockable is N-1)
Definition: core_feature_cache.h:72
CCM_IC_UNLOCK
@ CCM_IC_UNLOCK
Unlock the specific I-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:92
CCM_IC_LOCK
@ CCM_IC_LOCK
Lock the specific I-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:91