1 /*
2  * Copyright (c) 2019-2020 Cobham Gaisler AB
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.h>
10 #include <zephyr/irq_offload.h>
11 
12 volatile irq_offload_routine_t _offload_routine;
13 static volatile const void *offload_param;
14 
z_irq_do_offload(void)15 void z_irq_do_offload(void)
16 {
17 	irq_offload_routine_t tmp;
18 
19 	if (!_offload_routine) {
20 		return;
21 	}
22 
23 	tmp = _offload_routine;
24 	_offload_routine = NULL;
25 
26 	tmp((const void *)offload_param);
27 }
28 
arch_irq_offload(irq_offload_routine_t routine,const void * parameter)29 void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
30 {
31 	unsigned int key;
32 
33 	key = irq_lock();
34 	_offload_routine = routine;
35 	offload_param = parameter;
36 
37 	/* Generate irq offload trap */
38 	__asm__ volatile ("ta 13");
39 
40 	irq_unlock(key);
41 }
42 
arch_irq_offload_init(void)43 void arch_irq_offload_init(void)
44 {
45 }
46