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
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:49:15 +08:00
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/irq_offload.h>
|
2023-10-08 07:27:41 +08:00
|
|
|
#include <cmsis_core.h>
|
2015-11-18 06:08:45 +08:00
|
|
|
|
2017-04-20 03:53:48 +08:00
|
|
|
volatile irq_offload_routine_t offload_routine;
|
2020-07-10 16:57:23 +08:00
|
|
|
static const void *offload_param;
|
2015-11-18 06:08:45 +08:00
|
|
|
|
2019-10-01 03:31:07 +08:00
|
|
|
/* Called by z_arm_svc */
|
2019-03-14 23:20:46 +08:00
|
|
|
void z_irq_do_offload(void)
|
2015-11-18 06:08:45 +08:00
|
|
|
{
|
|
|
|
offload_routine(offload_param);
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:57:23 +08:00
|
|
|
void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
|
2015-11-18 06:08:45 +08:00
|
|
|
{
|
2023-10-08 07:27:41 +08:00
|
|
|
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) && !defined(CONFIG_ARMV8_M_BASELINE) \
|
|
|
|
&& defined(CONFIG_ASSERT)
|
|
|
|
/* ARMv6-M HardFault if you make a SVC call with interrupts locked.
|
2017-06-02 04:36:44 +08:00
|
|
|
*/
|
2023-10-08 07:27:41 +08:00
|
|
|
__ASSERT(__get_PRIMASK() == 0U, "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
|
|
|
}
|
2024-07-09 05:08:30 +08:00
|
|
|
|
|
|
|
void arch_irq_offload_init(void)
|
|
|
|
{
|
|
|
|
}
|