1 /* 2 * Copyright (c) 2020 Antony Pavlov <antonynpavlov@gmail.com> 3 * 4 * based on arch/riscv/core/irq_offload.c 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #include <zephyr/kernel.h> 10 #include <zephyr/kernel_structs.h> 11 #include <kernel_internal.h> 12 #include <zephyr/irq.h> 13 #include <zephyr/irq_offload.h> 14 15 volatile irq_offload_routine_t _offload_routine; 16 static volatile const void *offload_param; 17 18 /* 19 * Called by z_mips_enter_irq() 20 * 21 * Just in case the offload routine itself generates an unhandled 22 * exception, clear the offload_routine global before executing. 23 */ z_irq_do_offload(void)24void z_irq_do_offload(void) 25 { 26 irq_offload_routine_t tmp; 27 28 if (!_offload_routine) { 29 return; 30 } 31 32 tmp = _offload_routine; 33 _offload_routine = NULL; 34 35 tmp((const void *)offload_param); 36 } 37 arch_irq_offload(irq_offload_routine_t routine,const void * parameter)38void arch_irq_offload(irq_offload_routine_t routine, const void *parameter) 39 { 40 unsigned int key; 41 42 key = irq_lock(); 43 _offload_routine = routine; 44 offload_param = parameter; 45 46 /* Generate irq offload trap */ 47 __asm__ volatile ("syscall"); 48 49 irq_unlock(key); 50 } 51 arch_irq_offload_init(void)52void arch_irq_offload_init(void) 53 { 54 } 55