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)
268 #define intc_m_get_threshold() \
269 intc_get_threshold(HPM_PLIC_TARGET_M_MODE)
276 #define intc_m_complete_irq(irq) \
277 intc_complete_irq(HPM_PLIC_TARGET_M_MODE, irq)
283 #define intc_m_claim_irq() intc_claim_irq(HPM_PLIC_TARGET_M_MODE)
291 #define intc_m_enable_irq_with_priority(irq, priority) \
293 intc_set_irq_priority(irq, priority); \
294 intc_m_enable_irq(irq); \
345 #define intc_s_enable_irq(irq) \
346 intc_enable_irq(HPM_PLIC_TARGET_S_MODE, irq)
353 #define intc_s_disable_irq(irq) \
354 intc_disable_irq(HPM_PLIC_TARGET_S_MODE, irq)
356 #define intc_set_s_threshold(threshold) \
357 intc_set_threshold(HPM_PLIC_TARGET_S_MODE, threshold)
364 #define intc_s_complete_irq(irq) \
365 intc_complete_irq(HPM_PLIC_TARGET_S_MODE, irq)
371 #define intc_s_claim_irq() intc_claim_irq(HPM_PLIC_TARGET_S_MODE)
379 #define intc_s_enable_irq_with_priority(irq, priority) \
381 intc_set_irq_priority(irq, priority); \
382 intc_s_enable_irq(irq); \
467 extern int __vector_table[];
477 ATTR_ALWAYS_INLINE
static inline void install_isr(uint32_t irq, uint32_t isr)
479 __vector_table[irq] = isr;
494 extern int __vector_s_table[];
503 ATTR_ALWAYS_INLINE
static inline void install_s_isr(uint32_t irq, uint32_t isr)
505 __vector_s_table[irq] = isr;
527 #define SAVE_CSR(r) register long __##r = read_csr(r);
534 #define RESTORE_CSR(r) write_csr(r, __##r);
536 #if defined(SUPPORT_PFT_ARCH) && SUPPORT_PFT_ARCH
537 #define SAVE_MXSTATUS() SAVE_CSR(CSR_MXSTATUS)
538 #define RESTORE_MXSTATUS() RESTORE_CSR(CSR_MXSTATUS)
540 #define SAVE_MXSTATUS()
541 #define RESTORE_MXSTATUS()
545 #define SAVE_FCSR() register int __fcsr = read_fcsr();
546 #define RESTORE_FCSR() write_fcsr(__fcsr);
549 #define RESTORE_FCSR()
553 #define SAVE_UCODE() SAVE_CSR(CSR_UCODE)
554 #define RESTORE_UCODE() RESTORE_CSR(CSR_UCODE)
557 #define RESTORE_UCODE()
561 #if __riscv_flen == 32
563 #define CONTEXT_REG_NUM (4 * (16 + 4 + 20))
566 #define CONTEXT_REG_NUM (4 * (16 + 4 + 20 * 2))
571 #define CONTEXT_REG_NUM (4 * (16 + 4))
579 #if __riscv_flen == 32
581 #define SAVE_FPU_CONTEXT() { \
584 c.fswsp ft1, 21*4 \n\
585 c.fswsp ft2, 22*4 \n\
586 c.fswsp ft3, 23*4 \n\
587 c.fswsp ft4, 24*4 \n\
588 c.fswsp ft5, 25*4 \n\
589 c.fswsp ft6, 26*4 \n\
590 c.fswsp ft7, 27*4 \n\
591 c.fswsp fa0, 28*4 \n\
592 c.fswsp fa1, 29*4 \n\
593 c.fswsp fa2, 30*4 \n\
594 c.fswsp fa3, 31*4 \n\
595 c.fswsp fa4, 32*4 \n\
596 c.fswsp fa5, 33*4 \n\
597 c.fswsp fa6, 34*4 \n\
598 c.fswsp fa7, 35*4 \n\
599 c.fswsp ft8, 36*4 \n\
600 c.fswsp ft9, 37*4 \n\
601 c.fswsp ft10, 38*4 \n\
602 c.fswsp ft11, 39*4 \n");\
609 #define RESTORE_FPU_CONTEXT() { \
612 c.flwsp ft1, 21*4 \n\
613 c.flwsp ft2, 22*4 \n\
614 c.flwsp ft3, 23*4 \n\
615 c.flwsp ft4, 24*4 \n\
616 c.flwsp ft5, 25*4 \n\
617 c.flwsp ft6, 26*4 \n\
618 c.flwsp ft7, 27*4 \n\
619 c.flwsp fa0, 28*4 \n\
620 c.flwsp fa1, 29*4 \n\
621 c.flwsp fa2, 30*4 \n\
622 c.flwsp fa3, 31*4 \n\
623 c.flwsp fa4, 32*4 \n\
624 c.flwsp fa5, 33*4 \n\
625 c.flwsp fa6, 34*4 \n\
626 c.flwsp fa7, 35*4 \n\
627 c.flwsp ft8, 36*4 \n\
628 c.flwsp ft9, 37*4 \n\
629 c.flwsp ft10, 38*4 \n\
630 c.flwsp ft11, 39*4 \n");\
633 #define SAVE_FPU_CONTEXT() { \
635 c.fswsp ft0, 20*4(sp)\n\
636 c.fswsp ft1, 21*4(sp) \n\
637 c.fswsp ft2, 22*4(sp) \n\
638 c.fswsp ft3, 23*4(sp) \n\
639 c.fswsp ft4, 24*4(sp) \n\
640 c.fswsp ft5, 25*4(sp) \n\
641 c.fswsp ft6, 26*4(sp) \n\
642 c.fswsp ft7, 27*4(sp) \n\
643 c.fswsp fa0, 28*4(sp) \n\
644 c.fswsp fa1, 29*4(sp) \n\
645 c.fswsp fa2, 30*4(sp) \n\
646 c.fswsp fa3, 31*4(sp) \n\
647 c.fswsp fa4, 32*4(sp) \n\
648 c.fswsp fa5, 33*4(sp) \n\
649 c.fswsp fa6, 34*4(sp) \n\
650 c.fswsp fa7, 35*4(sp) \n\
651 c.fswsp ft8, 36*4(sp) \n\
652 c.fswsp ft9, 37*4(sp) \n\
653 c.fswsp ft10, 38*4(sp) \n\
654 c.fswsp ft11, 39*4(sp) \n");\
661 #define RESTORE_FPU_CONTEXT() { \
663 c.flwsp ft0, 20*4(sp)\n\
664 c.flwsp ft1, 21*4(sp) \n\
665 c.flwsp ft2, 22*4(sp) \n\
666 c.flwsp ft3, 23*4(sp) \n\
667 c.flwsp ft4, 24*4(sp) \n\
668 c.flwsp ft5, 25*4(sp) \n\
669 c.flwsp ft6, 26*4(sp) \n\
670 c.flwsp ft7, 27*4(sp) \n\
671 c.flwsp fa0, 28*4(sp) \n\
672 c.flwsp fa1, 29*4(sp) \n\
673 c.flwsp fa2, 30*4(sp) \n\
674 c.flwsp fa3, 31*4(sp) \n\
675 c.flwsp fa4, 32*4(sp) \n\
676 c.flwsp fa5, 33*4(sp) \n\
677 c.flwsp fa6, 34*4(sp) \n\
678 c.flwsp fa7, 35*4(sp) \n\
679 c.flwsp ft8, 36*4(sp) \n\
680 c.flwsp ft9, 37*4(sp) \n\
681 c.flwsp ft10, 38*4(sp) \n\
682 c.flwsp ft11, 39*4(sp) \n");\
687 #define SAVE_FPU_CONTEXT() { \
690 c.fsdsp ft1, 22*4 \n\
691 c.fsdsp ft2, 24*4 \n\
692 c.fsdsp ft3, 26*4 \n\
693 c.fsdsp ft4, 28*4 \n\
694 c.fsdsp ft5, 30*4 \n\
695 c.fsdsp ft6, 32*4 \n\
696 c.fsdsp ft7, 34*4 \n\
697 c.fsdsp fa0, 36*4 \n\
698 c.fsdsp fa1, 38*4 \n\
699 c.fsdsp fa2, 40*4 \n\
700 c.fsdsp fa3, 42*4 \n\
701 c.fsdsp fa4, 44*4 \n\
702 c.fsdsp fa5, 46*4 \n\
703 c.fsdsp fa6, 48*4 \n\
704 c.fsdsp fa7, 50*4 \n\
705 c.fsdsp ft8, 52*4 \n\
706 c.fsdsp ft9, 54*4 \n\
707 c.fsdsp ft10, 56*4 \n\
708 c.fsdsp ft11, 58*4 \n");\
715 #define RESTORE_FPU_CONTEXT() { \
718 c.fldsp ft1, 22*4 \n\
719 c.fldsp ft2, 24*4 \n\
720 c.fldsp ft3, 26*4 \n\
721 c.fldsp ft4, 28*4 \n\
722 c.fldsp ft5, 30*4 \n\
723 c.fldsp ft6, 32*4 \n\
724 c.fldsp ft7, 34*4 \n\
725 c.fldsp fa0, 36*4 \n\
726 c.fldsp fa1, 38*4 \n\
727 c.fldsp fa2, 40*4 \n\
728 c.fldsp fa3, 42*4 \n\
729 c.fldsp fa4, 44*4 \n\
730 c.fldsp fa5, 46*4 \n\
731 c.fldsp fa6, 48*4 \n\
732 c.fldsp fa7, 50*4 \n\
733 c.fldsp ft8, 52*4 \n\
734 c.fldsp ft9, 54*4 \n\
735 c.fldsp ft10, 56*4 \n\
736 c.fldsp ft11, 58*4 \n");\
739 #define SAVE_FPU_CONTEXT() { \
741 c.fsdsp ft0, 20*4(sp)\n\
742 c.fsdsp ft1, 22*4(sp) \n\
743 c.fsdsp ft2, 24*4(sp) \n\
744 c.fsdsp ft3, 26*4(sp) \n\
745 c.fsdsp ft4, 28*4(sp) \n\
746 c.fsdsp ft5, 30*4(sp) \n\
747 c.fsdsp ft6, 32*4(sp) \n\
748 c.fsdsp ft7, 34*4(sp) \n\
749 c.fsdsp fa0, 36*4(sp) \n\
750 c.fsdsp fa1, 38*4(sp) \n\
751 c.fsdsp fa2, 40*4(sp) \n\
752 c.fsdsp fa3, 42*4(sp) \n\
753 c.fsdsp fa4, 44*4(sp) \n\
754 c.fsdsp fa5, 46*4(sp) \n\
755 c.fsdsp fa6, 48*4(sp) \n\
756 c.fsdsp fa7, 50*4(sp) \n\
757 c.fsdsp ft8, 52*4(sp) \n\
758 c.fsdsp ft9, 54*4(sp) \n\
759 c.fsdsp ft10, 56*4(sp) \n\
760 c.fsdsp ft11, 58*4(sp) \n");\
767 #define RESTORE_FPU_CONTEXT() { \
769 c.fldsp ft0, 20*4(sp)\n\
770 c.fldsp ft1, 22*4(sp) \n\
771 c.fldsp ft2, 24*4(sp) \n\
772 c.fldsp ft3, 26*4(sp) \n\
773 c.fldsp ft4, 28*4(sp) \n\
774 c.fldsp ft5, 30*4(sp) \n\
775 c.fldsp ft6, 32*4(sp) \n\
776 c.fldsp ft7, 34*4(sp) \n\
777 c.fldsp fa0, 36*4(sp) \n\
778 c.fldsp fa1, 38*4(sp) \n\
779 c.fldsp fa2, 40*4(sp) \n\
780 c.fldsp fa3, 42*4(sp) \n\
781 c.fldsp fa4, 44*4(sp) \n\
782 c.fldsp fa5, 46*4(sp) \n\
783 c.fldsp fa6, 48*4(sp) \n\
784 c.fldsp fa7, 50*4(sp) \n\
785 c.fldsp ft8, 52*4(sp) \n\
786 c.fldsp ft9, 54*4(sp) \n\
787 c.fldsp ft10, 56*4(sp) \n\
788 c.fldsp ft11, 58*4(sp) \n");\
793 #define SAVE_FPU_CONTEXT()
794 #define RESTORE_FPU_CONTEXT()
801 #define SAVE_CALLER_CONTEXT() { \
802 __asm volatile("addi sp, sp, %0" : : "i"(-CONTEXT_REG_NUM) :);\
824 SAVE_FPU_CONTEXT(); \
830 #define RESTORE_CALLER_CONTEXT() { \
851 c.lwsp t6, 19*4 \n");\
852 RESTORE_FPU_CONTEXT(); \
853 __asm volatile("addi sp, sp, %0" : : "i"(CONTEXT_REG_NUM) :);\
859 #define SAVE_CALLER_CONTEXT() { \
860 __asm volatile("addi sp, sp, %0" : : "i"(-CONTEXT_REG_NUM) :);\
862 c.swsp ra, 0*4(sp) \n\
863 c.swsp t0, 1*4(sp) \n\
864 c.swsp t1, 2*4(sp) \n\
865 c.swsp t2, 3*4(sp) \n\
866 c.swsp s1, 4*4(sp) \n\
867 c.swsp a0, 5*4(sp) \n\
868 c.swsp a1, 6*4(sp) \n\
869 c.swsp a2, 7*4(sp) \n\
870 c.swsp a3, 8*4(sp) \n\
871 c.swsp a4, 9*4(sp) \n\
872 c.swsp a5, 10*4(sp) \n\
873 c.swsp a6, 11*4(sp) \n\
874 c.swsp a7, 12*4(sp) \n\
875 c.swsp s2, 13*4(sp) \n\
876 c.swsp s3, 14*4(sp) \n\
877 c.swsp s4, 15*4(sp) \n\
878 c.swsp t3, 16*4(sp) \n\
879 c.swsp t4, 17*4(sp) \n\
880 c.swsp t5, 18*4(sp) \n\
881 c.swsp t6, 19*4(sp)"); \
882 SAVE_FPU_CONTEXT(); \
888 #define RESTORE_CALLER_CONTEXT() { \
890 c.lwsp ra, 0*4(sp) \n\
891 c.lwsp t0, 1*4(sp) \n\
892 c.lwsp t1, 2*4(sp) \n\
893 c.lwsp t2, 3*4(sp) \n\
894 c.lwsp s1, 4*4(sp) \n\
895 c.lwsp a0, 5*4(sp) \n\
896 c.lwsp a1, 6*4(sp) \n\
897 c.lwsp a2, 7*4(sp) \n\
898 c.lwsp a3, 8*4(sp) \n\
899 c.lwsp a4, 9*4(sp) \n\
900 c.lwsp a5, 10*4(sp) \n\
901 c.lwsp a6, 11*4(sp) \n\
902 c.lwsp a7, 12*4(sp) \n\
903 c.lwsp s2, 13*4(sp) \n\
904 c.lwsp s3, 14*4(sp) \n\
905 c.lwsp s4, 15*4(sp) \n\
906 c.lwsp t3, 16*4(sp) \n\
907 c.lwsp t4, 17*4(sp) \n\
908 c.lwsp t5, 18*4(sp) \n\
909 c.lwsp t6, 19*4(sp) \n");\
910 RESTORE_FPU_CONTEXT(); \
911 __asm volatile("addi sp, sp, %0" : : "i"(CONTEXT_REG_NUM) :);\
916 #define SAVE_FPU_STATE() { \
917 __asm volatile("frcsr s1\n"); \
920 #define RESTORE_FPU_STATE() { \
921 __asm volatile("fscsr s1\n"); \
924 #define SAVE_FPU_STATE()
925 #define RESTORE_FPU_STATE()
933 #define SAVE_DSP_CONTEXT() { \
934 __asm volatile("csrrs s4, %0, x0\n" ::"i"(CSR_UCODE):); \
940 #define RESTORE_DSP_CONTEXT() {\
941 __asm volatile("csrw %0, s4\n" ::"i"(CSR_UCODE):); \
945 #define SAVE_DSP_CONTEXT()
946 #define RESTORE_DSP_CONTEXT()
957 #define ENTER_NESTED_IRQ_HANDLING_M() { \
960 csrr s3, mstatus \n");\
962 SAVE_DSP_CONTEXT(); \
963 __asm volatile("csrsi mstatus, 8"); \
969 #define COMPLETE_IRQ_HANDLING_M(irq_num) { \
970 __asm volatile("csrci mstatus, 8"); \
971 __asm volatile("lui a4, 0xe4200"); \
972 __asm volatile("li a3, %0" : : "i" (irq_num) :); \
973 __asm volatile("sw a3, 4(a4)"); \
984 #define EXIT_NESTED_IRQ_HANDLING_M() { \
988 RESTORE_FPU_STATE(); \
989 RESTORE_DSP_CONTEXT(); \
993 #define ENTER_NESTED_IRQ_HANDLING_S() {\
996 csrr s3, sstatus \n");\
998 SAVE_DSP_CONTEXT(); \
999 __asm volatile("csrsi sstatus, 2"); \
1001 #define COMPLETE_IRQ_HANDLING_S(irq_num) {\
1002 __asm volatile("csrci sstatus, 2"); \
1003 __asm volatile("lui a4, 0xe4201"); \
1004 __asm volatile("li a3, %0" : : "i" (irq_num) :); \
1005 __asm volatile("sw a3, 4(a4)"); \
1015 #define EXIT_NESTED_IRQ_HANDLING_S() { \
1017 csrw sstatus, s3 \n\
1018 csrw sepc, s2 \n");\
1019 RESTORE_FPU_STATE(); \
1020 RESTORE_DSP_CONTEXT(); \
1024 #define NESTED_IRQ_ENTER() \
1025 SAVE_CSR(CSR_MEPC) \
1026 SAVE_CSR(CSR_MSTATUS) \
1030 set_csr(CSR_MSTATUS, CSR_MSTATUS_MIE_MASK);
1033 #define NESTED_IRQ_EXIT() \
1034 RESTORE_CSR(CSR_MSTATUS) \
1035 RESTORE_CSR(CSR_MEPC) \
1036 RESTORE_MXSTATUS() \
1041 #define HPM_EXTERN_C extern "C"
1043 #define HPM_EXTERN_C
1046 #define ISR_NAME_M(irq_num) default_isr_##irq_num
1047 #define ISR_NAME_S(irq_num) default_isr_s_##irq_num
1054 #if !defined(USE_NONVECTOR_MODE) || (USE_NONVECTOR_MODE == 0)
1055 #if defined(CONFIG_FREERTOS) && CONFIG_FREERTOS
1056 #define FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num) irq_handler_wrapper_##irq_num
1057 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1058 void isr(void) __attribute__((section(".isr_vector"))); \
1059 HPM_EXTERN_C void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) __attribute__((section(".isr_vector"))); \
1060 void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) \
1071 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1072 void isr(void) __attribute__((section(".isr_s_vector")));\
1073 HPM_EXTERN_C void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) __attribute__((section(".isr_s_vector")));\
1074 void FREERTOS_VECTOR_ISR_WRAPPER_NAME(irq_num)(void) \
1080 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1081 void isr(void) __attribute__((section(".isr_vector")));\
1082 HPM_EXTERN_C HPM_ATTR_MACHINE_INTERRUPT void ISR_NAME_M(irq_num)(void);\
1083 HPM_ATTR_MACHINE_INTERRUPT void ISR_NAME_M(irq_num)(void) \
1085 SAVE_CALLER_CONTEXT(); \
1086 ENTER_NESTED_IRQ_HANDLING_M();\
1087 __asm volatile("la t1, %0\n\t" : : "i" (isr) : );\
1088 __asm volatile("jalr t1\n");\
1089 COMPLETE_IRQ_HANDLING_M(irq_num);\
1090 EXIT_NESTED_IRQ_HANDLING_M();\
1091 RESTORE_CALLER_CONTEXT();\
1092 __asm volatile("fence io, io");\
1101 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1102 void isr(void) __attribute__((section(".isr_s_vector")));\
1103 HPM_EXTERN_C HPM_ATTR_SUPERVISOR_INTERRUPT void ISR_NAME_S(irq_num)(void);\
1104 HPM_ATTR_SUPERVISOR_INTERRUPT void ISR_NAME_S(irq_num)(void) {\
1105 SAVE_CALLER_CONTEXT(); \
1106 ENTER_NESTED_IRQ_HANDLING_S();\
1107 __asm volatile("la t1, %0\n\t" : : "i" (isr) : );\
1108 __asm volatile("jalr t1\n");\
1109 COMPLETE_IRQ_HANDLING_S(irq_num);\
1110 EXIT_NESTED_IRQ_HANDLING_S();\
1111 RESTORE_CALLER_CONTEXT();\
1112 __asm volatile("fence io, io");\
1117 #define SDK_DECLARE_EXT_ISR_M(irq_num, isr) \
1118 void isr(void) __attribute__((section(".isr_vector")));\
1119 HPM_EXTERN_C void ISR_NAME_M(irq_num)(void) __attribute__((section(".isr_vector")));\
1120 void ISR_NAME_M(irq_num)(void) { \
1124 #define SDK_DECLARE_EXT_ISR_S(irq_num, isr) \
1125 void isr(void) __attribute__((section(".isr_vector")));\
1126 HPM_EXTERN_C void ISR_NAME_S(irq_num)(void) __attribute__((section(".isr_vector")));\
1127 void ISR_NAME_S(irq_num)(void) { \
1139 #define SDK_DECLARE_MCHTMR_ISR(isr) \
1140 void isr(void) __attribute__((section(".isr_vector")));\
1141 HPM_EXTERN_C void mchtmr_isr(void) __attribute__((section(".isr_vector"))); \
1142 void mchtmr_isr(void) {\
1151 #define SDK_DECLARE_SWI_ISR(isr)\
1152 void isr(void) __attribute__((section(".isr_vector")));\
1153 HPM_EXTERN_C void swi_isr(void) __attribute__((section(".isr_vector"))); \
1154 void swi_isr(void) {\
1165 #define SDK_DECLARE_MCHTMR_ISR_S(isr) \
1166 void isr(void) __attribute__((section(".isr_vector")));\
1167 HPM_EXTERN_C void mchtmr_s_isr(void) __attribute__((section(".isr_vector"))); \
1168 void mchtmr_s_isr(void) {\
1177 #define SDK_DECLARE_SWI_ISR_S(isr)\
1178 void isr(void) __attribute__((section(".isr_vector")));\
1179 HPM_EXTERN_C void swi_s_isr(void) __attribute__((section(".isr_vector"))); \
1180 void swi_s_isr(void) {\
1184 #define CSR_MSTATUS_MPP_S_MODE (0x1)
1185 #define MODE_SWITCH_FROM_M(mstatus, mepc, label, mode) \
1188 write_csr(mepc, label); \
1190 clear_csr(mstatus, CSR_MSTATUS_MPP_MASK); \
1191 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:52
#define HPM_PLIC_BASE
Definition: hpm_soc.h:38
#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:458
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:335
static ATTR_ALWAYS_INLINE void intc_s_trigger_swi(void)
Trigger software interrupt for supervisor mode.
Definition: hpm_interrupt.h:325
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:403
static ATTR_ALWAYS_INLINE void intc_disable_irq(uint32_t target, uint32_t irq)
Disable specific interrupt.
Definition: hpm_interrupt.h:414
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:477
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:514
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:392
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:503
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:315
static void switch_to_s_mode(s_mode_entry entry)
Switch mode to supervisor from machine.
Definition: hpm_interrupt.h:1201
static ATTR_ALWAYS_INLINE uint32_t intc_get_threshold(uint32_t target)
Get interrupt threshold.
Definition: hpm_interrupt.h:435
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:425
static ATTR_ALWAYS_INLINE void uninstall_isr(uint32_t irq)
Uninstall ISR for certain IRQ for ram based vector table.
Definition: hpm_interrupt.h:488
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:446
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:305
#define CSR_MSTATUS_MPP_S_MODE
Definition: hpm_interrupt.h:1184
void default_s_irq_entry(void)
#define MODE_SWITCH_FROM_M(mstatus, mepc, label, mode)
Definition: hpm_interrupt.h:1185
void default_irq_entry(void)
#define PLICSWI
Definition: hpm_interrupt.h:190
void(* s_mode_entry)(void)
Definition: hpm_interrupt.h:1195
#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