Xenomai  3.1
Device Registration Services
Collaboration diagram for Device Registration Services:

Data Structures

struct  rtdm_fd_ops
 RTDM file operation descriptor. More...
 

Macros

#define RTDM_MAX_MINOR   4096
 Maximum number of named devices per driver. More...
 

Functions

int rtdm_open_handler (struct rtdm_fd *fd, int oflags)
 Open handler for named devices. More...
 
int rtdm_socket_handler (struct rtdm_fd *fd, int protocol)
 Socket creation handler for protocol devices. More...
 
void rtdm_close_handler (struct rtdm_fd *fd)
 Close handler. More...
 
int rtdm_ioctl_handler (struct rtdm_fd *fd, unsigned int request, void __user *arg)
 IOCTL handler. More...
 
ssize_t rtdm_read_handler (struct rtdm_fd *fd, void __user *buf, size_t size)
 Read handler. More...
 
ssize_t rtdm_write_handler (struct rtdm_fd *fd, const void __user *buf, size_t size)
 Write handler. More...
 
ssize_t rtdm_recvmsg_handler (struct rtdm_fd *fd, struct user_msghdr *msg, int flags)
 Receive message handler. More...
 
ssize_t rtdm_sendmsg_handler (struct rtdm_fd *fd, const struct user_msghdr *msg, int flags)
 Transmit message handler. More...
 
int rtdm_select_handler (struct rtdm_fd *fd, struct xnselector *selector, unsigned int type, unsigned int index)
 Select handler. More...
 
int rtdm_mmap_handler (struct rtdm_fd *fd, struct vm_area_struct *vma)
 Memory mapping handler. More...
 
unsigned long rtdm_get_unmapped_area_handler (struct rtdm_fd *fd, unsigned long len, unsigned long pgoff, unsigned long flags)
 Allocate mapping region in address space. More...
 
int rtdm_dev_register (struct rtdm_device *dev)
 
Register a RTDM device More...
 
void rtdm_dev_unregister (struct rtdm_device *dev)
 
Unregister a RTDM device More...
 
int rtdm_drv_set_sysclass (struct rtdm_driver *drv, struct class *cls)
 
Set the kernel device class of a RTDM driver. 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)
 

Detailed Description

Macro Definition Documentation

◆ RTDM_DEVICE_TYPE_MASK

#define RTDM_DEVICE_TYPE_MASK   0x00F0

Mask selecting the device type.

◆ RTDM_EXCLUSIVE

#define RTDM_EXCLUSIVE   0x0001

If set, only a single instance of the device can be requested by an application.

◆ RTDM_FIXED_MINOR

#define RTDM_FIXED_MINOR   0x0002

Use fixed minor provided in the rtdm_device description for registering.

If this flag is absent, the RTDM core assigns minor numbers to devices managed by a driver in order of registration.

◆ RTDM_MAX_MINOR

#define RTDM_MAX_MINOR   4096

Maximum number of named devices per driver.

◆ RTDM_NAMED_DEVICE

#define RTDM_NAMED_DEVICE   0x0010

If set, the device is addressed via a clear-text name.

◆ RTDM_PROTOCOL_DEVICE

#define RTDM_PROTOCOL_DEVICE   0x0020

If set, the device is addressed via a combination of protocol ID and socket type.

Referenced by udd_register_device().

Function Documentation

◆ rtdm_close_handler()

void rtdm_close_handler ( struct rtdm_fd *  fd)

Close handler.

Parameters
[in]fdFile descriptor associated with opened device instance.
See also
close() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_dev_register()

int rtdm_dev_register ( struct rtdm_device dev)


Register a RTDM device

Registers a device in the RTDM namespace.

