RKH
rkhtrc_filter.h
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
38 /* -------------------------- Development history -------------------------- */
39 /*
40  * 2017.04.15 LeFr v2.4.05 Initial version
41  */
42 
43 /* -------------------------------- Authors -------------------------------- */
44 /*
45  * LeFr Leandro Francucci francuccilea@gmail.com
46  */
47 
48 /* --------------------------------- Notes --------------------------------- */
49 /* --------------------------------- Module -------------------------------- */
50 #ifndef __RKHTRC_FILTER_H__
51 #define __RKHTRC_FILTER_H__
52 
53 /* ----------------------------- Include files ----------------------------- */
54 #include "rkhtrc_define.h"
55 
56 /* ---------------------- External C language linkage ---------------------- */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* --------------------------------- Macros -------------------------------- */
62 #if RKH_CFG_TRC_EN == RKH_ENABLED && RKH_CFG_TRC_RTFIL_EN == RKH_ENABLED
63 
70  #define RKH_FILTER_ON_GROUP(grp) \
71  rkh_trc_filter_group_(FILTER_ON, (grp), EUNCHANGE)
72 
80  #define RKH_FILTER_OFF_GROUP(grp) \
81  rkh_trc_filter_group_(FILTER_OFF, (grp), EUNCHANGE)
82 
90  #define RKH_FILTER_ON_EVENT(evt) \
91  rkh_trc_filter_event_(FILTER_ON, (evt))
92 
103  #define RKH_FILTER_OFF_EVENT(evt) \
104  rkh_trc_filter_event_(FILTER_OFF, (evt))
105 
112  #define RKH_FILTER_ON_GROUP_ALL_EVENTS(grp) \
113  rkh_trc_filter_group_(FILTER_ON, (grp), ECHANGE)
114 
124  #define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp) \
125  rkh_trc_filter_group_(FILTER_OFF, (grp), ECHANGE)
126 
127  #if RKH_CFG_TRC_RTFIL_SMA_EN == RKH_ENABLED
128 
136  #define RKH_FILTER_ON_SMA(sma) \
137  rkh_trc_symFil(RKHFilterSma, RKH_SMA_ACCESS_CONST(sma, prio), \
138  FILTER_ON)
139 
146  #define RKH_FILTER_ON_ALL_SMA() \
147  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_ON))
148 
156  #define RKH_FILTER_OFF_SMA(sma) \
157  rkh_trc_symFil(RKHFilterSma, RKH_SMA_ACCESS_CONST(sma, prio), \
158  FILTER_OFF)
159 
166  #define RKH_FILTER_OFF_ALL_SMA() \
167  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_OFF))
168 
169  #else
170  #define RKH_FILTER_ON_SMA(sma) (void)0
171  #define RKH_FILTER_ON_ALL_SMA() (void)0
172  #define RKH_FILTER_OFF_SMA(sma) (void)0
173  #define RKH_FILTER_OFF_ALL_SMA() (void)0
174  #endif
175 
176  #if RKH_CFG_TRC_RTFIL_SIGNAL_EN == RKH_ENABLED
177 
184  #define RKH_FILTER_ON_SIGNAL(sig) \
185  rkh_trc_symFil(RKHFilterSignal, (sig), FILTER_ON)
186 
193  #define RKH_FILTER_ON_ALL_SIGNALS() \
194  rkh_trc_symFil(RKHFilterSignal, 0, RKH_TRC_SET_ALL(FILTER_ON))
195 
203  #define RKH_FILTER_OFF_SIGNAL(sig) \
204  rkh_trc_symFil(RKHFilterSignal, (sig), FILTER_OFF)
205 
212  #define RKH_FILTER_OFF_ALL_SIGNALS() \
213  rkh_trc_symFil(RKHFilterSignal, 0, RKH_TRC_SET_ALL(FILTER_OFF))
214  #else
215  #define RKH_FILTER_ON_SIGNAL(sig) (void)0
216  #define RKH_FILTER_ON_ALL_SIGNALS() (void)0
217  #define RKH_FILTER_OFF_SIGNAL(sig) (void)0
218  #define RKH_FILTER_OFF_ALL_SIGNALS() (void)0
219  #endif
220 #else
221  #define RKH_FILTER_ON_GROUP(grp) (void)0
222  #define RKH_FILTER_OFF_GROUP(grp) (void)0
223  #define RKH_FILTER_ON_EVENT(evt) (void)0
224  #define RKH_FILTER_OFF_EVENT(evt) (void)0
225  #define RKH_FILTER_ON_GROUP_ALL_EVENTS(grp) (void)0
226  #define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp) (void)0
227  #define RKH_FILTER_ON_SMA(sma) (void)0
228  #define RKH_FILTER_ON_ALL_SMA() (void)0
229  #define RKH_FILTER_OFF_SMA(sma) (void)0
230  #define RKH_FILTER_OFF_ALL_SMA() (void)0
231  #define RKH_FILTER_ON_SIGNAL(sig) (void)0
232  #define RKH_FILTER_ON_ALL_SIGNALS() (void)0
233  #define RKH_FILTER_OFF_SIGNAL(sig) (void)0
234  #define RKH_FILTER_OFF_ALL_SIGNALS() (void)0
235 #endif
236 
237 /* -------------------------------- Constants ------------------------------ */
238 /* ------------------------------- Data types ------------------------------ */
243 #if RKH_TRC_MAX_SMA > RKH_TRC_MAX_SIGNALS
244  #if (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(8)
245  typedef rui8_t RKH_TRC_FSLOT;
246  #elif (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(16)
247  typedef rui16_t RKH_TRC_FSLOT;
248  #elif (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(32)
249  typedef rui32_t RKH_TRC_FSLOT;
250  #else
251  typedef rui8_t RKH_TRC_FSLOT;
252  #endif
253 #else
254  #if (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(8)
255  typedef rui8_t RKH_TRC_FSLOT;
256  #elif (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(16)
257  typedef rui16_t RKH_TRC_FSLOT;
258  #elif (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(32)
259  typedef rui32_t RKH_TRC_FSLOT;
260  #else
261  typedef rui8_t RKH_TRC_FSLOT;
262  #endif
263 #endif
264 
269 typedef struct RKH_TRC_FIL_T
270 {
271  RKH_TRC_FSLOT size;
272  rui8_t *const tbl;
273 } RKH_TRC_FIL_T;
274 
275 typedef enum
276 {
277  FILTER_ON, FILTER_OFF
278 } RKH_TRC_FOPT;
279 
280 typedef enum RKHFilter
281 {
282  RKHFilterTrcEvt, RKHFilterSignal, RKHFilterSma,
283  RKHFilterNums
284 } RKHFilter;
285 
286 typedef struct RKH_FilterTbl
287 {
288  const RKH_TRC_FIL_T *signal;
289  const RKH_TRC_FIL_T *ao;
290  rui8_t *event;
291  rui8_t *group;
292  const RKH_GMTBL_T *grpFilMap;
293 } RKH_FilterTbl;
294 
295 /* -------------------------- External variables --------------------------- */
296 /* -------------------------- Function prototypes -------------------------- */
338 void rkh_trc_filter_group_(rui8_t ctrl, RKH_TG_T grp, rui8_t mode);
339 
382 void rkh_trc_filter_event_(rui8_t ctrl, RKH_TE_ID_T evt);
383 
399 rbool_t rkh_trc_isoff_(RKH_TE_ID_T e);
400 
416 void rkh_trc_symFil(RKHFilter fd, RKH_TRC_FSLOT slot, rui8_t mode);
417 
433 rbool_t rkh_trc_symFil_isoff(RKHFilter fd, RKH_TRC_FSLOT slot);
434 
441 void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl);
442 
443 /* -------------------- External C language linkage end -------------------- */
444 #ifdef __cplusplus
445 }
446 #endif
447 
448 /* ------------------------------ Module end ------------------------------- */
449 #endif
450 
451 /* ------------------------------ End of file ------------------------------ */
Defines constants and macros which are internally used by RKH trace facility.
void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl)
Get a memory reference to every trace filter table.
Represents the filter of signal and active object.
void rkh_trc_filter_group_(rui8_t ctrl, RKH_TG_T grp, rui8_t mode)
Emit or suppress all trace events from a specific group.
void rkh_trc_symFil(RKHFilter fd, RKH_TRC_FSLOT slot, rui8_t mode)
Emmit or suppresse trace events related to a particular active object or event signal.
rui8_t RKH_TE_ID_T
Describes a trace event identification (ID).
rui8_t RKH_TG_T
Group of events.
void rkh_trc_filter_event_(rui8_t ctrl, RKH_TE_ID_T evt)
Emit or suppress a specific event.
rbool_t rkh_trc_symFil_isoff(RKHFilter fd, RKH_TRC_FSLOT slot)
Test the active objecto or signal filter condition.
rui8_t *const tbl
rui8_t RKH_TRC_FSLOT
This data type defines the size of filter table for AO and signals.
rbool_t rkh_trc_isoff_(RKH_TE_ID_T e)
Test the group and event filter condition.