NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
core_feature_cache.h
1 /*
2  * Copyright (c) 2019 Nuclei Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __CORE_FEATURE_CACHE_H__
19 #define __CORE_FEATURE_CACHE_H__
20 
24 /*
25  * Cache Feature Configuration Macro:
26  * 1. __ICACHE_PRESENT: Define whether I-Cache Unit is present or not.
27  * * 0: Not present
28  * * 1: Present
29  * 2. __DCACHE_PRESENT: Define whether D-Cache Unit is present or not.
30  * * 0: Not present
31  * * 1: Present
32  * 3. __CCM_PRESENT: Define whether Nuclei Cache Control and Maintainence(CCM) Unit is present or not.
33  * * 0: Not present
34  * * 1: Present
35  */
36 #ifdef __cplusplus
37  extern "C" {
38 #endif
39 
40 #include "core_feature_base.h"
41 
42 
43 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
44 
45 /* ########################## Cache functions #################################### */
70 typedef enum CCM_OP_FINFO {
76 } CCM_OP_FINFO_Type;
77 
81 typedef enum CCM_CMD {
82  CCM_DC_INVAL = 0x0,
83  CCM_DC_WB = 0x1,
85  CCM_DC_LOCK = 0x3,
86  CCM_DC_UNLOCK = 0x4,
88  CCM_DC_WB_ALL = 0x7,
90  CCM_IC_INVAL = 0x8,
91  CCM_IC_LOCK = 0xb,
92  CCM_IC_UNLOCK = 0xc,
94 } CCM_CMD_Type;
95 
99 typedef struct CacheInfo {
100  uint32_t linesize;
101  uint32_t ways;
102  uint32_t setperway;
103  uint32_t size;
104 } CacheInfo_Type;
105 
106 #if __riscv_xlen == 32
107 #define CCM_SUEN_SUEN_Msk (0xFFFFFFFFUL)
108 #else
109 #define CCM_SUEN_SUEN_Msk (0xFFFFFFFFFFFFFFFFUL)
110 #endif
111 
124 {
126 }
127 
140 {
142 }
143 
154 {
156 } /* End of Doxygen Group NMSIS_Core_Cache */
158 #endif
159 
160 #if defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1)
161 
179 {
181  return 1;
182  }
183  return 0;
184 }
185 
197 {
199 }
200 
212 {
214 }
215 
227 {
229 }
230 
242 {
244 }
245 
246 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
247 
257 __STATIC_FORCEINLINE int32_t GetICacheInfo(CacheInfo_Type *info)
258 {
259  if (info == NULL) {
260  return -1;
261  }
263  info->setperway = (1 << csr_ccfg.b.set) << 3;
264  info->ways = (1 + csr_ccfg.b.way);
265  if (csr_ccfg.b.lsize == 0) {
266  info->linesize = 0;
267  } else {
268  info->linesize = (1 << (csr_ccfg.b.lsize - 1)) << 3;
269  }
270  info->size = info->setperway * info->ways * info->linesize;
271  return 0;
272 }
273 
284 __STATIC_FORCEINLINE void MInvalICacheLine(unsigned long addr)
285 {
288 }
289 
301 __STATIC_FORCEINLINE void MInvalICacheLines(unsigned long addr, unsigned long cnt)
302 {
303  if (cnt > 0) {
304  unsigned long i;
306  for (i = 0; i < cnt; i++) {
308  }
309  }
310 }
311 
322 __STATIC_FORCEINLINE void SInvalICacheLine(unsigned long addr)
323 {
326 }
327 
339 __STATIC_FORCEINLINE void SInvalICacheLines(unsigned long addr, unsigned long cnt)
340 {
341  if (cnt > 0) {
342  unsigned long i;
344  for (i = 0; i < cnt; i++) {
346  }
347  }
348 }
349 
360 __STATIC_FORCEINLINE void UInvalICacheLine(unsigned long addr)
361 {
364 }
365 
377 __STATIC_FORCEINLINE void UInvalICacheLines(unsigned long addr, unsigned long cnt)
378 {
379  if (cnt > 0) {
380  unsigned long i;
382  for (i = 0; i < cnt; i++) {
384  }
385  }
386 }
387 
398 __STATIC_FORCEINLINE unsigned long MLockICacheLine(unsigned long addr)
399 {
403 }
404 
417 __STATIC_FORCEINLINE unsigned long MLockICacheLines(unsigned long addr, unsigned long cnt)
418 {
419  if (cnt > 0) {
420  unsigned long i;
421  unsigned long fail_info = CCM_OP_SUCCESS;
423  for (i = 0; i < cnt; i++) {
425  fail_info = __RV_CSR_READ(CSR_CCM_MDATA);
426  if (CCM_OP_SUCCESS != fail_info) {
427  return fail_info;
428  }
429  }
430  }
431  return CCM_OP_SUCCESS;
432 }
433 
444 __STATIC_FORCEINLINE unsigned long SLockICacheLine(unsigned long addr)
445 {
449 }
450 
463 __STATIC_FORCEINLINE unsigned long SLockICacheLines(unsigned long addr, unsigned long cnt)
464 {
465  if (cnt > 0) {
466  unsigned long i;
467  unsigned long fail_info = CCM_OP_SUCCESS;
469  for (i = 0; i < cnt; i++) {
471  fail_info = __RV_CSR_READ(CSR_CCM_SDATA);
472  if (CCM_OP_SUCCESS != fail_info) {
473  return fail_info;
474  }
475  }
476  }
477  return CCM_OP_SUCCESS;
478 }
479 
490 __STATIC_FORCEINLINE unsigned long ULockICacheLine(unsigned long addr)
491 {
495 }
496 
509 __STATIC_FORCEINLINE unsigned long ULockICacheLines(unsigned long addr, unsigned long cnt)
510 {
511  if (cnt > 0) {
512  unsigned long i;
513  unsigned long fail_info = CCM_OP_SUCCESS;
515  for (i = 0; i < cnt; i++) {
517  fail_info = __RV_CSR_READ(CSR_CCM_UDATA);
518  if (CCM_OP_SUCCESS != fail_info) {
519  return fail_info;
520  }
521  }
522  }
523  return CCM_OP_SUCCESS;
524 }
525 
535 __STATIC_FORCEINLINE void MUnlockICacheLine(unsigned long addr)
536 {
539 }
540 
552 __STATIC_FORCEINLINE void MUnlockICacheLines(unsigned long addr, unsigned long cnt)
553 {
554  if (cnt > 0) {
555  unsigned long i;
557  for (i = 0; i < cnt; i++) {
559  }
560  }
561 }
562 
572 __STATIC_FORCEINLINE void SUnlockICacheLine(unsigned long addr)
573 {
576 }
577 
589 __STATIC_FORCEINLINE void SUnlockICacheLines(unsigned long addr, unsigned long cnt)
590 {
591  if (cnt > 0) {
592  unsigned long i;
594  for (i = 0; i < cnt; i++) {
596  }
597  }
598 }
599 
609 __STATIC_FORCEINLINE void UUnlockICacheLine(unsigned long addr)
610 {
613 }
614 
626 __STATIC_FORCEINLINE void UUnlockICacheLines(unsigned long addr, unsigned long cnt)
627 {
628  if (cnt > 0) {
629  unsigned long i;
631  for (i = 0; i < cnt; i++) {
633  }
634  }
635 }
636 
647 {
649 }
650 
661 {
663 }
664 
675 {
677 }
678 #endif /* defined(__CCM_PRESENT) && (__CCM_PRESENT == 1) */
679  /* End of Doxygen Group NMSIS_Core_ICache */
680 #endif /* defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1) */
681 
682 #if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1)
683 
700 {
702  return 1;
703  }
704  return 0;
705 }
706 
718 {
720 }
721 
733 {
735 }
736 
748 {
750 }
751 
763 {
765 }
766 
767 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
768 
778 __STATIC_FORCEINLINE int32_t GetDCacheInfo(CacheInfo_Type *info)
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 }
794 
805 __STATIC_FORCEINLINE void MInvalDCacheLine(unsigned long addr)
806 {
809 }
810 
822 __STATIC_FORCEINLINE void MInvalDCacheLines(unsigned long addr, unsigned long cnt)
823 {
824  if (cnt > 0) {
825  unsigned long i;
827  for (i = 0; i < cnt; i++) {
829  }
830  }
831 }
832 
843 __STATIC_FORCEINLINE void SInvalDCacheLine(unsigned long addr)
844 {
847 }
848 
860 __STATIC_FORCEINLINE void SInvalDCacheLines(unsigned long addr, unsigned long cnt)
861 {
862  if (cnt > 0) {
863  unsigned long i;
865  for (i = 0; i < cnt; i++) {
867  }
868  }
869 }
870 
881 __STATIC_FORCEINLINE void UInvalDCacheLine(unsigned long addr)
882 {
885 }
886 
898 __STATIC_FORCEINLINE void UInvalDCacheLines(unsigned long addr, unsigned long cnt)
899 {
900  if (cnt > 0) {
901  unsigned long i;
903  for (i = 0; i < cnt; i++) {
905  }
906  }
907 }
908 
918 __STATIC_FORCEINLINE void MFlushDCacheLine(unsigned long addr)
919 {
922 }
923 
935 __STATIC_FORCEINLINE void MFlushDCacheLines(unsigned long addr, unsigned long cnt)
936 {
937  if (cnt > 0) {
938  unsigned long i;
940  for (i = 0; i < cnt; i++) {
942  }
943  }
944 }
945 
955 __STATIC_FORCEINLINE void SFlushDCacheLine(unsigned long addr)
956 {
959 }
960 
972 __STATIC_FORCEINLINE void SFlushDCacheLines(unsigned long addr, unsigned long cnt)
973 {
974  if (cnt > 0) {
975  unsigned long i;
977  for (i = 0; i < cnt; i++) {
979  }
980  }
981 }
982 
992 __STATIC_FORCEINLINE void UFlushDCacheLine(unsigned long addr)
993 {
996 }
997 
1009 __STATIC_FORCEINLINE void UFlushDCacheLines(unsigned long addr, unsigned long cnt)
1010 {
1011  if (cnt > 0) {
1012  unsigned long i;
1014  for (i = 0; i < cnt; i++) {
1016  }
1017  }
1018 }
1019 
1030 {
1033 }
1034 
1046 __STATIC_FORCEINLINE void MFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1047 {
1048  if (cnt > 0) {
1049  unsigned long i;
1051  for (i = 0; i < cnt; i++) {
1053  }
1054  }
1055 }
1056 
1067 {
1070 }
1071 
1083 __STATIC_FORCEINLINE void SFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1084 {
1085  if (cnt > 0) {
1086  unsigned long i;
1088  for (i = 0; i < cnt; i++) {
1090  }
1091  }
1092 }
1093 
1104 {
1107 }
1108 
1120 __STATIC_FORCEINLINE void UFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1121 {
1122  if (cnt > 0) {
1123  unsigned long i;
1125  for (i = 0; i < cnt; i++) {
1127  }
1128  }
1129 }
1130 
1141 __STATIC_FORCEINLINE unsigned long MLockDCacheLine(unsigned long addr)
1142 {
1145  return __RV_CSR_READ(CSR_CCM_MDATA);
1146 }
1147 
1160 __STATIC_FORCEINLINE unsigned long MLockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1176 
1187 __STATIC_FORCEINLINE unsigned long SLockDCacheLine(unsigned long addr)
1188 {
1191  return __RV_CSR_READ(CSR_CCM_SDATA);
1192 }
1193 
1206 __STATIC_FORCEINLINE unsigned long SLockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1222 
1233 __STATIC_FORCEINLINE unsigned long ULockDCacheLine(unsigned long addr)
1234 {
1237  return __RV_CSR_READ(CSR_CCM_UDATA);
1238 }
1239 
1252 __STATIC_FORCEINLINE unsigned long ULockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1268 
1278 __STATIC_FORCEINLINE void MUnlockDCacheLine(unsigned long addr)
1279 {
1282 }
1283 
1295 __STATIC_FORCEINLINE void MUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1296 {
1297  if (cnt > 0) {
1298  unsigned long i;
1300  for (i = 0; i < cnt; i++) {
1302  }
1303  }
1304 }
1305 
1315 __STATIC_FORCEINLINE void SUnlockDCacheLine(unsigned long addr)
1316 {
1319 }
1320 
1332 __STATIC_FORCEINLINE void SUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1333 {
1334  if (cnt > 0) {
1335  unsigned long i;
1337  for (i = 0; i < cnt; i++) {
1339  }
1340  }
1341 }
1342 
1352 __STATIC_FORCEINLINE void UUnlockDCacheLine(unsigned long addr)
1353 {
1356 }
1357 
1369 __STATIC_FORCEINLINE void UUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1370 {
1371  if (cnt > 0) {
1372  unsigned long i;
1374  for (i = 0; i < cnt; i++) {
1376  }
1377  }
1378 }
1379 
1390 {
1392 }
1393 
1404 {
1406 }
1407 
1420 {
1422 }
1423 
1434 {
1436 }
1437 
1448 {
1450 }
1451 
1462 {
1464 }
1465 
1476 {
1478 }
1479 
1490 {
1492 }
1493 
1504 {
1506 }
1507 #endif /* defined(__CCM_PRESENT) && (__CCM_PRESENT == 1) */
1508  /* End of Doxygen Group NMSIS_Core_DCache */
1510 #endif /* defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1) */
1511 
1512 #ifdef __cplusplus
1513 }
1514 #endif
1515 #endif /* __CORE_FEATURE_CACHE_H__ */
CSR_MDCFGINFO_Type::way
rv_csr_t way
D-Cache way.
Definition: core_feature_base.h:369
DCachePresent
__STATIC_FORCEINLINE int32_t DCachePresent(void)
Check DCache Unit Present or Not.
Definition: core_feature_cache.h:699
DisableICacheECC
__STATIC_FORCEINLINE void DisableICacheECC(void)
Disable ICache ECC.
Definition: core_feature_cache.h:241
DisableDCache
__STATIC_FORCEINLINE void DisableDCache(void)
Disable DCache.
Definition: core_feature_cache.h:732
SInvalDCacheLines
__STATIC_FORCEINLINE void SInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:860
UUnlockICacheLines
__STATIC_FORCEINLINE void UUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:626
MInvalDCacheLine
__STATIC_FORCEINLINE void MInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:805
SFlushDCacheLines
__STATIC_FORCEINLINE void SFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:972
SFlushInvalDCacheLines
__STATIC_FORCEINLINE void SFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:1083
CSR_CCM_SUEN
#define CSR_CCM_SUEN
Definition: riscv_encoding.h:984
ULockDCacheLines
__STATIC_FORCEINLINE unsigned long ULockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:1252
MInvalICacheLines
__STATIC_FORCEINLINE void MInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:301
ULockDCacheLine
__STATIC_FORCEINLINE unsigned long ULockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:1233
MLockDCacheLine
__STATIC_FORCEINLINE unsigned long MLockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:1141
EnableSUCCM
__STATIC_FORCEINLINE void EnableSUCCM(void)
Enable CCM operation in Supervisor/User Mode.
Definition: core_feature_cache.h:123
CCM_IC_INVAL_ALL
@ CCM_IC_INVAL_ALL
Unlock and invalidate all the I-Cache lines.
Definition: core_feature_cache.h:93
CSR_MICFGINFO_Type::lsize
rv_csr_t lsize
I-Cache line size.
Definition: core_feature_base.h:352
UInvalDCache
__STATIC_FORCEINLINE void UInvalDCache(void)
Invalidate all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1419
MLockICacheLine
__STATIC_FORCEINLINE unsigned long MLockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:398
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
UFlushInvalDCache
__STATIC_FORCEINLINE void UFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1503
ULockICacheLine
__STATIC_FORCEINLINE unsigned long ULockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:490
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
CSR_MICFGINFO_Type
Union type to access MICFG_INFO CSR register.
Definition: core_feature_base.h:348
MFlushInvalDCache
__STATIC_FORCEINLINE void MFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in M-Mode.
Definition: core_feature_cache.h:1475
SUnlockICacheLine
__STATIC_FORCEINLINE void SUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:572
UInvalDCacheLine
__STATIC_FORCEINLINE void UInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:881
SUnlockDCacheLines
__STATIC_FORCEINLINE void SUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:1332
SFlushDCacheLine
__STATIC_FORCEINLINE void SFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:955
UUnlockICacheLine
__STATIC_FORCEINLINE void UUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:609
CSR_MDCFGINFO_Type
Union type to access MDCFG_INFO CSR register.
Definition: core_feature_base.h:366
SFlushInvalDCacheLine
__STATIC_FORCEINLINE void SFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:1066
CSR_MCFG_INFO
#define CSR_MCFG_INFO
Definition: riscv_encoding.h:969
UFlushDCache
__STATIC_FORCEINLINE void UFlushDCache(void)
Flush all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1461
CCM_CMD
CCM_CMD
Cache CCM Command Types.
Definition: core_feature_cache.h:81
MFlushDCacheLine
__STATIC_FORCEINLINE void MFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:918
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
UFlushInvalDCacheLine
__STATIC_FORCEINLINE void UFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:1103
CacheInfo::setperway
uint32_t setperway
Cache set per way.
Definition: core_feature_cache.h:102
DisableDCacheECC
__STATIC_FORCEINLINE void DisableDCacheECC(void)
Disable DCache ECC.
Definition: core_feature_cache.h:762
SInvalDCacheLine
__STATIC_FORCEINLINE void SInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:843
FlushPipeCCM
__STATIC_FORCEINLINE void FlushPipeCCM(void)
Flush pipeline after CCM operation.
Definition: core_feature_cache.h:153
UInvalICacheLines
__STATIC_FORCEINLINE void UInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:377
CacheInfo::size
uint32_t size
Cache total size in bytes.
Definition: core_feature_cache.h:103
MUnlockICacheLine
__STATIC_FORCEINLINE void MUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:535
CacheInfo::ways
uint32_t ways
Cache ways.
Definition: core_feature_cache.h:101
GetICacheInfo
__STATIC_FORCEINLINE int32_t GetICacheInfo(CacheInfo_Type *info)
Get I-Cache Information.
Definition: core_feature_cache.h:257
EnableDCacheECC
__STATIC_FORCEINLINE void EnableDCacheECC(void)
Enable DCache ECC.
Definition: core_feature_cache.h:747
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_SUEN_SUEN_Msk
#define CCM_SUEN_SUEN_Msk
CSR CCM_SUEN: SUEN Mask.
Definition: core_feature_cache.h:109
SUnlockDCacheLine
__STATIC_FORCEINLINE void SUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:1315
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
UUnlockDCacheLine
__STATIC_FORCEINLINE void UUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:1352
ULockICacheLines
__STATIC_FORCEINLINE unsigned long ULockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:509
EnableDCache
__STATIC_FORCEINLINE void EnableDCache(void)
Enable DCache.
Definition: core_feature_cache.h:717
CCM_OP_SUCCESS
@ CCM_OP_SUCCESS
Lock Succeed.
Definition: core_feature_cache.h:71
UInvalICache
__STATIC_FORCEINLINE void UInvalICache(void)
Invalidate all I-Cache lines in U-Mode.
Definition: core_feature_cache.h:674
CSR_CCM_MDATA
#define CSR_CCM_MDATA
Definition: riscv_encoding.h:983
SFlushDCache
__STATIC_FORCEINLINE void SFlushDCache(void)
Flush all D-Cache lines in S-Mode.
Definition: core_feature_cache.h:1447
CacheInfo
Cache Information Type.
Definition: core_feature_cache.h:99
MInvalDCache
__STATIC_FORCEINLINE void MInvalDCache(void)
Invalidate all D-Cache lines in M-Mode.
Definition: core_feature_cache.h:1389
MFlushInvalDCacheLines
__STATIC_FORCEINLINE void MFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:1046
SLockICacheLine
__STATIC_FORCEINLINE unsigned long SLockICacheLine(unsigned long addr)
Lock one I-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:444
CSR_MDCFGINFO_Type::b
struct CSR_MDCFGINFO_Type::@14 b
Structure used for bit access.
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
MCFG_INFO_ICACHE
#define MCFG_INFO_ICACHE
Definition: riscv_encoding.h:254
UFlushInvalDCacheLines
__STATIC_FORCEINLINE void UFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
Flush and invalidate several D-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:1120
SFlushInvalDCache
__STATIC_FORCEINLINE void SFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in S-Mode.
Definition: core_feature_cache.h:1489
CacheInfo::linesize
uint32_t linesize
Cache Line size in bytes.
Definition: core_feature_cache.h:100
CSR_MICFGINFO_Type::set
rv_csr_t set
I-Cache sets per way.
Definition: core_feature_base.h:350
CSR_MICFGINFO_Type::b
struct CSR_MICFGINFO_Type::@13 b
Structure used for bit access.
CCM_DC_WB_ALL
@ CCM_DC_WB_ALL
Flush all the valid and dirty D-Cache lines.
Definition: core_feature_cache.h:88
DisableSUCCM
__STATIC_FORCEINLINE void DisableSUCCM(void)
Disable CCM operation in Supervisor/User Mode.
Definition: core_feature_cache.h:139
CSR_MICFGINFO_Type::way
rv_csr_t way
I-Cache way.
Definition: core_feature_base.h:351
MFlushDCacheLines
__STATIC_FORCEINLINE void MFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:935
MUnlockICacheLines
__STATIC_FORCEINLINE void MUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:552
__STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE
Define a static function that should be always inlined by the compiler.
Definition: nmsis_gcc.h:70
CSR_MCACHE_CTL
#define CSR_MCACHE_CTL
Definition: riscv_encoding.h:918
MInvalICache
__STATIC_FORCEINLINE void MInvalICache(void)
Invalidate all I-Cache lines in M-Mode.
Definition: core_feature_cache.h:646
UFlushDCacheLines
__STATIC_FORCEINLINE void UFlushDCacheLines(unsigned long addr, unsigned long cnt)
Flush several D-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:1009
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
MFlushInvalDCacheLine
__STATIC_FORCEINLINE void MFlushInvalDCacheLine(unsigned long addr)
Flush and invalidate one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:1029
SLockICacheLines
__STATIC_FORCEINLINE unsigned long SLockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:463
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
MInvalICacheLine
__STATIC_FORCEINLINE void MInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:284
UInvalICacheLine
__STATIC_FORCEINLINE void UInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:360
SLockDCacheLines
__STATIC_FORCEINLINE unsigned long SLockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:1206
MInvalDCacheLines
__STATIC_FORCEINLINE void MInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:822
CSR_MICFG_INFO
#define CSR_MICFG_INFO
Definition: riscv_encoding.h:967
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
SInvalICache
__STATIC_FORCEINLINE void SInvalICache(void)
Invalidate all I-Cache lines in S-Mode.
Definition: core_feature_cache.h:660
CSR_CCM_SCOMMAND
#define CSR_CCM_SCOMMAND
Definition: riscv_encoding.h:986
MLockDCacheLines
__STATIC_FORCEINLINE unsigned long MLockDCacheLines(unsigned long addr, unsigned long cnt)
Lock several D-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:1160
CCM_OP_FINFO
CCM_OP_FINFO
Cache CCM Operation Fail Info.
Definition: core_feature_cache.h:70
CCM_DC_WB
@ CCM_DC_WB
Flush the specific D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:83
MFlushDCache
__STATIC_FORCEINLINE void MFlushDCache(void)
Flush all D-Cache lines in M-Mode.
Definition: core_feature_cache.h:1433
EnableICacheECC
__STATIC_FORCEINLINE void EnableICacheECC(void)
Enable ICache ECC.
Definition: core_feature_cache.h:226
__RV_CSR_SET
#define __RV_CSR_SET(csr, val)
CSR operation Macro for csrs instruction.
Definition: core_feature_base.h:536
UUnlockDCacheLines
__STATIC_FORCEINLINE void UUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:1369
DisableICache
__STATIC_FORCEINLINE void DisableICache(void)
Disable ICache.
Definition: core_feature_cache.h:211
CCM_DC_INVAL_ALL
@ CCM_DC_INVAL_ALL
Unlock and invalidate all the D-Cache lines.
Definition: core_feature_cache.h:89
MUnlockDCacheLine
__STATIC_FORCEINLINE void MUnlockDCacheLine(unsigned long addr)
Unlock one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:1278
UFlushDCacheLine
__STATIC_FORCEINLINE void UFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:992
MUnlockDCacheLines
__STATIC_FORCEINLINE void MUnlockDCacheLines(unsigned long addr, unsigned long cnt)
Unlock several D-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:1295
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
SInvalICacheLine
__STATIC_FORCEINLINE void SInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:322
MCACHE_CTL_IC_EN
#define MCACHE_CTL_IC_EN
Definition: riscv_encoding.h:228
CSR_CCM_MCOMMAND
#define CSR_CCM_MCOMMAND
Definition: riscv_encoding.h:982
EnableICache
__STATIC_FORCEINLINE void EnableICache(void)
Enable ICache.
Definition: core_feature_cache.h:196
CCM_DC_INVAL
@ CCM_DC_INVAL
Unlock and invalidate D-Cache line specified by CSR CCM_XBEGINADDR.
Definition: core_feature_cache.h:82
SUnlockICacheLines
__STATIC_FORCEINLINE void SUnlockICacheLines(unsigned long addr, unsigned long cnt)
Unlock several I-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:589
SLockDCacheLine
__STATIC_FORCEINLINE unsigned long SLockDCacheLine(unsigned long addr)
Lock one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:1187
CSR_MDCFG_INFO
#define CSR_MDCFG_INFO
Definition: riscv_encoding.h:968
SInvalICacheLines
__STATIC_FORCEINLINE void SInvalICacheLines(unsigned long addr, unsigned long cnt)
Invalidate several I-Cache lines specified by address in S-Mode.
Definition: core_feature_cache.h:339
MCACHE_CTL_IC_ECC_EN
#define MCACHE_CTL_IC_ECC_EN
Definition: riscv_encoding.h:230
GetDCacheInfo
__STATIC_FORCEINLINE int32_t GetDCacheInfo(CacheInfo_Type *info)
Get D-Cache Information.
Definition: core_feature_cache.h:778
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
SInvalDCache
__STATIC_FORCEINLINE void SInvalDCache(void)
Invalidate all D-Cache lines in S-Mode.
Definition: core_feature_cache.h:1403
MLockICacheLines
__STATIC_FORCEINLINE unsigned long MLockICacheLines(unsigned long addr, unsigned long cnt)
Lock several I-Cache lines specified by address in M-Mode.
Definition: core_feature_cache.h:417
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
UInvalDCacheLines
__STATIC_FORCEINLINE void UInvalDCacheLines(unsigned long addr, unsigned long cnt)
Invalidate several D-Cache lines specified by address in U-Mode.
Definition: core_feature_cache.h:898
ICachePresent
__STATIC_FORCEINLINE int32_t ICachePresent(void)
Check ICache Unit Present or Not.
Definition: core_feature_cache.h:178
CSR_MDCFGINFO_Type::lsize
rv_csr_t lsize
D-Cache line size.
Definition: core_feature_base.h:370
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