Xenomai  3.0.5
driver.h File Reference

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

Include dependency graph for 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_dev_context
 Device context. More...
 
struct  rtdm_sm_ops
 RTDM state management handlers. More...
 
struct  rtdm_driver
 RTDM driver. More...
 
struct  rtdm_device
 RTDM device. More...
 

Macros

#define RTDM_MAX_MINOR   1024
 Maximum number of named devices per driver. More...
 
#define cobalt_atomic_enter(__context)
 Enter atomic section (dual kernel only) More...
 
#define cobalt_atomic_leave(__context)
 Leave atomic section (dual kernel only) More...
 
#define RTDM_EXECUTE_ATOMICALLY(code_block)
 Execute code block atomically (DEPRECATED) More...
 
#define RTDM_LOCK_UNLOCKED(__name)   IPIPE_SPIN_LOCK_UNLOCKED
 Static lock initialisation.
 
#define rtdm_lock_get_irqsave(__lock, __context)   ((__context) = __rtdm_lock_get_irqsave(__lock))
 Acquire lock and disable preemption, by stalling the head domain. More...
 
#define rtdm_lock_irqsave(__context)   splhigh(__context)
 Disable preemption locally. More...
 
#define rtdm_lock_irqrestore(__context)   splexit(__context)
 Restore preemption state. More...
 
#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_FIXED_MINOR   0x0002
 Use fixed minor provided in the rtdm_device description for registering. 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...
 
#define RTDM_SECURE_DEVICE   0x80000000
 Flag indicating a secure variant of RTDM (not supported here)
 
RTDM_IRQTYPE_xxx

Interrupt registrations flags

#define RTDM_IRQTYPE_SHARED   XN_IRQTYPE_SHARED
 Enable IRQ-sharing with other real-time drivers.
 
#define RTDM_IRQTYPE_EDGE   XN_IRQTYPE_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_IRQ_NONE
 Unhandled interrupt.
 
#define RTDM_IRQ_HANDLED   XN_IRQ_HANDLED
 Denote handled interrupt.
 
#define RTDM_IRQ_DISABLE   XN_IRQ_DISABLE
 Request interrupt disabling on exit.
 
Task Priority Range

Maximum and minimum task priorities

#define RTDM_TASK_LOWEST_PRIORITY   0
 
#define RTDM_TASK_HIGHEST_PRIORITY   99
 
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 ipipe_spinlock_t rtdm_lock_t
 Lock variable.
 
typedef unsigned long rtdm_lockctx_t
 Variable to save the context while holding a lock.
 
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...
 

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_fd_to_private (struct rtdm_fd *fd)
 Locate the driver private area associated to a device context structure. More...
 
static struct rtdm_fd * rtdm_private_to_fd (void *dev_private)
 Locate a device file descriptor structure from its driver private area. More...
 
static bool rtdm_fd_is_user (struct rtdm_fd *fd)
 Tell whether the passed file descriptor belongs to an application. More...
 
static struct rtdm_devicertdm_fd_device (struct rtdm_fd *fd)
 Locate a device structure from a file descriptor. More...
 
int rtdm_dev_register (struct rtdm_device *device)
 Register a RTDM device. More...
 
void rtdm_dev_unregister (struct rtdm_device *device)
 Unregister a RTDM device. More...
 
void rtdm_toseq_init (rtdm_toseq_t *timeout_seq, nanosecs_rel_t timeout)
 Initialise a timeout sequence. More...
 
static void rtdm_lock_init (rtdm_lock_t *lock)
 Dynamic lock initialisation. More...
 
static void rtdm_lock_get (rtdm_lock_t *lock)
 Acquire lock from non-preemptible contexts. More...
 
static void rtdm_lock_put (rtdm_lock_t *lock)
 Release lock without preemption restoration. More...
 
