NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
core_feature_eclic.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_ECLIC__
19 #define __CORE_FEATURE_ECLIC__
20 
24 /*
25  * ECLIC Feature Configuration Macro:
26  * 1. __ECLIC_PRESENT: Define whether Enhanced Core Local Interrupt Controller (ECLIC) Unit is present or not
27  * * 0: Not present
28  * * 1: Present
29  * 2. __ECLIC_BASEADDR: Base address of the ECLIC unit.
30  * 3. __ECLIC_INTCTLBITS: Optional, if defined, it should set to the value of ECLIC_GetInfoCtlbits(), define the number of hardware bits are actually implemented in the clicintctl registers.
31  * Valid number is 1 - 8.
32  * 4. __ECLIC_INTNUM: Define the external interrupt number of ECLIC Unit
33  * 5. __TEE_PRESENT: Define whether TEE feature present, if present, ECLIC will present with S-Mode ECLIC feature
34  * * 0: Not present
35  * * 1: Present
36  *
37  */
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include "core_feature_base.h"
43 
44 #if defined(__ECLIC_PRESENT) && (__ECLIC_PRESENT == 1)
45 
56 typedef union
57 {
58  struct {
59  __IM uint8_t _reserved0:1;
60  __IOM uint8_t nlbits:4;
61  __IM uint8_t nmbits:2;
62  __IM uint8_t _reserved1:1;
63  } b;
64  uint8_t w;
65 } CLICCFG_Type;
66 
70 typedef union {
71  struct {
72  __IM uint32_t numint:13;
73  __IM uint32_t version:8;
74  __IM uint32_t intctlbits:4;
75  __IM uint32_t _reserved0:7;
76  } b;
77  __IM uint32_t w;
79 
83 typedef struct {
84  __IOM uint8_t INTIP;
85  __IOM uint8_t INTIE;
86  __IOM uint8_t INTATTR;
87  __IOM uint8_t INTCTRL;
89 
93 typedef struct {
94  __IOM uint8_t CFG;
95  __IM uint8_t RESERVED0[3];
96  __IM uint32_t INFO;
97  __IM uint8_t RESERVED1;
98 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
99  __IOM uint8_t STH;
100 #else
101  __IM uint8_t RESERVED2;
102 #endif
103  __IM uint8_t RESERVED3;
104  __IOM uint8_t MTH;
105  uint32_t RESERVED4[1021];
106 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
107  CLIC_CTRL_Type CTRL[1024];
108  __IM uint32_t RESERVED5[2];
109  __IM uint8_t RESERVED6;
110  __IOM uint8_t SSTH;
111  __IM uint8_t RESERVED7;
112  __IM uint8_t RESERVED8;
113  __IM uint32_t RESERVED9[1021];
114  CLIC_CTRL_Type SCTRL[1024];
115 #else
116  CLIC_CTRL_Type CTRL[4096];
117 #endif
118 } CLIC_Type;
119 
120 #define CLIC_CLICCFG_NLBIT_Pos 1U
121 #define CLIC_CLICCFG_NLBIT_Msk (0xFUL << CLIC_CLICCFG_NLBIT_Pos)
123 #define CLIC_CLICINFO_CTLBIT_Pos 21U
124 #define CLIC_CLICINFO_CTLBIT_Msk (0xFUL << CLIC_CLICINFO_CTLBIT_Pos)
126 #define CLIC_CLICINFO_VER_Pos 13U
127 #define CLIC_CLICINFO_VER_Msk (0xFFUL << CLIC_CLICCFG_NLBIT_Pos)
129 #define CLIC_CLICINFO_NUM_Pos 0U
130 #define CLIC_CLICINFO_NUM_Msk (0xFFFUL << CLIC_CLICINFO_NUM_Pos)
132 #define CLIC_INTIP_IP_Pos 0U
133 #define CLIC_INTIP_IP_Msk (0x1UL << CLIC_INTIP_IP_Pos)
135 #define CLIC_INTIE_IE_Pos 0U
136 #define CLIC_INTIE_IE_Msk (0x1UL << CLIC_INTIE_IE_Pos)
138 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
139 #define CLIC_INTATTR_MODE_Pos 6U
140 #define CLIC_INTATTR_MODE_Msk (0x3U << CLIC_INTATTR_MODE_Pos)
141 #endif
142 
143 #define CLIC_INTATTR_TRIG_Pos 1U
144 #define CLIC_INTATTR_TRIG_Msk (0x3UL << CLIC_INTATTR_TRIG_Pos)
146 #define CLIC_INTATTR_SHV_Pos 0U
147 #define CLIC_INTATTR_SHV_Msk (0x1UL << CLIC_INTATTR_SHV_Pos)
149 #define ECLIC_MAX_NLBITS 8U
150 #define ECLIC_MODE_MTVEC_Msk 3U
152 #define ECLIC_NON_VECTOR_INTERRUPT 0x0
153 #define ECLIC_VECTOR_INTERRUPT 0x1
156 typedef enum ECLIC_TRIGGER {
161 } ECLIC_TRIGGER_Type;
162 
163 #ifndef __ECLIC_BASEADDR
164 /* Base address of ECLIC(__ECLIC_BASEADDR) should be defined in <Device.h> */
165 #error "__ECLIC_BASEADDR is not defined, please check!"
166 #endif
167 
168 #ifndef __ECLIC_INTCTLBITS
169 /* Define __ECLIC_INTCTLBITS to get via ECLIC->INFO if not defined */
170 #define __ECLIC_INTCTLBITS (__ECLIC_GetInfoCtlbits())
171 #endif
172 
173 /* ECLIC Memory mapping of Device */
174 #define ECLIC_BASE __ECLIC_BASEADDR
175 #define ECLIC ((CLIC_Type *) ECLIC_BASE) /* end of group NMSIS_Core_ECLIC_Registers */
178 
179 /* ########################## ECLIC functions #################################### */
197 /* The following enum IRQn definition in this file
198  * is only used for doxygen documentation generation,
199  * The <Device>.h is the real file to define it by vendor
200  */
201 #if defined(__ONLY_FOR_DOXYGEN_DOCUMENT_GENERATION__)
202 typedef enum IRQn {
203  /* ========= Nuclei N/NX Core Specific Interrupt Numbers =========== */
204  /* Core Internal Interrupt IRQn definitions */
225  /* ========= Device Specific Interrupt Numbers =================== */
226  /* ToDo: add here your device specific external interrupt numbers.
227  * 19~max(NUM_INTERRUPT, 1023) is reserved number for user.
228  * Maxmum interrupt supported could get from clicinfo.NUM_INTERRUPT.
229  * According the interrupt handlers defined in startup_Device.S
230  * eg.: Interrupt for Timer#1 eclic_tim1_handler -> TIM1_IRQn */
233 } IRQn_Type;
234 #endif /* __ONLY_FOR_DOXYGEN_DOCUMENT_GENERATION__ */
235 
236 #ifdef NMSIS_ECLIC_VIRTUAL
237  #ifndef NMSIS_ECLIC_VIRTUAL_HEADER_FILE
238  #define NMSIS_ECLIC_VIRTUAL_HEADER_FILE "nmsis_eclic_virtual.h"
239  #endif
240  #include NMSIS_ECLIC_VIRTUAL_HEADER_FILE
241 #else
242  #define ECLIC_SetCfgNlbits __ECLIC_SetCfgNlbits
243  #define ECLIC_GetCfgNlbits __ECLIC_GetCfgNlbits
244  #define ECLIC_GetInfoVer __ECLIC_GetInfoVer
245  #define ECLIC_GetInfoCtlbits __ECLIC_GetInfoCtlbits
246  #define ECLIC_GetInfoNum __ECLIC_GetInfoNum
247  #define ECLIC_SetMth __ECLIC_SetMth
248  #define ECLIC_GetMth __ECLIC_GetMth
249  #define ECLIC_EnableIRQ __ECLIC_EnableIRQ
250  #define ECLIC_GetEnableIRQ __ECLIC_GetEnableIRQ
251  #define ECLIC_DisableIRQ __ECLIC_DisableIRQ
252  #define ECLIC_SetPendingIRQ __ECLIC_SetPendingIRQ
253  #define ECLIC_GetPendingIRQ __ECLIC_GetPendingIRQ
254  #define ECLIC_ClearPendingIRQ __ECLIC_ClearPendingIRQ
255  #define ECLIC_SetTrigIRQ __ECLIC_SetTrigIRQ
256  #define ECLIC_GetTrigIRQ __ECLIC_GetTrigIRQ
257  #define ECLIC_SetShvIRQ __ECLIC_SetShvIRQ
258  #define ECLIC_GetShvIRQ __ECLIC_GetShvIRQ
259  #define ECLIC_SetCtrlIRQ __ECLIC_SetCtrlIRQ
260  #define ECLIC_GetCtrlIRQ __ECLIC_GetCtrlIRQ
261  #define ECLIC_SetLevelIRQ __ECLIC_SetLevelIRQ
262  #define ECLIC_GetLevelIRQ __ECLIC_GetLevelIRQ
263  #define ECLIC_SetPriorityIRQ __ECLIC_SetPriorityIRQ
264  #define ECLIC_GetPriorityIRQ __ECLIC_GetPriorityIRQ
265 
266  /* For TEE */
267 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
268  #define ECLIC_SetModeIRQ __ECLIC_SetModeIRQ
269  #define ECLIC_SetSth __ECLIC_SetSth
270  #define ECLIC_GetSth __ECLIC_GetSth
271  #define ECLIC_SetTrigIRQ_S __ECLIC_SetTrigIRQ_S
272  #define ECLIC_GetTrigIRQ_S __ECLIC_GetTrigIRQ_S
273  #define ECLIC_SetShvIRQ_S __ECLIC_SetShvIRQ_S
274  #define ECLIC_GetShvIRQ_S __ECLIC_GetShvIRQ_S
275  #define ECLIC_SetCtrlIRQ_S __ECLIC_SetCtrlIRQ_S
276  #define ECLIC_GetCtrlIRQ_S __ECLIC_GetCtrlIRQ_S
277  #define ECLIC_SetLevelIRQ_S __ECLIC_SetLevelIRQ_S
278  #define ECLIC_GetLevelIRQ_S __ECLIC_GetLevelIRQ_S
279  #define ECLIC_SetPriorityIRQ_S __ECLIC_SetPriorityIRQ_S
280  #define ECLIC_GetPriorityIRQ_S __ECLIC_GetPriorityIRQ_S
281  #define ECLIC_EnableIRQ_S __ECLIC_EnableIRQ_S
282  #define ECLIC_GetEnableIRQ_S __ECLIC_GetEnableIRQ_S
283  #define ECLIC_DisableIRQ_S __ECLIC_DisableIRQ_S
284 
285 #endif
286 #endif /* NMSIS_ECLIC_VIRTUAL */
287 
288 #ifdef NMSIS_VECTAB_VIRTUAL
289  #ifndef NMSIS_VECTAB_VIRTUAL_HEADER_FILE
290  #define NMSIS_VECTAB_VIRTUAL_HEADER_FILE "nmsis_vectab_virtual.h"
291  #endif
292  #include NMSIS_VECTAB_VIRTUAL_HEADER_FILE
293 #else
294  #define ECLIC_SetVector __ECLIC_SetVector
295  #define ECLIC_GetVector __ECLIC_GetVector
296 
297 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
298  #define ECLIC_SetVector_S __ECLIC_SetVector_S
299  #define ECLIC_GetVector_S __ECLIC_GetVector_S
300 #endif
301 #endif /* (NMSIS_VECTAB_VIRTUAL) */
302 
314 {
315  ECLIC->CFG &= ~CLIC_CLICCFG_NLBIT_Msk;
316  ECLIC->CFG |= (uint8_t)((nlbits <<CLIC_CLICCFG_NLBIT_Pos) & CLIC_CLICCFG_NLBIT_Msk);
317 }
318 
330 {
331  return ((uint32_t)((ECLIC->CFG & CLIC_CLICCFG_NLBIT_Msk) >> CLIC_CLICCFG_NLBIT_Pos));
332 }
333 
346 {
347  return ((uint32_t)((ECLIC->INFO & CLIC_CLICINFO_VER_Msk) >> CLIC_CLICINFO_VER_Pos));
348 }
349 
363 {
364  return ((uint32_t)((ECLIC->INFO & CLIC_CLICINFO_CTLBIT_Msk) >> CLIC_CLICINFO_CTLBIT_Pos));
365 }
366 
379 {
380  return ((uint32_t)((ECLIC->INFO & CLIC_CLICINFO_NUM_Msk) >> CLIC_CLICINFO_NUM_Pos));
381 }
382 
392 {
393  ECLIC->MTH = mth;
394 }
395 
405 {
406  return (ECLIC->MTH);
407 }
408 
409 
421 {
422  ECLIC->CTRL[IRQn].INTIE |= CLIC_INTIE_IE_Msk;
423 }
424 
440 {
441  return ((uint32_t) (ECLIC->CTRL[IRQn].INTIE) & CLIC_INTIE_IE_Msk);
442 }
443 
455 {
456  ECLIC->CTRL[IRQn].INTIE &= ~CLIC_INTIE_IE_Msk;
457 }
458 
474 {
475  return ((uint32_t)(ECLIC->CTRL[IRQn].INTIP) & CLIC_INTIP_IP_Msk);
476 }
477 
490 {
491  ECLIC->CTRL[IRQn].INTIP |= CLIC_INTIP_IP_Msk;
492 }
493 
507 {
508  ECLIC->CTRL[IRQn].INTIP &= ~CLIC_INTIP_IP_Msk;
509 }
510 
527 __STATIC_FORCEINLINE void __ECLIC_SetTrigIRQ(IRQn_Type IRQn, uint32_t trig)
528 {
529  ECLIC->CTRL[IRQn].INTATTR &= ~CLIC_INTATTR_TRIG_Msk;
530  ECLIC->CTRL[IRQn].INTATTR |= (uint8_t)(trig << CLIC_INTATTR_TRIG_Pos);
531 }
532 
549 {
550  return ((uint32_t)(((ECLIC->CTRL[IRQn].INTATTR) & CLIC_INTATTR_TRIG_Msk) >> CLIC_INTATTR_TRIG_Pos));
551 }
552 
566 __STATIC_FORCEINLINE void __ECLIC_SetShvIRQ(IRQn_Type IRQn, uint32_t shv)
567 {
568  ECLIC->CTRL[IRQn].INTATTR &= ~CLIC_INTATTR_SHV_Msk;
569  ECLIC->CTRL[IRQn].INTATTR |= (uint8_t)(shv << CLIC_INTATTR_SHV_Pos);
570 }
571 
586 {
587  return ((uint32_t)(((ECLIC->CTRL[IRQn].INTATTR) & CLIC_INTATTR_SHV_Msk) >> CLIC_INTATTR_SHV_Pos));
588 }
589 
601 __STATIC_FORCEINLINE void __ECLIC_SetCtrlIRQ(IRQn_Type IRQn, uint8_t intctrl)
602 {
603  ECLIC->CTRL[IRQn].INTCTRL = intctrl;
604 }
605 
618 {
619  return (ECLIC->CTRL[IRQn].INTCTRL);
620 }
621 
637 __STATIC_FORCEINLINE void __ECLIC_SetLevelIRQ(IRQn_Type IRQn, uint8_t lvl_abs)
638 {
639  uint8_t nlbits = __ECLIC_GetCfgNlbits();
640  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
641 
642  if (nlbits == 0) {
643  return;
644  }
645 
646  if (nlbits > intctlbits) {
647  nlbits = intctlbits;
648  }
649  uint8_t maxlvl = ((1 << nlbits) - 1);
650  if (lvl_abs > maxlvl) {
651  lvl_abs = maxlvl;
652  }
653  uint8_t lvl = lvl_abs << (ECLIC_MAX_NLBITS - nlbits);
654  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ(IRQn);
655  cur_ctrl = cur_ctrl << nlbits;
656  cur_ctrl = cur_ctrl >> nlbits;
657  __ECLIC_SetCtrlIRQ(IRQn, (cur_ctrl | lvl));
658 }
659 
672 {
673  uint8_t nlbits = __ECLIC_GetCfgNlbits();
674  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
675 
676  if (nlbits == 0) {
677  return 0;
678  }
679 
680  if (nlbits > intctlbits) {
681  nlbits = intctlbits;
682  }
683  uint8_t intctrl = __ECLIC_GetCtrlIRQ(IRQn);
684  uint8_t lvl_abs = intctrl >> (ECLIC_MAX_NLBITS - nlbits);
685  return lvl_abs;
686 }
687 
703 {
704  uint8_t nlbits = __ECLIC_GetCfgNlbits();
705  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
706  if (nlbits < intctlbits) {
707  uint8_t maxpri = ((1 << (intctlbits - nlbits)) - 1);
708  if (pri > maxpri) {
709  pri = maxpri;
710  }
711  pri = pri << (ECLIC_MAX_NLBITS - intctlbits);
712  uint8_t mask = ((uint8_t)(-1)) >> intctlbits;
713  pri = pri | mask;
714  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ(IRQn);
715  cur_ctrl = cur_ctrl >> (ECLIC_MAX_NLBITS - nlbits);
716  cur_ctrl = cur_ctrl << (ECLIC_MAX_NLBITS - nlbits);
717  __ECLIC_SetCtrlIRQ(IRQn, (cur_ctrl | pri));
718  }
719 }
720 
733 {
734  uint8_t nlbits = __ECLIC_GetCfgNlbits();
735  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
736  if (nlbits < intctlbits) {
737  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ(IRQn);
738  uint8_t pri = cur_ctrl << nlbits;
739  pri = pri >> nlbits;
740  pri = pri >> (ECLIC_MAX_NLBITS - intctlbits);
741  return pri;
742  } else {
743  return 0;
744  }
745 }
746 
764 {
765  volatile unsigned long vec_base;
766  vec_base = ((unsigned long)__RV_CSR_READ(CSR_MTVT));
767  vec_base += ((unsigned long)IRQn) * sizeof(unsigned long);
768  (* (unsigned long *) vec_base) = vector;
769 #if (defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1))
770 #if (defined(__CCM_PRESENT) && (__CCM_PRESENT == 1))
771  MFlushDCacheLine((unsigned long)vec_base);
772 #endif
773 #endif
774 #if (defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1))
775 #if (defined(__CCM_PRESENT) && (__CCM_PRESENT == 1))
776  MInvalICacheLine((unsigned long)vec_base);
777 #else
778  __FENCE_I();
779 #endif
780 #endif
781 }
782 
796 {
797 #if __RISCV_XLEN == 32
798  return (*(uint32_t *)(__RV_CSR_READ(CSR_MTVT) + IRQn * 4));
799 #elif __RISCV_XLEN == 64
800  return (*(uint64_t *)(__RV_CSR_READ(CSR_MTVT) + IRQn * 8));
801 #else // TODO Need cover for XLEN=128 case in future
802  return (*(uint64_t *)(__RV_CSR_READ(CSR_MTVT) + IRQn * 8));
803 #endif
804 }
805 
806 #if defined(__TEE_PRESENT) && (__TEE_PRESENT == 1)
807 
821 __STATIC_FORCEINLINE void __ECLIC_SetModeIRQ(IRQn_Type IRQn, uint32_t mode)
822 {
823  /*
824  * only 1 or 3 can be assigned to mode in one step.the default value of mode is 3,
825  * which can't be clear to 0 firstly, then OR it to 1
826  */
827  ECLIC->CTRL[IRQn].INTATTR = (uint8_t)(mode << CLIC_INTATTR_MODE_Pos) + \
828  (ECLIC->SCTRL[IRQn].INTATTR & (~CLIC_INTATTR_MODE_Msk));
829 }
830 
843 {
844  ECLIC->STH = sth;
845 }
846 
859 {
860  return (ECLIC->STH);
861 }
862 
879 __STATIC_FORCEINLINE void __ECLIC_SetTrigIRQ_S(IRQn_Type IRQn, uint32_t trig)
880 {
881  ECLIC->SCTRL[IRQn].INTATTR &= ~CLIC_INTATTR_TRIG_Msk;
882  ECLIC->SCTRL[IRQn].INTATTR |= (uint8_t)(trig << CLIC_INTATTR_TRIG_Pos);
883 }
884 
901 {
902  return ((uint8_t)(((ECLIC->SCTRL[IRQn].INTATTR) & CLIC_INTATTR_TRIG_Msk) >> CLIC_INTATTR_TRIG_Pos));
903 }
904 
905 
919 __STATIC_FORCEINLINE void __ECLIC_SetShvIRQ_S(IRQn_Type IRQn, uint32_t shv)
920 {
921  ECLIC->SCTRL[IRQn].INTATTR &= ~CLIC_INTATTR_SHV_Msk;
922  ECLIC->SCTRL[IRQn].INTATTR |= (uint8_t)(shv << CLIC_INTATTR_SHV_Pos);
923 }
924 
939 {
940  return ((uint8_t)(((ECLIC->SCTRL[IRQn].INTATTR) & CLIC_INTATTR_SHV_Msk) >> CLIC_INTATTR_SHV_Pos));
941 }
942 
954 __STATIC_FORCEINLINE void __ECLIC_SetCtrlIRQ_S(IRQn_Type IRQn, uint8_t intctrl)
955 {
956  ECLIC->SCTRL[IRQn].INTCTRL = intctrl;
957 }
958 
971 {
972  return (ECLIC->SCTRL[IRQn].INTCTRL);
973 }
974 
990 __STATIC_FORCEINLINE void __ECLIC_SetLevelIRQ_S(IRQn_Type IRQn, uint8_t lvl_abs)
991 {
992  uint8_t nlbits = __ECLIC_GetCfgNlbits();
993  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
994 
995  if (nlbits == 0) {
996  return;
997  }
998 
999  if (nlbits > intctlbits) {
1000  nlbits = intctlbits;
1001  }
1002  uint8_t maxlvl = ((1 << nlbits) - 1);
1003  if (lvl_abs > maxlvl) {
1004  lvl_abs = maxlvl;
1005  }
1006  uint8_t lvl = lvl_abs << (ECLIC_MAX_NLBITS - nlbits);
1007  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ_S(IRQn);
1008  cur_ctrl = cur_ctrl << nlbits;
1009  cur_ctrl = cur_ctrl >> nlbits;
1010  __ECLIC_SetCtrlIRQ_S(IRQn, (cur_ctrl | lvl));
1011 }
1012 
1013 
1026 {
1027  uint8_t nlbits = __ECLIC_GetCfgNlbits();
1028  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
1029 
1030  if (nlbits == 0) {
1031  return 0;
1032  }
1033 
1034  if (nlbits > intctlbits) {
1035  nlbits = intctlbits;
1036  }
1037  uint8_t intctrl = __ECLIC_GetCtrlIRQ_S(IRQn);
1038  uint8_t lvl_abs = intctrl >> (ECLIC_MAX_NLBITS - nlbits);
1039  return lvl_abs;
1040 }
1041 
1057 {
1058  uint8_t nlbits = __ECLIC_GetCfgNlbits();
1059  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
1060  if (nlbits < intctlbits) {
1061  uint8_t maxpri = ((1 << (intctlbits - nlbits)) - 1);
1062  if (pri > maxpri) {
1063  pri = maxpri;
1064  }
1065  pri = pri << (ECLIC_MAX_NLBITS - intctlbits);
1066  uint8_t mask = ((uint8_t)(-1)) >> intctlbits;
1067  pri = pri | mask;
1068  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ_S(IRQn);
1069  cur_ctrl = cur_ctrl >> (ECLIC_MAX_NLBITS - nlbits);
1070  cur_ctrl = cur_ctrl << (ECLIC_MAX_NLBITS - nlbits);
1071  __ECLIC_SetCtrlIRQ_S(IRQn, (cur_ctrl | pri));
1072  }
1073 }
1074 
1087 {
1088  uint8_t nlbits = __ECLIC_GetCfgNlbits();
1089  uint8_t intctlbits = (uint8_t)__ECLIC_INTCTLBITS;
1090  if (nlbits < intctlbits) {
1091  uint8_t cur_ctrl = __ECLIC_GetCtrlIRQ_S(IRQn);
1092  uint8_t pri = cur_ctrl << nlbits;
1093  pri = pri >> nlbits;
1094  pri = pri >> (ECLIC_MAX_NLBITS - intctlbits);
1095  return pri;
1096  } else {
1097  return 0;
1098  }
1099 }
1100 
1112 {
1113  ECLIC->SCTRL[IRQn].INTIE |= CLIC_INTIE_IE_Msk;
1114 }
1115 
1131 {
1132  return ((uint8_t) (ECLIC->SCTRL[IRQn].INTIE) & CLIC_INTIE_IE_Msk);
1133 }
1134 
1146 {
1147  ECLIC->SCTRL[IRQn].INTIE &= ~CLIC_INTIE_IE_Msk;
1148 }
1149 
1167 {
1168  volatile unsigned long vec_base;
1169  vec_base = ((unsigned long)__RV_CSR_READ(CSR_STVT));
1170  vec_base += ((unsigned long)IRQn) * sizeof(unsigned long);
1171  (* (unsigned long *) vec_base) = vector;
1172 #if (defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1))
1173 #if (defined(__CCM_PRESENT) && (__CCM_PRESENT == 1))
1174  SFlushDCacheLine((unsigned long)vec_base);
1175 #endif
1176 #endif
1177 #if (defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1))
1178 #if (defined(__CCM_PRESENT) && (__CCM_PRESENT == 1))
1179  SInvalICacheLine((unsigned long)vec_base);
1180 #else
1181  __FENCE_I();
1182 #endif
1183 #endif
1184 }
1185 
1199 {
1200 #if __RISCV_XLEN == 32
1201  return (*(uint32_t *)(__RV_CSR_READ(CSR_STVT) + IRQn * 4));
1202 #elif __RISCV_XLEN == 64
1203  return (*(uint64_t *)(__RV_CSR_READ(CSR_STVT) + IRQn * 8));
1204 #else // TODO Need cover for XLEN=128 case in future
1205  return (*(uint64_t *)(__RV_CSR_READ(CSR_STVT) + IRQn * 8));
1206 #endif
1207 }
1208 
1209 #endif /* defined(__TEE_PRESENT) && (__TEE_PRESENT == 1) */
1210 
1223 {
1224  addr &= (rv_csr_t)(~0x3F);
1225  addr |= ECLIC_MODE_MTVEC_Msk;
1226  __RV_CSR_WRITE(CSR_MTVEC, addr);
1227 }
1228 
1241 {
1242  unsigned long addr = __RV_CSR_READ(CSR_MTVEC);
1243  return (addr & ~ECLIC_MODE_MTVEC_Msk);
1244 }
1245 
1258 {
1259  if (__RV_CSR_READ(CSR_MTVT2) & 0x1) {
1260  __RV_CSR_WRITE(CSR_MTVT2, addr | 0x01);
1261  } else {
1262  addr &= (rv_csr_t)(~0x3F);
1263  addr |= ECLIC_MODE_MTVEC_Msk;
1264  __RV_CSR_WRITE(CSR_MTVEC, addr);
1265  }
1266 }
1267 
1280 {
1281  if (__RV_CSR_READ(CSR_MTVT2) & 0x1) {
1282  return __RV_CSR_READ(CSR_MTVT2) & (~(rv_csr_t)(0x1));
1283  } else {
1285  return (addr & ~ECLIC_MODE_MTVEC_Msk);
1286  }
1287 }
1288 
1300 {
1301  return __RV_CSR_READ(CSR_MNVEC);
1302 }
1303 
1334 #define SAVE_IRQ_CSR_CONTEXT() \
1335  rv_csr_t __mcause = __RV_CSR_READ(CSR_MCAUSE); \
1336  rv_csr_t __mepc = __RV_CSR_READ(CSR_MEPC); \
1337  rv_csr_t __msubm = __RV_CSR_READ(CSR_MSUBM); \
1338  __enable_irq();
1339 
1341 #define SAVE_IRQ_CSR_CONTEXT_S() \
1342  rv_csr_t __scause = __RV_CSR_READ(CSR_SCAUSE); \
1343  rv_csr_t __sepc = __RV_CSR_READ(CSR_SEPC); \
1344  __enable_irq_s();
1345 
1346 
1356 #define RESTORE_IRQ_CSR_CONTEXT() \
1357  __disable_irq(); \
1358  __RV_CSR_WRITE(CSR_MSUBM, __msubm); \
1359  __RV_CSR_WRITE(CSR_MEPC, __mepc); \
1360  __RV_CSR_WRITE(CSR_MCAUSE, __mcause);
1361 
1363 #define RESTORE_IRQ_CSR_CONTEXT_S() \
1364  __disable_irq_s(); \
1365  __RV_CSR_WRITE(CSR_SEPC, __sepc); \
1366  __RV_CSR_WRITE(CSR_SCAUSE, __scause);
1367  /* End of Doxygen Group NMSIS_Core_IntExc */
1368 
1369 #endif /* defined(__ECLIC_PRESENT) && (__ECLIC_PRESENT == 1) */
1370 
1371 #ifdef __cplusplus
1372 }
1373 #endif
1374 #endif /* __CORE_FEATURE_ECLIC__ */
__IM
#define __IM
Defines 'read only' structure member permissions.
Definition: nmsis_compiler.h:65
__ECLIC_GetVector
__STATIC_FORCEINLINE rv_csr_t __ECLIC_GetVector(IRQn_Type IRQn)
Get Interrupt Vector of a specific interrupt.
Definition: core_feature_eclic.h:795
__ECLIC_EnableIRQ_S
__STATIC_FORCEINLINE void __ECLIC_EnableIRQ_S(IRQn_Type IRQn)
Enable a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1111
SysTimer_IRQn
@ SysTimer_IRQn
System Timer Interrupt.
Definition: core_feature_eclic.h:212
Reserved5_IRQn
@ Reserved5_IRQn
Internal reserved.
Definition: core_feature_eclic.h:211
CLIC_Type::INFO
__IM uint32_t INFO
Offset: 0x004 (R/ ) CLIC information register.
Definition: core_feature_eclic.h:96
CLIC_INTIE_IE_Msk
#define CLIC_INTIE_IE_Msk
CLIC INTIE: IE Mask.
Definition: core_feature_eclic.h:136
__ECLIC_SetShvIRQ
__STATIC_FORCEINLINE void __ECLIC_SetShvIRQ(IRQn_Type IRQn, uint32_t shv)
Set interrupt working mode for a specific interrupt.
Definition: core_feature_eclic.h:566
Reserved3_IRQn
@ Reserved3_IRQn
Internal reserved.
Definition: core_feature_eclic.h:209
CLIC_INTATTR_TRIG_Pos
#define CLIC_INTATTR_TRIG_Pos
CLIC INTATTR: TRIG Position.
Definition: core_feature_eclic.h:143
CLICCFG_Type::w
uint8_t w
Type used for byte access.
Definition: core_feature_eclic.h:64
Reserved14_IRQn
@ Reserved14_IRQn
Internal reserved.
Definition: core_feature_eclic.h:221
__ECLIC_DisableIRQ_S
__STATIC_FORCEINLINE void __ECLIC_DisableIRQ_S(IRQn_Type IRQn)
Disable a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1145
CLIC_Type::RESERVED7
__IM uint8_t RESERVED7
Definition: core_feature_eclic.h:111
CLICINFO_Type::numint
__IM uint32_t numint
bit: 0..12 number of maximum interrupt inputs supported
Definition: core_feature_eclic.h:72
CLIC_INTATTR_MODE_Msk
#define CLIC_INTATTR_MODE_Msk
CLIC INTATTA: Mode Mask.
Definition: core_feature_eclic.h:140
__ECLIC_GetTrigIRQ
__STATIC_FORCEINLINE uint32_t __ECLIC_GetTrigIRQ(IRQn_Type IRQn)
Get trigger mode and polarity for a specific interrupt.
Definition: core_feature_eclic.h:548
ECLIC_NEGTIVE_EDGE_TRIGGER
@ ECLIC_NEGTIVE_EDGE_TRIGGER
Negtive/Falling Edge Triggered, trig[0] = 1, trig[1] = 1.
Definition: core_feature_eclic.h:159
CSR_MTVEC
#define CSR_MTVEC
Definition: riscv_encoding.h:571
Reserved7_IRQn
@ Reserved7_IRQn
Internal reserved.
Definition: core_feature_eclic.h:214
__ECLIC_GetShvIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetShvIRQ_S(IRQn_Type IRQn)
Get interrupt working mode for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:938
CLIC_INTATTR_SHV_Pos
#define CLIC_INTATTR_SHV_Pos
CLIC INTATTR: SHV Position.
Definition: core_feature_eclic.h:146
__set_exc_entry
__STATIC_FORCEINLINE void __set_exc_entry(rv_csr_t addr)
Set Exception entry address.
Definition: core_feature_eclic.h:1222
__ECLIC_SetLevelIRQ
__STATIC_FORCEINLINE void __ECLIC_SetLevelIRQ(IRQn_Type IRQn, uint8_t lvl_abs)
Set ECLIC Interrupt level of a specific interrupt.
Definition: core_feature_eclic.h:637
__ECLIC_GetMth
__STATIC_FORCEINLINE uint8_t __ECLIC_GetMth(void)
Get Machine Mode Interrupt Level Threshold.
Definition: core_feature_eclic.h:404
__ECLIC_SetShvIRQ_S
__STATIC_FORCEINLINE void __ECLIC_SetShvIRQ_S(IRQn_Type IRQn, uint32_t shv)
Set interrupt working mode for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:919
Reserved6_IRQn
@ Reserved6_IRQn
Internal reserved.
Definition: core_feature_eclic.h:213
Reserved0_IRQn
@ Reserved0_IRQn
Internal reserved.
Definition: core_feature_eclic.h:205
CLIC_Type::STH
__IOM uint8_t STH
Offset: 0x009 (R/W ) CLIC supervisor mode interrupt-level threshold.
Definition: core_feature_eclic.h:99
CLIC_CTRL_Type::INTIE
__IOM uint8_t INTIE
Offset: 0x001 (R/W) Interrupt set enable register.
Definition: core_feature_eclic.h:85
__ECLIC_SetPriorityIRQ
__STATIC_FORCEINLINE void __ECLIC_SetPriorityIRQ(IRQn_Type IRQn, uint8_t pri)
Get ECLIC Interrupt priority of a specific interrupt.
Definition: core_feature_eclic.h:702
CLICCFG_Type::nlbits
__IOM uint8_t nlbits
bit: 1..4 specified the bit-width of level and priority in the register clicintctl[i]
Definition: core_feature_eclic.h:60
CLIC_CLICCFG_NLBIT_Msk
#define CLIC_CLICCFG_NLBIT_Msk
CLIC CLICCFG: NLBIT Mask.
Definition: core_feature_eclic.h:121
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
CLICCFG_Type
Union type to access CLICFG configure register.
Definition: core_feature_eclic.h:56
CLICCFG_Type::_reserved1
__IM uint8_t _reserved1
Definition: core_feature_eclic.h:62
Reserved8_IRQn
@ Reserved8_IRQn
Internal reserved.
Definition: core_feature_eclic.h:215
__IOM
#define __IOM
Defines 'read/write' structure member permissions.
Definition: nmsis_compiler.h:69
CLIC_CTRL_Type::INTATTR
__IOM uint8_t INTATTR
Offset: 0x002 (R/W) Interrupt set attributes register.
Definition: core_feature_eclic.h:86
CLICINFO_Type::_reserved0
__IM uint32_t _reserved0
bit: 25..31 Reserved
Definition: core_feature_eclic.h:75
ECLIC_POSTIVE_EDGE_TRIGGER
@ ECLIC_POSTIVE_EDGE_TRIGGER
Postive/Rising Edge Triggered, trig[0] = 1, trig[1] = 0.
Definition: core_feature_eclic.h:158
CSR_MTVT
#define CSR_MTVT
Definition: riscv_encoding.h:900
__ECLIC_GetCtrlIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetCtrlIRQ_S(IRQn_Type IRQn)
Get ECLIC Interrupt Input Control Register value for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:970
CSR_STVT
#define CSR_STVT
Definition: riscv_encoding.h:556
__ECLIC_GetInfoVer
__STATIC_FORCEINLINE uint32_t __ECLIC_GetInfoVer(void)
Get the ECLIC version number.
Definition: core_feature_eclic.h:345
ECLIC_MODE_MTVEC_Msk
#define ECLIC_MODE_MTVEC_Msk
ECLIC Mode mask for MTVT CSR Register.
Definition: core_feature_eclic.h:150
CLIC_INTATTR_MODE_Pos
#define CLIC_INTATTR_MODE_Pos
CLIC INTATTA: Mode Position.
Definition: core_feature_eclic.h:139
IRQn
IRQn
Definition of IRQn numbers.
Definition: core_feature_eclic.h:202
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
__ECLIC_SetMth
__STATIC_FORCEINLINE void __ECLIC_SetMth(uint8_t mth)
Set Machine Mode Interrupt Level Threshold.
Definition: core_feature_eclic.h:391
ECLIC
#define ECLIC
CLIC configuration struct.
Definition: core_feature_eclic.h:175
__RV_CSR_WRITE
#define __RV_CSR_WRITE(csr, val)
CSR operation Macro for csrw instruction.
Definition: core_feature_base.h:499
CLIC_Type
Access to the structure of ECLIC Memory Map, which is compatible with TEE.
Definition: core_feature_eclic.h:93
__ECLIC_SetVector_S
__STATIC_FORCEINLINE void __ECLIC_SetVector_S(IRQn_Type IRQn, rv_csr_t vector)
Set Interrupt Vector of a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1166
__ECLIC_SetCtrlIRQ
__STATIC_FORCEINLINE void __ECLIC_SetCtrlIRQ(IRQn_Type IRQn, uint8_t intctrl)
Modify ECLIC Interrupt Input Control Register for a specific interrupt.
Definition: core_feature_eclic.h:601
CLIC_CLICINFO_CTLBIT_Pos
#define CLIC_CLICINFO_CTLBIT_Pos
CLIC INTINFO: __ECLIC_GetInfoCtlbits() Position.
Definition: core_feature_eclic.h:123
__ECLIC_SetTrigIRQ
__STATIC_FORCEINLINE void __ECLIC_SetTrigIRQ(IRQn_Type IRQn, uint32_t trig)
Set trigger mode and polarity for a specific interrupt.
Definition: core_feature_eclic.h:527
SOC_INT_MAX
@ SOC_INT_MAX
Number of total interrupts.
Definition: core_feature_eclic.h:232
CLICCFG_Type::_reserved0
__IM uint8_t _reserved0
Definition: core_feature_eclic.h:59
CLIC_CTRL_Type
Access to the machine mode register structure of INTIP, INTIE, INTATTR, INTCTL.
Definition: core_feature_eclic.h:83
CLIC_Type::RESERVED3
__IM uint8_t RESERVED3
Definition: core_feature_eclic.h:103
__ECLIC_GetInfoNum
__STATIC_FORCEINLINE uint32_t __ECLIC_GetInfoNum(void)
Get number of maximum interrupt inputs supported.
Definition: core_feature_eclic.h:378
ECLIC_LEVEL_TRIGGER
@ ECLIC_LEVEL_TRIGGER
Level Triggerred, trig[0] = 0.
Definition: core_feature_eclic.h:157
CLICINFO_Type::intctlbits
__IM uint32_t intctlbits
bit: 21..24 specifies how many hardware bits are actually implemented in the clicintctl registers
Definition: core_feature_eclic.h:74
CLIC_INTATTR_SHV_Msk
#define CLIC_INTATTR_SHV_Msk
CLIC INTATTR: SHV Mask.
Definition: core_feature_eclic.h:147
ECLIC_MAX_TRIGGER
@ ECLIC_MAX_TRIGGER
MAX Supported Trigger Mode.
Definition: core_feature_eclic.h:160
__get_nonvec_entry
__STATIC_FORCEINLINE rv_csr_t __get_nonvec_entry(void)
Get Non-vector interrupt entry address.
Definition: core_feature_eclic.h:1279
CLIC_Type::RESERVED1
__IM uint8_t RESERVED1
Definition: core_feature_eclic.h:97
__ECLIC_GetShvIRQ
__STATIC_FORCEINLINE uint32_t __ECLIC_GetShvIRQ(IRQn_Type IRQn)
Get interrupt working mode for a specific interrupt.
Definition: core_feature_eclic.h:585
__ECLIC_GetSth
__STATIC_FORCEINLINE uint8_t __ECLIC_GetSth(void)
Get supervisor-mode Interrupt Level Threshold in supervisor mode.
Definition: core_feature_eclic.h:858
__ECLIC_SetVector
__STATIC_FORCEINLINE void __ECLIC_SetVector(IRQn_Type IRQn, rv_csr_t vector)
Set Interrupt Vector of a specific interrupt.
Definition: core_feature_eclic.h:763
__ECLIC_DisableIRQ
__STATIC_FORCEINLINE void __ECLIC_DisableIRQ(IRQn_Type IRQn)
Disable a specific interrupt.
Definition: core_feature_eclic.h:454
__ECLIC_EnableIRQ
__STATIC_FORCEINLINE void __ECLIC_EnableIRQ(IRQn_Type IRQn)
Enable a specific interrupt.
Definition: core_feature_eclic.h:420
FirstDeviceSpecificInterrupt_IRQn
@ FirstDeviceSpecificInterrupt_IRQn
First Device Specific Interrupt.
Definition: core_feature_eclic.h:231
Reserved16_IRQn
@ Reserved16_IRQn
Internal reserved.
Definition: core_feature_eclic.h:223
Reserved9_IRQn
@ Reserved9_IRQn
Internal reserved.
Definition: core_feature_eclic.h:216
CLIC_CTRL_Type::INTIP
__IOM uint8_t INTIP
Offset: 0x000 (R/W) Interrupt set pending register.
Definition: core_feature_eclic.h:84
__ECLIC_SetTrigIRQ_S
__STATIC_FORCEINLINE void __ECLIC_SetTrigIRQ_S(IRQn_Type IRQn, uint32_t trig)
Set trigger mode and polarity for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:879
CLIC_Type::MTH
__IOM uint8_t MTH
Offset: 0x00B(R/W) CLIC machine mode interrupt-level threshold.
Definition: core_feature_eclic.h:104
CLIC_Type::RESERVED8
__IM uint8_t RESERVED8
Definition: core_feature_eclic.h:112
CLIC_CLICINFO_NUM_Msk
#define CLIC_CLICINFO_NUM_Msk
CLIC CLICINFO: NUM Mask.
Definition: core_feature_eclic.h:130
__STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE
Define a static function that should be always inlined by the compiler.
Definition: nmsis_gcc.h:70
__ECLIC_GetEnableIRQ
__STATIC_FORCEINLINE uint32_t __ECLIC_GetEnableIRQ(IRQn_Type IRQn)
Get a specific interrupt enable status.
Definition: core_feature_eclic.h:439
__set_nonvec_entry
__STATIC_FORCEINLINE void __set_nonvec_entry(rv_csr_t addr)
Set Non-vector interrupt entry address.
Definition: core_feature_eclic.h:1257
__ECLIC_GetCfgNlbits
__STATIC_FORCEINLINE uint32_t __ECLIC_GetCfgNlbits(void)
Get nlbits value.
Definition: core_feature_eclic.h:329
Reserved15_IRQn
@ Reserved15_IRQn
Internal reserved.
Definition: core_feature_eclic.h:222
ECLIC_MAX_NLBITS
#define ECLIC_MAX_NLBITS
Max nlbit of the CLICINTCTLBITS.
Definition: core_feature_eclic.h:149
Reserved2_IRQn
@ Reserved2_IRQn
Internal reserved.
Definition: core_feature_eclic.h:207
CLIC_CLICCFG_NLBIT_Pos
#define CLIC_CLICCFG_NLBIT_Pos
CLIC CLICCFG: NLBIT Position.
Definition: core_feature_eclic.h:120
__ECLIC_GetPriorityIRQ
__STATIC_FORCEINLINE uint8_t __ECLIC_GetPriorityIRQ(IRQn_Type IRQn)
Get ECLIC Interrupt priority of a specific interrupt.
Definition: core_feature_eclic.h:732
CSR_MNVEC
#define CSR_MNVEC
Definition: riscv_encoding.h:915
__ECLIC_GetLevelIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetLevelIRQ_S(IRQn_Type IRQn)
Get ECLIC Interrupt level of a specific interrupt.
Definition: core_feature_eclic.h:1025
CLICINFO_Type
Union type to access CLICINFO information register.
Definition: core_feature_eclic.h:70
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
Reserved11_IRQn
@ Reserved11_IRQn
Internal reserved.
Definition: core_feature_eclic.h:218
CLIC_CTRL_Type::INTCTRL
__IOM uint8_t INTCTRL
Offset: 0x003 (R/W) Interrupt configure register.
Definition: core_feature_eclic.h:87
__RV_CSR_READ
#define __RV_CSR_READ(csr)
CSR operation Macro for csrr instruction.
Definition: core_feature_base.h:481
__get_nmi_entry
__STATIC_FORCEINLINE rv_csr_t __get_nmi_entry(void)
Get NMI interrupt entry from 'CSR_MNVEC'.
Definition: core_feature_eclic.h:1299
__ECLIC_GetEnableIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetEnableIRQ_S(IRQn_Type IRQn)
Get a specific interrupt enable status in supervisor mode.
Definition: core_feature_eclic.h:1130
CLIC_INTATTR_TRIG_Msk
#define CLIC_INTATTR_TRIG_Msk
CLIC INTATTR: TRIG Mask.
Definition: core_feature_eclic.h:144
Reserved10_IRQn
@ Reserved10_IRQn
Internal reserved.
Definition: core_feature_eclic.h:217
__ECLIC_GetCtrlIRQ
__STATIC_FORCEINLINE uint8_t __ECLIC_GetCtrlIRQ(IRQn_Type IRQn)
Get ECLIC Interrupt Input Control Register value for a specific interrupt.
Definition: core_feature_eclic.h:617
__ECLIC_SetPriorityIRQ_S
__STATIC_FORCEINLINE void __ECLIC_SetPriorityIRQ_S(IRQn_Type IRQn, uint8_t pri)
Set ECLIC Interrupt priority of a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1056
__ECLIC_GetPriorityIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetPriorityIRQ_S(IRQn_Type IRQn)
Get ECLIC Interrupt priority of a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1086
__ECLIC_SetCtrlIRQ_S
__STATIC_FORCEINLINE void __ECLIC_SetCtrlIRQ_S(IRQn_Type IRQn, uint8_t intctrl)
Modify ECLIC Interrupt Input Control Register for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:954
__ECLIC_GetPendingIRQ
__STATIC_FORCEINLINE int32_t __ECLIC_GetPendingIRQ(IRQn_Type IRQn)
Get the pending specific interrupt.
Definition: core_feature_eclic.h:473
CSR_MTVT2
#define CSR_MTVT2
Definition: riscv_encoding.h:932
__ECLIC_ClearPendingIRQ
__STATIC_FORCEINLINE void __ECLIC_ClearPendingIRQ(IRQn_Type IRQn)
Clear a specific interrupt from pending.
Definition: core_feature_eclic.h:506
CLIC_Type::CFG
__IOM uint8_t CFG
Offset: 0x000 (R/W) CLIC configuration register.
Definition: core_feature_eclic.h:94
CLIC_Type::RESERVED6
__IM uint8_t RESERVED6
Definition: core_feature_eclic.h:109
__get_exc_entry
__STATIC_FORCEINLINE rv_csr_t __get_exc_entry(void)
Get Exception entry address.
Definition: core_feature_eclic.h:1240
__ECLIC_SetSth
__STATIC_FORCEINLINE void __ECLIC_SetSth(uint8_t sth)
Set supervisor-mode Interrupt Level Threshold in supervisor mode.
Definition: core_feature_eclic.h:842
CLIC_Type::SSTH
__IOM uint8_t SSTH
Offset: 0x2009 (R) CLIC supervisor mode threshold register, which is a mirror to mintthresh....
Definition: core_feature_eclic.h:110
Reserved4_IRQn
@ Reserved4_IRQn
Internal reserved.
Definition: core_feature_eclic.h:210
Reserved13_IRQn
@ Reserved13_IRQn
Internal reserved.
Definition: core_feature_eclic.h:220
CLICINFO_Type::version
__IM uint32_t version
bit: 13..20 20:17 for architecture version,16:13 for implementation version
Definition: core_feature_eclic.h:73
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
Reserved1_IRQn
@ Reserved1_IRQn
Internal reserved.
Definition: core_feature_eclic.h:206
__ECLIC_GetLevelIRQ
__STATIC_FORCEINLINE uint8_t __ECLIC_GetLevelIRQ(IRQn_Type IRQn)
Get ECLIC Interrupt level of a specific interrupt.
Definition: core_feature_eclic.h:671
SysTimerSW_IRQn
@ SysTimerSW_IRQn
System Timer SW interrupt.
Definition: core_feature_eclic.h:208
CLICINFO_Type::w
__IM uint32_t w
Type used for word access.
Definition: core_feature_eclic.h:77
__ECLIC_GetVector_S
__STATIC_FORCEINLINE rv_csr_t __ECLIC_GetVector_S(IRQn_Type IRQn)
Get Interrupt Vector of a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:1198
__ECLIC_GetTrigIRQ_S
__STATIC_FORCEINLINE uint8_t __ECLIC_GetTrigIRQ_S(IRQn_Type IRQn)
Get trigger mode and polarity for a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:900
CLIC_CLICINFO_VER_Pos
#define CLIC_CLICINFO_VER_Pos
CLIC CLICINFO: VERSION Position.
Definition: core_feature_eclic.h:126
__ECLIC_GetInfoCtlbits
__STATIC_FORCEINLINE uint32_t __ECLIC_GetInfoCtlbits(void)
Get CLICINTCTLBITS.
Definition: core_feature_eclic.h:362
__ECLIC_SetLevelIRQ_S
__STATIC_FORCEINLINE void __ECLIC_SetLevelIRQ_S(IRQn_Type IRQn, uint8_t lvl_abs)
Set ECLIC Interrupt level of a specific interrupt in supervisor mode.
Definition: core_feature_eclic.h:990
__ECLIC_SetModeIRQ
__STATIC_FORCEINLINE void __ECLIC_SetModeIRQ(IRQn_Type IRQn, uint32_t mode)
Set privilege mode of a specific interrupt.
Definition: core_feature_eclic.h:821
CLIC_CLICINFO_CTLBIT_Msk
#define CLIC_CLICINFO_CTLBIT_Msk
CLIC INTINFO: __ECLIC_GetInfoCtlbits() Mask.
Definition: core_feature_eclic.h:124
Reserved12_IRQn
@ Reserved12_IRQn
Internal reserved.
Definition: core_feature_eclic.h:219
__ECLIC_SetPendingIRQ
__STATIC_FORCEINLINE void __ECLIC_SetPendingIRQ(IRQn_Type IRQn)
Set a specific interrupt to pending.
Definition: core_feature_eclic.h:489
__FENCE_I
__STATIC_FORCEINLINE void __FENCE_I(void)
Fence.i Instruction.
Definition: core_feature_base.h:1475
CLICCFG_Type::nmbits
__IM uint8_t nmbits
bit: 5..6 ties to 1 if supervisor-level interrupt supported, or else it's reserved
Definition: core_feature_eclic.h:61
rv_csr_t
unsigned long rv_csr_t
Type of Control and Status Register(CSR), depends on the XLEN defined in RISC-V.
Definition: core_feature_base.h:55
CLIC_INTIP_IP_Msk
#define CLIC_INTIP_IP_Msk
CLIC INTIP: IP Mask.
Definition: core_feature_eclic.h:133
__ECLIC_SetCfgNlbits
__STATIC_FORCEINLINE void __ECLIC_SetCfgNlbits(uint32_t nlbits)
Set nlbits value.
Definition: core_feature_eclic.h:313
CLIC_CLICINFO_NUM_Pos
#define CLIC_CLICINFO_NUM_Pos
CLIC CLICINFO: NUM Position.
Definition: core_feature_eclic.h:129
CLIC_CLICINFO_VER_Msk
#define CLIC_CLICINFO_VER_Msk
CLIC CLICINFO: VERSION Mask.
Definition: core_feature_eclic.h:127