Parameters
[in]devDevice descriptor.
Returns
0 is returned upon success. Otherwise:
  • -EINVAL is returned if the descriptor contains invalid entries. RTDM_PROFILE_INFO() must appear in the list of initializers for the driver properties.
  • -EEXIST is returned if the specified device name of protocol ID is already in use.
  • -ENOMEM is returned if a memory allocation failed in the process of registering the device.
  • -EAGAIN is returned if no registry slot is available (check/raise CONFIG_XENO_OPT_REGISTRY_NRSLOTS).
  • -ENOSYS is returned if the real-time core is disabled.
  • -ENXIO is returned if no valid minor could be assigned
Tags
secondary-only

◆ rtdm_dev_unregister()

void rtdm_dev_unregister ( struct rtdm_device dev)


Unregister a RTDM device

Removes the device from the RTDM namespace. This routine first attempts to teardown all active connections to the device prior to unregistering.

Parameters
[in]devDevice descriptor.
Tags
secondary-only

◆ rtdm_drv_set_sysclass()

int rtdm_drv_set_sysclass ( struct rtdm_driver drv,
struct class *  cls 
)


Set the kernel device class of a RTDM driver.

Set the kernel device class assigned to the RTDM driver. By default, RTDM drivers belong to Linux's "rtdm" device class, creating a device node hierarchy rooted at /dev/rtdm, and sysfs nodes under /sys/class/rtdm.

This call assigns a user-defined kernel device class to the RTDM driver, so that its devices are created into a different system hierarchy.

rtdm_drv_set_sysclass() is meaningful only before the first device which is attached to drv is registered by a call to rtdm_dev_register().

Parameters
[in]drvAddress of the RTDM driver descriptor.
[in]clsPointer to the kernel device class. NULL is allowed to clear a previous setting, switching back to the default "rtdm" device class.
Returns
0 on success, otherwise:
  • -EBUSY is returned if the kernel device class has already been set for drv, or some device(s) attached to drv are currently registered.
Tags
task-unrestricted
Attention
The kernel device class set by this call is not related to the RTDM class identification as defined by the RTDM profiles in any way. This is strictly related to the Linux kernel device hierarchy.

◆ rtdm_get_unmapped_area_handler()

unsigned long rtdm_get_unmapped_area_handler ( struct rtdm_fd *  fd,
unsigned long  len,
unsigned long  pgoff,
unsigned long  flags 
)

Allocate mapping region in address space.

When present, this optional handler should return the start address of a free region in the process's address space, large enough to cover the ongoing mmap() operation. If unspecified, the default architecture-defined handler is invoked.

Most drivers can omit this handler, except on MMU-less platforms (see second note).

Parameters
[in]fdFile descriptor
[in]lenLength of the requested region
[in]pgoffPage frame number to map to (see second note).
[in]flagsRequested mapping flags
Returns
The start address of the mapping region on success. On failure, a negative error code should be returned, with -ENOSYS meaning that the driver does not want to provide such information, in which case the ongoing mmap() operation will fail.
Note
The address hint passed to the mmap() request is deliberately ignored by RTDM, and therefore not passed to this handler.
On MMU-less platforms, this handler is required because RTDM issues mapping requests over a shareable character device internally. In such context, the RTDM core may pass a null pgoff argument to the handler, for probing for the logical start address of the memory region to map to. Otherwise, when pgoff is non-zero, pgoff << PAGE_SHIFT is usually returned.

◆ rtdm_ioctl_handler()

int rtdm_ioctl_handler ( struct rtdm_fd *  fd,
unsigned int  request,
void __user *  arg 
)

IOCTL handler.

Parameters
[in]fdFile descriptor
[in]requestRequest number as passed by the user
[in,out]argRequest argument as passed by the user
Returns
A positive value or 0 on success. On failure return either -ENOSYS, to request that the function be called again from the opposite realtime/non-realtime context, or another negative error code.
See also
ioctl() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_mmap_handler()

int rtdm_mmap_handler ( struct rtdm_fd *  fd,
struct vm_area_struct *  vma 
)

Memory mapping handler.