static void rtdm_lock_put_irqrestore (rtdm_lock_t *lock, rtdm_lockctx_t context)
 Release lock and restore preemption state. 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_schedule_nrt_work (struct work_struct *lostage_work)
 Put a work task in Linux non real-time global workqueue from primary mode. 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)
 Initialise 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_event_init (rtdm_event_t *event, unsigned long pending)
 Initialise 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_event_pulse (rtdm_event_t *event)
 Signal an event occurrence to currently listening waiters. More...
 
void rtdm_event_destroy (rtdm_event_t *event)
 Destroy an event. More...
 
void rtdm_sem_init (rtdm_sem_t *sem, unsigned long value)
 Initialise 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_sem_destroy (rtdm_sem_t *sem)
 Destroy 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...
 
void rtdm_mutex_unlock (rtdm_mutex_t *mutex)
 Release a mutex. More...
 
void rtdm_mutex_destroy (rtdm_mutex_t *mutex)
 Destroy a mutex. More...
 
int rtdm_ratelimit (struct rtdm_ratelimit_state *rs, const char *func)
 Enforces a rate limit. More...
 

RTDM profile information descriptor

RTDM profile information

This descriptor details the profile information associated to a RTDM class of device managed by a driver.

#define RTDM_CLASS_MAGIC   0x8284636c
 Initializer for class profile information. More...
 
#define RTDM_PROFILE_INFO(__name, __id, __subid, __version)
 Initializer for class profile information. More...
 
int rtdm_drv_set_sysclass (struct rtdm_driver *drv, struct class *cls)
 Set the kernel device class of a RTDM driver. More...
 

Detailed Description

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

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 Copyright (C) 2014 Philippe Gerum rpm@x.nosp@m.enom.nosp@m.ai.or.nosp@m.g

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.

Macro Definition Documentation

◆ RTDM_CLASS_MAGIC

#define RTDM_CLASS_MAGIC   0x8284636c

Initializer for class profile information.

This macro must be used to fill in the class profile information field from a RTDM driver.

Parameters
__nameClass name (unquoted).
__idClass major identification number (profile_version.class_id).
__subidClass minor identification number (profile_version.subclass_id).
__versionProfile version number.
Note
See Device Profiles.

◆ RTDM_PROFILE_INFO

#define RTDM_PROFILE_INFO (   __name,
  __id,
  __subid,
  __version 
)
Value:
{ \
.name = ( # __name ), \
.class_id = (__id), \
.subclass_id = (__subid), \
.version = (__version), \
.magic = ~RTDM_CLASS_MAGIC, \
.owner = THIS_MODULE, \
.kdev_class = NULL, \
}
#define RTDM_CLASS_MAGIC
Initializer for class profile information.
Definition: driver.h:299

Initializer for class profile information.

This macro must be used to fill in the class profile information field from a RTDM driver.

Parameters
__nameClass name (unquoted).
__idClass major identification number (profile_version.class_id).
__subidClass minor identification number (profile_version.subclass_id).
__versionProfile version number.
Note
See Device Profiles.

Function Documentation

◆ rtdm_fd_device()

static struct rtdm_device* rtdm_fd_device ( struct rtdm_fd *  fd)
static

Locate a device structure from a file descriptor.

Parameters
[in]fdFile descriptor
Returns
The address of the device structure to which this file descriptor is attached.

Referenced by udd_get_device().

◆ rtdm_fd_is_user()

static bool rtdm_fd_is_user ( struct rtdm_fd *  fd)
inlinestatic

Tell whether the passed file descriptor belongs to an application.

Parameters
[in]fdFile descriptor
Returns
true if passed file descriptor belongs to an application, false otherwise.

◆ rtdm_fd_to_private()

static void* rtdm_fd_to_private ( struct rtdm_fd *  fd)
inlinestatic

Locate the driver private area associated to a device context structure.

Parameters
[in]fdFile descriptor structure associated with opened device instance
Returns
The address of the private driver area associated to file descriptor.

◆ rtdm_private_to_fd()

static struct rtdm_fd* rtdm_private_to_fd ( void *  dev_private)
static

Locate a device file descriptor structure from its driver private area.

Parameters
[in]dev_privateAddress of a private context area
Returns
The address of the file descriptor structure defining dev_private.