2015-11-18 06:08:45 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-11-18 06:08:45 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file Software interrupts utility code - ARM implementation
|
|
|
|
*/
|
|
|
|
|
2016-12-23 21:35:34 +08:00
|
|
|
#include <kernel.h>
|
2015-11-18 06:08:45 +08:00
|
|
|
#include <irq_offload.h>
|
|
|
|
|
2017-04-20 03:53:48 +08:00
|
|
|
volatile irq_offload_routine_t offload_routine;
|
2015-11-18 06:08:45 +08:00
|
|
|
static void *offload_param;
|
|
|
|
|
|
|
|
/* Called by __svc */
|
|
|
|
void _irq_do_offload(void)
|
|
|
|
{
|
|
|
|
offload_routine(offload_param);
|
|
|
|
}
|
|
|
|
|
|
|
|
void irq_offload(irq_offload_routine_t routine, void *parameter)
|
|
|
|
{
|
2018-02-07 06:47:58 +08:00
|
|
|
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) && defined(CONFIG_ASSERT)
|
2019-02-07 17:05:30 +08:00
|
|
|
/* ARMv6-M/ARMv8-M Baseline HardFault if you make a SVC call with
|
|
|
|
* interrupts locked.
|
2017-06-02 04:36:44 +08:00
|
|
|
*/
|
|
|
|
unsigned int key;
|
2015-11-18 06:08:45 +08:00
|
|
|
|
2017-06-02 04:36:44 +08:00
|
|
|
__asm__ volatile("mrs %0, PRIMASK;" : "=r" (key) : : "memory");
|
|
|
|
__ASSERT(key == 0, "irq_offload called with interrupts locked\n");
|
2018-02-07 06:47:58 +08:00
|
|
|
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE && CONFIG_ASSERT */
|
2017-06-02 04:36:44 +08:00
|
|
|
|
|
|
|
k_sched_lock();
|
2015-11-18 06:08:45 +08:00
|
|
|
offload_routine = routine;
|
|
|
|
offload_param = parameter;
|
|
|
|
|
2017-04-20 03:53:48 +08:00
|
|
|
__asm__ volatile ("svc %[id]"
|
|
|
|
:
|
|
|
|
: [id] "i" (_SVC_CALL_IRQ_OFFLOAD)
|
|
|
|
: "memory");
|
|
|
|
|
|
|
|
offload_routine = NULL;
|
2017-06-02 04:36:44 +08:00
|
|
|
k_sched_unlock();
|
2015-11-18 06:08:45 +08:00
|
|
|
}
|