# rtai_trace.h

    00001 /*
    00002  * This file contains the necessary definitions for the RTAI tracer.
    00003  *
    00004  * Copyright (C) 2000, Karim Yaghmour <karym@opersys.com>
    00005  *
    00006  * This program is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU General Public License as
    00008  * published by the Free Software Foundation; either version 2 of the
    00009  * License, or (at your option) any later version.
    00010  *
    00011  * This program is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014  * GNU General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU General Public License
    00017  * along with this program; if not, write to the Free Software
    00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00019  */
    00020
    00021 #ifndef _RTAI_TRACE_H
    00022 #define _RTAI_TRACE_H
    00023
    00024 #include <rtai_types.h>
    00025
    00026 #if defined(CONFIG_RTAI_TRACE) && defined(__KERNEL__)
    00027
    00028 #include <linux/trace.h>
    00029
    00030 /* Is RTAI tracing enabled */
    00031
    00032 /* The functions to the tracer management code */
    00033 int rt_register_tracer
    00034        (tracer_call   /* The tracer function */);
    00035 int rt_unregister_tracer
    00036        (tracer_call   /* The tracer function */);
    00037 int rt_trace_event
    00038        (uint8_t       /* Event ID (as defined in this header file) */,
    00039         void*         /* Structure describing the event */);
    00040
    00041 /* Generic macros */
    00042 #define RT_TRACE_EVENT(ID, DATA) rt_trace_event(ID, DATA)
    00043
    00044 #define TRACE_RTAI_START TRACE_EV_MAX
    00045
    00046 /* Traced events */
    00047 #define TRACE_RTAI_EV_MOUNT              TRACE_RTAI_START +  1   /* The RTAI subsystem was mounted */
    00048 #define TRACE_RTAI_EV_UMOUNT             TRACE_RTAI_START +  2   /* The RTAI subsystem was unmounted */
    00049 #define TRACE_RTAI_EV_GLOBAL_IRQ_ENTRY   TRACE_RTAI_START +  3   /* Entry in a global IRQ */
    00050 #define TRACE_RTAI_EV_GLOBAL_IRQ_EXIT    TRACE_RTAI_START +  4   /* Exit from a global IRQ */
    00051 #define TRACE_RTAI_EV_OWN_IRQ_ENTRY      TRACE_RTAI_START +  5   /* Entry in a CPU own IRQ */
    00052 #define TRACE_RTAI_EV_OWN_IRQ_EXIT       TRACE_RTAI_START +  6   /* Exit from a CPU own IRQ */
    00053 #define TRACE_RTAI_EV_TRAP_ENTRY         TRACE_RTAI_START +  7   /* Entry in a trap */
    00054 #define TRACE_RTAI_EV_TRAP_EXIT          TRACE_RTAI_START +  8   /* Exit from a trap */
    00055 #define TRACE_RTAI_EV_SRQ_ENTRY          TRACE_RTAI_START +  9   /* Entry in a SRQ */
    00056 #define TRACE_RTAI_EV_SRQ_EXIT           TRACE_RTAI_START + 10   /* Exit from a SRQ */
    00057 #define TRACE_RTAI_EV_SWITCHTO_LINUX     TRACE_RTAI_START + 11   /* Switch a CPU to Linux */
    00058 #define TRACE_RTAI_EV_SWITCHTO_RT        TRACE_RTAI_START + 12   /* Switch a CPU to real-time */
    00059 #define TRACE_RTAI_EV_SCHED_CHANGE       TRACE_RTAI_START + 13   /* A scheduling change has occured */
    00060 #define TRACE_RTAI_EV_TASK               TRACE_RTAI_START + 14   /* Hit key part of task services */
    00061 #define TRACE_RTAI_EV_TIMER              TRACE_RTAI_START + 15   /* Hit key part of timer services */
    00062 #define TRACE_RTAI_EV_SEM                TRACE_RTAI_START + 16   /* Hit key part of semaphore services */
    00063 #define TRACE_RTAI_EV_MSG                TRACE_RTAI_START + 17   /* Hit key part of message services */
    00064 #define TRACE_RTAI_EV_RPC                TRACE_RTAI_START + 18   /* Hit key part of RPC services */
    00065 #define TRACE_RTAI_EV_MBX                TRACE_RTAI_START + 19   /* Hit key part of mail box services */
    00066 #define TRACE_RTAI_EV_FIFO               TRACE_RTAI_START + 20   /* Hit key part of FIFO services */
    00067 #define TRACE_RTAI_EV_SHM                TRACE_RTAI_START + 21   /* Hit key part of shared memory services */
    00068 #define TRACE_RTAI_EV_POSIX              TRACE_RTAI_START + 22   /* Hit key part of Posix services */
    00069 #define TRACE_RTAI_EV_LXRT               TRACE_RTAI_START + 23   /* Hit key part of LXRT services */
    00070 #define TRACE_RTAI_EV_LXRTI              TRACE_RTAI_START + 24   /* Hit key part of LXRT-Informed services */
    00071
    00072 /* Max number of traced events */
    00073 #define TRACE_RTAI_EV_MAX               TRACE_RTAI_EV_LXRTI
    00074
    00075 /* Structures and macros for traced events */
    00076 /*  TRACE_RTAI_MOUNT */
    00077 #define TRACE_RTAI_MOUNT()    rt_trace_event(TRACE_RTAI_EV_MOUNT, NULL)
    00078
    00079 /*  TRACE_RTAI_UMOUNT */
    00080 #define TRACE_RTAI_UMOUNT()   rt_trace_event(TRACE_RTAI_EV_UMOUNT, NULL)
    00081
    00082 /*  TRACE_RTAI_GLOBAL_IRQ_ENTRY */
    00083 typedef struct _trace_rtai_global_irq_entry
    00084 {
    00085   uint8_t  irq_id;      /* IRQ number */
    00086   uint8_t  kernel;      /* Are we executing kernel code */
    00087 } LTT_PACKED_STRUCT trace_rtai_global_irq_entry;
    00088 #if CONFIG_X86
    00089 #define TRACE_RTAI_GLOBAL_IRQ_ENTRY(ID, __dummy) \
    00090            do \
    00091            {\
    00092            uint32_t                    eflags, xcs; \
    00093            trace_rtai_global_irq_entry irq_entry;\
    00094            irq_entry.irq_id = ID;\
    00095            __asm__ __volatile__("pushfl; pop %0": "=g" (eflags)); \
    00096            __asm__ __volatile__("pushl %%cs; pop %0": "=g" (xcs)); \
    00097            irq_entry.kernel = !((VM_MASK & eflags) || (3 & xcs));\
    00098            rt_trace_event(TRACE_RTAI_EV_GLOBAL_IRQ_ENTRY, &irq_entry);\
    00099            } while(0)
    00100 #endif
    00101 #if CONFIG_PPC
    00102 #define TRACE_RTAI_GLOBAL_IRQ_ENTRY(ID, KERNEL) \
    00103            do \
    00104            {\
    00105            trace_rtai_global_irq_entry irq_entry;\
    00106            irq_entry.irq_id = ID;\
    00107            irq_entry.kernel = KERNEL;\
    00108            rt_trace_event(TRACE_RTAI_EV_GLOBAL_IRQ_ENTRY, &irq_entry);\
    00109            } while(0)
    00110 #endif
    00111
    00112 /*  TRACE_RTAI_GLOBAL_IRQ_EXIT */
    00113 #define TRACE_RTAI_GLOBAL_IRQ_EXIT() rt_trace_event(TRACE_RTAI_EV_GLOBAL_IRQ_EXIT, NULL)
    00114
    00115 /*  TRACE_RTAI_OWN_IRQ_ENTRY */
    00116 typedef struct _trace_rtai_own_irq_entry
    00117 {
    00118   uint8_t  irq_id;      /* IRQ number */
    00119   uint8_t  kernel;      /* Are we executing kernel code */
    00120 } LTT_PACKED_STRUCT trace_rtai_own_irq_entry;
    00121 #if CONFIG_X86
    00122 #define TRACE_RTAI_OWN_IRQ_ENTRY(ID) \
    00123            do \
    00124            {\
    00125            uint32_t                 eflags, xcs; \
    00126            trace_rtai_own_irq_entry irq_entry;\
    00127            irq_entry.irq_id = ID;\
    00128            __asm__ __volatile__("pushfl; pop %0": "=g" (eflags)); \
    00129            __asm__ __volatile__("pushl %%cs; pop %0": "=g" (xcs)); \
    00130            irq_entry.kernel = !((VM_MASK & eflags) || (3 & xcs));\
    00131            rt_trace_event(TRACE_RTAI_EV_OWN_IRQ_ENTRY, &irq_entry);\
    00132            } while(0)
    00133 #endif
    00134 #if CONFIG_PPC
    00135 #define TRACE_RTAI_OWN_IRQ_ENTRY(ID, KERNEL) \
    00136            do \
    00137            {\
    00138            trace_rtai_own_irq_entry irq_entry;\
    00139            irq_entry.irq_id = ID;\
    00140            irq_entry.kernel = KERNEL;\
    00141            rt_trace_event(TRACE_RTAI_EV_OWN_IRQ_ENTRY, &irq_entry);\
    00142            } while(0)
    00143 #endif
    00144
    00145 /*  TRACE_RTAI_OWN_IRQ_EXIT */
    00146 #define TRACE_RTAI_OWN_IRQ_EXIT() rt_trace_event(TRACE_RTAI_EV_OWN_IRQ_EXIT, NULL)
    00147
    00148 /*  TRACE_RTAI_TRAP_ENTRY */
    00149 typedef struct _trace_rtai_trap_entry
    00150 {
    00151   uint8_t   trap_id;        /* Trap number */
    00152   uint32_t  address;        /* Address where trap occured */
    00153 } LTT_PACKED_STRUCT trace_rtai_trap_entry;
    00154 #define TRACE_RTAI_TRAP_ENTRY(ID,ADDR) \
    00155            do \
    00156            {\
    00157            trace_rtai_trap_entry trap_event;\
    00158            trap_event.trap_id = ID;\
    00159            trap_event.address = ADDR; \
    00160            rt_trace_event(TRACE_RTAI_EV_TRAP_ENTRY, &trap_event);\
    00161            } while(0)
    00162 /*
    00163            uint32_t              eip; \
    00164            __asm__ __volatile__("pushl %%ip; pop %0": "=g" (eip)); \
    00165            trap_event.address = eip;\
    00166 */
    00167
    00168 /*  TRACE_RTAI_TRAP_EXIT */
    00169 #define TRACE_RTAI_TRAP_EXIT() rt_trace_event(TRACE_RTAI_EV_TRAP_EXIT, NULL)
    00170
    00171 /*  TRACE_RTAI_SRQ_ENTRY */
    00172 typedef struct _trace_rtai_srq_entry
    00173 {
    00174   uint8_t  srq_id;      /* SRQ number */
    00175   uint8_t  kernel;      /* Are we executing kernel code */
    00176 } LTT_PACKED_STRUCT trace_rtai_srq_entry;
    00177 #if CONFIG_X86
    00178 #define TRACE_RTAI_SRQ_ENTRY(ID) \
    00179            do \
    00180            {\
    00181            uint32_t             eflags, xcs; \
    00182            trace_rtai_srq_entry srq_entry;\
    00183            srq_entry.srq_id = ID;\
    00184            __asm__ __volatile__("pushfl; pop %0": "=g" (eflags)); \
    00185            __asm__ __volatile__("pushl %%cs; pop %0": "=g" (xcs)); \
    00186            srq_entry.kernel = !((VM_MASK & eflags) || (3 & xcs));\
    00187            rt_trace_event(TRACE_RTAI_EV_SRQ_ENTRY, &srq_entry);\
    00188            } while(0)
    00189 #endif
    00190 #if CONFIG_PPC || CONFIG_ARM
    00191 #define TRACE_RTAI_SRQ_ENTRY(ID,KERNEL) \
    00192            do \
    00193            {\
    00194            trace_rtai_srq_entry srq_entry;\
    00195            srq_entry.srq_id = ID;\
    00196            srq_entry.kernel = KERNEL;\
    00197            rt_trace_event(TRACE_RTAI_EV_SRQ_ENTRY, &srq_entry);\
    00198            } while(0)
    00199 #endif
    00200
    00201 /*  TRACE_RTAI_SRQ_EXIT */
    00202 #define TRACE_RTAI_SRQ_EXIT() rt_trace_event(TRACE_RTAI_EV_SRQ_EXIT, NULL)
    00203
    00204 /*  TRACE_RTAI_SWITCHTO_LINUX */
    00205 typedef struct _trace_rtai_switchto_linux
    00206 {
    00207   uint8_t   cpu_id;         /* The CPUID being switched to Linux */
    00208 } LTT_PACKED_STRUCT trace_rtai_switchto_linux;
    00209 #define TRACE_RTAI_SWITCHTO_LINUX(ID) \
    00210            do \
    00211            {\
    00212            trace_rtai_switchto_linux switch_event; \
    00213            switch_event.cpu_id = (uint8_t) ID; \
    00214            rt_trace_event(TRACE_RTAI_EV_SWITCHTO_LINUX, &switch_event); \
    00215            } while(0)
    00216
    00217 /*  TRACE_RTAI_SWITCHTO_RT */
    00218 typedef struct _trace_rtai_switchto_rt
    00219 {
    00220   uint8_t   cpu_id;         /* The CPUID being switched to RT */
    00221 } LTT_PACKED_STRUCT trace_rtai_switchto_rt;
    00222 #define TRACE_RTAI_SWITCHTO_RT(ID) \
    00223            do \
    00224            {\
    00225            trace_rtai_switchto_rt switch_event; \
    00226            switch_event.cpu_id = (uint8_t) ID; \
    00227            rt_trace_event(TRACE_RTAI_EV_SWITCHTO_RT, &switch_event); \
    00228            } while(0)
    00229
    00230 /*  TRACE_RTAI_SCHED_CHANGE */
    00231 typedef struct _trace_rtai_sched_change
    00232 {
    00233   uint32_t  out;         /* Outgoing process */
    00234   uint32_t  in;          /* Incoming process */
    00235   uint32_t  out_state;   /* Outgoing process' state */
    00236 } LTT_PACKED_STRUCT trace_rtai_sched_change;
    00237 #define TRACE_RTAI_SCHED_CHANGE(OUT, IN, OUT_STATE) \
    00238            do \
    00239            {\
    00240            trace_rtai_sched_change sched_event;\
    00241            sched_event.out       = (uint32_t) OUT;\
    00242            sched_event.in        = (uint32_t) IN;\
    00243            sched_event.out_state = (uint32_t) OUT_STATE; \
    00244            rt_trace_event(TRACE_RTAI_EV_SCHED_CHANGE, &sched_event);\
    00245            } while(0)
    00246
    00247 /*  TRACE_RTAI_TASK */
    00248 #define TRACE_RTAI_EV_TASK_INIT                    1     /* Initialize task */
    00249 #define TRACE_RTAI_EV_TASK_DELETE                  2     /* Delete task */
    00250 #define TRACE_RTAI_EV_TASK_SIG_HANDLER             3     /* Set signal handler */
    00251 #define TRACE_RTAI_EV_TASK_YIELD                   4     /* Yield CPU control */
    00252 #define TRACE_RTAI_EV_TASK_SUSPEND                 5     /* Suspend task */
    00253 #define TRACE_RTAI_EV_TASK_RESUME                  6     /* Resume task */
    00254 #define TRACE_RTAI_EV_TASK_MAKE_PERIOD_RELATIVE    7     /* Make task periodic relative in nanoseconds */
    00255 #define TRACE_RTAI_EV_TASK_MAKE_PERIOD             8     /* Make task periodic */
    00256 #define TRACE_RTAI_EV_TASK_WAIT_PERIOD             9     /* Wait until the next period */
    00257 #define TRACE_RTAI_EV_TASK_BUSY_SLEEP             10     /* Busy sleep */
    00258 #define TRACE_RTAI_EV_TASK_SLEEP                  11     /* Sleep */
    00259 #define TRACE_RTAI_EV_TASK_SLEEP_UNTIL            12     /* Sleep until */
    00260 typedef struct _trace_rtai_task
    00261 {
    00262   uint8_t   event_sub_id;  /* Task event ID */
    00263   uint32_t  event_data1;   /* Event data */
    00264   uint64_t  event_data2;   /* Event data 2 */
    00265   uint64_t  event_data3;   /* Event data 3 */
    00266 } LTT_PACKED_STRUCT trace_rtai_task;
    00267 #define TRACE_RTAI_TASK(ID, DATA1, DATA2, DATA3) \
    00268            do \
    00269            {\
    00270            trace_rtai_task task_event;\
    00271            task_event.event_sub_id = (uint8_t)  ID;\
    00272            task_event.event_data1  = (uint32_t) DATA1; \
    00273            task_event.event_data2  = (uint64_t) DATA2; \
    00274            task_event.event_data3  = (uint64_t) DATA3; \
    00275            rt_trace_event(TRACE_RTAI_EV_TASK, &task_event);\
    00276            } while(0)
    00277
    00278 /*  TRACE_RTAI_TIMER */
    00279 #define TRACE_RTAI_EV_TIMER_REQUEST                1     /* Request timer */
    00280 #define TRACE_RTAI_EV_TIMER_FREE                   2     /* Free timer */
    00281 #define TRACE_RTAI_EV_TIMER_REQUEST_APIC           3     /* Request APIC timers */
    00282 #define TRACE_RTAI_EV_TIMER_APIC_FREE              4     /* Free APIC timers */
    00283 #define TRACE_RTAI_EV_TIMER_HANDLE_EXPIRY          5     /* Handle timer expiry */
    00284 typedef struct _trace_rtai_timer
    00285 {
    00286   uint8_t   event_sub_id;  /* Timer event ID */
    00287   uint32_t  event_data1;   /* Event data 1 */
    00288   uint32_t  event_data2;   /* Event data 2 */
    00289 } LTT_PACKED_STRUCT trace_rtai_timer;
    00290 #define TRACE_RTAI_TIMER(ID, DATA1, DATA2) \
    00291            do \
    00292            {\
    00293            trace_rtai_timer timer_event; \
    00294            timer_event.event_sub_id = (uint8_t)  ID; \
    00295            timer_event.event_data1  = (uint32_t) DATA1; \
    00296            timer_event.event_data2  = (uint32_t) DATA2; \
    00297            rt_trace_event(TRACE_RTAI_EV_TIMER, &timer_event); \
    00298            } while(0)
    00299
    00300 /*  TRACE_RTAI_SEM */
    00301 #define TRACE_RTAI_EV_SEM_INIT                     1     /* Initialize semaphore */
    00302 #define TRACE_RTAI_EV_SEM_DELETE                   2     /* Delete semaphore */
    00303 #define TRACE_RTAI_EV_SEM_SIGNAL                   3     /* Signal semaphore */
    00304 #define TRACE_RTAI_EV_SEM_WAIT                     4     /* Wait on semaphore */
    00305 #define TRACE_RTAI_EV_SEM_WAIT_IF                  5     /* Take semaphore if possible */
    00306 #define TRACE_RTAI_EV_SEM_WAIT_UNTIL               6     /* Wait on semaphore until a certain time */
    00307 typedef struct _trace_rtai_sem
    00308 {
    00309   uint8_t   event_sub_id;  /* Semaphore event ID */
    00310   uint32_t  event_data1;   /* Event data 1 */
    00311   uint64_t  event_data2;   /* Event data 2 */
    00312 } LTT_PACKED_STRUCT trace_rtai_sem;
    00313 #define TRACE_RTAI_SEM(ID, DATA1, DATA2) \
    00314            do \
    00315            {\
    00316            trace_rtai_sem sem_event; \
    00317            sem_event.event_sub_id = (uint8_t)  ID; \
    00318            sem_event.event_data1  = (uint32_t) DATA1; \
    00319            sem_event.event_data2  = (uint64_t) DATA2; \
    00320            rt_trace_event(TRACE_RTAI_EV_SEM, &sem_event); \
    00321            } while(0)
    00322
    00323 /*  TRACE_RTAI_MSG */
    00324 #define TRACE_RTAI_EV_MSG_SEND                      1    /* Send a message */
    00325 #define TRACE_RTAI_EV_MSG_SEND_IF                   2    /* Send if possible */
    00326 #define TRACE_RTAI_EV_MSG_SEND_UNTIL                3    /* Try sending until a certain time */
    00327 #define TRACE_RTAI_EV_MSG_RECV                      4    /* Receive a message */
    00328 #define TRACE_RTAI_EV_MSG_RECV_IF                   5    /* Receive if possible */
    00329 #define TRACE_RTAI_EV_MSG_RECV_UNTIL                6    /* Try receiving until a certain time */
    00330 typedef struct _trace_rtai_msg
    00331 {
    00332   uint8_t   event_sub_id;  /* Message event ID */
    00333   uint32_t  event_data1;   /* Event data 1 */
    00334   uint32_t  event_data2;   /* Event data 2 */
    00335   uint64_t  event_data3;   /* Event data 3 */
    00336 } LTT_PACKED_STRUCT trace_rtai_msg;
    00337 #define TRACE_RTAI_MSG(ID, DATA1, DATA2, DATA3) \
    00338            do \
    00339            {\
    00340            trace_rtai_msg msg_event; \
    00341            msg_event.event_sub_id = (uint8_t)  ID; \
    00342            msg_event.event_data1  = (uint32_t) DATA1; \
    00343            msg_event.event_data2  = (uint32_t) DATA2; \
    00344            msg_event.event_data3  = (uint64_t) DATA3; \
    00345            rt_trace_event(TRACE_RTAI_EV_MSG, &msg_event); \
    00346            } while(0)
    00347
    00348 /*  TRACE_RTAI_RPC */
    00349 #define TRACE_RTAI_EV_RPC_MAKE                       1    /* Make a remote procedure call */
    00350 #define TRACE_RTAI_EV_RPC_MAKE_IF                    2    /* Make RPC if receiver is ready */
    00351 #define TRACE_RTAI_EV_RPC_MAKE_UNTIL                 3    /* Try making an RPC until a certain time */
    00352 #define TRACE_RTAI_EV_RPC_RETURN                     4    /* Send result of RPC back to caller */
    00353 typedef struct _trace_rtai_rpc
    00354 {
    00355   uint8_t   event_sub_id;  /* RPC event ID */
    00356   uint32_t  event_data1;   /* Event data 1 */
    00357   uint32_t  event_data2;   /* Event data 2 */
    00358   uint64_t  event_data3;   /* Event data 3 */
    00359 } LTT_PACKED_STRUCT trace_rtai_rpc;
    00360 #define TRACE_RTAI_RPC(ID, DATA1, DATA2, DATA3) \
    00361            do \
    00362            {\
    00363            trace_rtai_rpc rpc_event; \
    00364            rpc_event.event_sub_id = (uint8_t)  ID; \
    00365            rpc_event.event_data1  = (uint32_t) DATA1; \
    00366            rpc_event.event_data2  = (uint32_t) DATA2; \
    00367            rpc_event.event_data3  = (uint64_t) DATA3; \
    00368            rt_trace_event(TRACE_RTAI_EV_RPC, &rpc_event); \
    00369            } while(0)
    00370
    00371 /*  TRACE_RTAI_MBX */
    00372 #define TRACE_RTAI_EV_MBX_INIT                       1    /* Initialize Message BoX */
    00373 #define TRACE_RTAI_EV_MBX_DELETE                     2    /* Delete message box */
    00374 #define TRACE_RTAI_EV_MBX_SEND                       3    /* Send a message to a message box */
    00375 #define TRACE_RTAI_EV_MBX_SEND_WP                    4    /* Send as many bytes as possible */
    00376 #define TRACE_RTAI_EV_MBX_SEND_IF                    5    /* Send a message if possible */
    00377 #define TRACE_RTAI_EV_MBX_SEND_UNTIL                 6    /* Try sending until a certain time */
    00378 #define TRACE_RTAI_EV_MBX_RECV                       7    /* Receive a message */
    00379 #define TRACE_RTAI_EV_MBX_RECV_WP                    8    /* Receive as many bytes as possible */
    00380 #define TRACE_RTAI_EV_MBX_RECV_IF                    9    /* Receive a message if available */
    00381 #define TRACE_RTAI_EV_MBX_RECV_UNTIL                10    /* Try receiving until a certain time */
    00382 typedef struct _trace_rtai_mbx
    00383 {
    00384   uint8_t   event_sub_id;  /* Message Box event ID */
    00385   uint32_t  event_data1;   /* Event data 1 */
    00386   uint32_t  event_data2;   /* Event data 2 */
    00387   uint64_t  event_data3;   /* Event data 3 */
    00388 } LTT_PACKED_STRUCT trace_rtai_mbx;
    00389 #define TRACE_RTAI_MBX(ID, DATA1, DATA2, DATA3) \
    00390            do \
    00391            {\
    00392            trace_rtai_mbx mbx_event; \
    00393            mbx_event.event_sub_id = (uint8_t)  ID; \
    00394            mbx_event.event_data1  = (uint32_t) DATA1; \
    00395            mbx_event.event_data2  = (uint32_t) DATA2; \
    00396            mbx_event.event_data3  = (uint64_t) DATA3; \
    00397            rt_trace_event(TRACE_RTAI_EV_MBX, &mbx_event); \
    00398            } while(0)
    00399
    00400 /*  TRACE_RTAI_FIFO */
    00401 #define TRACE_RTAI_EV_FIFO_CREATE                     1   /* Create FIFO */
    00402 #define TRACE_RTAI_EV_FIFO_DESTROY                    2   /* Destroy FIFO */
    00403 #define TRACE_RTAI_EV_FIFO_RESET                      3   /* Reset FIFO */
    00404 #define TRACE_RTAI_EV_FIFO_RESIZE                     4   /* Resize FIFO */
    00405 #define TRACE_RTAI_EV_FIFO_PUT                        5   /* Write data to FIFO */
    00406 #define TRACE_RTAI_EV_FIFO_GET                        6   /* Get data from FIFO */
    00407 #define TRACE_RTAI_EV_FIFO_CREATE_HANDLER             7   /* Install FIFO handler */
    00408 #define TRACE_RTAI_EV_FIFO_OPEN                       8   /* Open FIFO */
    00409 #define TRACE_RTAI_EV_FIFO_RELEASE                    9   /* Release FIFO */
    00410 #define TRACE_RTAI_EV_FIFO_READ                      10   /* Read from FIFO */
    00411 #define TRACE_RTAI_EV_FIFO_WRITE                     11   /* Write to FIFO */
    00412 #define TRACE_RTAI_EV_FIFO_READ_TIMED                12   /* Read with time limit */
    00413 #define TRACE_RTAI_EV_FIFO_WRITE_TIMED               13   /* Write with time limit */
    00414 #define TRACE_RTAI_EV_FIFO_READ_ALLATONCE            14   /* Read all the data from FIFO */
    00415 #define TRACE_RTAI_EV_FIFO_LLSEEK                    15   /* Seek position into FIFO */
    00416 #define TRACE_RTAI_EV_FIFO_FASYNC                    16   /* Asynchronous notification */
    00417 #define TRACE_RTAI_EV_FIFO_IOCTL                     17   /* IO control on FIFO */
    00418 #define TRACE_RTAI_EV_FIFO_POLL                      18   /* Poll FIFO */
    00419 #define TRACE_RTAI_EV_FIFO_SUSPEND_TIMED             19   /* Suspend task for given period */
    00420 #define TRACE_RTAI_EV_FIFO_SET_ASYNC_SIG             20   /* Set asynchrounous signal */
    00421 #define TRACE_RTAI_EV_FIFO_SEM_INIT                  21   /* Initialize semaphore */
    00422 #define TRACE_RTAI_EV_FIFO_SEM_POST                  22   /* Post semaphore */
    00423 #define TRACE_RTAI_EV_FIFO_SEM_WAIT                  23   /* Wait on semaphore */
    00424 #define TRACE_RTAI_EV_FIFO_SEM_TRY_WAIT              24   /* Try waiting on semaphore */
    00425 #define TRACE_RTAI_EV_FIFO_SEM_TIMED_WAIT            25   /* Wait on semaphore until a certain time */
    00426 #define TRACE_RTAI_EV_FIFO_SEM_DESTROY               26   /* Destroy semaphore  */
    00427 typedef struct _trace_rtai_fifo
    00428 {
    00429   uint8_t   event_sub_id;  /* FIFO event ID */
    00430   uint32_t  event_data1;   /* Event data 1 */
    00431   uint32_t  event_data2;   /* Event data 2 */
    00432 } LTT_PACKED_STRUCT trace_rtai_fifo;
    00433 #define TRACE_RTAI_FIFO(ID, DATA1, DATA2) \
    00434            do \
    00435            {\
    00436            trace_rtai_fifo fifo_event; \
    00437            fifo_event.event_sub_id = (uint8_t)  ID; \
    00438            fifo_event.event_data1  = (uint32_t) DATA1; \
    00439            fifo_event.event_data2  = (uint32_t) DATA2; \
    00440            rt_trace_event(TRACE_RTAI_EV_FIFO, &fifo_event); \
    00441            } while(0)
    00442
    00443 /*  TRACE_RTAI_SHM */
    00444 #define TRACE_RTAI_EV_SHM_MALLOC                       1  /* Allocate shared memory */
    00445 #define TRACE_RTAI_EV_SHM_KMALLOC                      2  /* Allocate shared memory in kernel space */
    00446 #define TRACE_RTAI_EV_SHM_GET_SIZE                     3  /* Get the size of the shared memory area */
    00447 #define TRACE_RTAI_EV_SHM_FREE                         4  /* Free shared memory */
    00448 #define TRACE_RTAI_EV_SHM_KFREE                        5  /* Free kernel space shared memory */
    00449 typedef struct _trace_rtai_shm
    00450 {
    00451   uint8_t   event_sub_id;  /* SHared Memory event ID */
    00452   uint32_t  event_data1;   /* Event data 1 */
    00453   uint32_t  event_data2;   /* Event data 2 */
    00454   uint32_t  event_data3;   /* Event data 3 */
    00455 } LTT_PACKED_STRUCT trace_rtai_shm;
    00456 #define TRACE_RTAI_SHM(ID, DATA1, DATA2, DATA3) \
    00457            do \
    00458            {\
    00459            trace_rtai_shm shm_event; \
    00460            shm_event.event_sub_id = (uint8_t)  ID; \
    00461            shm_event.event_data1  = (uint32_t) DATA1; \
    00462            shm_event.event_data2  = (uint32_t) DATA2; \
    00463            shm_event.event_data3  = (uint32_t) DATA3; \
    00464            rt_trace_event(TRACE_RTAI_EV_SHM, &shm_event); \
    00465            } while(0)
    00466
    00467 /*  TRACE_RTAI_POSIX */
    00468 #define TRACE_RTAI_EV_POSIX_MQ_OPEN                       1  /* Open/create message queue */
    00469 #define TRACE_RTAI_EV_POSIX_MQ_CLOSE                      2  /* Close message queue */
    00470 #define TRACE_RTAI_EV_POSIX_MQ_SEND                       3  /* Send message to queue */
    00471 #define TRACE_RTAI_EV_POSIX_MQ_RECV                       4  /* Receive message from queue */
    00472 #define TRACE_RTAI_EV_POSIX_MQ_GET_ATTR                   5  /* Get message queue attributes */
    00473 #define TRACE_RTAI_EV_POSIX_MQ_SET_ATTR                   6  /* Set message queue attributes */
    00474 #define TRACE_RTAI_EV_POSIX_MQ_NOTIFY                     7  /* Register to be notified of message arrival */
    00475 #define TRACE_RTAI_EV_POSIX_MQ_UNLINK                     8  /* Destroy message queue */
    00476 #define TRACE_RTAI_EV_POSIX_PTHREAD_CREATE                9  /* Create RT task */
    00477 #define TRACE_RTAI_EV_POSIX_PTHREAD_EXIT                 10  /* Terminate calling thread */
    00478 #define TRACE_RTAI_EV_POSIX_PTHREAD_SELF                 11  /* Get thread ID */
    00479 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_INIT            12  /* Initialize thread attribute */
    00480 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_DESTROY         13  /* Destroy thread attribute */
    00481 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_SETDETACHSTATE  14  /* Set detach state of thread */
    00482 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_GETDETACHSTATE  15  /* Get detach state of thread */
    00483 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_SETSCHEDPARAM   16  /* Set thread scheduling parameters */
    00484 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_GETSCHEDPARAM   17  /* Get thread scheduling parameters */
    00485 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_SETSCHEDPOLICY  18  /* Set thread scheduling policy */
    00486 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_GETSCHEDPOLICY  19  /* Get thread scheduling policy */
    00487 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_SETINHERITSCHED 20  /* Set thread scheduling inheritance */
    00488 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_GETINHERITSCHED 21  /* Get thread scheduling inheritance */
    00489 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_SETSCOPE        22  /* Set thread scheduling scope */
    00490 #define TRACE_RTAI_EV_POSIX_PTHREAD_ATTR_GETSCOPE        23  /* Get thread scheduling scope */
    00491 #define TRACE_RTAI_EV_POSIX_PTHREAD_SCHED_YIELD          24  /* Yield processor control */
    00492 #define TRACE_RTAI_EV_POSIX_PTHREAD_CLOCK_GETTIME        25  /* Get current clock count */
    00493 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEX_INIT           26  /* Initialize mutex */
    00494 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEX_DESTROY        27  /* Destroy mutex */
    00495 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEXATTR_INIT       28  /* Initiatize mutex attribute */
    00496 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEXATTR_DESTROY    29  /* Destroy mutex attribute */
    00497 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEXATTR_SETKIND_NP 30  /* Set kind of attribute */
    00498 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEXATTR_GETKIND_NP 31  /* Get kind of attribute */
    00499 #define TRACE_RTAI_EV_POSIX_PTHREAD_SETSCHEDPARAM        32  /* Set scheduling parameters */
    00500 #define TRACE_RTAI_EV_POSIX_PTHREAD_GETSCHEDPARAM        33  /* Get scheduling parameters */
    00501 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEX_TRY_LOCK       34  /* Non-blocking mutex lock */
    00502 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEX_LOCK           35  /* Blocking mutex lock */
    00503 #define TRACE_RTAI_EV_POSIX_PTHREAD_MUTEX_UNLOCK         36  /* Mutex unlock */
    00504 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_INIT            37  /* Initialize conditionnal variable */
    00505 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_DESTROY         38  /* Destroy cond. variable */
    00506 #define TRACE_RTAI_EV_POSIX_PTHREAD_CONDATTR_INIT        39  /* Initialize cond. attribute variable */
    00507 #define TRACE_RTAI_EV_POSIX_PTHREAD_CONDATTR_DESTROY     40  /* Destroy cond. attribute variable */
    00508 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_WAIT            41  /* Wait for cond. variable to be signaled */
    00509 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_TIMEDWAIT       42  /* Wait for a certain time */
    00510 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_SIGNAL          43  /* Signal a waiting thread */
    00511 #define TRACE_RTAI_EV_POSIX_PTHREAD_COND_BROADCAST       44  /* Signal all waiting threads */
    00512 typedef struct _trace_rtai_posix
    00513 {
    00514   uint8_t   event_sub_id;  /* POSIX event ID */
    00515   uint32_t  event_data1;   /* Event data 1 */
    00516   uint32_t  event_data2;   /* Event data 2 */
    00517   uint32_t  event_data3;   /* Event data 3 */
    00518 } LTT_PACKED_STRUCT trace_rtai_posix;
    00519 #define TRACE_RTAI_POSIX(ID, DATA1, DATA2, DATA3) \
    00520            do \
    00521            {\
    00522            trace_rtai_posix posix_event; \
    00523            posix_event.event_sub_id = (uint8_t)  ID; \
    00524            posix_event.event_data1  = (uint32_t) DATA1; \
    00525            posix_event.event_data2  = (uint32_t) DATA2; \
    00526            posix_event.event_data3  = (uint32_t) DATA3; \
    00527            rt_trace_event(TRACE_RTAI_EV_POSIX, &posix_event); \
    00528            } while(0)
    00529
    00530 /*  TRACE_RTAI_LXRT */
    00531 #define TRACE_RTAI_EV_LXRT_RTAI_SYSCALL_ENTRY             1  /* Entry in LXRT syscall */
    00532 #define TRACE_RTAI_EV_LXRT_RTAI_SYSCALL_EXIT              2  /* Exit from LXRT syscall */
    00533 #define TRACE_RTAI_EV_LXCHANGE                   3  /* Scheduling change */
    00534 #define TRACE_RTAI_EV_LXRT_STEAL_TASK                     4  /* Take task control from Linux */
    00535 #define TRACE_RTAI_EV_LXRT_GIVE_BACK_TASK                 5  /* Give task control back to Linux */
    00536 #define TRACE_RTAI_EV_LXRT_SUSPEND                        6  /* Suspend a task */
    00537 #define TRACE_RTAI_EV_LXRT_RESUME                         7  /* Resume task's execution */
    00538 #define TRACE_RTAI_EV_LXRT_HANDLE                         8  /* Handle a request for an RTAI service */
    00539 typedef struct _trace_rtai_lxrt
    00540 {
    00541   uint8_t   event_sub_id;  /* LXRT event ID */
    00542   uint32_t  event_data1;   /* Event data 1 */
    00543   uint32_t  event_data2;   /* Event data 2 */
    00544   uint32_t  event_data3;   /* Event data 3 */
    00545 } LTT_PACKED_STRUCT trace_rtai_lxrt;
    00546 #define TRACE_RTAI_LXRT(ID, DATA1, DATA2, DATA3) \
    00547            do \
    00548            {\
    00549            trace_rtai_lxrt lxrt_event; \
    00550            lxrt_event.event_sub_id = (uint8_t)  ID; \
    00551            lxrt_event.event_data1  = (uint32_t) DATA1; \
    00552            lxrt_event.event_data2  = (uint32_t) DATA2; \
    00553            lxrt_event.event_data3  = (uint32_t) DATA3; \
    00554            rt_trace_event(TRACE_RTAI_EV_LXRT, &lxrt_event); \
    00555            } while(0)
    00556
    00557 /*  TRACE_RTAI_LXRTI */
    00558 #define TRACE_RTAI_EV_LXRTI_NAME_ATTACH                    1  /* Register current process as name */
    00559 #define TRACE_RTAI_EV_LXRTI_NAME_LOCATE                    2  /* Locate a given process usint it's name */
    00560 #define TRACE_RTAI_EV_LXRTI_NAME_DETACH                    3  /* Detach process from name */
    00561 #define TRACE_RTAI_EV_LXRTI_SEND                           4  /* Send message to PID */
    00562 #define TRACE_RTAI_EV_LXRTI_RECV                           5  /* Receive message */
    00563 #define TRACE_RTAI_EV_LXRTI_CRECV                          6  /* Non-blocking receive */
    00564 #define TRACE_RTAI_EV_LXRTI_REPLY                          7  /* Reply to message received */
    00565 #define TRACE_RTAI_EV_LXRTI_PROXY_ATTACH                   8  /* Attach proxy to process */
    00566 #define TRACE_RTAI_EV_LXRTI_PROXY_DETACH                   9  /* Detach proxy from process */
    00567 #define TRACE_RTAI_EV_LXRTI_TRIGGER                       10  /* Trigger proxy */
    00568 typedef struct _trace_rtai_lxrti
    00569 {
    00570   uint8_t   event_sub_id;  /* LXRT event ID */
    00571   uint32_t  event_data1;   /* Event data 1 */
    00572   uint32_t  event_data2;   /* Event data 2 */
    00573   uint64_t  event_data3;   /* Event data 3 */
    00574 } LTT_PACKED_STRUCT trace_rtai_lxrti;
    00575 #define TRACE_RTAI_LXRTI(ID, DATA1, DATA2, DATA3) \
    00576            do \
    00577            {\
    00578            trace_rtai_lxrti lxrti_event; \
    00579            lxrti_event.event_sub_id = (uint8_t)  ID; \
    00580            lxrti_event.event_data1  = (uint32_t) DATA1; \
    00581            lxrti_event.event_data2  = (uint32_t) DATA2; \
    00582            lxrti_event.event_data3  = (uint64_t) DATA3; \
    00583            rt_trace_event(TRACE_RTAI_EV_LXRTI, &lxrti_event); \
    00584            } while(0)
    00585
    00586 #else /* !(CONFIG_RTAI_TRACE && __KERNEL__) */
    00587 #define RT_TRACE_EVENT(ID, DATA)
    00588 #define TRACE_RTAI_MOUNT()
    00589 #define TRACE_RTAI_UMOUNT()
    00590 #define TRACE_RTAI_GLOBAL_IRQ_ENTRY(ID,X)
    00591 #define TRACE_RTAI_GLOBAL_IRQ_EXIT()
    00592 #define TRACE_RTAI_OWN_IRQ_ENTRY(ID)
    00593 #define TRACE_RTAI_OWN_IRQ_EXIT()
    00594 #define TRACE_RTAI_TRAP_ENTRY(ID,ADDR)
    00595 #define TRACE_RTAI_TRAP_EXIT()
    00596 #if CONFIG_PPC || CONFIG_ARM
    00597 #define TRACE_RTAI_SRQ_ENTRY(ID,KERNEL)
    00598 #else
    00599 #define TRACE_RTAI_SRQ_ENTRY(a)
    00600 #endif
    00601 #define TRACE_RTAI_SRQ_EXIT()
    00602 #define TRACE_RTAI_SWITCHTO_LINUX(ID)
    00603 #define TRACE_RTAI_SWITCHTO_RT(ID)
    00604 #define TRACE_RTAI_SCHED_CHANGE(OUT, IN, OUT_STATE)
    00605 #define TRACE_RTAI_TASK(ID, DATA1, DATA2, DATA3)
    00606 #define TRACE_RTAI_TIMER(ID, DATA1, DATA2)
    00607 #define TRACE_RTAI_SEM(ID, DATA1, DATA2)
    00608 #define TRACE_RTAI_MSG(ID, DATA1, DATA2, DATA3)
    00609 #define TRACE_RTAI_RPC(ID, DATA1, DATA2, DATA3)
    00610 #define TRACE_RTAI_MBX(ID, DATA1, DATA2, DATA3)
    00611 #define TRACE_RTAI_FIFO(ID, DATA1, DATA2)
    00612 #define TRACE_RTAI_SHM(ID, DATA1, DATA2, DATA3)
    00613 #define TRACE_RTAI_POSIX(ID, DATA1, DATA2, DATA3)
    00614 #define TRACE_RTAI_LXRT(ID, DATA1, DATA2, DATA3)
    00615 #define TRACE_RTAI_LXRTI(ID, DATA1, DATA2, DATA3)
    00616 #endif /* CONFIG_RTAI_TRACE && __KERNEL__ */
    00617
    00618 #endif /* !_RTAI_TRACE_H */