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 14 volatile irq_offload_routine_t offload_routine; 15 static const void *offload_param; 16 17 /* Called by z_arm_svc */ z_irq_do_offload(void)18void z_irq_do_offload(void) 19 { 20 offload_routine(offload_param); 21 } 22 arch_irq_offload(irq_offload_routine_t routine,const void * parameter)23void arch_irq_offload(irq_offload_routine_t routine, const void *parameter) 24 { 25 #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) && defined(CONFIG_ASSERT) 26 /* ARMv6-M/ARMv8-M Baseline HardFault if you make a SVC call with 27 * interrupts locked. 28 */ 29 unsigned int key; 30 31 __asm__ volatile("mrs %0, PRIMASK;" : "=r" (key) : : "memory"); 32 __ASSERT(key == 0U, "irq_offload called with interrupts locked\n"); 33 #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE && CONFIG_ASSERT */ 34 35 k_sched_lock(); 36 offload_routine = routine; 37 offload_param = parameter; 38 39 __asm__ volatile ("svc %[id]" 40 : 41 : [id] "i" (_SVC_CALL_IRQ_OFFLOAD) 42 : "memory"); 43 44 offload_routine = NULL; 45 k_sched_unlock(); 46 } 47