Xenomai API  2.6.5
rtdm_driver.h File Reference

Real-Time Driver Model for Xenomai, driver API header. More...

Include dependency graph for rtdm_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rtdm_operations
 Device operations. More...
 
struct  rtdm_dev_context
 Device context. More...
 
struct  rtdm_device
 RTDM device. More...
 

Macros

#define rtdm_irq_get_arg(irq_handle, type)   ((type *)irq_handle->cookie)
 Retrieve IRQ handler argument. More...
 
Device Flags

Static flags describing a RTDM device

#define RTDM_EXCLUSIVE   0x0001
 If set, only a single instance of the device can be requested by an application. More...
 
#define RTDM_NAMED_DEVICE   0x0010
 If set, the device is addressed via a clear-text name. More...
 
#define RTDM_PROTOCOL_DEVICE   0x0020
 If set, the device is addressed via a combination of protocol ID and socket type. More...
 
#define RTDM_DEVICE_TYPE_MASK   0x00F0
 Mask selecting the device type. More...
 
Context Flags

Dynamic flags describing the state of an open RTDM device (bit numbers)

#define RTDM_CREATED_IN_NRT   0
 Set by RTDM if the device instance was created in non-real-time context. More...
 
#define RTDM_CLOSING   1
 Set by RTDM when the device is being closed. More...
 
#define RTDM_USER_CONTEXT_FLAG   8 /* first user-definable flag */
 Lowest bit number the driver developer can use freely.
 
Driver Versioning

Current revisions of RTDM structures, encoding of driver versions. See API Versioning for the interface revision.

#define RTDM_DEVICE_STRUCT_VER   5
 Version of struct rtdm_device.
 
#define RTDM_CONTEXT_STRUCT_VER   3
 Version of struct rtdm_dev_context.
 
#define RTDM_SECURE_DEVICE   0x80000000
 Flag indicating a secure variant of RTDM (not supported here)
 
#define RTDM_DRIVER_VER(major, minor, patch)   (((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF))
 Version code constructor for driver revisions.
 
#define RTDM_DRIVER_MAJOR_VER(ver)   (((ver) >> 16) & 0xFF)
 Get major version number from driver revision code.
 
#define RTDM_DRIVER_MINOR_VER(ver)   (((ver) >> 8) & 0xFF)
 Get minor version number from driver revision code.
 
#define RTDM_DRIVER_PATCH_VER(ver)   ((ver) & 0xFF)
 Get patch version number from driver revision code.
 
Global Lock across Scheduler Invocation
#define RTDM_EXECUTE_ATOMICALLY(code_block)
 Execute code block atomically. More...
 
RTDM_IRQTYPE_xxx

Interrupt registrations flags

#define RTDM_IRQTYPE_SHARED   XN_ISR_SHARED
 Enable IRQ-sharing with other real-time drivers.
 
#define RTDM_IRQTYPE_EDGE   XN_ISR_EDGE
 Mark IRQ as edge-triggered, relevant for correct handling of shared edge-triggered IRQs.
 
RTDM_IRQ_xxx

Return flags of interrupt handlers

#define RTDM_IRQ_NONE   XN_ISR_NONE
 Unhandled interrupt.
 
#define RTDM_IRQ_HANDLED   XN_ISR_HANDLED
 Denote handled interrupt.
 
Task Priority Range

Maximum and minimum task priorities

#define RTDM_TASK_LOWEST_PRIORITY   XNSCHED_LOW_PRIO
 
#define RTDM_TASK_HIGHEST_PRIORITY   XNSCHED_HIGH_PRIO
 
Task Priority Modification

Raise or lower task priorities by one level

#define RTDM_TASK_RAISE_PRIORITY   (+1)
 
#define RTDM_TASK_LOWER_PRIORITY   (-1)
 

Typedefs

typedef int(* rtdm_irq_handler_t) (rtdm_irq_t *irq_handle)
 Interrupt handler. More...
 
typedef void(* rtdm_nrtsig_handler_t) (rtdm_nrtsig_t nrt_sig, void *arg)
 Non-real-time signal handler. More...
 
typedef void(* rtdm_timer_handler_t) (rtdm_timer_t *timer)
 Timer handler. More...
 
typedef void(* rtdm_task_proc_t) (void *arg)
 Real-time task procedure. More...
 
Operation Handler Prototypes
typedef int(* rtdm_open_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int oflag)
 Named device open handler. More...
 
typedef int(* rtdm_socket_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int protocol)
 Socket creation handler for protocol devices. More...
 
typedef int(* rtdm_close_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info)
 Close handler. More...
 
typedef int(* rtdm_ioctl_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void __user *arg)
 IOCTL handler. More...
 
typedef int(* rtdm_select_bind_handler_t) (struct rtdm_dev_context *context, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index)
 Select binding handler. More...
 
typedef ssize_t(* rtdm_read_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, void *buf, size_t nbyte)
 Read handler. More...
 
typedef ssize_t(* rtdm_write_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, const void *buf, size_t nbyte)
 Write handler. More...
 
typedef ssize_t(* rtdm_recvmsg_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, struct user_msghdr *msg, int flags)
 Receive message handler. More...
 
typedef ssize_t(* rtdm_sendmsg_handler_t) (struct rtdm_dev_context *context, rtdm_user_info_t *user_info, const struct user_msghdr *msg, int flags)
 Transmit message handler. More...
 

Enumerations

RTDM_SELECTTYPE_xxx

Event types select can bind to

enum  rtdm_selecttype { RTDM_SELECTTYPE_READ = XNSELECT_READ, RTDM_SELECTTYPE_WRITE = XNSELECT_WRITE, RTDM_SELECTTYPE_EXCEPT = XNSELECT_EXCEPT }
 
