8 #ifndef HPM_INTERRUPT_H
9 #define HPM_INTERRUPT_H
254 #define intc_m_enable_irq(irq) \
255 intc_enable_irq(HPM_PLIC_TARGET_M_MODE, irq)
262 #define intc_m_disable_irq(irq) \
263 intc_disable_irq(HPM_PLIC_TARGET_M_MODE, irq)
265 #define intc_m_set_threshold(threshold) \
266 intc_set_threshold(HPM_PLIC_TARGET_M_MODE, threshold)
273 #define intc_m_complete_irq(irq) \
274 intc_complete_irq(HPM_PLIC_TARGET_M_MODE, irq)
280 #define intc_m_claim_irq() intc_claim_irq(HPM_PLIC_TARGET_M_MODE)
288 #define intc_m_enable_irq_with_priority(irq, priority) \
290 intc_set_irq_priority(irq, priority); \
291 intc_m_enable_irq(irq); \
342 #define intc_s_enable_irq(irq) \
343 intc_enable_irq(HPM_PLIC_TARGET_S_MODE, irq)
350 #define intc_s_disable_irq(irq) \
351 intc_disable_irq(HPM_PLIC_TARGET_S_MODE, irq)
353 #define intc_set_s_threshold(threshold) \
354 intc_set_threshold(HPM_PLIC_TARGET_S_MODE, threshold)
361 #define intc_s_complete_irq(irq) \
362 intc_complete_irq(HPM_PLIC_TARGET_S_MODE, irq)
368 #define intc_s_claim_irq() intc_claim_irq(HPM_PLIC_TARGET_S_MODE)
376 #define intc_s_enable_irq_with_priority(irq, priority) \
378 intc_set_irq_priority(irq, priority); \
379 intc_s_enable_irq(irq); \
454 extern int __vector_table[];
464 ATTR_ALWAYS_INLINE
static inline void install_isr(uint32_t irq, uint32_t isr)
466 __vector_table[irq] = isr;
481 extern int __vector_s_table[];
490 ATTR_ALWAYS_INLINE
static inline void install_s_isr(uint32_t irq, uint32_t isr)
492 __vector_s_table[irq] = isr;
514 #define SAVE_CSR(r) register long __##r = read_csr(r);
521 #define RESTORE_CSR(r) write_csr(r, __##r);
523 #if defined(SUPPORT_PFT_ARCH) && SUPPORT_PFT_ARCH
524 #define SAVE_MXSTATUS() SAVE_CSR(CSR_MXSTATUS)
525 #define RESTORE_MXSTATUS() RESTORE_CSR(CSR_MXSTATUS)
527 #define SAVE_MXSTATUS()
528 #define RESTORE_MXSTATUS()
532 #define SAVE_FCSR() register int __fcsr = read_fcsr();
533 #define RESTORE_FCSR() write_fcsr(__fcsr);
536 #define RESTORE_FCSR()
540 #define SAVE_UCODE() SAVE_CSR(CSR_UCODE)
541 #define RESTORE_UCODE() RESTORE_CSR(CSR_UCODE)
544 #define RESTORE_UCODE()
548 #if __riscv_flen == 32
550 #define CONTEXT_REG_NUM (4 * (16 + 4 + 20))
553 #define CONTEXT_REG_NUM (4 * (16 + 4 + 20 * 2))
558 #define CONTEXT_REG_NUM (4 * (16 + 4))
566 #if __riscv_flen == 32
568 #define SAVE_FPU_CONTEXT() { \
571 c.fswsp ft1, 21*4 \n\
572 c.fswsp ft2, 22*4 \n\
573 c.fswsp ft3, 23*4 \n\
574 c.fswsp ft4, 24*4 \n\
575 c.fswsp ft5, 25*4 \n\
576 c.fswsp ft6, 26*4 \n\
577 c.fswsp ft7, 27*4 \n\
578 c.fswsp fa0, 28*4 \n\
579 c.fswsp fa1, 29*4 \n\
580 c.fswsp fa2, 30*4 \n\
581 c.fswsp fa3, 31*4 \n\
582 c.fswsp fa4, 32*4 \n\
583 c.fswsp fa5, 33*4 \n\
584 c.fswsp fa6, 34*4 \n\
585 c.fswsp fa7, 35*4 \n\
586 c.fswsp ft8, 36*4 \n\
587 c.fswsp ft9, 37*4 \n\
588 c.fswsp ft10, 38*4 \n\
589 c.fswsp ft11, 39*4 \n");\
596 #define RESTORE_FPU_CONTEXT() { \
599 c.flwsp ft1, 21*4 \n\
600 c.flwsp ft2, 22*4 \n\
601 c.flwsp ft3, 23*4 \n\
602 c.flwsp ft4, 24*4 \n\
603 c.flwsp ft5, 25*4 \n\
604 c.flwsp ft6, 26*4 \n\
605 c.flwsp ft7, 27*4 \n\
606 c.flwsp fa0, 28*4 \n\
607 c.flwsp fa1, 29*4 \n\
608 c.flwsp fa2, 30*4 \n\
609 c.flwsp fa3, 31*4 \n\
610 c.flwsp fa4, 32*4 \n\
611 c.flwsp fa5, 33*4 \n\
612 c.flwsp fa6, 34*4 \n\
613 c.flwsp fa7, 35*4 \n\
614 c.flwsp ft8, 36*4 \n\
615 c.flwsp ft9, 37*4 \n\
616 c.flwsp ft10, 38*4 \n\
617 c.flwsp ft11, 39*4 \n");\
620 #define SAVE_FPU_CONTEXT() { \
622 c.fswsp ft0, 20*4(sp)\n\
623 c.fswsp ft1, 21*4(sp) \n\
624 c.fswsp ft2, 22*4(sp) \n\
625 c.fswsp ft3, 23*4(sp) \n\
626 c.fswsp ft4, 24*4(sp) \n\
627 c.fswsp ft5, 25*4(sp) \n\
628 c.fswsp ft6, 26*4(sp) \n\
629 c.fswsp ft7, 27*4(sp) \n\
630 c.fswsp fa0, 28*4(sp) \n\
631 c.fswsp fa1, 29*4(sp) \n\
632 c.fswsp fa2, 30*4(sp) \n\
633 c.fswsp fa3, 31*4(sp) \n\
634 c.fswsp fa4, 32*4(sp) \n\
635 c.fswsp fa5, 33*4(sp) \n\
636 c.fswsp fa6, 34*4(sp) \n\
637 c.fswsp fa7, 35*4(sp) \n\
638 c.fswsp ft8, 36*4(sp) \n\
639 c.fswsp ft9, 37*4(sp) \n\
640 c.fswsp ft10, 38*4(sp) \n\
641 c.fswsp ft11, 39*4(sp) \n");\
648 #define RESTORE_FPU_CONTEXT() { \
650 c.flwsp ft0, 20*4(sp)\n\
651 c.flwsp ft1, 21*4(sp) \n\
652 c.flwsp ft2, 22*4(sp) \n\
653 c.flwsp ft3, 23*4(sp) \n\
654 c.flwsp ft4, 24*4(sp) \n\
655 c.flwsp ft5, 25*4(sp) \n\
656 c.flwsp ft6, 26*4(sp) \n\
657 c.flwsp ft7, 27*4(sp) \n\
658 c.flwsp fa0, 28*4(sp) \n\
659 c.flwsp fa1, 29*4(sp) \n\
660 c.flwsp fa2, 30*4(sp) \n\
661 c.flwsp fa3, 31*4(sp) \n\
662 c.flwsp fa4, 32*4(sp) \n\
663 c.flwsp fa5, 33*4(sp) \n\
664 c.flwsp fa6, 34*4(sp) \n\
665 c.flwsp fa7, 35*4(sp) \n\
666 c.flwsp ft8, 36*4(sp) \n\
667 c.flwsp ft9, 37*4(sp) \n\
668 c.flwsp ft10, 38*4(sp) \n\
669 c.flwsp ft11, 39*4(sp) \n");\
674 #define SAVE_FPU_CONTEXT() { \
677 c.fsdsp ft1, 22*4 \n\
678 c.fsdsp ft2, 24*4 \n\
679 c.fsdsp ft3, 26*4 \n\
680 c.fsdsp ft4, 28*4 \n\
681 c.fsdsp ft5, 30*4 \n\
682 c.fsdsp ft6, 32*4 \n\
683 c.fsdsp ft7, 34*4 \n\
684 c.fsdsp fa0, 36*4 \n\
685 c.fsdsp fa1, 38*4 \n\
686 c.fsdsp fa2, 40*4 \n\
687 c.fsdsp fa3, 42*4 \n\
688 c.fsdsp fa4, 44*4 \n\
689 c.fsdsp fa5, 46*4 \n\
690 c.fsdsp fa6, 48*4 \n\
691 c.fsdsp fa7, 50*4 \n\
692 c.fsdsp ft8, 52*4 \n\
693 c.fsdsp ft9, 54*4 \n\
694 c.fsdsp ft10, 56*4 \n\
695 c.fsdsp ft11, 58*4 \n");\
702 #define RESTORE_FPU_CONTEXT() { \
705 c.fldsp ft1, 22*4 \n\
706 c.fldsp ft2, 24*4 \n\
707 c.fldsp ft3, 26*4 \n\
708 c.fldsp ft4, 28*4 \n\
709 c.fldsp ft5, 30*4 \n\
710 c.fldsp ft6, 32*4 \n\
711 c.fldsp ft7, 34*4 \n\
712 c.fldsp fa0, 36*4 \n\
713 c.fldsp fa1, 38*4 \n\
714 c.fldsp fa2, 40*4 \n\
715 c.fldsp fa3, 42*4 \n\
716 c.fldsp fa4, 44*4 \n\
717 c.fldsp fa5, 46*4 \n\
718 c.fldsp fa6, 48*4 \n\
719 c.fldsp fa7, 50*4 \n\
720 c.fldsp ft8, 52*4 \n\
721 c.fldsp ft9, 54*4 \n\
722 c.fldsp ft10, 56*4 \n\
723 c.fldsp ft11, 58*4 \n");\
726 #define SAVE_FPU_CONTEXT() { \
728 c.fsdsp ft0, 20*4(sp)\n\
729 c.fsdsp ft1, 22*4(sp) \n\
730 c.fsdsp ft2, 24*4(sp) \n\
731 c.fsdsp ft3, 26*4(sp) \n\
732 c.fsdsp ft4, 28*4(sp) \n\
733 c.fsdsp ft5, 30*4(sp) \n\
734 c.fsdsp ft6, 32*4(sp) \n\
735 c.fsdsp ft7, 34*4(sp) \n\
736 c.fsdsp fa0, 36*4(sp) \n\
737 c.fsdsp fa1, 38*4(sp) \n\
738 c.fsdsp fa2, 40*4(sp) \n\
739 c.fsdsp fa3, 42*4(sp) \n\
740 c.fsdsp fa4, 44*4(sp) \n\
741 c.fsdsp fa5, 46*4(sp) \n\
742 c.fsdsp fa6, 48*4(sp) \n\
743 c.fsdsp fa7, 50*4(sp) \n\
744 c.fsdsp ft8, 52*4(sp) \n\
745 c.fsdsp ft9, 54*4(sp) \n\
746 c.fsdsp ft10, 56*4(sp) \n\
747 c.fsdsp ft11, 58*4(sp) \n");\
754 #define RESTORE_FPU_CONTEXT() { \
756 c.fldsp ft0, 20*4(sp)\n\
757 c.fldsp ft1, 22*4(sp) \n\
758 c.fldsp ft2, 24*4(sp) \n\
759 c.fldsp ft3, 26*4(sp) \n\
760 c.fldsp ft4, 28*4(sp) \n\
761 c.fldsp ft5, 30*4(sp) \n\
762 c.fldsp ft6, 32*4(sp) \n\
763 c.fldsp ft7, 34*4(sp) \n\
764 c.fldsp fa0, 36*4(sp) \n\
765 c.fldsp fa1, 38*4(sp) \n\
766 c.fldsp fa2, 40*4(sp) \n\
767 c.fldsp fa3, 42*4(sp) \n\
768 c.fldsp fa4, 44*4(sp) \n\
769 c.fldsp fa5, 46*4(sp) \n\
770 c.fldsp fa6, 48*4(sp) \n\
771 c.fldsp fa7, 50*4(sp) \n\
772 c.fldsp ft8, 52*4(sp) \n\
773 c.fldsp ft9, 54*4(sp) \n\
774 c.fldsp ft10, 56*4(sp) \n\
775 c.fldsp ft11, 58*4(sp) \n");\
780 #define SAVE_FPU_CONTEXT()
781 #define RESTORE_FPU_CONTEXT()
788 #define SAVE_CALLER_CONTEXT() { \
789 __asm volatile("addi sp, sp, %0" : : "i"(-CONTEXT_REG_NUM) :);\
811 SAVE_FPU_CONTEXT(); \
817 #define RESTORE_CALLER_CONTEXT() { \
838 c.lwsp t6, 19*4 \n");\
839 RESTORE_FPU_CONTEXT(); \
840 __asm volatile("addi sp, sp, %0" : : "i"(CONTEXT_REG_NUM) :);\
846 #define SAVE_CALLER_CONTEXT() { \
847 __asm volatile("addi sp, sp, %0" : : "i"(-CONTEXT_REG_NUM) :);\
849 c.swsp ra, 0*4(sp) \n\
850 c.swsp t0, 1*4(sp) \n\
851 c.swsp t1, 2*4(sp) \n\
852 c.swsp t2, 3*4(sp) \n\
853 c.swsp s0, 4*4(sp) \n\
854 c.swsp s1, 5*4(sp) \n\
855 c.swsp a0, 6*4(sp) \n\
856 c.swsp a1, 7*4(sp) \n\
857 c.swsp a2, 8*4(sp) \n\
858 c.swsp a3, 9*4(sp) \n\
859 c.swsp a4, 10*4(sp) \n\
860 c.swsp a5, 11*4(sp) \n\
861 c.swsp a6, 12*4(sp) \n\
862 c.swsp a7, 13*4(sp) \n\
863 c.swsp s2, 14*4(sp) \n\
864 c.swsp s3, 15*4(sp) \n\
865 c.swsp t3, 16*4(sp) \n\
866 c.swsp t4, 17*4(sp) \n\
867 c.swsp t5, 18*4(sp) \n\
868 c.swsp t6, 19*4(sp)"); \
869 SAVE_FPU_CONTEXT(); \
875 #define RESTORE_CALLER_CONTEXT() { \
877 c.lwsp ra, 0*4(sp) \n\
878 c.lwsp t0, 1*4(sp) \n\
879 c.lwsp t1, 2*4(sp) \n\
880 c.lwsp t2, 3*4(sp) \n\
881 c.lwsp s0, 4*4(sp) \n\
882 c.lwsp s1, 5*4(sp) \n\
883 c.lwsp a0, 6*4(sp) \n\
884 c.lwsp a1, 7*4(sp) \n\
885 c.lwsp a2, 8*4(sp) \n\
886 c.lwsp a3, 9*4(sp) \n\
887 c.lwsp a4, 10*4(sp) \n\
888 c.lwsp a5, 11*4(sp) \n\
889 c.lwsp a6, 12*4(sp) \n\
890 c.lwsp a7, 13*4(sp) \n\
891 c.lwsp s2, 14*4(sp) \n\
892 c.lwsp s3, 15*4(sp) \n\
893 c.lwsp t3, 16*4(sp) \n\
894 c.lwsp t4, 17*4(sp) \n\
895 c.lwsp t5, 18*4(sp) \n\
896 c.lwsp t6, 19*4(sp) \n");\
897 RESTORE_FPU_CONTEXT(); \
898 __asm volatile("addi sp, sp, %0" : : "i"(CONTEXT_REG_NUM) :);\
903 #define SAVE_FPU_STATE() { \
904 __asm volatile("frcsr s1\n"); \
907 #define RESTORE_FPU_STATE() { \
908 __asm volatile("fscsr s1\n"); \
911 #define SAVE_FPU_STATE()
912 #define RESTORE_FPU_STATE()
920 #define SAVE_DSP_CONTEXT() { \
921 __asm volatile("csrrs s0, %0, x0\n" ::"i"(CSR_UCODE):); \
927 #define RESTORE_DSP_CONTEXT() {\
928 __asm volatile("csrw %0, s0\n" ::"i"(CSR_UCODE):); \
932 #define SAVE_DSP_CONTEXT()
933 #define RESTORE_DSP_CONTEXT()
944 #define ENTER_NESTED_IRQ_HANDLING_M() { \
947 csrr s3, mstatus \n");\
949 SAVE_DSP_CONTEXT(); \
950 __asm volatile("csrsi mstatus, 8"); \
956 #define COMPLETE_IRQ_HANDLING_M(irq_num) { \
957 __asm volatile("csrci mstatus, 8"); \
958 __asm volatile("lui a4, 0xe4200"); \
959 __asm volatile("li a3, %0" : : "i" (irq_num) :); \
960 __asm volatile("sw a3, 4(a4)"); \
971 #define EXIT_NESTED_IRQ_HANDLING_M() { \
975 RESTORE_FPU_STATE(); \
976 RESTORE_DSP_CONTEXT(); \
980 #define ENTER_NESTED_IRQ_HANDLING_S() {\
983 csrr s3, sstatus \n");\
985 SAVE_DSP_CONTEXT(); \
986 __asm volatile("csrsi sstatus, 2"); \
988 #define COMPLETE_IRQ_HANDLING_S(irq_num) {\
989 __asm volatile("csrci sstatus, 2"); \
990 __asm volatile("lui a4, 0xe4201"); \
991 __asm volatile("li a3, %0" : : "i" (irq_num) :); \
992 __asm volatile("sw a3, 4(a4)"); \
1002 #define EXIT_NESTED_IRQ_HANDLING_S() { \
1004 csrw sstatus, s3 \n\
1005 csrw sepc, s2 \n");\
1006 RESTORE_FPU_STATE(); \
1007 RESTORE_DSP_CONTEXT(); \
1011 #define NESTED_IRQ_ENTER() \
1012 SAVE_CSR(CSR_MEPC) \
1013 SAVE_CSR(CSR_MSTATUS) \
1017 set_csr(CSR_MSTATUS, CSR_MSTATUS_MIE_MASK);
1020 #define NESTED_IRQ_EXIT() \
1021 RESTORE_CSR(CSR_MSTATUS) \
1022 RESTORE_CSR(CSR_MEPC) \
1023 RESTORE_MXSTATUS() \
1028 #define EXTERN_C extern "C"
1033 #define ISR_NAME_M(irq_num) default_isr_##irq_num
1034 #define ISR_NAME_S(irq_num) default_isr_s_##irq_num
1041 #if !defined(USE_NONVECTOR_MODE) || (USE_NONVECTOR_MODE == 0)
1042 #if defined(CONFIG_FREERTOS) && CONFIG_FREERTOS
1043 #define FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num) irq_handler_wrapper_##irq_num
1044 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1045 void isr(void) __attribute__((section(".isr_vector"))); \
1046 EXTERN_C void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) __attribute__((section(".isr_vector"))); \
1047 void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) \
1058 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1059 void isr(void) __attribute__((section(".isr_s_vector")));\
1060 EXTERN_C void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) __attribute__((section(".isr_s_vector")));\
1061 void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) \
1066 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1067 void isr(void) __attribute__((section(".isr_vector")));\
1068 EXTERN_C void ISR_NAME_M(irq_num)(void) __attribute__((section(".isr_vector")));\
1069 void ISR_NAME_M(irq_num)(void) \
1071 SAVE_CALLER_CONTEXT(); \
1072 ENTER_NESTED_IRQ_HANDLING_M();\
1073 __asm volatile("la t1, %0\n\t" : : "i" (isr) : );\
1074 __asm volatile("jalr t1\n");\
1075 COMPLETE_IRQ_HANDLING_M(irq_num);\
1076 EXIT_NESTED_IRQ_HANDLING_M();\
1077 RESTORE_CALLER_CONTEXT();\
1078 __asm volatile("fence io, io");\
1079 __asm volatile("mret\n");\
1088 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1089 void isr(void) __attribute__((section(".isr_s_vector")));\
1090 EXTERN_C void ISR_NAME_S(irq_num)(void) __attribute__((section(".isr_s_vector")));\
1091 void ISR_NAME_S(irq_num)(void) {\
1092 SAVE_CALLER_CONTEXT(); \
1093 ENTER_NESTED_IRQ_HANDLING_S();\
1094 __asm volatile("la t1, %0\n\t" : : "i" (isr) : );\
1095 __asm volatile("jalr t1\n");\
1096 COMPLETE_IRQ_HANDLING_S(irq_num);\
1097 EXIT_NESTED_IRQ_HANDLING_S();\
1098 RESTORE_CALLER_CONTEXT();\
1099 __asm volatile("fence io, io");\
1100 __asm volatile("sret\n");\
1105 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1106 void isr(void) __attribute__((section(".isr_vector")));\
1107 EXTERN_C void ISR_NAME_M(irq_num)(void) __attribute__((section(".isr_vector")));\
1108 void ISR_NAME_M(irq_num)(void) { \
1112 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1113 void isr(void) __attribute__((section(".isr_vector")));\
1114 EXTERN_C void ISR_NAME_S(irq_num)(void) __attribute__((section(".isr_vector")));\
1115 void ISR_NAME_S(irq_num)(void) { \
1127 #define SDK_DECLARE_MCHTMR_ISR(isr) \
1128 void isr(void) __attribute__((section(".isr_vector")));\
1129 EXTERN_C void mchtmr_isr(void) __attribute__((section(".isr_vector"))); \
1130 void mchtmr_isr(void) {\
1139 #define SDK_DECLARE_SWI_ISR(isr)\
1140 void isr(void) __attribute__((section(".isr_vector")));\
1141 EXTERN_C void swi_isr(void) __attribute__((section(".isr_vector"))); \
1142 void swi_isr(void) {\
1153 #define SDK_DECLARE_MCHTMR_ISR_S(isr) \
1154 void isr(void) __attribute__((section(".isr_vector")));\
1155 EXTERN_C void mchtmr_s_isr(void) __attribute__((section(".isr_vector"))); \
1156 void mchtmr_s_isr(void) {\
1165 #define SDK_DECLARE_SWI_ISR_S(isr)\
1166 void isr(void) __attribute__((section(".isr_vector")));\
1167 EXTERN_C void swi_s_isr(void) __attribute__((section(".isr_vector"))); \
1168 void swi_s_isr(void) {\
1172 #define CSR_MSTATUS_MPP_S_MODE (0x1)
1173 #define MODE_SWITCH_FROM_M(mstatus, mepc, label, mode) \
1176 write_csr(mepc, label); \
1178 clear_csr(mstatus, CSR_MSTATUS_MPP_MASK); \
1179 set_csr(mstatus, CSR_MSTATUS_MPP_SET(mode)); \
#define CSR_MIE_MEIE_MASK
Definition: hpm_csr_regs.h:734
#define CSR_MEPC
Definition: hpm_csr_regs.h:31
#define CSR_MSTATUS
Definition: hpm_csr_regs.h:21
#define CSR_MIE_MTIE_MASK
Definition: hpm_csr_regs.h:758
#define CSR_MIE
Definition: hpm_csr_regs.h:23
#define CSR_MIE_MSIE_MASK
Definition: hpm_csr_regs.h:782
#define HPM_PLICSW_BASE
Definition: hpm_soc.h:94
#define HPM_PLIC_BASE
Definition: hpm_soc.h:80
#define CSR_SEPC
Definition: hpm_csr_regs.h:27
#define CSR_SSTATUS
Definition: hpm_csr_regs.h:21
#define CSR_SIE_SEIE_MASK
Definition: hpm_csr_regs.h:677
#define CSR_SIE_SSIE_MASK
Definition: hpm_csr_regs.h:725
#define CSR_SIP
Definition: hpm_csr_regs.h:30
#define CSR_SIE_STIE_MASK
Definition: hpm_csr_regs.h:701
#define CSR_MIDELEG
Definition: hpm_csr_regs.h:35
#define CSR_SIP_SSIP_MASK
Definition: hpm_csr_regs.h:889
#define CSR_SIE
Definition: hpm_csr_regs.h:24
static ATTR_ALWAYS_INLINE void intc_complete_irq(uint32_t target, uint32_t irq)
Complete IRQ.
Definition: hpm_interrupt.h:445
static ATTR_ALWAYS_INLINE void enable_global_irq(uint32_t mask)
Enable global IRQ with mask.
Definition: hpm_interrupt.h:34
static ATTR_ALWAYS_INLINE void intc_m_disable_swi(void)
Disable software interrupt.
Definition: hpm_interrupt.h:216
static ATTR_ALWAYS_INLINE void intc_s_complete_swi(void)
Complete software interrupt for supervisor mode.
Definition: hpm_interrupt.h:332
static ATTR_ALWAYS_INLINE void intc_s_trigger_swi(void)
Trigger software interrupt for supervisor mode.
Definition: hpm_interrupt.h:322
static ATTR_ALWAYS_INLINE void disable_irq_from_intc(void)
Disable IRQ from interrupt controller.
Definition: hpm_interrupt.h:73
static ATTR_ALWAYS_INLINE void intc_set_irq_priority(uint32_t irq, uint32_t priority)
Set interrupt priority.
Definition: hpm_interrupt.h:400
static ATTR_ALWAYS_INLINE void intc_disable_irq(uint32_t target, uint32_t irq)
Disable specific interrupt.
Definition: hpm_interrupt.h:411
static ATTR_ALWAYS_INLINE void intc_m_trigger_swi(void)
Trigger software interrupt.
Definition: hpm_interrupt.h:226
static ATTR_ALWAYS_INLINE void install_isr(uint32_t irq, uint32_t isr)
Install ISR for certain IRQ for ram based vector table.
Definition: hpm_interrupt.h:464
static ATTR_ALWAYS_INLINE void restore_s_global_irq(uint32_t mask)
Restore global IRQ with mask for supervisor mode.
Definition: hpm_interrupt.h:144
static ATTR_ALWAYS_INLINE void enable_irq_from_intc(void)
Enable IRQ from interrupt controller.
Definition: hpm_interrupt.h:64
static ATTR_ALWAYS_INLINE void restore_global_irq(uint32_t mask)
Restore global IRQ with mask.
Definition: hpm_interrupt.h:55
static ATTR_ALWAYS_INLINE void uninstall_s_isr(uint32_t irq)
Uninstall ISR for certain IRQ for ram based vector table for supervisor mode.
Definition: hpm_interrupt.h:501
static ATTR_ALWAYS_INLINE void enable_s_global_irq(uint32_t mask)
Enable global IRQ with mask for supervisor mode.
Definition: hpm_interrupt.h:123
static ATTR_ALWAYS_INLINE void intc_enable_irq(uint32_t target, uint32_t irq)
Definition: hpm_interrupt.h:389
static ATTR_ALWAYS_INLINE void install_s_isr(uint32_t irq, uint32_t isr)
Install ISR for certain IRQ for ram based vector table for supervisor mode.
Definition: hpm_interrupt.h:490
static ATTR_ALWAYS_INLINE void enable_s_irq_from_intc(void)
Enable IRQ from interrupt controller for supervisor mode.
Definition: hpm_interrupt.h:162
static ATTR_ALWAYS_INLINE void delegate_irq(uint32_t mask)
Delegate IRQ handling.
Definition: hpm_interrupt.h:100
static ATTR_ALWAYS_INLINE void undelegate_irq(uint32_t mask)
Undelegate IRQ handling.
Definition: hpm_interrupt.h:110
static ATTR_ALWAYS_INLINE void disable_mchtmr_irq(void)
Disable machine timer IRQ.
Definition: hpm_interrupt.h:90
static ATTR_ALWAYS_INLINE void intc_m_init_swi(void)
Initialize software interrupt.
Definition: hpm_interrupt.h:196
static ATTR_ALWAYS_INLINE void intc_m_enable_swi(void)
Enable software interrupt.
Definition: hpm_interrupt.h:206
static ATTR_ALWAYS_INLINE void intc_m_complete_swi(void)
Complete software interrupt.
Definition: hpm_interrupt.h:244
static ATTR_ALWAYS_INLINE void intc_s_disable_swi(void)
Disable software interrupt for supervisor mode.
Definition: hpm_interrupt.h:312
static void switch_to_s_mode(s_mode_entry entry)
Switch mode to supervisor from machine.
Definition: hpm_interrupt.h:1189
static ATTR_ALWAYS_INLINE void enable_s_mchtmr_irq(void)
Enable machine timer IRQ for supervisor mode.
Definition: hpm_interrupt.h:170
static ATTR_ALWAYS_INLINE void intc_set_threshold(uint32_t target, uint32_t threshold)
Set interrupt threshold.
Definition: hpm_interrupt.h:422
static ATTR_ALWAYS_INLINE void uninstall_isr(uint32_t irq)
Uninstall ISR for certain IRQ for ram based vector table.
Definition: hpm_interrupt.h:475
static ATTR_ALWAYS_INLINE uint32_t disable_s_global_irq(uint32_t mask)
Disable global IRQ with mask and return sstatus for supervisor mode.
Definition: hpm_interrupt.h:134
static ATTR_ALWAYS_INLINE uint32_t intc_claim_irq(uint32_t target)
Claim IRQ.
Definition: hpm_interrupt.h:433
static ATTR_ALWAYS_INLINE void intc_m_claim_swi(void)
Claim software interrupt.
Definition: hpm_interrupt.h:235
static ATTR_ALWAYS_INLINE uint32_t disable_global_irq(uint32_t mask)
Disable global IRQ with mask and return mstatus.
Definition: hpm_interrupt.h:45
static ATTR_ALWAYS_INLINE void disable_s_mchtmr_irq(void)
Disable machine timer IRQ.
Definition: hpm_interrupt.h:179
static ATTR_ALWAYS_INLINE void enable_mchtmr_irq(void)
Enable machine timer IRQ.
Definition: hpm_interrupt.h:81
static ATTR_ALWAYS_INLINE void disable_s_irq_from_intc(void)
Disable IRQ from interrupt controller for supervisor mode.
Definition: hpm_interrupt.h:153
static ATTR_ALWAYS_INLINE void intc_s_enable_swi(void)
Enable software interrupt for supervisor mode.
Definition: hpm_interrupt.h:302
#define CSR_MSTATUS_MPP_S_MODE
Definition: hpm_interrupt.h:1172
void default_s_irq_entry(void)
#define MODE_SWITCH_FROM_M(mstatus, mepc, label, mode)
Definition: hpm_interrupt.h:1173
void default_irq_entry(void)
#define PLICSWI
Definition: hpm_interrupt.h:190
void(* s_mode_entry)(void)
Definition: hpm_interrupt.h:1184
#define HPM_PLIC_TARGET_M_MODE
Definition: hpm_plic_drv.h:17
#define set_csr(csr_num, bit)
set bits in csr
Definition: riscv_core.h:58
#define clear_csr(csr_num, bit)
clear bits in csr
Definition: riscv_core.h:30
#define read_clear_csr(csr_num, bit)
read and clear bits in csr
Definition: riscv_core.h:40