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

Functions that configure Data Cache. More...

Functions

__STATIC_FORCEINLINE int32_t DCachePresent (void)
 Check DCache Unit Present or Not. More...
 
__STATIC_FORCEINLINE void EnableDCache (void)
 Enable DCache. More...
 
__STATIC_FORCEINLINE void DisableDCache (void)
 Disable DCache. More...
 
__STATIC_FORCEINLINE void EnableDCacheECC (void)
 Enable DCache ECC. More...
 
__STATIC_FORCEINLINE void DisableDCacheECC (void)
 Disable DCache ECC. More...
 
__STATIC_FORCEINLINE int32_t GetDCacheInfo (CacheInfo_Type *info)
 Get D-Cache Information. More...
 
__STATIC_FORCEINLINE void MInvalDCacheLine (unsigned long addr)
 Invalidate one D-Cache line specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void MInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Invalidate several D-Cache lines specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void SInvalDCacheLine (unsigned long addr)
 Invalidate one D-Cache line specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void SInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Invalidate several D-Cache lines specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void UInvalDCacheLine (unsigned long addr)
 Invalidate one D-Cache line specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void UInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Invalidate several D-Cache lines specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void MFlushDCacheLine (unsigned long addr)
 Flush one D-Cache line specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void MFlushDCacheLines (unsigned long addr, unsigned long cnt)
 Flush several D-Cache lines specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void SFlushDCacheLine (unsigned long addr)
 Flush one D-Cache line specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void SFlushDCacheLines (unsigned long addr, unsigned long cnt)
 Flush several D-Cache lines specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void UFlushDCacheLine (unsigned long addr)
 Flush one D-Cache line specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void UFlushDCacheLines (unsigned long addr, unsigned long cnt)
 Flush several D-Cache lines specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void MFlushInvalDCacheLine (unsigned long addr)
 Flush and invalidate one D-Cache line specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void MFlushInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Flush and invalidate several D-Cache lines specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void SFlushInvalDCacheLine (unsigned long addr)
 Flush and invalidate one D-Cache line specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void SFlushInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Flush and invalidate several D-Cache lines specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void UFlushInvalDCacheLine (unsigned long addr)
 Flush and invalidate one D-Cache line specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void UFlushInvalDCacheLines (unsigned long addr, unsigned long cnt)
 Flush and invalidate several D-Cache lines specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE unsigned long MLockDCacheLine (unsigned long addr)
 Lock one D-Cache line specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE unsigned long MLockDCacheLines (unsigned long addr, unsigned long cnt)
 Lock several D-Cache lines specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE unsigned long SLockDCacheLine (unsigned long addr)
 Lock one D-Cache line specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE unsigned long SLockDCacheLines (unsigned long addr, unsigned long cnt)
 Lock several D-Cache lines specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE unsigned long ULockDCacheLine (unsigned long addr)
 Lock one D-Cache line specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE unsigned long ULockDCacheLines (unsigned long addr, unsigned long cnt)
 Lock several D-Cache lines specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void MUnlockDCacheLine (unsigned long addr)
 Unlock one D-Cache line specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void MUnlockDCacheLines (unsigned long addr, unsigned long cnt)
 Unlock several D-Cache lines specified by address in M-Mode. More...
 
__STATIC_FORCEINLINE void SUnlockDCacheLine (unsigned long addr)
 Unlock one D-Cache line specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void SUnlockDCacheLines (unsigned long addr, unsigned long cnt)
 Unlock several D-Cache lines specified by address in S-Mode. More...
 
__STATIC_FORCEINLINE void UUnlockDCacheLine (unsigned long addr)
 Unlock one D-Cache line specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void UUnlockDCacheLines (unsigned long addr, unsigned long cnt)
 Unlock several D-Cache lines specified by address in U-Mode. More...
 
__STATIC_FORCEINLINE void MInvalDCache (void)
 Invalidate all D-Cache lines in M-Mode. More...
 
__STATIC_FORCEINLINE void SInvalDCache (void)
 Invalidate all D-Cache lines in S-Mode. More...
 
__STATIC_FORCEINLINE void UInvalDCache (void)
 Invalidate all D-Cache lines in U-Mode. More...
 
__STATIC_FORCEINLINE void MFlushDCache (void)
 Flush all D-Cache lines in M-Mode. More...
 
__STATIC_FORCEINLINE void SFlushDCache (void)
 Flush all D-Cache lines in S-Mode. More...
 
__STATIC_FORCEINLINE void UFlushDCache (void)
 Flush all D-Cache lines in U-Mode. More...
 
__STATIC_FORCEINLINE void MFlushInvalDCache (void)
 Flush and invalidate all D-Cache lines in M-Mode. More...
 
__STATIC_FORCEINLINE void SFlushInvalDCache (void)
 Flush and invalidate all D-Cache lines in S-Mode. More...
 
__STATIC_FORCEINLINE void UFlushInvalDCache (void)
 Flush and invalidate all D-Cache lines in U-Mode. More...
 

Detailed Description

Functions that configure Data Cache.

Function Documentation

◆ DCachePresent()

__STATIC_FORCEINLINE int32_t DCachePresent ( void  )

Check DCache Unit Present or Not.

This function check dcache unit present or not via mcfg_info csr

Remarks
  • This function might not work for some old nuclei processors
  • Please make sure the version of your nuclei processor contain DCACHE bit in mcfg_info
Returns
1 if present otherwise 0

Definition at line 700 of file core_feature_cache.h.

701 {
703  return 1;
704  }
705  return 0;
706 }

References __RV_CSR_READ, CSR_MCFG_INFO, and MCFG_INFO_DCACHE.

◆ DisableDCache()

__STATIC_FORCEINLINE void DisableDCache ( void  )

Disable DCache.

This function Disable D-Cache

Remarks
  • This function can be called in M-Mode only.
  • This CSR_MCACHE_CTL register control D Cache enable.
See also

Definition at line 733 of file core_feature_cache.h.

References __RV_CSR_CLEAR, CSR_MCACHE_CTL, and MCACHE_CTL_DC_EN.

◆ DisableDCacheECC()

__STATIC_FORCEINLINE void DisableDCacheECC ( void  )

Disable DCache ECC.

This function disable D-Cache ECC

Remarks
  • This function can be called in M-Mode only.
  • This CSR_MCACHE_CTL register control D Cache ECC enable.
See also

Definition at line 763 of file core_feature_cache.h.

References __RV_CSR_CLEAR, CSR_MCACHE_CTL, and MCACHE_CTL_DC_ECC_EN.

◆ EnableDCache()

__STATIC_FORCEINLINE void EnableDCache ( void  )

Enable DCache.

This function enable D-Cache

Remarks
  • This function can be called in M-Mode only.
  • This CSR_MCACHE_CTL register control D Cache enable.
See also

Definition at line 718 of file core_feature_cache.h.

References __RV_CSR_SET, CSR_MCACHE_CTL, and MCACHE_CTL_DC_EN.

◆ EnableDCacheECC()

__STATIC_FORCEINLINE void EnableDCacheECC ( void  )

Enable DCache ECC.

This function enable D-Cache ECC

Remarks
  • This function can be called in M-Mode only.
  • This CSR_MCACHE_CTL register control D Cache ECC enable.
See also

Definition at line 748 of file core_feature_cache.h.

References __RV_CSR_SET, CSR_MCACHE_CTL, and MCACHE_CTL_DC_ECC_EN.

◆ GetDCacheInfo()

__STATIC_FORCEINLINE int32_t GetDCacheInfo ( CacheInfo_Type *  info)

Get D-Cache Information.

This function get D-Cache Information

Remarks
  • This function can be called in M-Mode only.
  • You can use this function in combination with cache lines operations
See also

Definition at line 779 of file core_feature_cache.h.

780 {
781  if (info == NULL) {
782  return -1;
783  }
784  CSR_MDCFGINFO_Type csr_ccfg;
785  csr_ccfg.d = __RV_CSR_READ(CSR_MDCFG_INFO);
786  info->setperway = (1 << csr_ccfg.b.set) << 3;
787  info->ways = (1 + csr_ccfg.b.way);
788  if (csr_ccfg.b.lsize == 0) {
789  info->linesize = 0;
790  } else {
791  info->linesize = (1 << (csr_ccfg.b.lsize - 1)) << 3;
792  }
793  info->size = info->setperway * info->ways * info->linesize;
794  return 0;
795 }

References __RV_CSR_READ, CSR_MDCFGINFO_Type::b, CSR_MDCFG_INFO, CSR_MDCFGINFO_Type::d, CSR_MDCFGINFO_Type::lsize, CSR_MDCFGINFO_Type::set, and CSR_MDCFGINFO_Type::way.

◆ MFlushDCache()

__STATIC_FORCEINLINE void MFlushDCache ( void  )

Flush all D-Cache lines in M-Mode.

This function flush all D-Cache lines. Command CCM_DC_WB_ALL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 1435 of file core_feature_cache.h.

1436 {
1438 }

References __RV_CSR_WRITE, CCM_DC_WB_ALL, and CSR_CCM_MCOMMAND.

◆ MFlushDCacheLine()

__STATIC_FORCEINLINE void MFlushDCacheLine ( unsigned long  addr)

Flush one D-Cache line specified by address in M-Mode.

This function flush one D-Cache line specified by the address. Command CCM_DC_WB is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 920 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

Referenced by __ECLIC_SetVector().

◆ MFlushDCacheLines()

__STATIC_FORCEINLINE void MFlushDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush several D-Cache lines specified by address in M-Mode.

This function flush several D-Cache lines specified by the address and line count. Command CCM_DC_WB is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed
[in]cntcount of cache lines to be flushed

Definition at line 937 of file core_feature_cache.h.

938 {
939  if (cnt > 0) {
940  unsigned long i;
942  for (i = 0; i < cnt; i++) {
944  }
945  }
946 }

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MFlushInvalDCache()

__STATIC_FORCEINLINE void MFlushInvalDCache ( void  )

Flush and invalidate all D-Cache lines in M-Mode.

This function flush and invalidate all D-Cache lines. Command CCM_DC_WBINVAL_ALL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed and locked

Definition at line 1477 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL_ALL, and CSR_CCM_MCOMMAND.

◆ MFlushInvalDCacheLine()

__STATIC_FORCEINLINE void MFlushInvalDCacheLine ( unsigned long  addr)

Flush and invalidate one D-Cache line specified by address in M-Mode.

This function flush and invalidate one D-Cache line specified by the address. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated

Definition at line 1031 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MFlushInvalDCacheLines()

__STATIC_FORCEINLINE void MFlushInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush and invalidate several D-Cache lines specified by address in M-Mode.

This function flush and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated
[in]cntcount of cache lines to be flushed and invalidated

Definition at line 1048 of file core_feature_cache.h.

1049 {
1050  if (cnt > 0) {
1051  unsigned long i;
1053  for (i = 0; i < cnt; i++) {
1055  }
1056  }
1057 }

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MInvalDCache()

__STATIC_FORCEINLINE void MInvalDCache ( void  )

Invalidate all D-Cache lines in M-Mode.

This function invalidate all D-Cache lines. Command CCM_DC_INVAL_ALL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 1391 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL_ALL, and CSR_CCM_MCOMMAND.

◆ MInvalDCacheLine()

__STATIC_FORCEINLINE void MInvalDCacheLine ( unsigned long  addr)

Invalidate one D-Cache line specified by address in M-Mode.

This function unlock and invalidate one D-Cache line specified by the address. Command CCM_DC_INVAL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 807 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MInvalDCacheLines()

__STATIC_FORCEINLINE void MInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Invalidate several D-Cache lines specified by address in M-Mode.

This function unlock and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_INVAL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be invalidated
[in]cntcount of cache lines to be invalidated

Definition at line 824 of file core_feature_cache.h.

825 {
826  if (cnt > 0) {
827  unsigned long i;
829  for (i = 0; i < cnt; i++) {
831  }
832  }
833 }

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MLockDCacheLine()

__STATIC_FORCEINLINE unsigned long MLockDCacheLine ( unsigned long  addr)

Lock one D-Cache line specified by address in M-Mode.

This function lock one D-Cache line specified by the address. Command CCM_DC_LOCK is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1143 of file core_feature_cache.h.

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CSR_CCM_MBEGINADDR, CSR_CCM_MCOMMAND, and CSR_CCM_MDATA.

◆ MLockDCacheLines()

__STATIC_FORCEINLINE unsigned long MLockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Lock several D-Cache lines specified by address in M-Mode.

This function lock several D-Cache lines specified by the address and line count. Command CCM_DC_LOCK is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be locked
[in]cntcount of cache lines to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1162 of file core_feature_cache.h.

