Xenomai API  2.6.5
rtdm_driver.h
Go to the documentation of this file.
1 
26 #ifndef _RTDM_DRIVER_H
27 #define _RTDM_DRIVER_H
28 
29 #ifndef __KERNEL__
30 #error This header is for kernel space usage only. \
31  You are likely looking for rtdm/rtdm.h...
32 #endif /* !__KERNEL__ */
33 
34 #include <asm/atomic.h>
35 #include <linux/list.h>
36 
37 #include <nucleus/xenomai.h>
38 #include <nucleus/heap.h>
39 #include <nucleus/pod.h>
40 #include <nucleus/synch.h>
41 #include <nucleus/select.h>
42 #include <nucleus/vfile.h>
43 #include <rtdm/rtdm.h>
44 
45 /* debug support */
46 #include <nucleus/assert.h>
47 #ifdef CONFIG_PCI
48 #include <asm-generic/xenomai/pci_ids.h>
49 #endif /* CONFIG_PCI */
50 
51 #ifndef CONFIG_XENO_OPT_DEBUG_RTDM
52 #define CONFIG_XENO_OPT_DEBUG_RTDM 0
53 #endif
54 
55 struct rtdm_dev_context;
56 typedef struct xnselector rtdm_selector_t;
57 enum rtdm_selecttype;
58 
71 #define RTDM_EXCLUSIVE 0x0001
72 
74 #define RTDM_NAMED_DEVICE 0x0010
75 
78 #define RTDM_PROTOCOL_DEVICE 0x0020
79 
81 #define RTDM_DEVICE_TYPE_MASK 0x00F0
82 
91 #define RTDM_CREATED_IN_NRT 0
92 
94 #define RTDM_CLOSING 1
95 
97 #define RTDM_USER_CONTEXT_FLAG 8 /* first user-definable flag */
98 
107 #define RTDM_DEVICE_STRUCT_VER 5
108 
110 #define RTDM_CONTEXT_STRUCT_VER 3
111 
113 #define RTDM_SECURE_DEVICE 0x80000000
114 
116 #define RTDM_DRIVER_VER(major, minor, patch) \
117  (((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF))
118 
120 #define RTDM_DRIVER_MAJOR_VER(ver) (((ver) >> 16) & 0xFF)
121 
123 #define RTDM_DRIVER_MINOR_VER(ver) (((ver) >> 8) & 0xFF)
124 
126 #define RTDM_DRIVER_PATCH_VER(ver) ((ver) & 0xFF)
127 
141  RTDM_SELECTTYPE_READ = XNSELECT_READ,
142 
144  RTDM_SELECTTYPE_WRITE = XNSELECT_WRITE,
145 
147  RTDM_SELECTTYPE_EXCEPT = XNSELECT_EXCEPT
148 };
172 typedef int (*rtdm_open_handler_t)(struct rtdm_dev_context *context,
173  rtdm_user_info_t *user_info, int oflag);
174 
189 typedef int (*rtdm_socket_handler_t)(struct rtdm_dev_context *context,
190  rtdm_user_info_t *user_info, int protocol);
191 
212 typedef int (*rtdm_close_handler_t)(struct rtdm_dev_context *context,
213  rtdm_user_info_t *user_info);
214 
230 typedef int (*rtdm_ioctl_handler_t)(struct rtdm_dev_context *context,
231  rtdm_user_info_t *user_info,
232  unsigned int request, void __user *arg);
233 
247 typedef int (*rtdm_select_bind_handler_t)(struct rtdm_dev_context *context,
248  rtdm_selector_t *selector,
249  enum rtdm_selecttype type,
250  unsigned fd_index);
251 
267 typedef ssize_t (*rtdm_read_handler_t)(struct rtdm_dev_context *context,
268  rtdm_user_info_t *user_info,
269  void *buf, size_t nbyte);
270 
286 typedef ssize_t (*rtdm_write_handler_t)(struct rtdm_dev_context *context,
287  rtdm_user_info_t *user_info,
288  const void *buf, size_t nbyte);
289 
306 typedef ssize_t (*rtdm_recvmsg_handler_t)(struct rtdm_dev_context *context,
307  rtdm_user_info_t *user_info,
308  struct user_msghdr *msg, int flags);
309 
326 typedef ssize_t (*rtdm_sendmsg_handler_t)(struct rtdm_dev_context *context,
327  rtdm_user_info_t *user_info,
328  const struct user_msghdr *msg, int flags);
331 typedef int (*rtdm_rt_handler_t)(struct rtdm_dev_context *context,
332  rtdm_user_info_t *user_info, void *arg);
344 
349 
360 
373 
379 };
380 
381 struct rtdm_devctx_reserved {
382  void *owner;
383  struct list_head cleanup;
384 };
385 
399  unsigned long context_flags;
400 
402  int fd;
403 
407 
410 
413 
415  struct rtdm_devctx_reserved reserved;
416 
418  char dev_private[0];
419 };
420 
429 static inline void *
431 {
432  return (void *)context->dev_private;
433 }
434 
443 static inline struct rtdm_dev_context *
445 {
446  return container_of(dev_private, struct rtdm_dev_context, dev_private);
447 }
448 
449 struct rtdm_dev_reserved {
450  struct list_head entry;
451  atomic_t refcount;
452  struct rtdm_dev_context *exclusive_context;
453 };
454 
462 struct rtdm_device {
466 
470  size_t context_size;
471 
473  char device_name[RTDM_MAX_DEVNAME_LEN + 1];
474 
479 
488 
498 
501 
510  const char *driver_name;
515  const char *peripheral_name;
517  const char *provider_name;
518 
520  const char *proc_name;
521 #ifdef CONFIG_XENO_OPT_VFILE
522 
523  struct xnvfile_directory vfroot;
524  struct xnvfile_regular info_vfile;
525 #endif
526 
530  void *device_data;
531 
533  struct rtdm_dev_reserved reserved;
534 };
537 /* --- device registration --- */
538 
539 int rtdm_dev_register(struct rtdm_device *device);
540 int rtdm_dev_unregister(struct rtdm_device *device, unsigned int poll_delay);
541 
542 /* --- inter-driver API --- */
543 
544 #define rtdm_open rt_dev_open
545 #define rtdm_socket rt_dev_socket
546 #define rtdm_close rt_dev_close
547 #define rtdm_ioctl rt_dev_ioctl
548 #define rtdm_read rt_dev_read
549 #define rtdm_write rt_dev_write
550 #define rtdm_recvmsg rt_dev_recvmsg
551 #define rtdm_recv rt_dev_recv
552 #define rtdm_recvfrom rt_dev_recvfrom
553 #define rtdm_sendmsg rt_dev_sendmsg
554 #define rtdm_send rt_dev_send
555 #define rtdm_sendto rt_dev_sendto
556 #define rtdm_bind rt_dev_bind
557 #define rtdm_listen rt_dev_listen
558 #define rtdm_accept rt_dev_accept
559 #define rtdm_getsockopt rt_dev_getsockopt
560 #define rtdm_setsockopt rt_dev_setsockopt
561 #define rtdm_getsockname rt_dev_getsockname
562 #define rtdm_getpeername rt_dev_getpeername
563 #define rtdm_shutdown rt_dev_shutdown
564 
566 
567 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
568 
569 #define CONTEXT_IS_LOCKED(context) \
570  (atomic_read(&(context)->close_lock_count) > 1 || \
571  (test_bit(RTDM_CLOSING, &(context)->context_flags) && \
572  atomic_read(&(context)->close_lock_count) > 0))
573 
574 static inline void rtdm_context_lock(struct rtdm_dev_context *context)
575 {
576  XENO_ASSERT(RTDM, CONTEXT_IS_LOCKED(context),
577  /* just warn if context was a dangling pointer */);
578  atomic_inc(&context->close_lock_count);
579 }
580 
581 extern int rtdm_apc;
582 
583 static inline void rtdm_context_unlock(struct rtdm_dev_context *context)
584 {
585  XENO_ASSERT(RTDM, CONTEXT_IS_LOCKED(context),
586  /* just warn if context was a dangling pointer */);
587  smp_mb__before_atomic();
588  if (unlikely(atomic_dec_and_test(&context->close_lock_count)))
589  rthal_apc_schedule(rtdm_apc);
590 }
591 
592 static inline void rtdm_context_put(struct rtdm_dev_context *context)
593 {
594  rtdm_context_unlock(context);
595 }
596 
597 /* --- clock services --- */
598 struct xntbase;
599 extern struct xntbase *rtdm_tbase;
600 
601 static inline nanosecs_abs_t rtdm_clock_read(void)
602 {
603  return xntbase_ticks2ns(rtdm_tbase, xntbase_get_time(rtdm_tbase));
604 }
605 
606 static inline nanosecs_abs_t rtdm_clock_read_monotonic(void)
607 {
608  return xntbase_ticks2ns(rtdm_tbase, xntbase_get_jiffies(rtdm_tbase));
609 }
610 #endif /* !DOXYGEN_CPP */
611 
617 int rtdm_select_bind(int fd, rtdm_selector_t *selector,
618  enum rtdm_selecttype type, unsigned fd_index);
619 
620 /* --- spin lock services --- */
658 #ifdef DOXYGEN_CPP /* Beautify doxygen output */
659 #define RTDM_EXECUTE_ATOMICALLY(code_block) \
660 { \
661  <ENTER_ATOMIC_SECTION> \
662  code_block; \
663  <LEAVE_ATOMIC_SECTION> \
664 }
665 #else /* This is how it really works */
666 #define RTDM_EXECUTE_ATOMICALLY(code_block) \
667 { \
668  spl_t __rtdm_s; \
669  \
670  xnlock_get_irqsave(&nklock, __rtdm_s); \
671  __xnpod_lock_sched(); \
672  code_block; \
673  __xnpod_unlock_sched(); \
674  xnlock_put_irqrestore(&nklock, __rtdm_s); \
675 }
676 #endif
677 
687 #define RTDM_LOCK_UNLOCKED RTHAL_SPIN_LOCK_UNLOCKED
688 
690 typedef rthal_spinlock_t rtdm_lock_t;
691 
693 typedef unsigned long rtdm_lockctx_t;
694 
710 #define rtdm_lock_init(lock) rthal_spin_lock_init(lock)
711 
728 #ifdef DOXYGEN_CPP /* Beautify doxygen output */
729 #define rtdm_lock_get(lock) rthal_spin_lock(lock)
730 #else /* This is how it really works */
731 #define rtdm_lock_get(lock) \
732  do { \
733  XENO_BUGON(RTDM, !rthal_local_irq_disabled()); \
734  rthal_spin_lock(lock); \
735  __xnpod_lock_sched(); \
736  } while (0)
737 #endif
738 
755 #define rtdm_lock_put(lock) \
756  do { \
757  rthal_spin_unlock(lock); \
758  __xnpod_unlock_sched(); \
759  } while (0)
760 
778 #define rtdm_lock_get_irqsave(lock, context) \
779  do { \
780  rthal_spin_lock_irqsave(lock, context); \
781  __xnpod_lock_sched(); \
782  } while (0)
783 
801 #define rtdm_lock_put_irqrestore(lock, context) \
802  do { \
803  rthal_spin_unlock(lock); \
804  __xnpod_unlock_sched(); \
805  rthal_local_irq_restore(context); \
806  } while (0)
807 
824 #define rtdm_lock_irqsave(context) \
825  rthal_local_irq_save(context)
826 
843 #define rtdm_lock_irqrestore(context) \
844  rthal_local_irq_restore(context)
845 
849 /* --- Interrupt management services --- */
855 typedef xnintr_t rtdm_irq_t;
856 
863 #define RTDM_IRQTYPE_SHARED XN_ISR_SHARED
864 
866 #define RTDM_IRQTYPE_EDGE XN_ISR_EDGE
867 
876 typedef int (*rtdm_irq_handler_t)(rtdm_irq_t *irq_handle);
877 
884 #define RTDM_IRQ_NONE XN_ISR_NONE
885 
886 #define RTDM_IRQ_HANDLED XN_ISR_HANDLED
887 
906 #define rtdm_irq_get_arg(irq_handle, type) ((type *)irq_handle->cookie)
907 
909 int rtdm_irq_request(rtdm_irq_t *irq_handle, unsigned int irq_no,
910  rtdm_irq_handler_t handler, unsigned long flags,
911  const char *device_name, void *arg);
912 
913 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
914 static inline int rtdm_irq_free(rtdm_irq_t *irq_handle)
915 {
916  XENO_ASSERT(RTDM, xnpod_root_p(), return -EPERM;);
917  return xnintr_detach(irq_handle);
918 }
919 
920 static inline int rtdm_irq_enable(rtdm_irq_t *irq_handle)
921 {
922  return xnintr_enable(irq_handle);
923 }
924 
925 static inline int rtdm_irq_disable(rtdm_irq_t *irq_handle)
926 {
927  return xnintr_disable(irq_handle);
928 }
929 #endif /* !DOXYGEN_CPP */
930 
931 /* --- non-real-time signalling services --- */
932 
938 typedef unsigned rtdm_nrtsig_t;
939 
950 typedef void (*rtdm_nrtsig_handler_t)(rtdm_nrtsig_t nrt_sig, void *arg);
953 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
954 static inline int rtdm_nrtsig_init(rtdm_nrtsig_t *nrt_sig,
955  rtdm_nrtsig_handler_t handler, void *arg)
956 {
957  *nrt_sig = rthal_alloc_virq();
958 
959  if (*nrt_sig == 0)
960  return -EAGAIN;
961 
962  rthal_virtualize_irq(rthal_root_domain, *nrt_sig, handler, arg, NULL,
963  IPIPE_HANDLE_MASK);
964  return 0;
965 }
966 
967 static inline void rtdm_nrtsig_destroy(rtdm_nrtsig_t *nrt_sig)
968 {
969  rthal_virtualize_irq(rthal_root_domain, *nrt_sig, NULL, NULL, NULL, 0);
970 
971  rthal_free_virq(*nrt_sig);
972 }
973 
974 static inline void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig)
975 {
976  rthal_trigger_irq(*nrt_sig);
977 }
978 #endif /* !DOXYGEN_CPP */
979 
980 /* --- timer services --- */
981 
987 typedef xntimer_t rtdm_timer_t;
988 
994 typedef void (*rtdm_timer_handler_t)(rtdm_timer_t *timer);
995 
1004 
1007 
1010 };
1015 #ifndef DOXYGEN_CPP /* Avoid broken doxygen output */
1016 #define rtdm_timer_init(timer, handler, name) \
1017 ({ \
1018  xntimer_init((timer), rtdm_tbase, handler); \
1019  xntimer_set_name((timer), (name)); \
1020  0; \
1021 })
1022 #endif /* !DOXYGEN_CPP */
1023 
1024 void rtdm_timer_destroy(rtdm_timer_t *timer);
1025 
1026 int rtdm_timer_start(rtdm_timer_t *timer, nanosecs_abs_t expiry,
1027  nanosecs_rel_t interval, enum rtdm_timer_mode mode);
1028 
1029 void rtdm_timer_stop(rtdm_timer_t *timer);
1030 
1031 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1032 static inline int rtdm_timer_start_in_handler(rtdm_timer_t *timer,
1033  nanosecs_abs_t expiry,
1034  nanosecs_rel_t interval,
1035  enum rtdm_timer_mode mode)
1036 {
1037  return xntimer_start(timer, xntbase_ns2ticks_ceil(rtdm_tbase, expiry),
1038  xntbase_ns2ticks_ceil(rtdm_tbase, interval),
1039  (xntmode_t)mode);
1040 }
1041 
1042 static inline void rtdm_timer_stop_in_handler(rtdm_timer_t *timer)
1043 {
1044  xntimer_stop(timer);
1045 }
1046 #endif /* !DOXYGEN_CPP */
1047 
1048 /* --- task services --- */
1054 typedef xnthread_t rtdm_task_t;
1055 
1061 typedef void (*rtdm_task_proc_t)(void *arg);
1062 
1067 #define RTDM_TASK_LOWEST_PRIORITY XNSCHED_LOW_PRIO
1068 #define RTDM_TASK_HIGHEST_PRIORITY XNSCHED_HIGH_PRIO
1069 
1075 #define RTDM_TASK_RAISE_PRIORITY (+1)
1076 #define RTDM_TASK_LOWER_PRIORITY (-1)
1077 
1081 int rtdm_task_init(rtdm_task_t *task, const char *name,
1082  rtdm_task_proc_t task_proc, void *arg,
1083  int priority, nanosecs_rel_t period);
1084 int __rtdm_task_sleep(xnticks_t timeout, xntmode_t mode);
1086 
1087 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1088 static inline void rtdm_task_destroy(rtdm_task_t *task)
1089 {
1090  xnpod_delete_thread(task);
1091 }
1092 
1093 void rtdm_task_join_nrt(rtdm_task_t *task, unsigned int poll_delay);
1094 
1095 static inline void rtdm_task_set_priority(rtdm_task_t *task, int priority)
1096 {
1097  union xnsched_policy_param param = { .rt = { .prio = priority } };
1098  xnpod_set_thread_schedparam(task, &xnsched_class_rt, &param);
1099  xnpod_schedule();
1100 }
1101 
1102 static inline int rtdm_task_set_period(rtdm_task_t *task,
1103  nanosecs_rel_t period)
1104 {
1105  if (period < 0)
1106  period = 0;
1107  return xnpod_set_thread_periodic(task, XN_INFINITE,
1108  xntbase_ns2ticks_ceil
1109  (xnthread_time_base(task), period));
1110 }
1111 
1112 static inline int rtdm_task_unblock(rtdm_task_t *task)
1113 {
1114  int res = xnpod_unblock_thread(task);
1115 
1116  xnpod_schedule();
1117  return res;
1118 }
1119 
1120 static inline rtdm_task_t *rtdm_task_current(void)
1121 {
1122  return xnpod_current_thread();
1123 }
1124 
1125 static inline int rtdm_task_wait_period(void)
1126 {
1127  XENO_ASSERT(RTDM, !xnpod_unblockable_p(), return -EPERM;);
1128  return xnpod_wait_thread_period(NULL);
1129 }
1130 
1131 static inline int rtdm_task_sleep(nanosecs_rel_t delay)
1132 {
1133  return __rtdm_task_sleep(delay, XN_RELATIVE);
1134 }
1135 
1136 static inline int
1137 rtdm_task_sleep_abs(nanosecs_abs_t wakeup_date, enum rtdm_timer_mode mode)
1138 {
1139  /* For the sake of a consistent API usage... */
1140  if (mode != RTDM_TIMERMODE_ABSOLUTE && mode != RTDM_TIMERMODE_REALTIME)
1141  return -EINVAL;
1142  return __rtdm_task_sleep(wakeup_date, (xntmode_t)mode);
1143 }
1144 
1145 /* rtdm_task_sleep_abs shall be used instead */
1146 static inline int __deprecated rtdm_task_sleep_until(nanosecs_abs_t wakeup_time)
1147 {
1148  return __rtdm_task_sleep(wakeup_time, XN_REALTIME);
1149 }
1150 #endif /* !DOXYGEN_CPP */
1151 
1152 /* --- timeout sequences */
1153 
1154 typedef nanosecs_abs_t rtdm_toseq_t;
1155 
1156 void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, nanosecs_rel_t timeout);
1157 
1158 /* --- event services --- */
1159 
1160 typedef struct {
1161  xnsynch_t synch_base;
1162  DECLARE_XNSELECT(select_block);
1163 } rtdm_event_t;
1164 
1165 #define RTDM_EVENT_PENDING XNSYNCH_SPARE1
1166 
1167 void rtdm_event_init(rtdm_event_t *event, unsigned long pending);
1168 #ifdef CONFIG_XENO_OPT_RTDM_SELECT
1169 int rtdm_event_select_bind(rtdm_event_t *event, rtdm_selector_t *selector,
1170  enum rtdm_selecttype type, unsigned fd_index);
1171 #else /* !CONFIG_XENO_OPT_RTDM_SELECT */
1172 #define rtdm_event_select_bind(e, s, t, i) ({ (void)(e); -EBADF; })
1173 #endif /* !CONFIG_XENO_OPT_RTDM_SELECT */
1174 int rtdm_event_wait(rtdm_event_t *event);
1175 int rtdm_event_timedwait(rtdm_event_t *event, nanosecs_rel_t timeout,
1176  rtdm_toseq_t *timeout_seq);
1177 void rtdm_event_signal(rtdm_event_t *event);
1178 
1179 void rtdm_event_clear(rtdm_event_t *event);
1180 
1181 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1182 void __rtdm_synch_flush(xnsynch_t *synch, unsigned long reason);
1183 
1184 static inline void rtdm_event_pulse(rtdm_event_t *event)
1185 {
1186  trace_mark(xn_rtdm, event_pulse, "event %p", event);
1187  __rtdm_synch_flush(&event->synch_base, 0);
1188 }
1189 
1190 static inline void rtdm_event_destroy(rtdm_event_t *event)
1191 {
1192  trace_mark(xn_rtdm, event_destroy, "event %p", event);
1193  __rtdm_synch_flush(&event->synch_base, XNRMID);
1194  xnselect_destroy(&event->select_block);
1195 }
1196 #endif /* !DOXYGEN_CPP */
1197 
1198 /* --- semaphore services --- */
1199 
1200 typedef struct {
1201  unsigned long value;
1202  xnsynch_t synch_base;
1203  DECLARE_XNSELECT(select_block);
1204 } rtdm_sem_t;
1205 
1206 void rtdm_sem_init(rtdm_sem_t *sem, unsigned long value);
1207 #ifdef CONFIG_XENO_OPT_RTDM_SELECT
1208 int rtdm_sem_select_bind(rtdm_sem_t *sem, rtdm_selector_t *selector,
1209  enum rtdm_selecttype type, unsigned fd_index);
1210 #else /* !CONFIG_XENO_OPT_RTDM_SELECT */
1211 #define rtdm_sem_select_bind(s, se, t, i) ({ (void)(s); -EBADF; })
1212 #endif /* !CONFIG_XENO_OPT_RTDM_SELECT */
1213 int rtdm_sem_down(rtdm_sem_t *sem);
1214 int rtdm_sem_timeddown(rtdm_sem_t *sem, nanosecs_rel_t timeout,
1215  rtdm_toseq_t *timeout_seq);
1216 void rtdm_sem_up(rtdm_sem_t *sem);
1217 
1218 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1219 static inline void rtdm_sem_destroy(rtdm_sem_t *sem)
1220 {
1221  trace_mark(xn_rtdm, sem_destroy, "sem %p", sem);
1222  __rtdm_synch_flush(&sem->synch_base, XNRMID);
1223  xnselect_destroy(&sem->select_block);
1224 }
1225 #endif /* !DOXYGEN_CPP */
1226 
1227 /* --- mutex services --- */
1228 
1229 typedef struct {
1230  xnsynch_t synch_base;
1231 } rtdm_mutex_t;
1232 
1233 void rtdm_mutex_init(rtdm_mutex_t *mutex);
1234 int rtdm_mutex_lock(rtdm_mutex_t *mutex);
1235 int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, nanosecs_rel_t timeout,
1236  rtdm_toseq_t *timeout_seq);
1237 
1238 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1239 static inline void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
1240 {
1241  XENO_ASSERT(RTDM, !xnpod_asynch_p(), return;);
1242 
1243  trace_mark(xn_rtdm, mutex_unlock, "mutex %p", mutex);
1244 
1245  if (unlikely(xnsynch_release(&mutex->synch_base) != NULL))
1246  xnpod_schedule();
1247 }
1248 
1249 static inline void rtdm_mutex_destroy(rtdm_mutex_t *mutex)
1250 {
1251  trace_mark(xn_rtdm, mutex_destroy, "mutex %p", mutex);
1252 
1253  __rtdm_synch_flush(&mutex->synch_base, XNRMID);
1254 }
1255 #endif /* !DOXYGEN_CPP */
1256 
1257 /* --- utility functions --- */
1258 
1259 #define rtdm_printk(format, ...) printk(format, ##__VA_ARGS__)
1260 
1261 struct rtdm_ratelimit_state {
1262  rtdm_lock_t lock; /* protect the state */
1263  nanosecs_abs_t interval;
1264  int burst;
1265  int printed;
1266  int missed;
1267  nanosecs_abs_t begin;
1268 };
1269 
1270 int rtdm_ratelimit(struct rtdm_ratelimit_state *rs, const char *func);
1271 
1272 #define DEFINE_RTDM_RATELIMIT_STATE(name, interval_init, burst_init) \
1273  struct rtdm_ratelimit_state name = { \
1274  .lock = RTDM_LOCK_UNLOCKED, \
1275  .interval = interval_init, \
1276  .burst = burst_init, \
1277  }
1278 
1279 /* We use the Linux defaults */
1280 #define DEF_RTDM_RATELIMIT_INTERVAL 5000000000LL
1281 #define DEF_RTDM_RATELIMIT_BURST 10
1282 
1283 #define rtdm_printk_ratelimited(fmt, ...) ({ \
1284  static DEFINE_RTDM_RATELIMIT_STATE(_rs, \
1285  DEF_RTDM_RATELIMIT_INTERVAL, \
1286  DEF_RTDM_RATELIMIT_BURST); \
1287  \
1288  if (rtdm_ratelimit(&_rs, __func__)) \
1289  printk(fmt, ##__VA_ARGS__); \
1290 })
1291 
1292 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
1293 static inline void *rtdm_malloc(size_t size)
1294 {
1295  return xnmalloc(size);
1296 }
1297 
1298 static inline void rtdm_free(void *ptr)
1299 {
1300  xnfree(ptr);
1301 }
1302 
1303 #ifdef CONFIG_XENO_OPT_PERVASIVE
1304 int rtdm_mmap_to_user(rtdm_user_info_t *user_info,
1305  void *src_addr, size_t len,
1306  int prot, void **pptr,
1307  struct vm_operations_struct *vm_ops,
1308  void *vm_private_data);
1309 int rtdm_iomap_to_user(rtdm_user_info_t *user_info,
1310  phys_addr_t src_addr, size_t len,
1311  int prot, void **pptr,
1312  struct vm_operations_struct *vm_ops,
1313  void *vm_private_data);
1314 int rtdm_munmap(rtdm_user_info_t *user_info, void *ptr, size_t len);
1315 
1316 static inline int rtdm_read_user_ok(rtdm_user_info_t *user_info,
1317  const void __user *ptr, size_t size)
1318 {
1319  return access_rok(ptr, size);
1320 }
1321 
1322 static inline int rtdm_rw_user_ok(rtdm_user_info_t *user_info,
1323  const void __user *ptr, size_t size)
1324 {
1325  return access_wok(ptr, size);
1326 }
1327 
1328 static inline int rtdm_copy_from_user(rtdm_user_info_t *user_info,
1329  void *dst, const void __user *src,
1330  size_t size)
1331 {
1332  return __xn_copy_from_user(dst, src, size) ? -EFAULT : 0;
1333 }
1334 
1335 static inline int rtdm_safe_copy_from_user(rtdm_user_info_t *user_info,
1336  void *dst, const void __user *src,
1337  size_t size)
1338 {
1339  return (!access_rok(src, size) ||
1340  __xn_copy_from_user(dst, src, size)) ? -EFAULT : 0;
1341 }
1342 
1343 static inline int rtdm_copy_to_user(rtdm_user_info_t *user_info,
1344  void __user *dst, const void *src,
1345  size_t size)
1346 {
1347  return __xn_copy_to_user(dst, src, size) ? -EFAULT : 0;
1348 }
1349 
1350 static inline int rtdm_safe_copy_to_user(rtdm_user_info_t *user_info,
1351  void __user *dst, const void *src,
1352  size_t size)
1353 {
1354  return (!access_wok(dst, size) ||
1355  __xn_copy_to_user(dst, src, size)) ? -EFAULT : 0;
1356 }
1357 
1358 static inline int rtdm_strncpy_from_user(rtdm_user_info_t *user_info,
1359  char *dst,
1360  const char __user *src, size_t count)
1361 {
1362  if (unlikely(!access_rok(src, 1)))
1363  return -EFAULT;
1364  return __xn_strncpy_from_user(dst, src, count);
1365 }
1366 
1367 static inline int rtdm_rt_capable(rtdm_user_info_t *user_info)
1368 {
1369  XENO_ASSERT(RTDM, !xnpod_asynch_p(), return 0;);
1370 
1371  return (user_info ? xnshadow_thread(user_info) != NULL
1372  : !xnpod_root_p());
1373 }
1374 
1375 #else /* !CONFIG_XENO_OPT_PERVASIVE */
1376 /* Define void user<->kernel services that simply fail */
1377 #define rtdm_mmap_to_user(...) ({ -ENOSYS; })
1378 #define rtdm_munmap(...) ({ -ENOSYS; })
1379 #define rtdm_read_user_ok(...) ({ 0; })
1380 #define rtdm_rw_user_ok(...) ({ 0; })
1381 #define rtdm_copy_from_user(...) ({ -ENOSYS; })
1382 #define rtdm_safe_copy_from_user(...) ({ -ENOSYS; })
1383 #define rtdm_copy_to_user(...) ({ -ENOSYS; })
1384 #define rtdm_safe_copy_to_user(...) ({ -ENOSYS; })
1385 #define rtdm_strncpy_from_user(...) ({ -ENOSYS; })
1386 
1387 static inline int rtdm_rt_capable(rtdm_user_info_t *user_info)
1388 {
1389  XENO_ASSERT(RTDM, !xnpod_asynch_p(), return 0;);
1390 
1391  return !xnpod_root_p();
1392 }
1393 
1394 #endif /* CONFIG_XENO_OPT_PERVASIVE */
1395 
1396 static inline int rtdm_in_rt_context(void)
1397 {
1398  return (rthal_current_domain != rthal_root_domain);
1399 }
1400 
1401 #endif /* !DOXYGEN_CPP */
1402 
1403 int rtdm_exec_in_rt(struct rtdm_dev_context *context,
1404  rtdm_user_info_t *user_info, void *arg,
1405  rtdm_rt_handler_t handler);
1406 
1407 #endif /* _RTDM_DRIVER_H */
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.
Definition: core.c:623
This file is part of the Xenomai project.
void rtdm_context_unlock(struct rtdm_dev_context *context)
Decrement context reference counter.
size_t context_size
Size of driver defined appendix to struct rtdm_dev_context.
Definition: rtdm_driver.h:470
int rtdm_task_sleep_abs(nanosecs_abs_t wakeup_time, enum rtdm_timer_mode mode)
Sleep until a specified absolute time.
Select ouput buffer availability events.
Definition: rtdm_driver.h:144
int rtdm_dev_register(struct rtdm_device *device)
Register a RTDM device.
Definition: device.c:195
Device operations.
Definition: rtdm_driver.h:336
ssize_t(* rtdm_read_handler_t)(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, void *buf, size_t nbyte)
Read handler.
Definition: rtdm_driver.h:267
int xnpod_wait_thread_period(unsigned long *overruns_r)
Wait for the next periodic release point.
Definition: pod.c:2951
int rtdm_safe_copy_from_user(rtdm_user_info_t *user_info, void *dst, const void __user *src, size_t size)
Check if read access to user-space memory block and copy it to specified buffer.
int rtdm_task_set_period(rtdm_task_t *task, nanosecs_rel_t period)
Adjust real-time task period.
Adjustable timer with absolute timeout.
Definition: rtdm_driver.h:1009
Monotonic timer with absolute timeout.
Definition: rtdm_driver.h:1006
int rtdm_mmap_to_user(rtdm_user_info_t *user_info, void *src_addr, size_t len, int prot, void **pptr, struct vm_operations_struct *vm_ops, void *vm_private_data)
Map a kernel memory range into the address space of the user.
Definition: drvlib.c:1991
int rtdm_task_unblock(rtdm_task_t *task)
Activate a blocked real-time task.
int rtdm_task_sleep(nanosecs_rel_t delay)
Sleep a specified amount of time.
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:95
int xnpod_set_thread_periodic(xnthread_t *thread, xnticks_t idate, xnticks_t period)
Make a thread periodic.
Definition: pod.c:2850
int rtdm_safe_copy_to_user(rtdm_user_info_t *user_info, void __user *dst, const void *src, size_t size)
Check if read/write access to user-space memory block is safe and copy specified buffer to it...
char dev_private[0]
Begin of driver defined context data structure.
Definition: rtdm_driver.h:418
file descriptors events multiplexing header.
void rtdm_sem_init(rtdm_sem_t *sem, unsigned long value)
Initialise a semaphore.
Definition: drvlib.c:1120
void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, nanosecs_rel_t timeout)
Initialise a timeout sequence.
Definition: drvlib.c:735
rtdm_read_handler_t read_nrt
Read handler for non-real-time context (optional)
Definition: rtdm_driver.h:359
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.
Definition: drvlib.c:139
rtdm_select_bind_handler_t select_bind
Select binding handler for any context (optional)
Definition: rtdm_driver.h:351
int(* rtdm_ioctl_handler_t)(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void __user *arg)
IOCTL handler.
Definition: rtdm_driver.h:230
void rtdm_timer_destroy(rtdm_timer_t *timer)
Destroy a timer.
Definition: drvlib.c:527
int profile_version
Supported device profile version.
Definition: rtdm_driver.h:508
int rtdm_mutex_lock(rtdm_mutex_t *mutex)
Request a mutex.
Definition: drvlib.c:1482
int xnintr_enable(xnintr_t *intr)
Enable an interrupt object.
Definition: intr.c:833
void * device_data
Driver definable device data.
Definition: rtdm_driver.h:530
rtdm_sendmsg_handler_t sendmsg_rt
Transmit message handler for real-time context (optional)
Definition: rtdm_driver.h:375
int xnpod_unblock_thread(xnthread_t *thread)
Unblock a thread.
Definition: pod.c:1713
void rtdm_event_clear(rtdm_event_t *event)
Clear event state.
Definition: drvlib.c:1024
int rtdm_dev_unregister(struct rtdm_device *device, unsigned int poll_delay)
Unregisters a RTDM device.
Definition: device.c:397
void rtdm_nrtsig_pend(rtdm_nrtsig_t *nrt_sig)
Trigger non-real-time signal.
void rtdm_free(void *ptr)
Release real-time memory block.
int rtdm_sem_timeddown(rtdm_sem_t *sem, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
Decrement a semaphore with timeout.
Definition: drvlib.c:1229
rthal_spinlock_t rtdm_lock_t
Lock variable.
Definition: rtdm_driver.h:690
rtdm_write_handler_t write_rt
Write handler for real-time context (optional)
Definition: rtdm_driver.h:362
static xnticks_t xntbase_get_time(xntbase_t *base)
Get the clock time for a given time base.
Definition: timebase.h:301
rtdm_recvmsg_handler_t recvmsg_nrt
Receive message handler for non-real-time context (optional)
Definition: rtdm_driver.h:372
Select input data availability events.
Definition: rtdm_driver.h:141
int fd
Associated file descriptor.
Definition: rtdm_driver.h:402
int rtdm_irq_enable(rtdm_irq_t *irq_handle)
Enable interrupt line.
rtdm_ioctl_handler_t ioctl_rt
IOCTL from real-time context (optional)
Definition: rtdm_driver.h:346
rtdm_close_handler_t close_rt
Close handler for real-time contexts (optional, deprecated)
Definition: rtdm_driver.h:341
rtdm_socket_handler_t socket_rt
Protocol socket creation for real-time contexts, optional (but deprecated) if socket_nrt is non-NULL...
Definition: rtdm_driver.h:494
void rtdm_task_set_priority(rtdm_task_t *task, int priority)
Adjust real-time task priority.
void(* rtdm_timer_handler_t)(rtdm_timer_t *timer)
Timer handler.
Definition: rtdm_driver.h:994
struct rtdm_operations ops
Default operations on newly opened device instance.
Definition: rtdm_driver.h:500
void xnselect_destroy(struct xnselect *select_block)
Destroy the xnselect structure associated with a file descriptor.
Definition: select.c:179
int rtdm_nrtsig_init(rtdm_nrtsig_t *nrt_sig, rtdm_nrtsig_handler_t handler, void *arg)
Register a non-real-time signal handler.
void rtdm_nrtsig_destroy(rtdm_nrtsig_t *nrt_sig)
Release a non-realtime signal handler.
const char * peripheral_name
Informational peripheral name the device is attached to (reported via /proc)
Definition: rtdm_driver.h:515
struct rtdm_dev_context * rtdm_context_get(int fd)
Retrieve and lock a device context.
Definition: core.c:77
void rtdm_event_signal(rtdm_event_t *event)
Signal an event occurrence.
Definition: drvlib.c:850
int rtdm_strncpy_from_user(rtdm_user_info_t *user_info, char *dst, const char __user *src, size_t count)
Copy user-space string to specified buffer.
int rtdm_in_rt_context(void)
Test if running in a real-time task.
int xnpod_set_thread_schedparam(struct xnthread *thread, struct xnsched_class *sched_class, const union xnsched_policy_param *sched_param)
Change the base scheduling parameters of a thread.
Definition: pod.c:1817
int rtdm_munmap(rtdm_user_info_t *user_info, void *ptr, size_t len)
Unmap a user memory range.
Definition: drvlib.c:2101
void rtdm_timer_stop(rtdm_timer_t *timer)
Stop a timer.
Definition: drvlib.c:598
rtdm_open_handler_t open_nrt
Named device instance creation for non-real-time contexts, optional if open_rt is non-NULL...
Definition: rtdm_driver.h:487
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.
Definition: drvlib.c:1353
int rtdm_copy_to_user(rtdm_user_info_t *user_info, void __user *dst, const void *src, size_t size)
Copy specified buffer to user-space memory block.
rtdm_close_handler_t close_nrt
Close handler for non-real-time contexts (required)
Definition: rtdm_driver.h:343
Select exceptional events.
Definition: rtdm_driver.h:147
int device_flags
Device flags, see Device Flags for details.
Definition: rtdm_driver.h:468
static struct rtdm_dev_context * rtdm_private_to_context(void *dev_private)
Locate a device context structure from its driver private area.
Definition: rtdm_driver.h:444
uint64_t nanosecs_abs_t
RTDM type for representing absolute dates.
Definition: rtdm.h:89
struct xnthread * xnsynch_release(struct xnsynch *synch)
Give the resource ownership to the next waiting thread.
Definition: synch.c:775
void rtdm_event_init(rtdm_event_t *event, unsigned long pending)
Initialise an event.
Definition: drvlib.c:769
const char * provider_name
Informational driver provider name (reported via /proc)
Definition: rtdm_driver.h:517
int socket_type
Protocol device identification: socket type (SOCK_xxx)
Definition: rtdm_driver.h:478
void rtdm_task_busy_sleep(nanosecs_rel_t delay)
Busy-wait a specified amount of time.
Definition: drvlib.c:471
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.
Definition: rtdm_driver.h:247
int rtdm_irq_free(rtdm_irq_t *irq_handle)
Release an interrupt handler.
const char * proc_name
Name of /proc entry for the device, must not be NULL.
Definition: rtdm_driver.h:520
Real-time pod interface header.
char device_name[RTDM_MAX_DEVNAME_LEN+1]
Named device identification (orthogonal to Linux device name space)
Definition: rtdm_driver.h:473
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.
Definition: rtdm_driver.h:306
struct rtdm_operations * ops
Set of active device operation handlers.
Definition: rtdm_driver.h:409
unsigned long rtdm_lockctx_t
Variable to save the context while holding a lock.
Definition: rtdm_driver.h:693
void rtdm_mutex_init(rtdm_mutex_t *mutex)
Initialise a mutex.
Definition: drvlib.c:1405
int(* rtdm_irq_handler_t)(rtdm_irq_t *irq_handle)
Interrupt handler.
Definition: rtdm_driver.h:876
rtdm_read_handler_t read_rt
Read handler for real-time context (optional)
Definition: rtdm_driver.h:357
int rtdm_task_sleep_until(nanosecs_abs_t wakeup_time)
Sleep until a specified absolute time.
static void xnpod_schedule(void)
Rescheduling procedure entry point.
Definition: pod.h:251
int rtdm_copy_from_user(rtdm_user_info_t *user_info, void *dst, const void __user *src, size_t size)
Copy user-space memory block to specified buffer.
int rtdm_read_user_ok(rtdm_user_info_t *user_info, const void __user *ptr, size_t size)
Check if read access to user-space memory block is safe.
void xnpod_delete_thread(xnthread_t *thread)
Delete a thread.
Definition: pod.c:1070
void rtdm_mutex_destroy(rtdm_mutex_t *mutex)
Destroy a mutex.
rtdm_ioctl_handler_t ioctl_nrt
IOCTL from non-real-time context (optional)
Definition: rtdm_driver.h:348
struct rtdm_dev_reserved reserved
Data stored by RTDM inside a registered device (internal use only)
Definition: rtdm_driver.h:533
struct rtdm_device * device
Reference to owning device.
Definition: rtdm_driver.h:412
#define XNRMID
Pending on a removed resource.
Definition: thread.h:109
static void xntimer_stop(xntimer_t *timer)
Disarm a timer.
Definition: timer.h:420
int rtdm_sem_down(rtdm_sem_t *sem)
Decrement a semaphore.
Definition: drvlib.c:1184
int rtdm_event_timedwait(rtdm_event_t *event, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
Wait on event occurrence with timeout.
Definition: drvlib.c:944
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.
Definition: rtdm_driver.h:286
void rtdm_sem_destroy(rtdm_sem_t *sem)
Destroy a semaphore.
rtdm_socket_handler_t socket_nrt
Protocol socket creation for non-real-time contexts, optional if socket_rt is non-NULL, ignored for named devices.
Definition: rtdm_driver.h:497
int(* rtdm_open_handler_t)(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int oflag)
Named device open handler.
Definition: rtdm_driver.h:172
int(* rtdm_close_handler_t)(struct rtdm_dev_context *context, rtdm_user_info_t *user_info)
Close handler.
Definition: rtdm_driver.h:212
nanosecs_abs_t rtdm_clock_read_monotonic(void)
Get monotonic time.
void rtdm_timer_stop_in_handler(rtdm_timer_t *timer)
Stop a timer from inside a timer handler.
rtdm_recvmsg_handler_t recvmsg_rt
Receive message handler for real-time context (optional)
Definition: rtdm_driver.h:370
int device_id
Driver definable device ID.
Definition: rtdm_driver.h:528
int rtdm_timer_start(rtdm_timer_t *timer, nanosecs_abs_t expiry, nanosecs_rel_t interval, enum rtdm_timer_mode mode)
Start a timer.
Definition: drvlib.c:565
int xnintr_disable(xnintr_t *intr)
Disable an interrupt object.
Definition: intr.c:865
rtdm_open_handler_t open_rt
Named device instance creation for real-time contexts, optional (but deprecated) if open_nrt is non-N...
Definition: rtdm_driver.h:484
int rtdm_rw_user_ok(rtdm_user_info_t *user_info, const void __user *ptr, size_t size)
Check if read/write access to user-space memory block is safe.
nanosecs_abs_t rtdm_clock_read(void)
Get system time.
void rtdm_event_destroy(rtdm_event_t *event)
Destroy an event.
int(* rtdm_socket_handler_t)(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int protocol)
Socket creation handler for protocol devices.
Definition: rtdm_driver.h:189
int rtdm_task_wait_period(void)
Wait on next real-time task period.
int rtdm_irq_disable(rtdm_irq_t *irq_handle)
Disable interrupt line.
static int xntimer_start(xntimer_t *timer, xnticks_t value, xnticks_t interval, xntmode_t mode)
Arm a timer.
Definition: timer.h:388
void * rtdm_malloc(size_t size)
Allocate memory block in real-time context.
int rtdm_event_wait(rtdm_event_t *event)
Wait on event occurrence.
Definition: drvlib.c:899
const char * driver_name
Informational driver name (reported via /proc)
Definition: rtdm_driver.h:510
void rtdm_sem_up(rtdm_sem_t *sem)
Increment a semaphore.
Definition: drvlib.c:1302
struct rtdm_devctx_reserved reserved
Data stored by RTDM inside a device context (internal use only)
Definition: rtdm_driver.h:415
void rtdm_task_destroy(rtdm_task_t *task)
Destroy a real-time task.
rtdm_selecttype
Definition: rtdm_driver.h:139
void rtdm_task_join_nrt(rtdm_task_t *task, unsigned int poll_delay)
Wait on a real-time task to terminate.
Definition: drvlib.c:427
int rtdm_timer_start_in_handler(rtdm_timer_t *timer, nanosecs_abs_t expiry, nanosecs_rel_t interval, enum rtdm_timer_mode mode)
Start a timer from inside a timer handler.
void rtdm_context_put(struct rtdm_dev_context *context)
Release a device context obtained via rtdm_context_get()
atomic_t close_lock_count
Lock counter of context, held while structure is referenced by an operation handler.
Definition: rtdm_driver.h:406
Device context.
Definition: rtdm_driver.h:397
int xnintr_detach(xnintr_t *intr)
Detach an interrupt object.
Definition: intr.c:780
Monotonic timer with relative timeout.
Definition: rtdm_driver.h:1003
void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
Release a mutex.
rtdm_timer_mode
Definition: rtdm_driver.h:1001
void(* rtdm_nrtsig_handler_t)(rtdm_nrtsig_t nrt_sig, void *arg)
Non-real-time signal handler.
Definition: rtdm_driver.h:950
int struct_version
Revision number of this structure, see Driver Versioning defines.
Definition: rtdm_driver.h:465
static void * rtdm_context_to_private(struct rtdm_dev_context *context)
Locate the driver private area associated to a device context structure.
Definition: rtdm_driver.h:430
void(* rtdm_task_proc_t)(void *arg)
Real-time task procedure.
Definition: rtdm_driver.h:1061
rtdm_task_t * rtdm_task_current(void)
Get current real-time task.
int driver_version
Driver version, see Driver Versioning defines.
Definition: rtdm_driver.h:512
void rtdm_context_lock(struct rtdm_dev_context *context)
Increment context reference counter.
RTDM device.
Definition: rtdm_driver.h:462
int rtdm_ratelimit(struct rtdm_ratelimit_state *rs, const char *func)
Enforces a rate limit.
Definition: drvlib.c:2136
int sem_destroy(sem_t *sem)
Destroy an unnamed semaphore.
Definition: sem.c:214
int device_sub_class
Device sub-class, see RTDM_SUBCLASS_xxx definition in the Device Profiles.
Definition: rtdm_driver.h:506
int rtdm_rt_capable(rtdm_user_info_t *user_info)
Test if the caller is capable of running in real-time context.
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.
Definition: rtdm_driver.h:326
unsigned long context_flags
Context flags, see Context Flags for details.
Definition: rtdm_driver.h:399
int device_class
Device class ID, see RTDM_CLASS_xxx.
Definition: rtdm_driver.h:503
int rtdm_iomap_to_user(rtdm_user_info_t *user_info, phys_addr_t src_addr, size_t len, int prot, void **pptr, struct vm_operations_struct *vm_ops, void *vm_private_data)
Map an I/O memory range into the address space of the user.
Definition: drvlib.c:2059
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.
Definition: drvlib.c:1622
int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
Request a mutex with timeout.
Definition: drvlib.c:1523
rtdm_sendmsg_handler_t sendmsg_nrt
Transmit message handler for non-real-time context (optional)
Definition: rtdm_driver.h:377
rtdm_write_handler_t write_nrt
Write handler for non-real-time context (optional)
Definition: rtdm_driver.h:364
Real-Time Driver Model for Xenomai, user API header.
void rtdm_event_pulse(rtdm_event_t *event)
Signal an event occurrence to currently listening waiters.
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.
Definition: drvlib.c:1071
int protocol_family
Protocol device identification: protocol family (PF_xxx)
Definition: rtdm_driver.h:476