From f974cb0ae1cbdf6ad32f839f1d11e4aa241e08c0 Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Fri, 25 Oct 2019 14:54:17 +0200 Subject: [PATCH] posix arch: Untangle headers posix_soc_if.h is meant to be a private header between the POSIX ARCH, SOC, and maybe boards, it should not contain definitions meant to be used directly by the kernel or app. Some definitions were placed here due to a dependency moebius loop. Unravel that by removing all header dependencies in posix_soc_if.h, move those definitions out to a more logical place, and while we are here reduce the amount of users of irq_offload.h in POSIX arch related code Signed-off-by: Alberto Escolar Piedras --- arch/posix/core/irq.c | 2 ++ arch/posix/include/posix_soc_if.h | 14 +------------- boards/posix/native_posix/irq_handler.c | 4 ++-- boards/posix/nrf52_bsim/irq_handler.c | 4 ++-- include/arch/posix/arch.h | 12 ++++++++++++ 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/arch/posix/core/irq.c b/arch/posix/core/irq.c index 3207b139000..d0b16eba8ee 100644 --- a/arch/posix/core/irq.c +++ b/arch/posix/core/irq.c @@ -8,6 +8,8 @@ #include "board_irq.h" #ifdef CONFIG_IRQ_OFFLOAD +#include "irq_offload.h" + void z_arch_irq_offload(irq_offload_routine_t routine, void *parameter) { posix_irq_offload(routine, parameter); diff --git a/arch/posix/include/posix_soc_if.h b/arch/posix/include/posix_soc_if.h index e3c98833d05..0dede34e8e6 100644 --- a/arch/posix/include/posix_soc_if.h +++ b/arch/posix/include/posix_soc_if.h @@ -16,7 +16,6 @@ #include "posix_trace.h" #include "soc_irq.h" /* Must exist and define _ARCH_IRQ/ISR_* macros */ -#include "irq_offload.h" #ifdef __cplusplus extern "C" { @@ -33,20 +32,9 @@ void posix_irq_unlock(unsigned int key); void posix_irq_full_unlock(void); int posix_get_current_irq(void); #ifdef CONFIG_IRQ_OFFLOAD -void posix_irq_offload(irq_offload_routine_t routine, void *parameter); +void posix_irq_offload(void (*routine)(void *), void *parameter); #endif -static ALWAYS_INLINE unsigned int z_arch_irq_lock(void) -{ - return posix_irq_lock(); -} - - -static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key) -{ - posix_irq_unlock(key); -} - #ifdef __cplusplus } #endif diff --git a/boards/posix/native_posix/irq_handler.c b/boards/posix/native_posix/irq_handler.c index 4ad5fc2ad6a..9e15853dbdb 100644 --- a/boards/posix/native_posix/irq_handler.c +++ b/boards/posix/native_posix/irq_handler.c @@ -278,7 +278,7 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn) /** * Storage for functions offloaded to IRQ */ -static irq_offload_routine_t off_routine; +static void (*off_routine)(void *); static void *off_parameter; /** @@ -295,7 +295,7 @@ static void offload_sw_irq_handler(void *a) * * Raise the SW IRQ assigned to handled this */ -void posix_irq_offload(irq_offload_routine_t routine, void *parameter) +void posix_irq_offload(void (*routine)(void *), void *parameter) { off_routine = routine; off_parameter = parameter; diff --git a/boards/posix/nrf52_bsim/irq_handler.c b/boards/posix/nrf52_bsim/irq_handler.c index f7d4045f70f..43594d8c722 100644 --- a/boards/posix/nrf52_bsim/irq_handler.c +++ b/boards/posix/nrf52_bsim/irq_handler.c @@ -337,7 +337,7 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn) /** * Storage for functions offloaded to IRQ */ -static irq_offload_routine_t off_routine; +static void (*off_routine)(void *); static void *off_parameter; /** @@ -354,7 +354,7 @@ static void offload_sw_irq_handler(void *a) * * Raise the SW IRQ assigned to handled this */ -void posix_irq_offload(irq_offload_routine_t routine, void *parameter) +void posix_irq_offload(void (*routine)(void *), void *parameter) { off_routine = routine; off_parameter = parameter; diff --git a/include/arch/posix/arch.h b/include/arch/posix/arch.h index 522002d8c36..3ccf26cfc66 100644 --- a/include/arch/posix/arch.h +++ b/include/arch/posix/arch.h @@ -25,6 +25,7 @@ #include #include /* Each board must define this */ #include +#include #ifdef __cplusplus extern "C" { @@ -61,6 +62,17 @@ static ALWAYS_INLINE bool z_arch_irq_unlocked(unsigned int key) return key == false; } +static ALWAYS_INLINE unsigned int z_arch_irq_lock(void) +{ + return posix_irq_lock(); +} + + +static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key) +{ + posix_irq_unlock(key); +} + #ifdef __cplusplus } #endif