1163 {
1164  if (cnt > 0) {
1165  unsigned long i;
1166  unsigned long fail_info = CCM_OP_SUCCESS;
1168  for (i = 0; i < cnt; i++) {
1170  fail_info = __RV_CSR_READ(CSR_CCM_MDATA);
1171  if (CCM_OP_SUCCESS != fail_info) {
1172  return fail_info;
1173  }
1174  }
1175  }
1176  return CCM_OP_SUCCESS;
1177 }

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CCM_OP_SUCCESS, CSR_CCM_MBEGINADDR, CSR_CCM_MCOMMAND, and CSR_CCM_MDATA.

◆ MUnlockDCacheLine()

__STATIC_FORCEINLINE void MUnlockDCacheLine ( unsigned long  addr)

Unlock one D-Cache line specified by address in M-Mode.

This function unlock one D-Cache line specified by the address. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be unlocked

Definition at line 1280 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ MUnlockDCacheLines()

__STATIC_FORCEINLINE void MUnlockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Unlock several D-Cache lines specified by address in M-Mode.

This function unlock several D-Cache lines specified by the address and line count. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M-Mode only.
Parameters
[in]addrstart address to be unlocked
[in]cntcount of cache lines to be unlocked

Definition at line 1297 of file core_feature_cache.h.

1298 {
1299  if (cnt > 0) {
1300  unsigned long i;
1302  for (i = 0; i < cnt; i++) {
1304  }
1305  }
1306 }

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_MBEGINADDR, and CSR_CCM_MCOMMAND.

◆ SFlushDCache()

__STATIC_FORCEINLINE void SFlushDCache ( void  )

Flush all D-Cache lines in S-Mode.

This function flush all D-Cache lines. Command CCM_DC_WB_ALL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 1449 of file core_feature_cache.h.

1450 {
1452 }

References __RV_CSR_WRITE, CCM_DC_WB_ALL, and CSR_CCM_SCOMMAND.

◆ SFlushDCacheLine()

__STATIC_FORCEINLINE void SFlushDCacheLine ( unsigned long  addr)

Flush one D-Cache line specified by address in S-Mode.

This function flush one D-Cache line specified by the address. Command CCM_DC_WB is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 957 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

Referenced by __ECLIC_SetVector_S().

◆ SFlushDCacheLines()

__STATIC_FORCEINLINE void SFlushDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush several D-Cache lines specified by address in S-Mode.

This function flush several D-Cache lines specified by the address and line count. Command CCM_DC_WB is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed
[in]cntcount of cache lines to be flushed

Definition at line 974 of file core_feature_cache.h.

975 {
976  if (cnt > 0) {
977  unsigned long i;
979  for (i = 0; i < cnt; i++) {
981  }
982  }
983 }

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SFlushInvalDCache()

__STATIC_FORCEINLINE void SFlushInvalDCache ( void  )

Flush and invalidate all D-Cache lines in S-Mode.

This function flush and invalidate all D-Cache lines. Command CCM_DC_WBINVAL_ALL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed and locked

Definition at line 1491 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL_ALL, and CSR_CCM_SCOMMAND.

◆ SFlushInvalDCacheLine()

__STATIC_FORCEINLINE void SFlushInvalDCacheLine ( unsigned long  addr)

Flush and invalidate one D-Cache line specified by address in S-Mode.

This function flush and invalidate one D-Cache line specified by the address. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated

Definition at line 1068 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SFlushInvalDCacheLines()

__STATIC_FORCEINLINE void SFlushInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush and invalidate several D-Cache lines specified by address in S-Mode.

This function flush and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated
[in]cntcount of cache lines to be flushed and invalidated

Definition at line 1085 of file core_feature_cache.h.

1086 {
1087  if (cnt > 0) {
1088  unsigned long i;
1090  for (i = 0; i < cnt; i++) {
1092  }
1093  }
1094 }

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SInvalDCache()

__STATIC_FORCEINLINE void SInvalDCache ( void  )

Invalidate all D-Cache lines in S-Mode.

This function invalidate all D-Cache lines. Command CCM_DC_INVAL_ALL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 1405 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL_ALL, and CSR_CCM_SCOMMAND.

◆ SInvalDCacheLine()

__STATIC_FORCEINLINE void SInvalDCacheLine ( unsigned long  addr)

