NMSIS-Core  Version 1.3.1
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  }
262  CSR_MICFGINFO_Type csr_ccfg;
263  csr_ccfg.d = __RV_CSR_READ(CSR_MICFG_INFO);
264  info->setperway = (1 << csr_ccfg.b.set) << 3;
265  info->ways = (1 + csr_ccfg.b.way);
266  if (csr_ccfg.b.lsize == 0) {
267  info->linesize = 0;
268  } else {
269  info->linesize = (1 << (csr_ccfg.b.lsize - 1)) << 3;
270  }
271  info->size = info->setperway * info->ways * info->linesize;
272  return 0;
273 }
274 
285 __STATIC_FORCEINLINE void MInvalICacheLine(unsigned long addr)
286 {
289 }
290 
302 __STATIC_FORCEINLINE void MInvalICacheLines(unsigned long addr, unsigned long cnt)
303 {
304  if (cnt > 0) {
305  unsigned long i;
307  for (i = 0; i < cnt; i++) {
309  }
310  }
311 }
312 
323 __STATIC_FORCEINLINE void SInvalICacheLine(unsigned long addr)
324 {
327 }
328 
340 __STATIC_FORCEINLINE void SInvalICacheLines(unsigned long addr, unsigned long cnt)
341 {
342  if (cnt > 0) {
343  unsigned long i;
345  for (i = 0; i < cnt; i++) {
347  }
348  }
349 }
350 
361 __STATIC_FORCEINLINE void UInvalICacheLine(unsigned long addr)
362 {
365 }
366 
378 __STATIC_FORCEINLINE void UInvalICacheLines(unsigned long addr, unsigned long cnt)
379 {
380  if (cnt > 0) {
381  unsigned long i;
383  for (i = 0; i < cnt; i++) {
385  }
386  }
387 }
388 
399 __STATIC_FORCEINLINE unsigned long MLockICacheLine(unsigned long addr)
400 {
404 }
405 
418 __STATIC_FORCEINLINE unsigned long MLockICacheLines(unsigned long addr, unsigned long cnt)
419 {
420  if (cnt > 0) {
421  unsigned long i;
422  unsigned long fail_info = CCM_OP_SUCCESS;
424  for (i = 0; i < cnt; i++) {
426  fail_info = __RV_CSR_READ(CSR_CCM_MDATA);
427  if (CCM_OP_SUCCESS != fail_info) {
428  return fail_info;
429  }
430  }
431  }
432  return CCM_OP_SUCCESS;
433 }
434 
445 __STATIC_FORCEINLINE unsigned long SLockICacheLine(unsigned long addr)
446 {
450 }
451 
464 __STATIC_FORCEINLINE unsigned long SLockICacheLines(unsigned long addr, unsigned long cnt)
465 {
466  if (cnt > 0) {
467  unsigned long i;
468  unsigned long fail_info = CCM_OP_SUCCESS;
470  for (i = 0; i < cnt; i++) {
472  fail_info = __RV_CSR_READ(CSR_CCM_SDATA);
473  if (CCM_OP_SUCCESS != fail_info) {
474  return fail_info;
475  }
476  }
477  }
478  return CCM_OP_SUCCESS;
479 }
480 
491 __STATIC_FORCEINLINE unsigned long ULockICacheLine(unsigned long addr)
492 {
496 }
497 
510 __STATIC_FORCEINLINE unsigned long ULockICacheLines(unsigned long addr, unsigned long cnt)
511 {
512  if (cnt > 0) {
513  unsigned long i;
514  unsigned long fail_info = CCM_OP_SUCCESS;
516  for (i = 0; i < cnt; i++) {
518  fail_info = __RV_CSR_READ(CSR_CCM_UDATA);
519  if (CCM_OP_SUCCESS != fail_info) {
520  return fail_info;
521  }
522  }
523  }
524  return CCM_OP_SUCCESS;
525 }
526 
536 __STATIC_FORCEINLINE void MUnlockICacheLine(unsigned long addr)
537 {
540 }
541 
553 __STATIC_FORCEINLINE void MUnlockICacheLines(unsigned long addr, unsigned long cnt)
554 {
555  if (cnt > 0) {
556  unsigned long i;
558  for (i = 0; i < cnt; i++) {
560  }
561  }
562 }
563 
573 __STATIC_FORCEINLINE void SUnlockICacheLine(unsigned long addr)
574 {
577 }
578 
590 __STATIC_FORCEINLINE void SUnlockICacheLines(unsigned long addr, unsigned long cnt)
591 {
592  if (cnt > 0) {
593  unsigned long i;
595  for (i = 0; i < cnt; i++) {
597  }
598  }
599 }
600 
610 __STATIC_FORCEINLINE void UUnlockICacheLine(unsigned long addr)
611 {
614 }
615 
627 __STATIC_FORCEINLINE void UUnlockICacheLines(unsigned long addr, unsigned long cnt)
628 {
629  if (cnt > 0) {
630  unsigned long i;
632  for (i = 0; i < cnt; i++) {
634  }
635  }
636 }
637 
648 {
650 }
651 
662 {
664 }
665 
676 {
678 }
679 #endif /* defined(__CCM_PRESENT) && (__CCM_PRESENT == 1) */
680  /* End of Doxygen Group NMSIS_Core_ICache */
681 #endif /* defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1) */
682 
683 #if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1)
684 
701 {
703  return 1;
704  }
705  return 0;
706 }
707 
719 {
721 }
722 
734 {
736 }
737 
749 {
751 }
752 
764 {
766 }
767 
768 #if defined(__CCM_PRESENT) && (__CCM_PRESENT == 1)
769 
779 __STATIC_FORCEINLINE int32_t GetDCacheInfo(CacheInfo_Type *info)
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 }
796 
807 __STATIC_FORCEINLINE void MInvalDCacheLine(unsigned long addr)
808 {
811 }
812 
824 __STATIC_FORCEINLINE void MInvalDCacheLines(unsigned long addr, unsigned long cnt)
825 {
826  if (cnt > 0) {
827  unsigned long i;
829  for (i = 0; i < cnt; i++) {
831  }
832  }
833 }
834 
845 __STATIC_FORCEINLINE void SInvalDCacheLine(unsigned long addr)
846 {
849 }
850 
862 __STATIC_FORCEINLINE void SInvalDCacheLines(unsigned long addr, unsigned long cnt)
863 {
864  if (cnt > 0) {
865  unsigned long i;
867  for (i = 0; i < cnt; i++) {
869  }
870  }
871 }
872 
883 __STATIC_FORCEINLINE void UInvalDCacheLine(unsigned long addr)
884 {
887 }
888 
900 __STATIC_FORCEINLINE void UInvalDCacheLines(unsigned long addr, unsigned long cnt)
901 {
902  if (cnt > 0) {
903  unsigned long i;
905  for (i = 0; i < cnt; i++) {
907  }
908  }
909 }
910 
920 __STATIC_FORCEINLINE void MFlushDCacheLine(unsigned long addr)
921 {
924 }
925 
937 __STATIC_FORCEINLINE void MFlushDCacheLines(unsigned long addr, unsigned long cnt)
938 {
939  if (cnt > 0) {
940  unsigned long i;
942  for (i = 0; i < cnt; i++) {
944  }
945  }
946 }
947 
957 __STATIC_FORCEINLINE void SFlushDCacheLine(unsigned long addr)
958 {
961 }
962 
974 __STATIC_FORCEINLINE void SFlushDCacheLines(unsigned long addr, unsigned long cnt)
975 {
976  if (cnt > 0) {
977  unsigned long i;
979  for (i = 0; i < cnt; i++) {
981  }
982  }
983 }
984 
994 __STATIC_FORCEINLINE void UFlushDCacheLine(unsigned long addr)
995 {
998 }
999 
1011 __STATIC_FORCEINLINE void UFlushDCacheLines(unsigned long addr, unsigned long cnt)
1012 {
1013  if (cnt > 0) {
1014  unsigned long i;
1016  for (i = 0; i < cnt; i++) {
1018  }
1019  }
1020 }
1021 
1032 {
1035 }
1036 
1048 __STATIC_FORCEINLINE void MFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1049 {
1050  if (cnt > 0) {
1051  unsigned long i;
1053  for (i = 0; i < cnt; i++) {
1055  }
1056  }
1057 }
1058 
1069 {
1072 }
1073 
1085 __STATIC_FORCEINLINE void SFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1086 {
1087  if (cnt > 0) {
1088  unsigned long i;
1090  for (i = 0; i < cnt; i++) {
1092  }
1093  }
1094 }
1095 
1106 {
1109 }
1110 
1122 __STATIC_FORCEINLINE void UFlushInvalDCacheLines(unsigned long addr, unsigned long cnt)
1123 {
1124  if (cnt > 0) {
1125  unsigned long i;
1127  for (i = 0; i < cnt; i++) {
1129  }
1130  }
1131 }
1132 
1143 __STATIC_FORCEINLINE unsigned long MLockDCacheLine(unsigned long addr)
1144 {
1147  return __RV_CSR_READ(CSR_CCM_MDATA);
1148 }
1149 
1162 __STATIC_FORCEINLINE unsigned long MLockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1178 
1189 __STATIC_FORCEINLINE unsigned long SLockDCacheLine(unsigned long addr)
1190 {
1193  return __RV_CSR_READ(CSR_CCM_SDATA);
1194 }
1195 
1208 __STATIC_FORCEINLINE unsigned long SLockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1224 
1235 __STATIC_FORCEINLINE unsigned long ULockDCacheLine(unsigned long addr)
1236 {
1239  return __RV_CSR_READ(CSR_CCM_UDATA);
1240 }
1241 
1254 __STATIC_FORCEINLINE unsigned long ULockDCacheLines(unsigned long addr, unsigned long cnt)
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 }
1270 
1280 __STATIC_FORCEINLINE void MUnlockDCacheLine(unsigned long addr)
1281 {
1284 }
1285 
1297 __STATIC_FORCEINLINE void MUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1298 {
1299  if (cnt > 0) {
1300  unsigned long i;
1302  for (i = 0; i < cnt; i++) {
1304  }
1305  }
1306 }
1307 
1317 __STATIC_FORCEINLINE void SUnlockDCacheLine(unsigned long addr)
1318 {
1321 }
1322 
1334 __STATIC_FORCEINLINE void SUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1335 {
1336  if (cnt > 0) {
1337  unsigned long i;
1339  for (i = 0; i < cnt; i++) {
1341  }
1342  }
1343 }
1344 
1354 __STATIC_FORCEINLINE void UUnlockDCacheLine(unsigned long addr)
1355 {
1358 }
1359 
1371 __STATIC_FORCEINLINE void UUnlockDCacheLines(unsigned long addr, unsigned long cnt)
1372 {
1373  if (cnt > 0) {
1374  unsigned long i;
1376  for (i = 0; i < cnt; i++) {
1378  }
1379  }
1380 }
1381 
1392 {
1394 }
1395 
1406 {
1408 }
1409 
1422 {
1424 }
1425 
1436 {
1438 }
1439 
1450 {
1452 }
1453 
1464 {
1466 }
1467 
1478 {
1480 }
1481 
1492 {
1494 }
1495 
1506 {
1508 }
1509 #endif /* defined(__CCM_PRESENT) && (__CCM_PRESENT == 1) */
1510  /* End of Doxygen Group NMSIS_Core_DCache */
1512 #endif /* defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1) */
1513 
1514 #ifdef __cplusplus
1515 }
1516 #endif
1517 #endif /* __CORE_FEATURE_CACHE_H__ */
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
DCachePresent
__STATIC_FORCEINLINE int32_t DCachePresent(void)
Check DCache Unit Present or Not.
Definition: core_feature_cache.h:700
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:733
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:862
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:627
MInvalDCacheLine
__STATIC_FORCEINLINE void MInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:807
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:974
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:1085
CSR_CCM_SUEN
#define CSR_CCM_SUEN
Definition: riscv_encoding.h:1046
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:1254
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:302
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:1235
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:1143
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:371
UInvalDCache
__STATIC_FORCEINLINE void UInvalDCache(void)
Invalidate all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1421
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:399
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
UFlushInvalDCache
__STATIC_FORCEINLINE void UFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1505
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:491
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:367
MFlushInvalDCache
__STATIC_FORCEINLINE void MFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in M-Mode.
Definition: core_feature_cache.h:1477
SUnlockICacheLine
__STATIC_FORCEINLINE void SUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:573
UInvalDCacheLine
__STATIC_FORCEINLINE void UInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:883
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:1334
SFlushDCacheLine
__STATIC_FORCEINLINE void SFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:957
UUnlockICacheLine
__STATIC_FORCEINLINE void UUnlockICacheLine(unsigned long addr)
Unlock one I-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:610
CSR_MDCFGINFO_Type
Union type to access MDCFG_INFO CSR register.
Definition: core_feature_base.h:384
CSR_MICFGINFO_Type::d
rv_csr_t d
Type used for csr data access.
Definition: core_feature_base.h:378
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:1068
CSR_MCFG_INFO
#define CSR_MCFG_INFO
Definition: riscv_encoding.h:1026
UFlushDCache
__STATIC_FORCEINLINE void UFlushDCache(void)
Flush all D-Cache lines in U-Mode.
Definition: core_feature_cache.h:1463
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:920
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:532
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:1105
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:763
SInvalDCacheLine
__STATIC_FORCEINLINE void SInvalDCacheLine(unsigned long addr)
Invalidate one D-Cache line specified by address in S-Mode.
Definition: core_feature_cache.h:845
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:378
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:536
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:748
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_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:1317
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:1354
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:510
EnableDCache
__STATIC_FORCEINLINE void EnableDCache(void)
Enable DCache.
Definition: core_feature_cache.h:718
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:675
CSR_CCM_MDATA
#define CSR_CCM_MDATA
Definition: riscv_encoding.h:1045
SFlushDCache
__STATIC_FORCEINLINE void SFlushDCache(void)
Flush all D-Cache lines in S-Mode.
Definition: core_feature_cache.h:1449
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:1391
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:1048
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:445
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:1053
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:272
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:1122
SFlushInvalDCache
__STATIC_FORCEINLINE void SFlushInvalDCache(void)
Flush and invalidate all D-Cache lines in S-Mode.
Definition: core_feature_cache.h:1491
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:369
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:370
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:937
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:553
__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:948
MInvalICache
__STATIC_FORCEINLINE void MInvalICache(void)
Invalidate all I-Cache lines in M-Mode.
Definition: core_feature_cache.h:647
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:1011
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:1031
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:464
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
MInvalICacheLine
__STATIC_FORCEINLINE void MInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in M-Mode.
Definition: core_feature_cache.h:285
UInvalICacheLine
__STATIC_FORCEINLINE void UInvalICacheLine(unsigned long addr)
Invalidate one I-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:361
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:1208
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:824
CSR_MICFG_INFO
#define CSR_MICFG_INFO
Definition: riscv_encoding.h:1024
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
SInvalICache
__STATIC_FORCEINLINE void SInvalICache(void)
Invalidate all I-Cache lines in S-Mode.
Definition: core_feature_cache.h:661
CSR_CCM_SCOMMAND
#define CSR_CCM_SCOMMAND
Definition: riscv_encoding.h:1048
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:1162
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:1435
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:569
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:1371
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:1280
UFlushDCacheLine
__STATIC_FORCEINLINE void UFlushDCacheLine(unsigned long addr)
Flush one D-Cache line specified by address in U-Mode.
Definition: core_feature_cache.h:994
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:1297
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:323
MCACHE_CTL_IC_EN
#define MCACHE_CTL_IC_EN
Definition: riscv_encoding.h:240
CSR_CCM_MCOMMAND
#define CSR_CCM_MCOMMAND
Definition: riscv_encoding.h:1044
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:590
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:1189
CSR_MDCFG_INFO
#define CSR_MDCFG_INFO
Definition: riscv_encoding.h:1025
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:340
MCACHE_CTL_IC_ECC_EN
#define MCACHE_CTL_IC_ECC_EN
Definition: riscv_encoding.h:242
GetDCacheInfo
__STATIC_FORCEINLINE int32_t GetDCacheInfo(CacheInfo_Type *info)
Get D-Cache Information.
Definition: core_feature_cache.h:779
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:1405
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:418
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
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:900
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:388
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