23 #ifndef __ANALOGY_OS_FACILITIES__
24 #define __ANALOGY_OS_FACILITIES__
26 #if defined(__KERNEL__) && !defined(DOXYGEN_CPP)
29 #include <linux/spinlock.h>
30 #include <linux/sched.h>
31 #include <linux/time.h>
32 #include <linux/delay.h>
33 #include <linux/interrupt.h>
34 #include <asm/uaccess.h>
36 #if !(defined(CONFIG_XENO_SKIN_RTDM) || \
37 defined(CONFIG_XENO_SKIN_RTDM_MODULE))
38 #error Analogy needs RTDM enabled \
39 (statically or as amodule) to compile properly
47 #define A4L_PROMPT "Analogy: "
49 #define RTDM_SUBCLASS_ANALOGY 0
51 #define __a4l_err(fmt, args...) \
52 rtdm_printk(KERN_ERR A4L_PROMPT fmt, ##args)
54 #define __a4l_warn(fmt, args...) \
55 rtdm_printk(KERN_WARNING A4L_PROMPT fmt, ##args)
57 #define __a4l_info(fmt, args...) \
58 rtdm_printk(KERN_INFO A4L_PROMPT fmt, ##args)
60 #ifdef CONFIG_XENO_DRIVERS_ANALOGY_DEBUG
62 #define __a4l_dbg(level, debug, fmt, args...) \
64 if ((debug) >= (level)) \
65 rtdm_printk(KERN_DEBUG A4L_PROMPT fmt, ##args); \
68 #define core_dbg CONFIG_XENO_DRIVERS_ANALOGY_DEBUG_LEVEL
69 #define drv_dbg CONFIG_XENO_DRIVERS_ANALOGY_DRIVER_DEBUG_LEVEL
73 #define __a4l_dbg(level, debug, fmt, args...)
77 #define __a4l_dev_name(dev) \
78 (dev->driver == NULL) ? "unattached dev" : dev->driver->board_name
80 #define a4l_err(dev, fmt, args...) \
81 __a4l_err("%s: " fmt, __a4l_dev_name(dev), ##args)
83 #define a4l_warn(dev, fmt, args...) \
84 __a4l_warn("%s: " fmt, __a4l_dev_name(dev), ##args)
86 #define a4l_info(dev, fmt, args...) \
87 __a4l_info("%s: " fmt, __a4l_dev_name(dev), ##args)
89 #define a4l_dbg(level, debug, dev, fmt, args...) \
90 __a4l_dbg(level, debug, "%s: " fmt, __a4l_dev_name(dev), ##args)
96 #define A4L_LOCK_UNLOCKED RTDM_LOCK_UNLOCKED
98 #define a4l_lock_init(lock) rtdm_lock_init(lock)
99 #define a4l_lock(lock) rtdm_lock_get(lock)
100 #define a4l_unlock(lock) rtdm_lock_put(lock)
101 #define a4l_lock_irqsave(lock, context) \
102 rtdm_lock_get_irqsave(lock, context)
103 #define a4l_unlock_irqrestore(lock, context) \
104 rtdm_lock_put_irqrestore(lock, context)
108 #define A4L_TASK_LOWEST_PRIORITY RTDM_TASK_LOWEST_PRIORITY
109 #define A4L_TASK_HIGHEST_PRIORITY RTDM_TASK_HIGHEST_PRIORITY
111 typedef rtdm_task_t a4l_task_t;
114 #define a4l_task_init(tsk, name, proc, arg, priority) \
115 rtdm_task_init(tsk, name, proc, arg, priority, 0)
117 #define a4l_task_destroy(tsk) rtdm_task_destroy(tsk)
119 #define a4l_task_sleep(delay) rtdm_task_sleep(delay)
123 static inline void a4l_udelay(
unsigned int us)
137 void a4l_init_time(
void);
141 #define A4L_IRQ_SHARED RTDM_IRQTYPE_SHARED
142 #define A4L_IRQ_EDGE RTDM_IRQTYPE_EDGE
143 #define A4L_IRQ_DISABLED 0
145 typedef int (*a4l_irq_hdlr_t) (
unsigned int irq,
void *d);
147 struct a4l_irq_descriptor {
150 a4l_irq_hdlr_t handler;
153 rtdm_irq_t rtdm_desc;
155 typedef struct a4l_irq_descriptor a4l_irq_desc_t;
157 int __a4l_request_irq(a4l_irq_desc_t * dsc,
159 a4l_irq_hdlr_t handler,
160 unsigned long flags,
void *cookie);
161 int __a4l_free_irq(a4l_irq_desc_t * dsc);
165 #define __NRT_WAITER 1
166 #define __RT_WAITER 2
167 #define __EVT_PDING 3
170 unsigned long status;
171 rtdm_event_t rtdm_evt;
172 rtdm_nrtsig_t nrt_sig;
173 wait_queue_head_t wq;
175 typedef struct a4l_sync a4l_sync_t;
177 #define a4l_select_sync(snc, slr, type, fd) \
178 rtdm_event_select_bind(&((snc)->rtdm_evt), slr, type, fd)
180 int a4l_init_sync(a4l_sync_t * snc);
181 void a4l_cleanup_sync(a4l_sync_t * snc);
182 void a4l_flush_sync(a4l_sync_t * snc);
183 int a4l_wait_sync(a4l_sync_t * snc,
int rt);
184 int a4l_timedwait_sync(a4l_sync_t * snc,
185 int rt,
unsigned long long ns_timeout);
186 void a4l_signal_sync(a4l_sync_t * snc);
190 #define a4l_test_rt() rtdm_in_rt_context()
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:95
rthal_spinlock_t rtdm_lock_t
Lock variable.
Definition: rtdm_driver.h:690
uint64_t nanosecs_abs_t
RTDM type for representing absolute dates.
Definition: rtdm.h:89
void rtdm_task_busy_sleep(nanosecs_rel_t delay)
Busy-wait a specified amount of time.
Definition: drvlib.c:471
nanosecs_abs_t rtdm_clock_read(void)
Get system time.
void(* rtdm_task_proc_t)(void *arg)
Real-time task procedure.
Definition: rtdm_driver.h:1061
Real-Time Driver Model for Xenomai, driver API header.
unsigned long long a4l_get_time(void)
Get the absolute time in nanoseconds.