Invalidate one D-Cache line specified by address in S-Mode.

This function unlock and invalidate one D-Cache line specified by the address. Command CCM_DC_INVAL is written to CSR CSR_CCM_MCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 845 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SInvalDCacheLines()

__STATIC_FORCEINLINE void SInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Invalidate several D-Cache lines specified by address in S-Mode.

This function unlock and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_INVAL is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be invalidated
[in]cntcount of cache lines to be invalidated

Definition at line 862 of file core_feature_cache.h.

863 {
864  if (cnt > 0) {
865  unsigned long i;
867  for (i = 0; i < cnt; i++) {
869  }
870  }
871 }

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SLockDCacheLine()

__STATIC_FORCEINLINE unsigned long SLockDCacheLine ( unsigned long  addr)

Lock one D-Cache line specified by address in S-Mode.

This function lock one D-Cache line specified by the address. Command CCM_DC_LOCK is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1189 of file core_feature_cache.h.

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CSR_CCM_SBEGINADDR, CSR_CCM_SCOMMAND, and CSR_CCM_SDATA.

◆ SLockDCacheLines()

__STATIC_FORCEINLINE unsigned long SLockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Lock several D-Cache lines specified by address in S-Mode.

This function lock several D-Cache lines specified by the address and line count. Command CCM_DC_LOCK is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be locked
[in]cntcount of cache lines to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1208 of file core_feature_cache.h.

1209 {
1210  if (cnt > 0) {
1211  unsigned long i;
1212  unsigned long fail_info = CCM_OP_SUCCESS;
1214  for (i = 0; i < cnt; i++) {
1216  fail_info = __RV_CSR_READ(CSR_CCM_SDATA);
1217  if (CCM_OP_SUCCESS != fail_info) {
1218  return fail_info;
1219  }
1220  }
1221  }
1222  return CCM_OP_SUCCESS;
1223 }

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CCM_OP_SUCCESS, CSR_CCM_SBEGINADDR, CSR_CCM_SCOMMAND, and CSR_CCM_SDATA.

◆ SUnlockDCacheLine()

__STATIC_FORCEINLINE void SUnlockDCacheLine ( unsigned long  addr)

Unlock one D-Cache line specified by address in S-Mode.

This function unlock one D-Cache line specified by the address. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be unlocked

Definition at line 1317 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ SUnlockDCacheLines()

__STATIC_FORCEINLINE void SUnlockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Unlock several D-Cache lines specified by address in S-Mode.

This function unlock several D-Cache lines specified by the address and line count. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_SCOMMAND.

Remarks
This function must be executed in M/S-Mode only.
Parameters
[in]addrstart address to be unlocked
[in]cntcount of cache lines to be unlocked

Definition at line 1334 of file core_feature_cache.h.

1335 {
1336  if (cnt > 0) {
1337  unsigned long i;
1339  for (i = 0; i < cnt; i++) {
1341  }
1342  }
1343 }

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_SBEGINADDR, and CSR_CCM_SCOMMAND.

◆ UFlushDCache()

__STATIC_FORCEINLINE void UFlushDCache ( void  )

Flush all D-Cache lines in U-Mode.

This function flush all D-Cache lines. Command CCM_DC_WB_ALL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 1463 of file core_feature_cache.h.

1464 {
1466 }

References __RV_CSR_WRITE, CCM_DC_WB_ALL, and CSR_CCM_UCOMMAND.

◆ UFlushDCacheLine()

__STATIC_FORCEINLINE void UFlushDCacheLine ( unsigned long  addr)

Flush one D-Cache line specified by address in U-Mode.

This function flush one D-Cache line specified by the address. Command CCM_DC_WB is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed

Definition at line 994 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UFlushDCacheLines()

__STATIC_FORCEINLINE void UFlushDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush several D-Cache lines specified by address in U-Mode.

This function flush several D-Cache lines specified by the address and line count. Command CCM_DC_WB is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed
[in]cntcount of cache lines to be flushed

Definition at line 1011 of file core_feature_cache.h.

1012 {
1013  if (cnt > 0) {
1014  unsigned long i;
1016  for (i = 0; i < cnt; i++) {
1018  }
1019  }
1020 }

References __RV_CSR_WRITE, CCM_DC_WB, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UFlushInvalDCache()

