Xenomai  3.0.8
cobalt-rtdm.h
1 /*
2  * Copyright (C) 2014 Jan Kiszka <jan.kiszka@siemens.com>.
3  * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>.
4  *
5  * Xenomai is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 2 of the License,
8  * or (at your option) any later version.
9  *
10  * Xenomai is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Xenomai; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #undef TRACE_SYSTEM
21 #define TRACE_SYSTEM cobalt_rtdm
22 
23 #if !defined(_TRACE_COBALT_RTDM_H) || defined(TRACE_HEADER_MULTI_READ)
24 #define _TRACE_COBALT_RTDM_H
25 
26 #include <linux/tracepoint.h>
27 #include <linux/mman.h>
28 #include <linux/sched.h>
29 
30 struct rtdm_fd;
31 struct rtdm_event;
32 struct rtdm_sem;
33 struct rtdm_mutex;
34 struct xnthread;
35 struct rtdm_device;
36 struct rtdm_dev_context;
37 struct _rtdm_mmap_request;
38 
39 DECLARE_EVENT_CLASS(fd_event,
40  TP_PROTO(struct rtdm_fd *fd, int ufd),
41  TP_ARGS(fd, ufd),
42 
43  TP_STRUCT__entry(
44  __field(struct rtdm_device *, dev)
45  __field(int, ufd)
46  ),
47 
48  TP_fast_assign(
49  __entry->dev = rtdm_fd_to_context(fd)->device;
50  __entry->ufd = ufd;
51  ),
52 
53  TP_printk("device=%p fd=%d",
54  __entry->dev, __entry->ufd)
55 );
56 
57 DECLARE_EVENT_CLASS(fd_request,
58  TP_PROTO(struct task_struct *task,
59  struct rtdm_fd *fd, int ufd, unsigned long arg),
60  TP_ARGS(task, fd, ufd, arg),
61 
62  TP_STRUCT__entry(
63  __array(char, comm, TASK_COMM_LEN)
64  __field(pid_t, pid)
65  __field(struct rtdm_device *, dev)
66  __field(int, ufd)
67  __field(unsigned long, arg)
68  ),
69 
70  TP_fast_assign(
71  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
72  __entry->pid = task_pid_nr(task);
73  __entry->dev = rtdm_fd_to_context(fd)->device;
74  __entry->ufd = ufd;
75  __entry->arg = arg;
76  ),
77 
78  TP_printk("device=%p fd=%d arg=%#lx pid=%d comm=%s",
79  __entry->dev, __entry->ufd, __entry->arg,
80  __entry->pid, __entry->comm)
81 );
82 
83 DECLARE_EVENT_CLASS(fd_request_status,
84  TP_PROTO(struct task_struct *task,
85  struct rtdm_fd *fd, int ufd, int status),
86  TP_ARGS(task, fd, ufd, status),
87 
88  TP_STRUCT__entry(
89  __array(char, comm, TASK_COMM_LEN)
90  __field(pid_t, pid)
91  __field(struct rtdm_device *, dev)
92  __field(int, ufd)
93  ),
94 
95  TP_fast_assign(
96  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
97  __entry->pid = task_pid_nr(task);
98  __entry->dev =
99  !IS_ERR(fd) ? rtdm_fd_to_context(fd)->device : NULL;
100  __entry->ufd = ufd;
101  ),
102 
103  TP_printk("device=%p fd=%d pid=%d comm=%s",
104  __entry->dev, __entry->ufd, __entry->pid, __entry->comm)
105 );
106 
107 DECLARE_EVENT_CLASS(task_op,
108  TP_PROTO(struct xnthread *task),
109  TP_ARGS(task),
110 
111  TP_STRUCT__entry(
112  __field(struct xnthread *, task)
113  __string(task_name, task->name)
114  ),
115 
116  TP_fast_assign(
117  __entry->task = task;
118  __assign_str(task_name, task->name);
119  ),
120 
121  TP_printk("task %p(%s)", __entry->task, __get_str(task_name))
122 );
123 
124 DECLARE_EVENT_CLASS(event_op,
125  TP_PROTO(struct rtdm_event *ev),
126  TP_ARGS(ev),
127 
128  TP_STRUCT__entry(
129  __field(struct rtdm_event *, ev)
130  ),
131 
132  TP_fast_assign(
133  __entry->ev = ev;
134  ),
135 
136  TP_printk("event=%p", __entry->ev)
137 );
138 
139 DECLARE_EVENT_CLASS(sem_op,
140  TP_PROTO(struct rtdm_sem *sem),
141  TP_ARGS(sem),
142 
143  TP_STRUCT__entry(
144  __field(struct rtdm_sem *, sem)
145  ),
146 
147  TP_fast_assign(
148  __entry->sem = sem;
149  ),
150 
151  TP_printk("sem=%p", __entry->sem)
152 );
153 
154 DECLARE_EVENT_CLASS(mutex_op,
155  TP_PROTO(struct rtdm_mutex *mutex),
156  TP_ARGS(mutex),
157 
158  TP_STRUCT__entry(
159  __field(struct rtdm_mutex *, mutex)
160  ),
161 
162  TP_fast_assign(
163  __entry->mutex = mutex;
164  ),
165 
166  TP_printk("mutex=%p", __entry->mutex)
167 );
168 
169 TRACE_EVENT(cobalt_device_register,
170  TP_PROTO(struct rtdm_device *dev),
171  TP_ARGS(dev),
172 
173  TP_STRUCT__entry(
174  __field(struct rtdm_device *, dev)
175  __string(device_name, dev->name)
176  __field(int, flags)
177  __field(int, class_id)
178  __field(int, subclass_id)
179  __field(int, profile_version)
180  ),
181 
182  TP_fast_assign(
183  __entry->dev = dev;
184  __assign_str(device_name, dev->name);
185  __entry->flags = dev->driver->device_flags;
186  __entry->class_id = dev->driver->profile_info.class_id;
187  __entry->subclass_id = dev->driver->profile_info.subclass_id;
188  __entry->profile_version = dev->driver->profile_info.version;
189  ),
190 
191  TP_printk("%s device %s=%p flags=0x%x, class=%d.%d profile=%d",
192  (__entry->flags & RTDM_DEVICE_TYPE_MASK)
193  == RTDM_NAMED_DEVICE ? "named" : "protocol",
194  __get_str(device_name), __entry->dev,
195  __entry->flags, __entry->class_id, __entry->subclass_id,
196  __entry->profile_version)
197 );
198 
199 TRACE_EVENT(cobalt_device_unregister,
200  TP_PROTO(struct rtdm_device *dev),
201  TP_ARGS(dev),
202 
203  TP_STRUCT__entry(
204  __field(struct rtdm_device *, dev)
205  __string(device_name, dev->name)
206  ),
207 
208  TP_fast_assign(
209  __entry->dev = dev;
210  __assign_str(device_name, dev->name);
211  ),
212 
213  TP_printk("device %s=%p",
214  __get_str(device_name), __entry->dev)
215 );
216 
217 DEFINE_EVENT(fd_event, cobalt_fd_created,
218  TP_PROTO(struct rtdm_fd *fd, int ufd),
219  TP_ARGS(fd, ufd)
220 );
221 
222 DEFINE_EVENT(fd_request, cobalt_fd_open,
223  TP_PROTO(struct task_struct *task,
224  struct rtdm_fd *fd, int ufd,
225  unsigned long oflags),
226  TP_ARGS(task, fd, ufd, oflags)
227 );
228 
229 DEFINE_EVENT(fd_request, cobalt_fd_close,
230  TP_PROTO(struct task_struct *task,
231  struct rtdm_fd *fd, int ufd,
232  unsigned long lock_count),
233  TP_ARGS(task, fd, ufd, lock_count)
234 );
235 
236 DEFINE_EVENT(fd_request, cobalt_fd_socket,
237  TP_PROTO(struct task_struct *task,
238  struct rtdm_fd *fd, int ufd,
239  unsigned long protocol_family),
240  TP_ARGS(task, fd, ufd, protocol_family)
241 );
242 
243 DEFINE_EVENT(fd_request, cobalt_fd_read,
244  TP_PROTO(struct task_struct *task,
245  struct rtdm_fd *fd, int ufd,
246  unsigned long len),
247  TP_ARGS(task, fd, ufd, len)
248 );
249 
250 DEFINE_EVENT(fd_request, cobalt_fd_write,
251  TP_PROTO(struct task_struct *task,
252  struct rtdm_fd *fd, int ufd,
253  unsigned long len),
254  TP_ARGS(task, fd, ufd, len)
255 );
256 
257 DEFINE_EVENT(fd_request, cobalt_fd_ioctl,
258  TP_PROTO(struct task_struct *task,
259  struct rtdm_fd *fd, int ufd,
260  unsigned long request),
261  TP_ARGS(task, fd, ufd, request)
262 );
263 
264 DEFINE_EVENT(fd_request, cobalt_fd_sendmsg,
265  TP_PROTO(struct task_struct *task,
266  struct rtdm_fd *fd, int ufd,
267  unsigned long flags),
268  TP_ARGS(task, fd, ufd, flags)
269 );
270 
271 DEFINE_EVENT(fd_request, cobalt_fd_recvmsg,
272  TP_PROTO(struct task_struct *task,
273  struct rtdm_fd *fd, int ufd,
274  unsigned long flags),
275  TP_ARGS(task, fd, ufd, flags)
276 );
277 
278 #define cobalt_print_protbits(__prot) \
279  __print_flags(__prot, "|", \
280  {PROT_EXEC, "exec"}, \
281  {PROT_READ, "read"}, \
282  {PROT_WRITE, "write"})
283 
284 #define cobalt_print_mapbits(__flags) \
285  __print_flags(__flags, "|", \
286  {MAP_SHARED, "shared"}, \
287  {MAP_PRIVATE, "private"}, \
288  {MAP_ANONYMOUS, "anon"}, \
289  {MAP_FIXED, "fixed"}, \
290  {MAP_HUGETLB, "huge"}, \
291  {MAP_NONBLOCK, "nonblock"}, \
292  {MAP_NORESERVE, "noreserve"}, \
293  {MAP_POPULATE, "populate"}, \
294  {MAP_UNINITIALIZED, "uninit"})
295 
296 TRACE_EVENT(cobalt_fd_mmap,
297  TP_PROTO(struct task_struct *task,
298  struct rtdm_fd *fd, int ufd, struct _rtdm_mmap_request *rma),
299  TP_ARGS(task, fd, ufd, rma),
300 
301  TP_STRUCT__entry(
302  __array(char, comm, TASK_COMM_LEN)
303  __field(pid_t, pid)
304  __field(struct rtdm_device *, dev)
305  __field(int, ufd)
306  __field(size_t, length)
307  __field(off_t, offset)
308  __field(int, prot)
309  __field(int, flags)
310  ),
311 
312  TP_fast_assign(
313  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
314  __entry->pid = task_pid_nr(task);
315  __entry->dev = rtdm_fd_to_context(fd)->device;
316  __entry->ufd = ufd;
317  __entry->length = rma->length;
318  __entry->offset = rma->offset;
319  __entry->prot = rma->prot;
320  __entry->flags = rma->flags;
321  ),
322 
323  TP_printk("device=%p fd=%d area={ len:%zu, off:%Lu }"
324  " prot=%#x(%s) flags=%#x(%s) pid=%d comm=%s",
325  __entry->dev, __entry->ufd, __entry->length,
326  (unsigned long long)__entry->offset,
327  __entry->prot, cobalt_print_protbits(__entry->prot),
328  __entry->flags, cobalt_print_mapbits(__entry->flags),
329  __entry->pid, __entry->comm)
330 );
331 
332 DEFINE_EVENT(fd_request_status, cobalt_fd_ioctl_status,
333  TP_PROTO(struct task_struct *task,
334  struct rtdm_fd *fd, int ufd,
335  int status),
336  TP_ARGS(task, fd, ufd, status)
337 );
338 
339 DEFINE_EVENT(fd_request_status, cobalt_fd_read_status,
340  TP_PROTO(struct task_struct *task,
341  struct rtdm_fd *fd, int ufd,
342  int status),
343  TP_ARGS(task, fd, ufd, status)
344 );
345 
346 DEFINE_EVENT(fd_request_status, cobalt_fd_write_status,
347  TP_PROTO(struct task_struct *task,
348  struct rtdm_fd *fd, int ufd,
349  int status),
350  TP_ARGS(task, fd, ufd, status)
351 );
352 
353 DEFINE_EVENT(fd_request_status, cobalt_fd_recvmsg_status,
354  TP_PROTO(struct task_struct *task,
355  struct rtdm_fd *fd, int ufd,
356  int status),
357  TP_ARGS(task, fd, ufd, status)
358 );
359 
360 DEFINE_EVENT(fd_request_status, cobalt_fd_sendmsg_status,
361  TP_PROTO(struct task_struct *task,
362  struct rtdm_fd *fd, int ufd,
363  int status),
364  TP_ARGS(task, fd, ufd, status)
365 );
366 
367 DEFINE_EVENT(fd_request_status, cobalt_fd_mmap_status,
368  TP_PROTO(struct task_struct *task,
369  struct rtdm_fd *fd, int ufd,
370  int status),
371  TP_ARGS(task, fd, ufd, status)
372 );
373 
374 DEFINE_EVENT(task_op, cobalt_driver_task_join,
375  TP_PROTO(struct xnthread *task),
376  TP_ARGS(task)
377 );
378 
379 TRACE_EVENT(cobalt_driver_event_init,
380  TP_PROTO(struct rtdm_event *ev, unsigned long pending),
381  TP_ARGS(ev, pending),
382 
383  TP_STRUCT__entry(
384  __field(struct rtdm_event *, ev)
385  __field(unsigned long, pending)
386  ),
387 
388  TP_fast_assign(
389  __entry->ev = ev;
390  __entry->pending = pending;
391  ),
392 
393  TP_printk("event=%p pending=%#lx",
394  __entry->ev, __entry->pending)
395 );
396 
397 TRACE_EVENT(cobalt_driver_event_wait,
398  TP_PROTO(struct rtdm_event *ev, struct xnthread *task),
399  TP_ARGS(ev, task),
400 
401  TP_STRUCT__entry(
402  __field(struct xnthread *, task)
403  __string(task_name, task->name)
404  __field(struct rtdm_event *, ev)
405  ),
406 
407  TP_fast_assign(
408  __entry->task = task;
409  __assign_str(task_name, task->name);
410  __entry->ev = ev;
411  ),
412 
413  TP_printk("event=%p task=%p(%s)",
414  __entry->ev, __entry->task, __get_str(task_name))
415 );
416 
417 DEFINE_EVENT(event_op, cobalt_driver_event_signal,
418  TP_PROTO(struct rtdm_event *ev),
419  TP_ARGS(ev)
420 );
421 
422 DEFINE_EVENT(event_op, cobalt_driver_event_clear,
423  TP_PROTO(struct rtdm_event *ev),
424  TP_ARGS(ev)
425 );
426 
427 DEFINE_EVENT(event_op, cobalt_driver_event_pulse,
428  TP_PROTO(struct rtdm_event *ev),
429  TP_ARGS(ev)
430 );
431 
432 DEFINE_EVENT(event_op, cobalt_driver_event_destroy,
433  TP_PROTO(struct rtdm_event *ev),
434  TP_ARGS(ev)
435 );
436 
437 TRACE_EVENT(cobalt_driver_sem_init,
438  TP_PROTO(struct rtdm_sem *sem, unsigned long value),
439  TP_ARGS(sem, value),
440 
441  TP_STRUCT__entry(
442  __field(struct rtdm_sem *, sem)
443  __field(unsigned long, value)
444  ),
445 
446  TP_fast_assign(
447  __entry->sem = sem;
448  __entry->value = value;
449  ),
450 
451  TP_printk("sem=%p value=%lu",
452  __entry->sem, __entry->value)
453 );
454 
455 TRACE_EVENT(cobalt_driver_sem_wait,
456  TP_PROTO(struct rtdm_sem *sem, struct xnthread *task),
457  TP_ARGS(sem, task),
458 
459  TP_STRUCT__entry(
460  __field(struct xnthread *, task)
461  __string(task_name, task->name)
462  __field(struct rtdm_sem *, sem)
463  ),
464 
465  TP_fast_assign(
466  __entry->task = task;
467  __assign_str(task_name, task->name);
468  __entry->sem = sem;
469  ),
470 
471  TP_printk("sem=%p task=%p(%s)",
472  __entry->sem, __entry->task, __get_str(task_name))
473 );
474 
475 DEFINE_EVENT(sem_op, cobalt_driver_sem_up,
476  TP_PROTO(struct rtdm_sem *sem),
477  TP_ARGS(sem)
478 );
479 
480 DEFINE_EVENT(sem_op, cobalt_driver_sem_destroy,
481  TP_PROTO(struct rtdm_sem *sem),
482  TP_ARGS(sem)
483 );
484 
485 DEFINE_EVENT(mutex_op, cobalt_driver_mutex_init,
486  TP_PROTO(struct rtdm_mutex *mutex),
487  TP_ARGS(mutex)
488 );
489 
490 DEFINE_EVENT(mutex_op, cobalt_driver_mutex_release,
491  TP_PROTO(struct rtdm_mutex *mutex),
492  TP_ARGS(mutex)
493 );
494 
495 DEFINE_EVENT(mutex_op, cobalt_driver_mutex_destroy,
496  TP_PROTO(struct rtdm_mutex *mutex),
497  TP_ARGS(mutex)
498 );
499 
500 TRACE_EVENT(cobalt_driver_mutex_wait,
501  TP_PROTO(struct rtdm_mutex *mutex, struct xnthread *task),
502  TP_ARGS(mutex, task),
503 
504  TP_STRUCT__entry(
505  __field(struct xnthread *, task)
506  __string(task_name, task->name)
507  __field(struct rtdm_mutex *, mutex)
508  ),
509 
510  TP_fast_assign(
511  __entry->task = task;
512  __assign_str(task_name, task->name);
513  __entry->mutex = mutex;
514  ),
515 
516  TP_printk("mutex=%p task=%p(%s)",
517  __entry->mutex, __entry->task, __get_str(task_name))
518 );
519 
520 #endif /* _TRACE_COBALT_RTDM_H */
521 
522 /* This part must be outside protection */
523 #undef TRACE_INCLUDE_PATH
524 #undef TRACE_INCLUDE_FILE
525 #define TRACE_INCLUDE_FILE cobalt-rtdm
526 #include <trace/define_trace.h>
struct rtdm_profile_info profile_info
Class profile information.
Definition: driver.h:255
int device_flags
Device flags, see Device Flags for details.
Definition: driver.h:260
struct rtdm_driver * driver
Device driver.
Definition: driver.h:340
#define RTDM_NAMED_DEVICE
If set, the device is addressed via a clear-text name.
Definition: driver.h:83
Device context.
Definition: driver.h:136
RTDM device.
Definition: driver.h:338
#define RTDM_DEVICE_TYPE_MASK
Mask selecting the device type.
Definition: driver.h:90