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