From 1b9ee4602ba01afb1db72141790b32bf436c5edb Mon Sep 17 00:00:00 2001 From: ljy <1134570045@qq.com> Date: Wed, 6 Jul 2022 18:02:09 +0800 Subject: [PATCH] modify interrupt --- include/rtdef.h | 17 +++++++++++++++ libcpu/arm/cortex-a/interrupt.c | 38 +++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/include/rtdef.h b/include/rtdef.h index 556c644f94..72dbb0a935 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -110,6 +110,23 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ #define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of mailbox .entry */ #define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of message queue .entry */ +#ifdef RT_USING_LWP +#define RT_DEVICE_CTRL_IOREMAP 0x13 /**< user device ioremap */ +#define RT_DEVICE_CTRL_IOUNREMAP 0x14 /**< user device unioremap */ +#define RT_DEVICE_CTRL_MMAP 0x15 /**< user device alloc pages and map */ +#define RT_DEVICE_CTRL_MUNMAP 0x16 /**< user device unmap and free pages*/ +#define RT_DEVICE_CTRL_DATA_GET 0x17 /**< user device get data from lwp */ +#define RT_DEVICE_CTRL_DATA_PUT 0x18 /**< user device put data to lwp*/ +#define RT_DEVICE_CTRL_CACHE_MAINTAIN 0x19 /**< user device cache maintain */ +#define RT_DEVICE_CTRL_SET_INT_HANDLER 0x1a /**< user device interrupt install */ +#define RT_DEVICE_CTRL_INT_UNMASK 0x1b /**< user device unmask interrupt */ +#define RT_DEVICE_CTRL_QUIT 0x1c /**< user device quit */ +#define RT_DEVICE_CTRL_CREATE 0x1d +#define RT_DEVICE_CTRL_SET_DEVICE_DATA 0x1e +#define RT_DEVICE_SET_INFO 0x1f +#endif + + #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #define __CLANG_ARM #endif diff --git a/libcpu/arm/cortex-a/interrupt.c b/libcpu/arm/cortex-a/interrupt.c index a93d816d21..dfdb9b9f3a 100644 --- a/libcpu/arm/cortex-a/interrupt.c +++ b/libcpu/arm/cortex-a/interrupt.c @@ -16,7 +16,9 @@ /* exception and interrupt handler table */ struct rt_irq_desc isr_table[MAX_HANDLERS]; - +#ifdef RT_USING_LWP +static int isr_table_uflag[MAX_HANDLERS]; +#endif #ifndef RT_USING_SMP /* Those variables will be accessed in ISR, so we need to share them. */ rt_uint32_t rt_interrupt_from_thread = 0; @@ -168,7 +170,14 @@ if (vector < 32) int rt_hw_interrupt_get_irq(void) { #ifndef SOC_BCM283x - return arm_gic_get_active_irq(0); + int ret = arm_gic_get_active_irq(0); +#ifdef RT_USING_LWP + if (isr_table_uflag[ret & GIC_ACK_INTID_MASK]) + { + rt_hw_interrupt_mask(ret & GIC_ACK_INTID_MASK); + } + return ret; +#endif #else return 0; #endif @@ -334,8 +343,8 @@ unsigned int rt_hw_interrupt_get_prior_group_bits(void) * @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 _rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, + void *param, const char *name, int userspace) { rt_isr_handler_t old_handler = RT_NULL; @@ -350,12 +359,33 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, #endif /* RT_USING_INTERRUPT_INFO */ isr_table[vector].handler = handler; isr_table[vector].param = param; +#ifdef RT_USING_LWP + isr_table_uflag[vector] = userspace; +#endif + } + else + { +#ifdef RT_USING_LWP + isr_table_uflag[vector] = 0; +#endif } } return old_handler; } +rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, + void *param, const char *name) +{ + return _rt_hw_interrupt_install(vector, handler, param, name, 0); +} + +rt_isr_handler_t rt_hw_interrupt_install_user(int vector, rt_isr_handler_t handler, + void *param, const char *name) +{ + return _rt_hw_interrupt_install(vector, handler, param, name, 1); +} + #ifdef RT_USING_SMP void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask) { -- Gitee