RTDM_TIMERMODE_xxx

Timer operation modes

enum  rtdm_timer_mode { RTDM_TIMERMODE_RELATIVE = XN_RELATIVE, RTDM_TIMERMODE_ABSOLUTE = XN_ABSOLUTE, RTDM_TIMERMODE_REALTIME = XN_REALTIME }
 

Functions

static void * rtdm_context_to_private (struct rtdm_dev_context *context)
 Locate the driver private area associated to a device context structure. More...
 
static struct rtdm_dev_contextrtdm_private_to_context (void *dev_private)
 Locate a device context structure from its driver private area. More...
 
int rtdm_dev_register (struct rtdm_device *device)
 Register a RTDM device. More...
 
int rtdm_dev_unregister (struct rtdm_device *device, unsigned int poll_delay)
 Unregisters a RTDM device. More...
 
struct rtdm_dev_contextrtdm_context_get (int fd)
 Retrieve and lock a device context. More...
 
int rtdm_select_bind (int fd, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index)
 Bind a selector to specified event types of a given file descriptor. More...
 
int rtdm_irq_request (rtdm_irq_t *irq_handle, unsigned int irq_no, rtdm_irq_handler_t handler, unsigned long flags, const char *device_name, void *arg)
 Register an interrupt handler. More...
 
void rtdm_timer_destroy (rtdm_timer_t *timer)
 Destroy a timer. More...
 
int rtdm_timer_start (rtdm_timer_t *timer, nanosecs_abs_t expiry, nanosecs_rel_t interval, enum rtdm_timer_mode mode)
 Start a timer. More...
 
void rtdm_timer_stop (rtdm_timer_t *timer)
 Stop a timer. More...
 
int rtdm_task_init (rtdm_task_t *task, const char *name, rtdm_task_proc_t task_proc, void *arg, int priority, nanosecs_rel_t period)
 Intialise and start a real-time task. More...
 
void rtdm_task_busy_sleep (nanosecs_rel_t delay)
 Busy-wait a specified amount of time. More...
 
void rtdm_toseq_init (rtdm_toseq_t *timeout_seq, nanosecs_rel_t timeout)
 Initialise a timeout sequence. More...
 
void rtdm_event_init (rtdm_event_t *event, unsigned long pending)
 Initialise an event. More...
 
int rtdm_event_select_bind (rtdm_event_t *event, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index)
 Bind a selector to an event. More...
 
int rtdm_event_wait (rtdm_event_t *event)
 Wait on event occurrence. More...
 
int rtdm_event_timedwait (rtdm_event_t *event, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
 Wait on event occurrence with timeout. More...
 
void rtdm_event_signal (rtdm_event_t *event)
 Signal an event occurrence. More...
 
void rtdm_event_clear (rtdm_event_t *event)
 Clear event state. More...
 
void rtdm_sem_init (rtdm_sem_t *sem, unsigned long value)
 Initialise a semaphore. More...
 
int rtdm_sem_select_bind (rtdm_sem_t *sem, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index)
 Bind a selector to a semaphore. More...
 
int rtdm_sem_down (rtdm_sem_t *sem)
 Decrement a semaphore. More...
 
int rtdm_sem_timeddown (rtdm_sem_t *sem, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
 Decrement a semaphore with timeout. More...
 
void rtdm_sem_up (rtdm_sem_t *sem)
 Increment a semaphore. More...
 
void rtdm_mutex_init (rtdm_mutex_t *mutex)
 Initialise a mutex. More...
 
int rtdm_mutex_lock (rtdm_mutex_t *mutex)
 Request a mutex. More...
 
int rtdm_mutex_timedlock (rtdm_mutex_t *mutex, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
 Request a mutex with timeout. More...
 
int rtdm_ratelimit (struct rtdm_ratelimit_state *rs, const char *func)
 Enforces a rate limit. More...
 

Spinlock with Preemption Deactivation

#define RTDM_LOCK_UNLOCKED   RTHAL_SPIN_LOCK_UNLOCKED
 Static lock initialisation.
 
#define rtdm_lock_init(lock)   rthal_spin_lock_init(lock)
 Dynamic lock initialisation. More...
 
#define rtdm_lock_get(lock)   rthal_spin_lock(lock)
 Acquire lock from non-preemptible contexts. More...
 
#define rtdm_lock_put(lock)
 Release lock without preemption restoration. More...
 
#define rtdm_lock_get_irqsave(lock, context)
 Acquire lock and disable preemption. More...
 
#define rtdm_lock_put_irqrestore(lock, context)
 Release lock and restore preemption state. More...
 
#define rtdm_lock_irqsave(context)   rthal_local_irq_save(context)
 Disable preemption locally. More...
 
#define rtdm_lock_irqrestore(context)   rthal_local_irq_restore(context)
 Restore preemption state. More...
 
typedef rthal_spinlock_t rtdm_lock_t
 Lock variable.
 
typedef unsigned long rtdm_lockctx_t
 Variable to save the context while holding a lock.
 

Detailed Description

Real-Time Driver Model for Xenomai, driver API header.

Note
Copyright (C) 2005-2007 Jan Kiszka jan.k.nosp@m.iszk.nosp@m.a@web.nosp@m..de
Copyright (C) 2005 Joerg Langenberg joerg.nosp@m..lan.nosp@m.genbe.nosp@m.rg@g.nosp@m.mx.ne.nosp@m.t
Copyright (C) 2008 Gilles Chanteperdrix gille.nosp@m.s.ch.nosp@m.antep.nosp@m.erdr.nosp@m.ix@xe.nosp@m.noma.nosp@m.i.org

Xenomai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Xenomai is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Xenomai; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.