1 /* 2 * Copyright (c) 2015 Intel corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file Software interrupts utility code - ARM implementation 9 */ 10 11 #include <zephyr/kernel.h> 12 #include <zephyr/irq_offload.h> 13 #include <cmsis_core.h> 14 15 volatile irq_offload_routine_t offload_routine; 16 static const void *offload_param; 17 18 /* Called by z_arm_svc */ z_irq_do_offload(void)19void z_irq_do_offload(void) 20 { 21 offload_routine(offload_param); 22 } 23 arch_irq_offload(irq_offload_routine_t routine,const void * parameter)24void arch_irq_offload(irq_offload_routine_t routine, const void *parameter) 25 { 26 #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) && !defined(CONFIG_ARMV8_M_BASELINE) \ 27 && defined(CONFIG_ASSERT) 28 /* ARMv6-M HardFault if you make a SVC call with interrupts locked. 29 */ 30 __ASSERT(__get_PRIMASK() == 0U, "irq_offload called with interrupts locked\n"); 31 #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE && CONFIG_ASSERT */ 32 33 k_sched_lock(); 34 offload_routine = routine; 35 offload_param = parameter; 36 37 __asm__ volatile ("svc %[id]" 38 : 39 : [id] "i" (_SVC_CALL_IRQ_OFFLOAD) 40 : "memory"); 41 42 offload_routine = NULL; 43 k_sched_unlock(); 44 } 45 arch_irq_offload_init(void)46void arch_irq_offload_init(void) 47 { 48 } 49