Parameters
[in]fdFile descriptor
[in]vmaVirtual memory area descriptor
Returns
0 on success. On failure, a negative error code is returned.
See also
mmap() in POSIX.1-2001, http://pubs.opengroup.org/onlinepubs/7908799/xsh/mmap.html
Note
The address hint passed to the mmap() request is deliberately ignored by RTDM.

◆ rtdm_open_handler()

int rtdm_open_handler ( struct rtdm_fd *  fd,
int  oflags 
)

Open handler for named devices.

Parameters
[in]fdFile descriptor associated with opened device instance
[in]oflagsOpen flags as passed by the user

The file descriptor carries a device minor information which can be retrieved by a call to rtdm_fd_minor(fd). The minor number can be used for distinguishing devices managed by a driver.

Returns
0 on success. On failure, a negative error code is returned.
See also
open() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_read_handler()

ssize_t rtdm_read_handler ( struct rtdm_fd *  fd,
void __user *  buf,
size_t  size 
)

Read handler.

Parameters
[in]fdFile descriptor
[out]bufInput buffer as passed by the user
[in]sizeNumber of bytes the user requests to read
Returns
On success, the number of bytes read. On failure return either -ENOSYS, to request that this handler be called again from the opposite realtime/non-realtime context, or another negative error code.
See also
read() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_recvmsg_handler()

ssize_t rtdm_recvmsg_handler ( struct rtdm_fd *  fd,
struct user_msghdr *  msg,
int  flags 
)

Receive message handler.

Parameters
[in]fdFile descriptor
[in,out]msgMessage descriptor as passed by the user, automatically mirrored to safe kernel memory in case of user mode call
[in]flagsMessage flags as passed by the user
Returns
On success, the number of bytes received. On failure return either -ENOSYS, to request that this handler be called again from the opposite realtime/non-realtime context, or another negative error code.
See also
recvmsg() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_select_handler()

int rtdm_select_handler ( struct rtdm_fd *  fd,
struct xnselector *  selector,
unsigned int  type,
unsigned int  index 
)

Select handler.

Parameters
[in]fdFile descriptor
selectorPointer to the selector structure
typeType of events (XNSELECT_READ, XNSELECT_WRITE, or XNSELECT_EXCEPT)
indexIndex of the file descriptor
Returns
0 on success. On failure, a negative error code is returned.
See also
select() in POSIX.1-2001, http://pubs.opengroup.org/onlinepubs/007908799/xsh/select.html

◆ rtdm_sendmsg_handler()

ssize_t rtdm_sendmsg_handler ( struct rtdm_fd *  fd,
const struct user_msghdr *  msg,
int  flags 
)

Transmit message handler.

Parameters
[in]fdFile descriptor
[in]msgMessage descriptor as passed by the user, automatically mirrored to safe kernel memory in case of user mode call
[in]flagsMessage flags as passed by the user
Returns
On success, the number of bytes transmitted. On failure return either -ENOSYS, to request that this handler be called again from the opposite realtime/non-realtime context, or another negative error code.
See also
sendmsg() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_socket_handler()

int rtdm_socket_handler ( struct rtdm_fd *  fd,
int  protocol 
)

Socket creation handler for protocol devices.

Parameters
[in]fdFile descriptor associated with opened device instance
[in]protocolProtocol number as passed by the user
Returns
0 on success. On failure, a negative error code is returned.
See also
socket() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

◆ rtdm_write_handler()

ssize_t rtdm_write_handler ( struct rtdm_fd *  fd,
const void __user *  buf,
size_t  size 
)

Write handler.

Parameters
[in]fdFile descriptor
[in]bufOutput buffer as passed by the user
[in]sizeNumber of bytes the user requests to write
Returns
On success, the number of bytes written. On failure return either -ENOSYS, to request that this handler be called again from the opposite realtime/non-realtime context, or another negative error code.
See also
write() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399