Module: xenomai-forge
Branch: next
Commit: f3e824900daf6014e6a76814a0b3c0ecd21c9a1e
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=f3e824900daf6014e6a76814a0b3c0ecd21c9a1e

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Apr 18 11:57:02 2014 +0200

cobalt/rtdm: convert legacy trace markers to kernel tracepoints

---

 include/cobalt/kernel/rtdm/driver.h |   17 +-
 include/cobalt/kernel/trace.h       |    4 -
 kernel/cobalt/rtdm/core.c           |   73 +++---
 kernel/cobalt/rtdm/device.c         |   25 +-
 kernel/cobalt/rtdm/drvlib.c         |   27 +--
 kernel/cobalt/trace/cobalt-rtdm.h   |  451 +++++++++++++++++++++++++++++++++++
 6 files changed, 501 insertions(+), 96 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 50d6e02..9c432c4 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -44,6 +44,7 @@
 
 /* debug support */
 #include <cobalt/kernel/assert.h>
+#include <trace/events/cobalt-rtdm.h>
 #ifdef CONFIG_PCI
 #include <asm-generic/xenomai/pci_ids.h>
 #endif /* CONFIG_PCI */
@@ -1165,7 +1166,7 @@ void rtdm_toseq_init(rtdm_toseq_t *timeout_seq, 
nanosecs_rel_t timeout);
 
 /* --- event services --- */
 
