]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ferret/include/sensors/list_producer_wrap.h
Update
[l4.git] / l4 / pkg / ferret / include / sensors / list_producer_wrap.h
1 /**
2  * \file   ferret/include/sensors/list_producer_wrap.h
3  * \brief  Convenience wrapper functions for creating events
4  *
5  * \date   2006-06-13
6  * \author Martin Pohlack  <mp26@os.inf.tu-dresden.de>
7  */
8 /*
9  * (c) 2006-2009 Technische Universität Dresden
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  */
14 #ifndef __FERRET_INCLUDE_SENSORS_LIST_PRODUCER_WRAP_H_
15 #define __FERRET_INCLUDE_SENSORS_LIST_PRODUCER_WRAP_H_
16
17 #include <l4/sys/compiler.h>
18 #include <l4/ferret/sensors/list.h>
19 #include <l4/ferret/sensors/list_producer.h>
20
21 EXTERN_C_BEGIN
22
23 /**********************************************************************
24  * Declarations
25  **********************************************************************/
26
27 /**********************************************************************
28  * Basic event poster functions
29  **********************************************************************/
30
31 #define FERRET_POST_sig(a, b...)                                          \
32 L4_INLINE void                                                            \
33 ferret_list_post##a(ferret_list_local_t * l, uint16_t maj, uint16_t min,  \
34                     uint16_t instance, b)
35
36 L4_INLINE void
37 ferret_list_post(ferret_list_local_t * l, uint16_t maj, uint16_t min,
38                  uint16_t instance);
39
40 FERRET_POST_sig(_1w, uint32_t d0);
41 FERRET_POST_sig(_2w, uint32_t d0, uint32_t d1);
42 FERRET_POST_sig(_3w, uint32_t d0, uint32_t d1, uint32_t d2);
43 FERRET_POST_sig(_4w, uint32_t d0, uint32_t d1, uint32_t d2, uint32_t d3);
44
45 /* No special handling for thread IDs anymore -- there _are_ non in Re. */
46 #if 0
47 FERRET_POST_sig(_1t,   l4_threadid_t t);
48 FERRET_POST_sig(_1t1w, l4_threadid_t t, uint32_t d0);
49 FERRET_POST_sig(_1t2w, l4_threadid_t t, uint32_t d0, uint32_t d1);
50 FERRET_POST_sig(_1t3w, l4_threadid_t t, uint32_t d0, uint32_t d1, uint32_t d2);
51 FERRET_POST_sig(_1t4w, l4_threadid_t t, uint32_t d0, uint32_t d1, uint32_t d2,
52                 uint32_t d3);
53 #endif
54
55 /**********************************************************************
56  * Experimental stuff
57  **********************************************************************/
58
59 #define FERRET_POSTX_sig(a, b...)                                         \
60 L4_INLINE void                                                            \
61 ferret_list_postX##a(ferret_list_local_t * l, uint32_t maj_min,           \
62                      uint16_t instance, b)
63
64 FERRET_POSTX_sig(_2w, uint32_t d0, uint32_t d1);
65
66 /**********************************************************************
67  * Conditional macros: here you can dynamically activate / deactivate
68  * logging
69  **********************************************************************/
70
71 #define FERRET_POST_sigc_body(n, a, b...)                                 \
72     do                                                                    \
73     {                                                                     \
74         if (a)                                                            \
75         {                                                                 \
76             ferret_list_post##n(b);                                       \
77         }                                                                 \
78     } while (0)
79
80 #define ferret_list_post_c(a, b...)   FERRET_POST_sigc_body(   , a, b)
81 #define ferret_list_post_1wc(a, b...) FERRET_POST_sigc_body(_1w, a, b)
82 #define ferret_list_post_2wc(a, b...) FERRET_POST_sigc_body(_2w, a, b)
83 #define ferret_list_post_3wc(a, b...) FERRET_POST_sigc_body(_3w, a, b)
84 #define ferret_list_post_4wc(a, b...) FERRET_POST_sigc_body(_4w, a, b)
85
86 #if 0
87 #define ferret_list_post_1tc(a, b...)   FERRET_POST_sigc_body(_1t  , a, b)
88 #define ferret_list_post_1t1wc(a, b...) FERRET_POST_sigc_body(_1t1w, a, b)
89 #define ferret_list_post_1t2wc(a, b...) FERRET_POST_sigc_body(_1t2w, a, b)
90 #define ferret_list_post_1t3wc(a, b...) FERRET_POST_sigc_body(_1t3w, a, b)
91 #define ferret_list_post_1t4wc(a, b...) FERRET_POST_sigc_body(_1t4w, a, b)
92 #endif
93
94 /**********************************************************************
95  * Implementations
96  **********************************************************************/
97
98 #define FERRET_POST_begin                                                 \
99 {                                                                         \
100     int index;                                                            \
101     ferret_list_entry_common_t * elc;                                     \
102                                                                           \
103     index = ferret_list_dequeue(l);                                       \
104     elc = (ferret_list_entry_common_t *)ferret_list_e4i(l->glob, index);  \
105     elc->major     = maj;                                                 \
106     elc->minor     = min;                                                 \
107     elc->instance  = instance;                                            \
108     elc->cpu       = 0;  // fixme
109
110 #define FERRET_POSTX_begin                                                \
111 {                                                                         \
112     int index;                                                            \
113     ferret_list_entry_common_t * elc;                                     \
114                                                                           \
115     index = ferret_list_dequeue(l);                                       \
116     elc = (ferret_list_entry_common_t *)ferret_list_e4i(l->glob, index);  \
117     elc->maj_min   = maj_min;                                             \
118     elc->instance  = instance;                                            \
119     elc->cpu       = 0;  // fixme
120
121 #define FERRET_POST_end                                                   \
122     ferret_list_commit(l, index);                                         \
123 }
124
125 #define FERRET_POST_assign_1w(o)                                          \
126     elc->data32[0 + (o)] = d0;
127
128 #define FERRET_POST_assign_2w(o)                                          \
129     elc->data32[0 + (o)] = d0;                                            \
130     elc->data32[1 + (o)] = d1;
131
132 #define FERRET_POST_assign_3w(o)                                          \
133     elc->data32[0 + (o)] = d0;                                            \
134     elc->data32[1 + (o)] = d1;                                            \
135     elc->data32[2 + (o)] = d2;
136
137 #define FERRET_POST_assign_4w(o)                                          \
138     elc->data32[0 + (o)] = d0;                                            \
139     elc->data32[1 + (o)] = d1;                                            \
140     elc->data32[2 + (o)] = d2;                                            \
141     elc->data32[3 + (o)] = d3;
142
143 #if 0
144 #define FERRET_POST_assign_1t                                             \
145     elc->data64[0] = t.raw;
146 #endif
147
148
149 L4_INLINE void
150 ferret_list_post(ferret_list_local_t * l, uint16_t maj, uint16_t min,
151                  uint16_t instance)
152 FERRET_POST_begin
153 FERRET_POST_end
154
155 FERRET_POST_sig(_1w, uint32_t d0)
156 FERRET_POST_begin
157 FERRET_POST_assign_1w(0)
158 FERRET_POST_end
159
160 FERRET_POST_sig(_2w, uint32_t d0, uint32_t d1)
161 FERRET_POST_begin
162 FERRET_POST_assign_2w(0)
163 FERRET_POST_end
164
165 FERRET_POSTX_sig(_2w, uint32_t d0, uint32_t d1)
166 FERRET_POSTX_begin
167 FERRET_POST_assign_2w(0)
168 FERRET_POST_end
169
170 FERRET_POST_sig(_3w, uint32_t d0, uint32_t d1, uint32_t d2)
171 FERRET_POST_begin
172 FERRET_POST_assign_3w(0)
173 FERRET_POST_end
174
175 FERRET_POST_sig(_4w, uint32_t d0, uint32_t d1, uint32_t d2, uint32_t d3)
176 FERRET_POST_begin
177 FERRET_POST_assign_4w(0)
178 FERRET_POST_end
179
180 #if 0
181 FERRET_POST_sig(_1t, l4_threadid_t t)
182 FERRET_POST_begin
183 FERRET_POST_assign_1t
184 FERRET_POST_end
185
186 FERRET_POST_sig(_1t1w, l4_threadid_t t, uint32_t d0)
187 FERRET_POST_begin
188 FERRET_POST_assign_1t
189 FERRET_POST_assign_1w(1)
190 FERRET_POST_end
191
192 FERRET_POST_sig(_1t2w, l4_threadid_t t, uint32_t d0, uint32_t d1)
193 FERRET_POST_begin
194 FERRET_POST_assign_1t
195 FERRET_POST_assign_2w(1)
196 FERRET_POST_end
197
198 FERRET_POST_sig(_1t3w, l4_threadid_t t, uint32_t d0, uint32_t d1, uint32_t d2)
199 FERRET_POST_begin
200 FERRET_POST_assign_1t
201 FERRET_POST_assign_3w(1)
202 FERRET_POST_end
203
204 FERRET_POST_sig(_1t4w, l4_threadid_t t, uint32_t d0, uint32_t d1, uint32_t d2,
205                 uint32_t d3)
206 FERRET_POST_begin
207 FERRET_POST_assign_1t
208 FERRET_POST_assign_4w(1)
209 FERRET_POST_end
210 #endif
211
212 // cleanup namespace
213 #undef FERRET_POST_sig
214 #undef FERRET_POSTX_sig
215 #undef FERRET_POST_begin
216 #undef FERRET_POSTX_begin
217 #undef FERRET_POST_end
218 #undef FERRET_POST_assign_1w
219 #undef FERRET_POST_assign_2w
220 #undef FERRET_POSTX_assign_2w
221 #undef FERRET_POST_assign_3w
222 #undef FERRET_POST_assign_4w
223 #undef FERRET_POST_assign_1t
224
225 EXTERN_C_END
226
227 #endif