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 site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
40 /* -------------------------- Development history -------------------------- */
41 /*
42  * 2017.04.15 LeFr v2.4.05 Initial version
43  */
44 
45 /* -------------------------------- Authors -------------------------------- */
46 /*
47  * LeFr Leandro Francucci lf@vortexmakes.com
48  */
49 
50 /* --------------------------------- Notes --------------------------------- */
51 /* --------------------------------- Module -------------------------------- */
52 #ifndef __RKHTRC_FILTER_H__
53 #define __RKHTRC_FILTER_H__
54 
55 /* ----------------------------- Include files ----------------------------- */
56 #include "rkhtrc_define.h"
57 
58 /* ---------------------- External C language linkage ---------------------- */
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* --------------------------------- Macros -------------------------------- */
64 #if RKH_CFG_TRC_EN == RKH_ENABLED && RKH_CFG_TRC_RTFIL_EN == RKH_ENABLED
72  #define RKH_FILTER_ON_GROUP(grp) \
73  rkh_trc_filter_group_(FILTER_ON, (grp), EUNCHANGE)
74 
82  #define RKH_FILTER_OFF_GROUP(grp) \
83  rkh_trc_filter_group_(FILTER_OFF, (grp), EUNCHANGE)
84 
92  #define RKH_FILTER_ON_EVENT(evt) \
93  rkh_trc_filter_event_(FILTER_ON, (evt))
94 
105  #define RKH_FILTER_OFF_EVENT(evt) \
106  rkh_trc_filter_event_(FILTER_OFF, (evt))
107 
114  #define RKH_FILTER_ON_GROUP_ALL_EVENTS(grp) \
115  rkh_trc_filter_group_(FILTER_ON, (grp), ECHANGE)
116 
126  #define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp) \
127  rkh_trc_filter_group_(FILTER_OFF, (grp), ECHANGE)
128 
129  #if RKH_CFG_TRC_RTFIL_SMA_EN == RKH_ENABLED
130 
138  #define RKH_FILTER_ON_SMA(sma) \
139  rkh_trc_symFil(RKHFilterSma, RKH_SMA_ACCESS_CONST(sma, prio), \
140  FILTER_ON)
141 
148  #define RKH_FILTER_ON_ALL_SMA() \
149  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_ON))
150 
158  #define RKH_FILTER_OFF_SMA(sma) \
159  rkh_trc_symFil(RKHFilterSma, RKH_SMA_ACCESS_CONST(sma, prio), \
160  FILTER_OFF)
161 
168  #define RKH_FILTER_OFF_ALL_SMA() \
169  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_OFF))
170 
171  #else
172  #define RKH_FILTER_ON_SMA(sma) (void)0
173  #define RKH_FILTER_ON_ALL_SMA() (void)0
174  #define RKH_FILTER_OFF_SMA(sma) (void)0
175  #define RKH_FILTER_OFF_ALL_SMA() (void)0
176  #endif
177 
178  #if RKH_CFG_TRC_RTFIL_SIGNAL_EN == RKH_ENABLED
186  #define RKH_FILTER_ON_SIGNAL(sig) \
187  rkh_trc_symFil(RKHFilterSignal, (sig), FILTER_ON)
188 
195  #define RKH_FILTER_ON_ALL_SIGNALS() \
196  rkh_trc_symFil(RKHFilterSignal, 0, RKH_TRC_SET_ALL(FILTER_ON))
197 
205  #define RKH_FILTER_OFF_SIGNAL(sig) \
206  rkh_trc_symFil(RKHFilterSignal, (sig), FILTER_OFF)
207 
214  #define RKH_FILTER_OFF_ALL_SIGNALS() \
215  rkh_trc_symFil(RKHFilterSignal, 0, RKH_TRC_SET_ALL(FILTER_OFF))
216  #else
217  #define RKH_FILTER_ON_SIGNAL(sig) (void)0
218  #define RKH_FILTER_ON_ALL_SIGNALS() (void)0
219  #define RKH_FILTER_OFF_SIGNAL(sig) (void)0
220  #define RKH_FILTER_OFF_ALL_SIGNALS() (void)0
221  #endif
222 #else
223  #define RKH_FILTER_ON_GROUP(grp) (void)0
224  #define RKH_FILTER_OFF_GROUP(grp) (void)0
225  #define RKH_FILTER_ON_EVENT(evt) (void)0
226  #define RKH_FILTER_OFF_EVENT(evt) (void)0
227  #define RKH_FILTER_ON_GROUP_ALL_EVENTS(grp) (void)0
228  #define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp) (void)0
229  #define RKH_FILTER_ON_SMA(sma) (void)0
230  #define RKH_FILTER_ON_ALL_SMA() (void)0
231  #define RKH_FILTER_OFF_SMA(sma) (void)0
232  #define RKH_FILTER_OFF_ALL_SMA() (void)0
233  #define RKH_FILTER_ON_SIGNAL(sig) (void)0
234  #define RKH_FILTER_ON_ALL_SIGNALS() (void)0
235  #define RKH_FILTER_OFF_SIGNAL(sig) (void)0
236  #define RKH_FILTER_OFF_ALL_SIGNALS() (void)0
237 #endif
238 
239 /* -------------------------------- Constants ------------------------------ */
240 /* ------------------------------- Data types ------------------------------ */
245 #if RKH_TRC_MAX_SMA > RKH_TRC_MAX_SIGNALS
246  #if (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(8)
247  typedef rui8_t RKH_TRC_FSLOT;
248  #elif (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(16)
249  typedef rui16_t RKH_TRC_FSLOT;
250  #elif (RKH_TRC_MAX_SMA * 8) <= RKH_BIT(32)
251  typedef rui32_t RKH_TRC_FSLOT;
252  #else
253  typedef rui8_t RKH_TRC_FSLOT;
254  #endif
255 #else
256  #if (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(8)
257  typedef rui8_t RKH_TRC_FSLOT;
258  #elif (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(16)
259  typedef rui16_t RKH_TRC_FSLOT;
260  #elif (RKH_TRC_MAX_SIGNALS * 8) <= RKH_BIT(32)
261  typedef rui32_t RKH_TRC_FSLOT;
262  #else
263  typedef rui8_t RKH_TRC_FSLOT;
264  #endif
265 #endif
266 
271 typedef struct RKH_TRC_FIL_T
272 {
273  RKH_TRC_FSLOT size;
274  rui8_t *const tbl;
275 } RKH_TRC_FIL_T;
276 
277 typedef enum
278 {
279  FILTER_ON, FILTER_OFF
280 } RKH_TRC_FOPT;
281 
282 typedef enum RKHFilter
283 {
284  RKHFilterTrcEvt, RKHFilterSignal, RKHFilterSma,
285  RKHFilterNums
286 } RKHFilter;
287 
288 typedef struct RKH_FilterTbl
289 {
290  const RKH_TRC_FIL_T *signal;
291  const RKH_TRC_FIL_T *ao;
292  rui8_t *event;
293  rui8_t *group;
294  const RKH_GMTBL_T *grpFilMap;
295 } RKH_FilterTbl;
296 
297 /* -------------------------- External variables --------------------------- */
298 /* -------------------------- Function prototypes -------------------------- */
340 void rkh_trc_filter_group_(rui8_t ctrl, RKH_TG_T grp, rui8_t mode);
341 
384 void rkh_trc_filter_event_(rui8_t ctrl, RKH_TE_ID_T evt);
385 
402 
418 void rkh_trc_symFil(RKHFilter fd, RKH_TRC_FSLOT slot, rui8_t mode);
419 
435 rbool_t rkh_trc_symFil_isoff(RKHFilter fd, RKH_TRC_FSLOT slot);
436 
443 void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl);
444 
445 /* -------------------- External C language linkage end -------------------- */
446 #ifdef __cplusplus
447 }
448 #endif
449 
450 /* ------------------------------ Module end ------------------------------- */
451 #endif
452 
453 /* ------------------------------ End of file ------------------------------ */
Defines constants and macros which are internally used by RKH trace facility.
rui8_t RKH_TG_T
Group of events.
rui8_t RKH_TE_ID_T
Describes a trace event identification (ID).
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_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.
rbool_t rkh_trc_isoff_(RKH_TE_ID_T e)
Test the group and event filter condition.
void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl)
Get a memory reference to every trace filter table.
rui8_t RKH_TRC_FSLOT
This data type defines the size of filter table for AO and signals.
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.
Represents the filter of signal and active object.
rui8_t *const tbl