NMSIS-Core  Version 1.2.0
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 699 of file core_feature_cache.h.

700 {
702  return 1;
703  }
704  return 0;
705 }

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 732 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 762 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 717 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 747 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 778 of file core_feature_cache.h.

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

References __RV_CSR_READ, CSR_MDCFGINFO_Type::b, CSR_MDCFG_INFO, 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 1433 of file core_feature_cache.h.

1434 {
1436 }

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 918 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 935 of file core_feature_cache.h.

936 {
937  if (cnt > 0) {
938  unsigned long i;
940  for (i = 0; i < cnt; i++) {
942  }
943  }
944 }

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 1475 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 1029 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 1046 of file core_feature_cache.h.

1047 {
1048  if (cnt > 0) {
1049  unsigned long i;
1051  for (i = 0; i < cnt; i++) {
1053  }
1054  }
1055 }

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 1389 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 805 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 822 of file core_feature_cache.h.

823 {
824  if (cnt > 0) {
825  unsigned long i;
827  for (i = 0; i < cnt; i++) {
829  }
830  }
831 }

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 1141 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 1160 of file core_feature_cache.h.

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

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 1278 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 1295 of file core_feature_cache.h.

1296 {
1297  if (cnt > 0) {
1298  unsigned long i;
1300  for (i = 0; i < cnt; i++) {
1302  }
1303  }
1304 }

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 1447 of file core_feature_cache.h.

1448 {
1450 }

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 955 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 972 of file core_feature_cache.h.

973 {
974  if (cnt > 0) {
975  unsigned long i;
977  for (i = 0; i < cnt; i++) {
979  }
980  }
981 }

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 1489 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 1066 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 1083 of file core_feature_cache.h.

1084 {
1085  if (cnt > 0) {
1086  unsigned long i;
1088  for (i = 0; i < cnt; i++) {
1090  }
1091  }
1092 }

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 1403 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 843 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 860 of file core_feature_cache.h.

861 {
862  if (cnt > 0) {
863  unsigned long i;
865  for (i = 0; i < cnt; i++) {
867  }
868  }
869 }

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 1187 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 1206 of file core_feature_cache.h.

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

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 1315 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 1332 of file core_feature_cache.h.

1333 {
1334  if (cnt > 0) {
1335  unsigned long i;
1337  for (i = 0; i < cnt; i++) {
1339  }
1340  }
1341 }

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 1461 of file core_feature_cache.h.

1462 {
1464 }

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 992 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 1009 of file core_feature_cache.h.

1010 {
1011  if (cnt > 0) {
1012  unsigned long i;
1014  for (i = 0; i < cnt; i++) {
1016  }
1017  }
1018 }

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 1503 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 1103 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 1120 of file core_feature_cache.h.

1121 {
1122  if (cnt > 0) {
1123  unsigned long i;
1125  for (i = 0; i < cnt; i++) {
1127  }
1128  }
1129 }

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 1419 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 881 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 898 of file core_feature_cache.h.

899 {
900  if (cnt > 0) {
901  unsigned long i;
903  for (i = 0; i < cnt; i++) {
905  }
906  }
907 }

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 1233 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 1252 of file core_feature_cache.h.

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

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 1352 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 1369 of file core_feature_cache.h.

1370 {
1371  if (cnt > 0) {
1372  unsigned long i;
1374  for (i = 0; i < cnt; i++) {
1376  }
1377  }
1378 }

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:369
CSR_CCM_MBEGINADDR
#define CSR_CCM_MBEGINADDR
Definition: riscv_encoding.h:981
__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
CSR_MDCFGINFO_Type
Union type to access MDCFG_INFO CSR register.
Definition: core_feature_base.h:366
CSR_MCFG_INFO
#define CSR_MCFG_INFO
Definition: riscv_encoding.h:969
__RV_CSR_WRITE
#define __RV_CSR_WRITE(csr, val)
CSR operation Macro for csrw instruction.
Definition: core_feature_base.h:499
CSR_CCM_SDATA
#define CSR_CCM_SDATA
Definition: riscv_encoding.h:987
CSR_CCM_UDATA
#define CSR_CCM_UDATA
Definition: riscv_encoding.h:990
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:983
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:918
MCACHE_CTL_DC_ECC_EN
#define MCACHE_CTL_DC_ECC_EN
Definition: riscv_encoding.h:237
CSR_CCM_SBEGINADDR
#define CSR_CCM_SBEGINADDR
Definition: riscv_encoding.h:985
CSR_MDCFGINFO_Type::set
rv_csr_t set
D-Cache sets per way.
Definition: core_feature_base.h:368
__RV_CSR_READ
#define __RV_CSR_READ(csr)
CSR operation Macro for csrr instruction.
Definition: core_feature_base.h:481
CSR_CCM_SCOMMAND
#define CSR_CCM_SCOMMAND
Definition: riscv_encoding.h:986
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
CSR_CCM_MCOMMAND
#define CSR_CCM_MCOMMAND
Definition: riscv_encoding.h:982
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:968
CSR_CCM_UCOMMAND
#define CSR_CCM_UCOMMAND
Definition: riscv_encoding.h:989
MCACHE_CTL_DC_EN
#define MCACHE_CTL_DC_EN
Definition: riscv_encoding.h:236
CSR_CCM_UBEGINADDR
#define CSR_CCM_UBEGINADDR
Definition: riscv_encoding.h:988
MCFG_INFO_DCACHE
#define MCFG_INFO_DCACHE
Definition: riscv_encoding.h:255
CSR_MDCFGINFO_Type::lsize
rv_csr_t lsize
D-Cache line size.
Definition: core_feature_base.h:370