__STATIC_FORCEINLINE void UFlushInvalDCache ( void  )

Flush and invalidate all D-Cache lines in U-Mode.

This function flush and invalidate all D-Cache lines. Command CCM_DC_WBINVAL_ALL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed and locked

Definition at line 1505 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL_ALL, and CSR_CCM_UCOMMAND.

◆ UFlushInvalDCacheLine()

__STATIC_FORCEINLINE void UFlushInvalDCacheLine ( unsigned long  addr)

Flush and invalidate one D-Cache line specified by address in U-Mode.

This function flush and invalidate one D-Cache line specified by the address. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated

Definition at line 1105 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UFlushInvalDCacheLines()

__STATIC_FORCEINLINE void UFlushInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Flush and invalidate several D-Cache lines specified by address in U-Mode.

This function flush and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_WBINVAL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be flushed and invalidated
[in]cntcount of cache lines to be flushed and invalidated

Definition at line 1122 of file core_feature_cache.h.

1123 {
1124  if (cnt > 0) {
1125  unsigned long i;
1127  for (i = 0; i < cnt; i++) {
1129  }
1130  }
1131 }

References __RV_CSR_WRITE, CCM_DC_WBINVAL, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UInvalDCache()

__STATIC_FORCEINLINE void UInvalDCache ( void  )

Invalidate all D-Cache lines in U-Mode.

This function invalidate all D-Cache lines. In U-Mode, this operation will be automatically translated to flush and invalidate operations by hardware. Command CCM_DC_INVAL_ALL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 1421 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL_ALL, and CSR_CCM_UCOMMAND.

◆ UInvalDCacheLine()

__STATIC_FORCEINLINE void UInvalDCacheLine ( unsigned long  addr)

Invalidate one D-Cache line specified by address in U-Mode.

This function unlock and invalidate one D-Cache line specified by the address. Command CCM_DC_INVAL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be invalidated

Definition at line 883 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UInvalDCacheLines()

__STATIC_FORCEINLINE void UInvalDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Invalidate several D-Cache lines specified by address in U-Mode.

This function unlock and invalidate several D-Cache lines specified by the address and line count. Command CCM_DC_INVAL is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be invalidated
[in]cntcount of cache lines to be invalidated

Definition at line 900 of file core_feature_cache.h.

901 {
902  if (cnt > 0) {
903  unsigned long i;
905  for (i = 0; i < cnt; i++) {
907  }
908  }
909 }

References __RV_CSR_WRITE, CCM_DC_INVAL, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ ULockDCacheLine()

__STATIC_FORCEINLINE unsigned long ULockDCacheLine ( unsigned long  addr)

Lock one D-Cache line specified by address in U-Mode.

This function lock one D-Cache line specified by the address. Command CCM_DC_LOCK is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1235 of file core_feature_cache.h.

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CSR_CCM_UBEGINADDR, CSR_CCM_UCOMMAND, and CSR_CCM_UDATA.

◆ ULockDCacheLines()

__STATIC_FORCEINLINE unsigned long ULockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Lock several D-Cache lines specified by address in U-Mode.

This function lock several D-Cache lines specified by the address and line count. Command CCM_DC_LOCK is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be locked
[in]cntcount of cache lines to be locked
Returns
result of CCM lock operation, see enum CCM_OP_FINFO

Definition at line 1254 of file core_feature_cache.h.

1255 {
1256  if (cnt > 0) {
1257  unsigned long i;
1258  unsigned long fail_info = CCM_OP_SUCCESS;
1260  for (i = 0; i < cnt; i++) {
1262  fail_info = __RV_CSR_READ(CSR_CCM_UDATA);
1263  if (CCM_OP_SUCCESS != fail_info) {
1264  return fail_info;
1265  }
1266  }
1267  }
1268  return CCM_OP_SUCCESS;
1269 }

References __RV_CSR_READ, __RV_CSR_WRITE, CCM_DC_LOCK, CCM_OP_SUCCESS, CSR_CCM_UBEGINADDR, CSR_CCM_UCOMMAND, and CSR_CCM_UDATA.

◆ UUnlockDCacheLine()

__STATIC_FORCEINLINE void UUnlockDCacheLine ( unsigned long  addr)

Unlock one D-Cache line specified by address in U-Mode.

This function unlock one D-Cache line specified by the address. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be unlocked

