1 /* 2 * Copyright (c) 2016 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/kernel_structs.h> 9 #include <zephyr/irq_offload.h> 10 11 volatile irq_offload_routine_t _offload_routine; 12 static volatile const void *offload_param; 13 14 /* Called by _enter_irq if it was passed 0 for ipending. 15 * Just in case the offload routine itself generates an unhandled 16 * exception, clear the offload_routine global before executing. 17 */ z_irq_do_offload(void)18void z_irq_do_offload(void) 19 { 20 irq_offload_routine_t tmp; 21 22 if (!_offload_routine) { 23 return; 24 } 25 26 tmp = _offload_routine; 27 _offload_routine = NULL; 28 29 tmp((const void *)offload_param); 30 } 31 arch_irq_offload(irq_offload_routine_t routine,const void * parameter)32void arch_irq_offload(irq_offload_routine_t routine, const void *parameter) 33 { 34 unsigned int key; 35 36 key = irq_lock(); 37 _offload_routine = routine; 38 offload_param = parameter; 39 40 __asm__ volatile ("trap"); 41 42 irq_unlock(key); 43 } 44 arch_irq_offload_init(void)45void arch_irq_offload_init(void) 46 { 47 } 48