Commit e702517c authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka

cobalt/apc: pipeline: abstract interface for deferred routine calls

Dovetail enables the regular irq_work() for submitting work from the
out-of-band stage (primary mode) to the in-band one (secondary
mode). We won't need APCs in the Dovetail case, let's move this code
to the I-pipe section.

No functional change is introduced.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent e56d4a66
......@@ -19,61 +19,14 @@
#ifndef _COBALT_KERNEL_APC_H
#define _COBALT_KERNEL_APC_H
#include <linux/ipipe.h>
#include <asm/xenomai/machine.h>
/**
* @addtogroup cobalt_core_apc
* @{
*/
int xnapc_alloc(const char *name,
void (*handler)(void *cookie),
void *cookie);
void xnapc_free(int apc);
static inline void __xnapc_schedule(int apc)
{
unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
if (!__test_and_set_bit(apc, p))
ipipe_post_irq_root(cobalt_pipeline.apc_virq);
}
/**
* @fn static inline int xnapc_schedule(int apc)
*
* @brief Schedule an APC invocation.
*
* This service marks the APC as pending for the Linux domain, so that
* its handler will be called as soon as possible, when the Linux
* domain gets back in control.
*
* When posted from the Linux domain, the APC handler is fired as soon
* as the interrupt mask is explicitly cleared by some kernel
* code. When posted from the Xenomai domain, the APC handler is
* fired as soon as the Linux domain is resumed, i.e. after Xenomai has
* completed all its pending duties.
*
* @param apc The APC id. to schedule.
*
* This service can be called from:
*
* - Any domain context, albeit the usual calling place is from the
* Xenomai domain.
*/
static inline void xnapc_schedule(int apc)
{
unsigned long flags;
flags = ipipe_test_and_stall_head() & 1;
__xnapc_schedule(apc);
ipipe_restore_head(flags);
}
void apc_dispatch(unsigned int virq, void *arg);
void __xnapc_schedule(int apc);
/** @} */
void xnapc_schedule(int apc);
#endif /* !_COBALT_KERNEL_APC_H */
obj-$(CONFIG_XENOMAI) += pipeline/ xenomai.o rtdm/ posix/
xenomai-y := apc.o \
arith.o \
xenomai-y := arith.o \
bufd.o \
clock.o \
heap.o \
......
......@@ -2,4 +2,4 @@ ccflags-y += -I$(srctree)/kernel
obj-y += pipeline.o
pipeline-y := init.o intr.o kevents.o
pipeline-y := init.o intr.o kevents.o apc.o
......@@ -18,6 +18,7 @@
*/
#include <linux/spinlock.h>
#include <linux/ipipe.h>
#include <asm/xenomai/machine.h>
#include <cobalt/kernel/apc.h>
/**
......@@ -157,4 +158,45 @@ void xnapc_free(int apc)
}
EXPORT_SYMBOL_GPL(xnapc_free);
void __xnapc_schedule(int apc)
{
unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
if (!__test_and_set_bit(apc, p))
ipipe_post_irq_root(cobalt_pipeline.apc_virq);
}
EXPORT_SYMBOL_GPL(__xnapc_schedule);
/**
* @fn static inline int xnapc_schedule(int apc)
*
* @brief Schedule an APC invocation.
*
* This service marks the APC as pending for the Linux domain, so that
* its handler will be called as soon as possible, when the Linux
* domain gets back in control.
*
* When posted from the Linux domain, the APC handler is fired as soon
* as the interrupt mask is explicitly cleared by some kernel
* code. When posted from the Xenomai domain, the APC handler is
* fired as soon as the Linux domain is resumed, i.e. after Xenomai has
* completed all its pending duties.
*
* @param apc The APC id. to schedule.
*
* This service can be called from:
*
* - Any domain context, albeit the usual calling place is from the
* Xenomai domain.
*/
void xnapc_schedule(int apc)
{
unsigned long flags;
flags = ipipe_test_and_stall_head() & 1;
__xnapc_schedule(apc);
ipipe_restore_head(flags);
}
EXPORT_SYMBOL_GPL(xnapc_schedule);
/** @} */
......@@ -18,6 +18,8 @@ module_param_named(timerfreq, timerfreq_arg, ulong, 0444);
static unsigned long clockfreq_arg;
module_param_named(clockfreq, clockfreq_arg, ulong, 0444);
void apc_dispatch(unsigned int virq, void *arg);
int __init pipeline_init(void)
{
struct ipipe_sysinfo sysinfo;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment