1 /* 2 * Copyright (c) 2016 Cadence Design Systems, Inc. 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #include <kernel.h> 7 #include <irq_offload.h> 8 #include <arch/xtensa/arch.h> 9 10 /* 11 * Xtensa core should support software interrupt in order to allow using 12 * irq_offload feature 13 */ 14 15 static irq_offload_routine_t offload_routine; 16 static const void *offload_param; 17 18 /* Called by ISR dispatcher */ z_irq_do_offload(const void * unused)19void z_irq_do_offload(const void *unused) 20 { 21 ARG_UNUSED(unused); 22 offload_routine(offload_param); 23 } 24 arch_irq_offload(irq_offload_routine_t routine,const void * parameter)25void arch_irq_offload(irq_offload_routine_t routine, const void *parameter) 26 { 27 IRQ_CONNECT(CONFIG_IRQ_OFFLOAD_INTNUM, XCHAL_EXCM_LEVEL, 28 z_irq_do_offload, NULL, 0); 29 arch_irq_disable(CONFIG_IRQ_OFFLOAD_INTNUM); 30 offload_routine = routine; 31 offload_param = parameter; 32 z_xt_set_intset(BIT(CONFIG_IRQ_OFFLOAD_INTNUM)); 33 /* 34 * Enable the software interrupt, in case it is disabled, so that IRQ 35 * offload is serviced. 36 */ 37 arch_irq_enable(CONFIG_IRQ_OFFLOAD_INTNUM); 38 } 39