-typedef struct {
+typedef struct rtdm_event {
        struct xnsynch synch_base;
        DECLARE_XNSELECT(select_block);
 } rtdm_event_t;
@@ -1187,13 +1188,13 @@ void __rtdm_synch_flush(struct xnsynch *synch, unsigned 
long reason);
 
 static inline void rtdm_event_pulse(rtdm_event_t *event)
 {
-       trace_mark(xn_rtdm, event_pulse, "event %p", event);
+       trace_cobalt_driver_event_pulse(event);
        __rtdm_synch_flush(&event->synch_base, 0);
 }
 
 static inline void rtdm_event_destroy(rtdm_event_t *event)
 {
-       trace_mark(xn_rtdm, event_destroy, "event %p", event);
+       trace_cobalt_driver_event_destroy(event);
        __rtdm_synch_flush(&event->synch_base, XNRMID);
        xnselect_destroy(&event->select_block);
 }
@@ -1201,7 +1202,7 @@ static inline void rtdm_event_destroy(rtdm_event_t *event)
 
 /* --- semaphore services --- */
 
-typedef struct {
+typedef struct rtdm_sem {
        unsigned long value;
        struct xnsynch synch_base;
        DECLARE_XNSELECT(select_block);
@@ -1218,7 +1219,7 @@ void rtdm_sem_up(rtdm_sem_t *sem);
 #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */
 static inline void rtdm_sem_destroy(rtdm_sem_t *sem)
 {
-       trace_mark(xn_rtdm, sem_destroy, "sem %p", sem);
+       trace_cobalt_driver_sem_destroy(sem);
        __rtdm_synch_flush(&sem->synch_base, XNRMID);
        xnselect_destroy(&sem->select_block);
 }
@@ -1226,7 +1227,7 @@ static inline void rtdm_sem_destroy(rtdm_sem_t *sem)
 
 /* --- mutex services --- */
 
-typedef struct {
+typedef struct rtdm_mutex {
        struct xnsynch synch_base;
 } rtdm_mutex_t;
 
@@ -1241,7 +1242,7 @@ static inline void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
        if (!XENO_ASSERT(RTDM, !xnsched_interrupt_p()))
                return;
 
-       trace_mark(xn_rtdm, mutex_unlock, "mutex %p", mutex);
+       trace_cobalt_driver_mutex_release(mutex);
 
        if (unlikely(xnsynch_release(&mutex->synch_base,
                                     xnsched_current_thread()) != NULL))
@@ -1250,7 +1251,7 @@ static inline void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
 
 static inline void rtdm_mutex_destroy(rtdm_mutex_t *mutex)
 {
-       trace_mark(xn_rtdm, mutex_destroy, "mutex %p", mutex);
+       trace_cobalt_driver_mutex_destroy(mutex);
 
        __rtdm_synch_flush(&mutex->synch_base, XNRMID);
 }
diff --git a/include/cobalt/kernel/trace.h b/include/cobalt/kernel/trace.h
index d143e3a..5f2b6ca 100644
--- a/include/cobalt/kernel/trace.h
+++ b/include/cobalt/kernel/trace.h
@@ -23,10 +23,6 @@
 #include <linux/ipipe_trace.h>
 #include <cobalt/uapi/kernel/trace.h>
 
-/* TEMP */
-#undef trace_mark
-#define trace_mark(channel, ev, fmt, args...)  do { } while (0)
-
 static inline int xntrace_max_begin(unsigned long v)
 {
        ipipe_trace_begin(v);
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 71f6d08..5c3af51 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -26,13 +26,14 @@
  * @{
  */
 
+#include <linux/workqueue.h>
 #include <cobalt/kernel/ppd.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/apc.h>
 #include "rtdm/syscall.h"
 #include "rtdm/internal.h"
-
-#include <linux/workqueue.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/cobalt-rtdm.h>
 
 #define CLOSURE_RETRY_PERIOD_MS        100
 
@@ -229,7 +230,7 @@ static void close_callback(struct work_struct *work)
                        if (err == -EAGAIN)
                                reschedule = 1;
                } else {
-                       trace_mark(xn_rtdm, fd_closed, "fd %d", context->fd);
+                       trace_cobalt_fd_closed(context);
 
                        cleanup_instance(context->device, context,
                                         test_bit(RTDM_CREATED_IN_NRT,
@@ -263,8 +264,6 @@ int __rt_dev_open(rtdm_user_info_t *user_info, const char 
*path, int oflag)
        int nrt_mode = !rtdm_in_rt_context();
 
        device = get_named_device(path);
-       trace_mark(xn_rtdm, open, "user_info %p path %s oflag %d device %p",
-                  user_info, path, oflag, device);
        ret = -ENODEV;
        if (!device)
                goto err_out;
@@ -273,6 +272,8 @@ int __rt_dev_open(rtdm_user_info_t *user_info, const char 
*path, int oflag)
        if (ret != 0)
                goto cleanup_out;
 
+       trace_cobalt_fd_open(user_info, context, oflag);
+
        if (nrt_mode) {
                context->context_flags = (1 << RTDM_CREATED_IN_NRT);
                ret = device->open_nrt(context, user_info, oflag);
@@ -289,8 +290,7 @@ int __rt_dev_open(rtdm_user_info_t *user_info, const char 
*path, int oflag)
 
        fildes->context = context;
 
-       trace_mark(xn_rtdm, fd_created,
-                  "device %p fd %d", device, context->fd);
+       trace_cobalt_fd_created(context);
 
        return context->fd;
 
@@ -314,9 +314,6 @@ int __rt_dev_socket(rtdm_user_info_t *user_info, int 
protocol_family,
        int nrt_mode = !rtdm_in_rt_context();
 
        device = get_protocol_device(protocol_family, socket_type);
-       trace_mark(xn_rtdm, socket, "user_info %p protocol_family %d "
-                  "socket_type %d protocol %d device %p",
-                  user_info, protocol_family, socket_type, protocol, device);
        ret = -EAFNOSUPPORT;
        if (!device)
                goto err_out;
@@ -325,6 +322,8 @@ int __rt_dev_socket(rtdm_user_info_t *user_info, int 
protocol_family,
        if (ret != 0)
                goto cleanup_out;
 
+       trace_cobalt_fd_socket(user_info, context, protocol_family);
+
        if (nrt_mode) {
                context->context_flags = (1 << RTDM_CREATED_IN_NRT);
                ret = device->socket_nrt(context, user_info, protocol);
@@ -341,8 +340,7 @@ int __rt_dev_socket(rtdm_user_info_t *user_info, int 
protocol_family,
 
        fildes->context = context;
 
-       trace_mark(xn_rtdm, fd_created,
-                  "device %p fd %d", device, context->fd);
+       trace_cobalt_fd_created(context);
 
        return context->fd;
 
@@ -363,8 +361,6 @@ int __rt_dev_close(rtdm_user_info_t *user_info, int fd)
        int ret;
        int nrt_mode = !rtdm_in_rt_context();
 
-       trace_mark(xn_rtdm, close, "user_info %p fd %d", user_info, fd);
-
        ret = -EBADF;
        if (unlikely((unsigned int)fd >= RTDM_FD_MAX))
                goto err_out;
@@ -390,6 +386,9 @@ int __rt_dev_close(rtdm_user_info_t *user_info, int fd)
        set_bit(RTDM_CLOSING, &context->context_flags);
        atomic_inc(&context->close_lock_count);
 
+       trace_cobalt_fd_close(user_info, context,
+                             atomic_read(&context->close_lock_count));
+
        __cleanup_fildes(&fildes_table[fd]);
 
        xnlock_put_irqrestore(&rt_fildes_lock, s);
@@ -419,7 +418,7 @@ int __rt_dev_close(rtdm_user_info_t *user_info, int fd)
 
        xnlock_put_irqrestore(&rt_fildes_lock, s);
 
-       trace_mark(xn_rtdm, fd_closed, "fd %d", context->fd);
+       trace_cobalt_fd_closed(context);
 
        cleanup_instance(context->device, context,
                         test_bit(RTDM_CREATED_IN_NRT,
@@ -463,7 +462,7 @@ void cleanup_process_files(struct rtdm_process *owner)
        }
 }
 
-#define MAJOR_FUNCTION_WRAPPER_TH(operation, args...)                  \
+#define MAJOR_FUNCTION_WRAPPER_TH(operation, trace_arg, args...)       \
 do {                                                                   \
        struct rtdm_dev_context *context;                               \
        struct rtdm_operations *ops;                                    \
@@ -474,6 +473,7 @@ do {                                                        
                \
        if (unlikely(!context))                                         \
                goto err_out;                                           \
                                                                        \
+       trace_cobalt_fd_ ## operation(user_info, context, trace_arg);   \
        ops = context->ops;                                             \
                                                                        \
        if (rtdm_in_rt_context())                                       \
@@ -484,18 +484,18 @@ do {                                                      
                \
        if (!XENO_ASSERT(RTDM, !spltest()))                             \
                    splnone();
 
-#define MAJOR_FUNCTION_WRAPPER_BH()                                    \
+#define MAJOR_FUNCTION_WRAPPER_BH(operation)                           \
        rtdm_context_unlock(context);                                   \
                                                                        \
 err_out:                                                               \
-       trace_mark(xn_rtdm, operation##_done, "result %d", ret);        \
+       trace_cobalt_fd_ ## operation ## _status(user_info, context, ret);\
        return ret;                                                     \
 } while (0)
 
-#define MAJOR_FUNCTION_WRAPPER(operation, args...)                     \
+#define MAJOR_FUNCTION_WRAPPER(operation, trace_arg, args...)          \
 do {                                                                   \
-       MAJOR_FUNCTION_WRAPPER_TH(operation, args);                     \
-       MAJOR_FUNCTION_WRAPPER_BH();                                    \
+       MAJOR_FUNCTION_WRAPPER_TH(operation, trace_arg, args);          \
+       MAJOR_FUNCTION_WRAPPER_BH(operation);                           \
 } while (0)
 
 int __rt_dev_ioctl(rtdm_user_info_t *user_info, int fd, int request, ...)
@@ -507,10 +507,7 @@ int __rt_dev_ioctl(rtdm_user_info_t *user_info, int fd, 
int request, ...)
        arg = va_arg(args, void __user *);
        va_end(args);
 
-       trace_mark(xn_rtdm, ioctl, "user_info %p fd %d request %d arg %p",
-                  user_info, fd, request, arg);
-
-       MAJOR_FUNCTION_WRAPPER_TH(ioctl, (unsigned int)request, arg);
+       MAJOR_FUNCTION_WRAPPER_TH(ioctl, request, (unsigned int)request, arg);
 
        if (unlikely(ret < 0) && (unsigned int)request == RTIOC_DEVICE_INFO) {
                struct rtdm_device *dev = context->device;
@@ -525,7 +522,7 @@ int __rt_dev_ioctl(rtdm_user_info_t *user_info, int fd, int 
request, ...)
                                             sizeof(dev_info));
        }
 
-       MAJOR_FUNCTION_WRAPPER_BH();
+       MAJOR_FUNCTION_WRAPPER_BH(ioctl);
 }
 
 EXPORT_SYMBOL_GPL(__rt_dev_ioctl);
@@ -533,9 +530,7 @@ EXPORT_SYMBOL_GPL(__rt_dev_ioctl);
 ssize_t __rt_dev_read(rtdm_user_info_t *user_info, int fd, void *buf,
                      size_t nbyte)
 {
-       trace_mark(xn_rtdm, read, "user_info %p fd %d buf %p nbyte %zu",
-                  user_info, fd, buf, nbyte);
-       MAJOR_FUNCTION_WRAPPER(read, buf, nbyte);
+       MAJOR_FUNCTION_WRAPPER(read, nbyte, buf, nbyte);
 }
 
 EXPORT_SYMBOL_GPL(__rt_dev_read);
@@ -543,9 +538,7 @@ EXPORT_SYMBOL_GPL(__rt_dev_read);
 ssize_t __rt_dev_write(rtdm_user_info_t *user_info, int fd, const void *buf,
                       size_t nbyte)
 {
-       trace_mark(xn_rtdm, write, "user_info %p fd %d buf %p nbyte %zu",
-                  user_info, fd, buf, nbyte);
-       MAJOR_FUNCTION_WRAPPER(write, buf, nbyte);
+       MAJOR_FUNCTION_WRAPPER(write, nbyte, buf, nbyte);
 }
 
 EXPORT_SYMBOL_GPL(__rt_dev_write);
@@ -553,13 +546,7 @@ EXPORT_SYMBOL_GPL(__rt_dev_write);
 ssize_t __rt_dev_recvmsg(rtdm_user_info_t *user_info, int fd,
                         struct msghdr *msg, int flags)
 {
-       trace_mark(xn_rtdm, recvmsg, "user_info %p fd %d msg_name %p "
-                  "msg_namelen %u msg_iov %p msg_iovlen %zu "
-                  "msg_control %p msg_controllen %zu msg_flags %d",
-                  user_info, fd, msg->msg_name, msg->msg_namelen,
-                  msg->msg_iov, msg->msg_iovlen, msg->msg_control,
-                  msg->msg_controllen, msg->msg_flags);
-       MAJOR_FUNCTION_WRAPPER(recvmsg, msg, flags);
+       MAJOR_FUNCTION_WRAPPER(recvmsg, flags, msg, flags);
 }
 
 EXPORT_SYMBOL_GPL(__rt_dev_recvmsg);
@@ -567,13 +554,7 @@ EXPORT_SYMBOL_GPL(__rt_dev_recvmsg);
 ssize_t __rt_dev_sendmsg(rtdm_user_info_t *user_info, int fd,
                         const struct msghdr *msg, int flags)
 {
-       trace_mark(xn_rtdm, sendmsg, "user_info %p fd %d msg_name %p "
-                  "msg_namelen %u msg_iov %p msg_iovlen %zu "
-                  "msg_control %p msg_controllen %zu msg_flags %d",
-                  user_info, fd, msg->msg_name, msg->msg_namelen,
-                  msg->msg_iov, msg->msg_iovlen, msg->msg_control,
-                  msg->msg_controllen, msg->msg_flags);
-       MAJOR_FUNCTION_WRAPPER(sendmsg, msg, flags);
+       MAJOR_FUNCTION_WRAPPER(sendmsg, flags, msg, flags);
 }
 
 EXPORT_SYMBOL_GPL(__rt_dev_sendmsg);
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 1aa2542..b9639a2 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -30,6 +30,7 @@
 #include <linux/semaphore.h>
 #include <cobalt/kernel/apc.h>
 #include "rtdm/internal.h"
+#include <trace/events/cobalt-rtdm.h>
 
 #define SET_DEFAULT_OP(device, operation)                              \
        (device).operation##_rt  = (void *)rtdm_no_support;             \
@@ -290,14 +291,9 @@ int rtdm_dev_register(struct rtdm_device *device)
 
        down(&nrt_dev_lock);
 
-       if ((device->device_flags & RTDM_DEVICE_TYPE_MASK) == 
RTDM_NAMED_DEVICE) {
-               trace_mark(xn_rtdm, nameddev_register, "device %p name %s "
-                          "flags %d class %d sub_class %d profile_version %d "
-                          "driver_version %d", device, device->device_name,
-                          device->device_flags, device->device_class,
-                          device->device_sub_class, device->profile_version,
-                          device->driver_version);
+       trace_cobalt_device_register(device);
 
+       if ((device->device_flags & RTDM_DEVICE_TYPE_MASK) == 
RTDM_NAMED_DEVICE) {
                hashkey =
                    get_name_hash(device->device_name, RTDM_MAX_DEVNAME_LEN,
                                  name_hashkey_mask);
@@ -324,15 +320,6 @@ int rtdm_dev_register(struct rtdm_device *device)
 
                up(&nrt_dev_lock);
        } else {
-               trace_mark(xn_rtdm, protocol_register, "device %p "
-                          "protocol_family %d socket_type %d flags %d "
-                          "class %d sub_class %d profile_version %d "
-                          "driver_version %d", device,
-                          device->protocol_family, device->socket_type,
-                          device->device_flags, device->device_class,
-                          device->device_sub_class, device->profile_version,
-                          device->driver_version);
-
                hashkey = get_proto_hash(device->protocol_family,
                                         device->socket_type);
 
@@ -415,8 +402,7 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
        if (!reg_dev)
                return -ENODEV;
 
-       trace_mark(xn_rtdm, dev_unregister, "device %p poll_delay %u",
-                  device, poll_delay);
+       trace_cobalt_device_unregister(device, poll_delay);
 
        down(&nrt_dev_lock);
        xnlock_get_irqsave(&rt_dev_lock, s);
@@ -427,7 +413,6 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
 
                if (!poll_delay) {
                        rtdm_dereference_device(reg_dev);
-                       trace_mark(xn_rtdm, dev_busy, "device %p", device);
                        return -EAGAIN;
                }
 
@@ -435,8 +420,6 @@ int rtdm_dev_unregister(struct rtdm_device *device, 
unsigned int poll_delay)
                        printk(XENO_WARN "RTDM device %s still in use - waiting 
for"
                               "release...\n", reg_dev->device_name);
                msleep(poll_delay);
-               trace_mark(xn_rtdm, dev_poll, "device %p", device);
-
                down(&nrt_dev_lock);
                xnlock_get_irqsave(&rt_dev_lock, s);
        }
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 33ca350..714d69a 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -41,6 +41,7 @@
 
 #include <rtdm/driver.h>
 #include "internal.h"
+#include <trace/events/cobalt-rtdm.h>
 
 /*!
  * @ingroup driverapi
@@ -442,8 +443,7 @@ void rtdm_task_join_nrt(rtdm_task_t *task, unsigned int 
poll_delay)
        if (!XENO_ASSERT(RTDM, xnsched_root_p()))
                return;
 
-       trace_mark(xn_rtdm, task_joinnrt, "thread %p poll_delay %u",
-                  task, poll_delay);
+       trace_cobalt_driver_task_join(task);
 
        xnthread_join(task, true);
 }
@@ -771,8 +771,7 @@ void rtdm_event_init(rtdm_event_t *event, unsigned long 
pending)
 {
        spl_t s;
 
-       trace_mark(xn_rtdm, event_init,
-                  "event %p pending %lu", event, pending);
+       trace_cobalt_driver_event_init(event, pending);
 
        /* Make atomic for re-initialisation support */
        xnlock_get_irqsave(&nklock, s);
@@ -853,7 +852,7 @@ void rtdm_event_signal(rtdm_event_t *event)
        int resched = 0;
        spl_t s;
 
-       trace_mark(xn_rtdm, event_signal, "event %p", event);
+       trace_cobalt_driver_event_signal(event);
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -952,9 +951,7 @@ int rtdm_event_timedwait(rtdm_event_t *event, 
nanosecs_rel_t timeout,
        if (!XENO_ASSERT(RTDM, !xnsched_unblockable_p()))
                return -EPERM;
 
-       trace_mark(xn_rtdm, event_timedwait,
-                  "event %p timeout %Lu timeout_seq %p timeout_seq_value %Lu",
-                  event, (long long)timeout, timeout_seq, (long 
long)(timeout_seq ? *timeout_seq : 0));
+       trace_cobalt_driver_event_wait(event, xnsched_current_thread());
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -1022,7 +1019,7 @@ void rtdm_event_clear(rtdm_event_t *event)
 {
        spl_t s;
 
-       trace_mark(xn_rtdm, event_clear, "event %p", event);
+       trace_cobalt_driver_event_clear(event);
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -1116,7 +1113,7 @@ void rtdm_sem_init(rtdm_sem_t *sem, unsigned long value)
 {
        spl_t s;
 
-       trace_mark(xn_rtdm, sem_init, "sem %p value %lu", sem, value);
+       trace_cobalt_driver_sem_init(sem, value);
 
        /* Make atomic for re-initialisation support */
        xnlock_get_irqsave(&nklock, s);
@@ -1231,9 +1228,7 @@ int rtdm_sem_timeddown(rtdm_sem_t *sem, nanosecs_rel_t 
timeout,
        if (!XENO_ASSERT(RTDM, !xnsched_unblockable_p()))
                return -EPERM;
 
-       trace_mark(xn_rtdm, sem_timedwait,
-                  "sem %p timeout %Lu timeout_seq %p timeout_seq_value %Lu",
-                  sem, (long long)timeout, timeout_seq, (long 
long)(timeout_seq ? *timeout_seq : 0));
+       trace_cobalt_driver_sem_wait(sem, xnsched_current_thread());
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -1295,7 +1290,7 @@ void rtdm_sem_up(rtdm_sem_t *sem)
 {
        spl_t s;
 
-       trace_mark(xn_rtdm, sem_up, "sem %p", sem);
+       trace_cobalt_driver_sem_up(sem);
 
        xnlock_get_irqsave(&nklock, s);
 
@@ -1517,9 +1512,7 @@ int rtdm_mutex_timedlock(rtdm_mutex_t *mutex, 
nanosecs_rel_t timeout,
        spl_t s;
        int err = 0;
 
-       trace_mark(xn_rtdm, mutex_timedlock,
-                  "mutex %p timeout %Lu timeout_seq %p timeout_seq_value %Lu",
-                  mutex, (long long)timeout, timeout_seq, (long 
long)(timeout_seq ? *timeout_seq : 0));
+       trace_cobalt_driver_mutex_wait(mutex, curr_thread);
 
        if (!XENO_ASSERT(RTDM, !xnsched_unblockable_p()))
                return -EPERM;
diff --git a/kernel/cobalt/trace/cobalt-rtdm.h 
b/kernel/cobalt/trace/cobalt-rtdm.h
new file mode 100644
index 0000000..1828fc7
--- /dev/null
+++ b/kernel/cobalt/trace/cobalt-rtdm.h
@@ -0,0 +1,451 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM cobalt-rtdm
+
+#if !defined(_TRACE_COBALT_RTDM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_COBALT_RTDM_H
+
+#include <linux/tracepoint.h>
+
+struct rtdm_event;
+struct rtdm_sem;
+struct rtdm_mutex;
+struct xnthread;
+struct rtdm_device;
+struct rtdm_dev_context;
+
+DECLARE_EVENT_CLASS(fd_event,
+       TP_PROTO(struct rtdm_dev_context *context),
+       TP_ARGS(context),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_device *, device)
+               __field(int, fd)
+       ),
+
+       TP_fast_assign(
+               __entry->device = context->device;
+               __entry->fd = context->fd;
+       ),
+
+       TP_printk("device=%p fd=%d",
+                 __entry->device, __entry->fd)
+);
+
+DECLARE_EVENT_CLASS(fd_request,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context, unsigned long arg),
+       TP_ARGS(task, context, arg),
+
+       TP_STRUCT__entry(
+               __field(struct task_struct *, task)
+               __array(char, comm, TASK_COMM_LEN)
+               __field(pid_t, pid)
+               __field(struct rtdm_device *, device)
+               __field(int, fd)
+               __field(unsigned long, arg)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+               __entry->pid = task->pid;
+               __entry->device = context->device;
+               __entry->fd = context->fd;
+               __entry->arg = arg;
+       ),
+
+       TP_printk("device=%p fd=%d arg=%#lx pid=%d comm=%s",
+                 __entry->device, __entry->fd, __entry->arg,
+                 __entry->pid, __entry->comm)
+);
+
+DECLARE_EVENT_CLASS(fd_request_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context, int status),
+       TP_ARGS(task, context, status),
+
+       TP_STRUCT__entry(
+               __field(struct task_struct *, task)
+               __array(char, comm, TASK_COMM_LEN)
+               __field(pid_t, pid)
+               __field(struct rtdm_device *, device)
+               __field(int, fd)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+               __entry->pid = task->pid;
+               __entry->device = context->device;
+               __entry->fd = context->fd;
+       ),
+
+       TP_printk("device=%p fd=%d pid=%d comm=%s",
+                 __entry->device, __entry->fd, __entry->pid, __entry->comm)
+);
+
+DECLARE_EVENT_CLASS(task_op,
+       TP_PROTO(struct xnthread *task),
+       TP_ARGS(task),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *, task)
+               __string(task_name, xnthread_name(task))
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __assign_str(task_name, xnthread_name(task));
+       ),
+
+       TP_printk("task %p(%s)", __entry->task, __get_str(task_name))
+);
+
+DECLARE_EVENT_CLASS(event_op,
+       TP_PROTO(struct rtdm_event *ev),
+       TP_ARGS(ev),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_event *, ev)
+       ),
+
+       TP_fast_assign(
+               __entry->ev = ev;
+       ),
+
+       TP_printk("event=%p", __entry->ev)
+);
+
+DECLARE_EVENT_CLASS(sem_op,
+       TP_PROTO(struct rtdm_sem *sem),
+       TP_ARGS(sem),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_sem *, sem)
+       ),
+
+       TP_fast_assign(
+               __entry->sem = sem;
+       ),
+
+       TP_printk("sem=%p", __entry->sem)
+);
+
+DECLARE_EVENT_CLASS(mutex_op,
+       TP_PROTO(struct rtdm_mutex *mutex),
+       TP_ARGS(mutex),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_mutex *, mutex)
+       ),
+
+       TP_fast_assign(
+               __entry->mutex = mutex;
+       ),
+
+       TP_printk("mutex=%p", __entry->mutex)
+);
+
+TRACE_EVENT(cobalt_device_register,
+       TP_PROTO(struct rtdm_device *device),
+       TP_ARGS(device),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_device *, device)
+               __string(device_name, device->device_name)
+               __field(int, flags)
+               __field(int, device_class)
+               __field(int, device_subclass)
+               __field(int, profile_version)
+               __field(int, driver_version)
+       ),
+
+       TP_fast_assign(
+               __entry->device = device;
+               __assign_str(device_name, device->device_name);
+               __entry->flags = device->device_flags;
+               __entry->device_class = device->device_class;
+               __entry->device_subclass = device->device_sub_class;
+               __entry->profile_version = device->profile_version;
+               __entry->driver_version = device->driver_version;
+       ),
+
+       TP_printk("%s device %s=%p version=%d flags=0x%x, class=%d.%d 
profile=%d",
+                 (__entry->flags & RTDM_DEVICE_TYPE_MASK)
+                 == RTDM_NAMED_DEVICE ? "named" : "protocol",
+                 __get_str(device_name), __entry->device, 
__entry->driver_version,
+                 __entry->flags, __entry->device_class, 
__entry->device_subclass,
+                 __entry->profile_version)
+);
+
+TRACE_EVENT(cobalt_device_unregister,
+       TP_PROTO(struct rtdm_device *device, unsigned int poll_delay),
+       TP_ARGS(device, poll_delay),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_device *, device)
+               __string(device_name, device->device_name)
+               __field(unsigned int, poll_delay)
+       ),
+
+       TP_fast_assign(
+               __entry->device = device;
+               __assign_str(device_name, device->device_name);
+               __entry->poll_delay = poll_delay;
+       ),
+
+       TP_printk("device %s=%p poll_delay=%u",
+                 __get_str(device_name), __entry->device, __entry->poll_delay)
+);
+
+DEFINE_EVENT(fd_event, cobalt_fd_created,
+       TP_PROTO(struct rtdm_dev_context *context),
+       TP_ARGS(context)
+);
+
+DEFINE_EVENT(fd_event, cobalt_fd_closed,
+       TP_PROTO(struct rtdm_dev_context *context),
+       TP_ARGS(context)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_open,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long oflags),
+       TP_ARGS(task, context, oflags)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_close,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long lock_count),
+       TP_ARGS(task, context, lock_count)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_socket,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long protocol_family),
+       TP_ARGS(task, context, protocol_family)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_read,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long len),
+       TP_ARGS(task, context, len)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_write,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long len),
+       TP_ARGS(task, context, len)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_ioctl,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long request),
+       TP_ARGS(task, context, request)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_sendmsg,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long flags),
+       TP_ARGS(task, context, flags)
+);
+
+DEFINE_EVENT(fd_request, cobalt_fd_recvmsg,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                unsigned long flags),
+       TP_ARGS(task, context, flags)
+);
+
+DEFINE_EVENT(fd_request_status, cobalt_fd_ioctl_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                int status),
+       TP_ARGS(task, context, status)
+);
+
+DEFINE_EVENT(fd_request_status, cobalt_fd_read_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                int status),
+       TP_ARGS(task, context, status)
+);
+
+DEFINE_EVENT(fd_request_status, cobalt_fd_write_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                int status),
+       TP_ARGS(task, context, status)
+);
+
+DEFINE_EVENT(fd_request_status, cobalt_fd_recvmsg_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                int status),
+       TP_ARGS(task, context, status)
+);
+
+DEFINE_EVENT(fd_request_status, cobalt_fd_sendmsg_status,
+       TP_PROTO(struct task_struct *task,
+                struct rtdm_dev_context *context,
+                int status),
+       TP_ARGS(task, context, status)
+);
+
+DEFINE_EVENT(task_op, cobalt_driver_task_join,
+       TP_PROTO(struct xnthread *task),
+       TP_ARGS(task)
+);
+
+TRACE_EVENT(cobalt_driver_event_init,
+       TP_PROTO(struct rtdm_event *ev, unsigned long pending),
+       TP_ARGS(ev, pending),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_event *, ev)
+               __field(unsigned long,  pending)
+       ),
+
+       TP_fast_assign(
+               __entry->ev = ev;
+               __entry->pending = pending;
+       ),
+
+       TP_printk("event=%p pending=%#lx",
+                 __entry->ev, __entry->pending)
+);
+
+TRACE_EVENT(cobalt_driver_event_wait,
+       TP_PROTO(struct rtdm_event *ev, struct xnthread *task),
+       TP_ARGS(ev, task),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *, task)
+               __string(task_name, xnthread_name(task))
+               __field(struct rtdm_event *, ev)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __assign_str(task_name, xnthread_name(task));
+               __entry->ev = ev;
+       ),
+
+       TP_printk("event=%p task=%p(%s)",
+                 __entry->ev, __entry->task, __get_str(task_name))
+);
+
+DEFINE_EVENT(event_op, cobalt_driver_event_signal,
+       TP_PROTO(struct rtdm_event *ev),
+       TP_ARGS(ev)
+);
+
+DEFINE_EVENT(event_op, cobalt_driver_event_clear,
+       TP_PROTO(struct rtdm_event *ev),
+       TP_ARGS(ev)
+);
+
+DEFINE_EVENT(event_op, cobalt_driver_event_pulse,
+       TP_PROTO(struct rtdm_event *ev),
+       TP_ARGS(ev)
+);
+
+DEFINE_EVENT(event_op, cobalt_driver_event_destroy,
+       TP_PROTO(struct rtdm_event *ev),
+       TP_ARGS(ev)
+);
+
+TRACE_EVENT(cobalt_driver_sem_init,
+       TP_PROTO(struct rtdm_sem *sem, unsigned long value),
+       TP_ARGS(sem, value),
+
+       TP_STRUCT__entry(
+               __field(struct rtdm_sem *, sem)
+               __field(unsigned long, value)
+       ),
+
+       TP_fast_assign(
+               __entry->sem = sem;
+               __entry->value = value;
+       ),
+
+       TP_printk("sem=%p value=%lu",
+                 __entry->sem, __entry->value)
+);
+
+TRACE_EVENT(cobalt_driver_sem_wait,
+       TP_PROTO(struct rtdm_sem *sem, struct xnthread *task),
+       TP_ARGS(sem, task),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *, task)
+               __string(task_name, xnthread_name(task))
+               __field(struct rtdm_sem *, sem)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __assign_str(task_name, xnthread_name(task));
+               __entry->sem = sem;
+       ),
+
+       TP_printk("sem=%p task=%p(%s)",
+                 __entry->sem, __entry->task, __get_str(task_name))
+);
+
+DEFINE_EVENT(sem_op, cobalt_driver_sem_up,
+       TP_PROTO(struct rtdm_sem *sem),
+       TP_ARGS(sem)
+);
+
+DEFINE_EVENT(sem_op, cobalt_driver_sem_destroy,
+       TP_PROTO(struct rtdm_sem *sem),
+       TP_ARGS(sem)
+);
+
+DEFINE_EVENT(mutex_op, cobalt_driver_mutex_init,
+       TP_PROTO(struct rtdm_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+DEFINE_EVENT(mutex_op, cobalt_driver_mutex_release,
+       TP_PROTO(struct rtdm_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+DEFINE_EVENT(mutex_op, cobalt_driver_mutex_destroy,
+       TP_PROTO(struct rtdm_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+TRACE_EVENT(cobalt_driver_mutex_wait,
+       TP_PROTO(struct rtdm_mutex *mutex, struct xnthread *task),
+       TP_ARGS(mutex, task),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *, task)
+               __string(task_name, xnthread_name(task))
+               __field(struct rtdm_mutex *, mutex)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __assign_str(task_name, xnthread_name(task));
+               __entry->mutex = mutex;
+       ),
+
+       TP_printk("mutex=%p task=%p(%s)",
+                 __entry->mutex, __entry->task, __get_str(task_name))
+);
+
+#endif /* _TRACE_COBALT_RTDM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to