diff options
| author | ZhangJing <[email protected]> | 2025-05-30 13:32:58 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2025-05-30 14:06:33 +0800 |
| commit | 97893c004c65760c638fd7eb571a08fc987a55e5 (patch) | |
| tree | 71c7c743e10a1281a104bfac56307e3d338a9818 /bsp/ultrarisc/arch/ur-cp100/interrupt.c | |
| parent | 93cc80e461d1e6d81e84c16caee4358f229e80f3 (diff) | |
[bsp]增加超睿DP1000 bsp支持v5.2.1
Diffstat (limited to 'bsp/ultrarisc/arch/ur-cp100/interrupt.c')
| -rw-r--r-- | bsp/ultrarisc/arch/ur-cp100/interrupt.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/bsp/ultrarisc/arch/ur-cp100/interrupt.c b/bsp/ultrarisc/arch/ur-cp100/interrupt.c new file mode 100644 index 0000000000..67947cd627 --- /dev/null +++ b/bsp/ultrarisc/arch/ur-cp100/interrupt.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2006-2025 RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + * 2018/12/27 Jesven Change irq enable/disable to cpu0 + */ +#include <plic.h> +#include "encoding.h" +#include "riscv.h" +#include "interrupt.h" + +struct rt_irq_desc irq_desc[MAX_HANDLERS]; + +static rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector, void *param) +{ + rt_kprintf("UN-handled interrupt %d occurred!!!\n", vector); + return RT_NULL; +} + +int rt_hw_plic_irq_enable(int irq_number) +{ + plic_irq_enable(irq_number); + return 0; +} + +int rt_hw_plic_irq_disable(int irq_number) +{ + plic_irq_disable(irq_number); + return 0; +} + +/** + * This function will un-mask a interrupt. + * @param vector the interrupt number + */ +void rt_hw_interrupt_umask(int vector) +{ + plic_set_priority(vector, 1); + + rt_hw_plic_irq_enable(vector); +} + +/** + * This function will install a interrupt service routine to a interrupt. + * @param vector the interrupt number + * @param new_handler the interrupt service routine to be installed + * @param old_handler the old interrupt service routine + */ +rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, + void *param, const char *name) +{ + rt_isr_handler_t old_handler = RT_NULL; + + if (vector < MAX_HANDLERS) + { + old_handler = irq_desc[vector].handler; + if (handler != RT_NULL) + { + irq_desc[vector].handler = (rt_isr_handler_t)handler; + irq_desc[vector].param = param; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name); + irq_desc[vector].counter = 0; +#endif + } + } + + return old_handler; +} + +void rt_hw_interrupt_init() +{ + /* Enable machine external interrupts. */ + /* set_csr(sie, SIP_SEIP); */ + int idx = 0; + /* init exceptions table */ + for (idx = 0; idx < MAX_HANDLERS; idx++) + { + irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle; + irq_desc[idx].param = RT_NULL; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default"); + irq_desc[idx].counter = 0; +#endif + } + /*init plic*/ + plic_init(); +}
\ No newline at end of file |
