kernel: split irq_offload ccode into own file

Move irq_offload code out of thread.c into own file. This code is not
related to threads.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2024-02-22 22:19:05 -05:00
commit 2c31db4cc8
3 changed files with 29 additions and 19 deletions

View file

@ -89,6 +89,12 @@ list(APPEND kernel_files
spinlock_validate.c)
endif()
if(CONFIG_IRQ_OFFLOAD)
list(APPEND kernel_files
irq_offload.c
)
endif()
if(CONFIG_XIP)
list(APPEND kernel_files
xip.c)

23
kernel/irq_offload.c Normal file
View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2018,2024 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/irq_offload.h>
/* Make offload_sem visible outside testing, in order to release
* it outside when error happened.
*/
K_SEM_DEFINE(offload_sem, 1, 1);
void irq_offload(irq_offload_routine_t routine, const void *parameter)
{
#ifdef CONFIG_IRQ_OFFLOAD_NESTED
arch_irq_offload(routine, parameter);
#else
k_sem_take(&offload_sem, K_FOREVER);
arch_irq_offload(routine, parameter);
k_sem_give(&offload_sem);
#endif
}

View file

@ -24,7 +24,6 @@
#include <zephyr/tracing/tracing.h>
#include <string.h>
#include <stdbool.h>
#include <zephyr/irq_offload.h>
#include <zephyr/sys/check.h>
#include <zephyr/random/random.h>
#include <zephyr/sys/atomic.h>
@ -975,24 +974,6 @@ static inline int z_vrfy_k_float_disable(struct k_thread *thread)
#include <syscalls/k_float_disable_mrsh.c>
#endif /* CONFIG_USERSPACE */
#ifdef CONFIG_IRQ_OFFLOAD
/* Make offload_sem visible outside under testing, in order to release
* it outside when error happened.
*/
K_SEM_DEFINE(offload_sem, 1, 1);
void irq_offload(irq_offload_routine_t routine, const void *parameter)
{
#ifdef CONFIG_IRQ_OFFLOAD_NESTED
arch_irq_offload(routine, parameter);
#else
k_sem_take(&offload_sem, K_FOREVER);
arch_irq_offload(routine, parameter);
k_sem_give(&offload_sem);
#endif
}
#endif
#if defined(CONFIG_INIT_STACKS) && defined(CONFIG_THREAD_STACK_INFO)
#ifdef CONFIG_STACK_GROWS_UP
#error "Unsupported configuration for stack analysis"