diff --git a/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/Makefile b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/Makefile index b09a11b1a..78887b427 100755 --- a/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/Makefile +++ b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := startup_RV32M1_ri5cy.S system_RV32M1_ri5cy.c interrupt.c +SRC_FILES := startup_RV32M1_ri5cy.S interrupt_gcc.S system_RV32M1_ri5cy.c interrupt.c include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt.c b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt.c index 82a711c03..735c51be4 100755 --- a/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt.c +++ b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt.c @@ -11,7 +11,7 @@ #include #include #include "fsl_common.h" - +#include int ArchDisableHwIrq(uint32_t irq_num) { @@ -45,6 +45,25 @@ void EnableLocalInterrupt(x_base oldstat) __enable_irq(); } - +typedef void (*irq_handler_t)(void); +extern const irq_handler_t isrTable[]; + +void SystemIrqHandler(uint32_t mcause) +{ + uint32_t intNum; + + if (mcause & 0x80000000) /* For external interrupt. */ + { + intNum = mcause & 0x1FUL; + + /* Clear pending flag in EVENT unit .*/ + EVENT_UNIT->INTPTPENDCLEAR = (1U << intNum); + + /* Now call the real irq handler for intNum */ + isrManager.done->incCounter(); + isrTable[intNum](); + isrManager.done->decCounter(); + } +} diff --git a/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt_gcc.S b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt_gcc.S new file mode 100644 index 000000000..0b47c9e29 --- /dev/null +++ b/Ubiquitous/XiUOS/arch/risc-v/rv32m1_vega/interrupt_gcc.S @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/02 Bernard The first version + */ + +#include "boot.h" + + .section .text.entry + .align 2 + .global IRQ_Handler +IRQ_Handler: + + SAVE_X_REGISTERS + + mv fp, sp + + /* switch to interrupt stack */ + la sp, __stack + + /* interrupt handle */ + + csrr a0, mcause + csrr a1, mepc + mv a2, sp + call SystemIrqHandler + + /* switch to from thread stack */ + + mv sp, fp + mv a0, fp + call KTaskOsAssignAfterIrq + j SwitchKTaskContextExit +