Definition at line 1354 of file core_feature_cache.h.

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

◆ UUnlockDCacheLines()

__STATIC_FORCEINLINE void UUnlockDCacheLines ( unsigned long  addr,
unsigned long  cnt 
)

Unlock several D-Cache lines specified by address in U-Mode.

This function unlock several D-Cache lines specified by the address and line count. Command CCM_DC_UNLOCK is written to CSR CSR_CCM_UCOMMAND.

Remarks
This function must be executed in M/S/U-Mode only.
Parameters
[in]addrstart address to be unlocked
[in]cntcount of cache lines to be unlocked

Definition at line 1371 of file core_feature_cache.h.

1372 {
1373  if (cnt > 0) {
1374  unsigned long i;
1376  for (i = 0; i < cnt; i++) {
1378  }
1379  }
1380 }

References __RV_CSR_WRITE, CCM_DC_UNLOCK, CSR_CCM_UBEGINADDR, and CSR_CCM_UCOMMAND.

CSR_MDCFGINFO_Type::way
rv_csr_t way
D-Cache way.
Definition: core_feature_base.h:387
CSR_MDCFGINFO_Type::d
rv_csr_t d
Type used for csr data access.
Definition: core_feature_base.h:394
CSR_CCM_MBEGINADDR
#define CSR_CCM_MBEGINADDR
Definition: riscv_encoding.h:1043
__RV_CSR_CLEAR
#define __RV_CSR_CLEAR(csr, val)
CSR operation Macro for csrc instruction.
Definition: core_feature_base.h:606
CCM_DC_LOCK
@ CCM_DC_LOCK
Lock the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:85
CSR_MDCFGINFO_Type
Union type to access MDCFG_INFO CSR register.
Definition: core_feature_base.h:384
CSR_MCFG_INFO
#define CSR_MCFG_INFO
Definition: riscv_encoding.h:1026
__RV_CSR_WRITE
#define __RV_CSR_WRITE(csr, val)
CSR operation Macro for csrw instruction.
Definition: core_feature_base.h:532
CSR_CCM_SDATA
#define CSR_CCM_SDATA
Definition: riscv_encoding.h:1049
CSR_CCM_UDATA
#define CSR_CCM_UDATA
Definition: riscv_encoding.h:1052
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
CSR_CCM_MDATA
#define CSR_CCM_MDATA
Definition: riscv_encoding.h:1045
CSR_MDCFGINFO_Type::b
struct CSR_MDCFGINFO_Type::@14 b
Structure used for bit access.
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
CSR_MCACHE_CTL
#define CSR_MCACHE_CTL
Definition: riscv_encoding.h:948
MCACHE_CTL_DC_ECC_EN
#define MCACHE_CTL_DC_ECC_EN
Definition: riscv_encoding.h:252
CSR_CCM_SBEGINADDR
#define CSR_CCM_SBEGINADDR
Definition: riscv_encoding.h:1047
CSR_MDCFGINFO_Type::set
rv_csr_t set
D-Cache sets per way.
Definition: core_feature_base.h:386
__RV_CSR_READ
#define __RV_CSR_READ(csr)
CSR operation Macro for csrr instruction.
Definition: core_feature_base.h:514
CSR_CCM_SCOMMAND
#define CSR_CCM_SCOMMAND
Definition: riscv_encoding.h:1048
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:569
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
CSR_CCM_MCOMMAND
#define CSR_CCM_MCOMMAND
Definition: riscv_encoding.h:1044
CCM_DC_INVAL
@ CCM_DC_INVAL
Unlock and invalidate D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:82
CSR_MDCFG_INFO
#define CSR_MDCFG_INFO
Definition: riscv_encoding.h:1025
CSR_CCM_UCOMMAND
#define CSR_CCM_UCOMMAND
Definition: riscv_encoding.h:1051
MCACHE_CTL_DC_EN
#define MCACHE_CTL_DC_EN
Definition: riscv_encoding.h:251
CSR_CCM_UBEGINADDR
#define CSR_CCM_UBEGINADDR
Definition: riscv_encoding.h:1050
MCFG_INFO_DCACHE
#define MCFG_INFO_DCACHE
Definition: riscv_encoding.h:273
CSR_MDCFGINFO_Type::lsize
rv_csr_t lsize
D-Cache line size.
Definition: core_feature_base.h:388