Home | History | Annotate | Download | only in utils
      1 /*
      2  * bmtrace_api.h
      3  *
      4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 
     35 /** \file   bmtrace_api.h
     36  *  \brief  bmtrace performance tracing module API definition
     37  *
     38  *  \see    bmtrace.c
     39  */
     40 
     41 #ifndef __BM_TRACE_API_H
     42 #define __BM_TRACE_API_H
     43 
     44 void            bm_enable(void);
     45 void            bm_disable(void);
     46 unsigned long   bm_act_trace_in(void);
     47 void            bm_act_trace_out(int loc, unsigned long in_ts);
     48 int             bm_act_register_event(char* module, char* context, char* group, unsigned char level, char* name, char* suffix, int is_param);
     49 void            bm_init(void);
     50 int             print_out_buffer(char *buf);
     51 
     52 
     53 #ifdef TIWLAN_BMTRACE
     54 #define TIWLAN_CLT_LEVEL 1
     55 #else
     56 #define TIWLAN_CLT_LEVEL 0
     57 #endif
     58 
     59 #define CL_TRACE_START() \
     60 	unsigned long in_ts = bm_act_trace_in();
     61 
     62 #define CL_TRACE_RESTART_Lx() \
     63 	in_ts = bm_act_trace_in();
     64 
     65 #define CL_TRACE_END(MODULE, CONTEXT, GROUP, LEVEL, SUFFIX) \
     66 	{ \
     67 		static int loc = 0; \
     68 		if (loc==0) \
     69 			loc = bm_act_register_event(MODULE, CONTEXT, GROUP, LEVEL, (char*)__FUNCTION__, SUFFIX, 0); \
     70 		bm_act_trace_out(loc, in_ts); \
     71 	}
     72 
     73 	#define CL_TRACE_START_L0() CL_TRACE_START()
     74 	#define CL_TRACE_END_L0() CL_TRACE_END("KERNEL", "SYS_CALL", "PLATFORM_TEST", 0, "")
     75 
     76 #if TIWLAN_CLT_LEVEL == 1
     77     #define CL_TRACE_INIT()     bm_init()
     78     #define CL_TRACE_ENABLE()   bm_enable()
     79     #define CL_TRACE_DISABLE()  bm_disable()
     80     #define CL_TRACE_PRINT(buf) print_out_buffer(buf)
     81 	#define CL_TRACE_START_L1() CL_TRACE_START()
     82 	#define CL_TRACE_START_L2()
     83 	#define CL_TRACE_START_L3()
     84 	#define CL_TRACE_START_L4()
     85 	#define CL_TRACE_START_L5()
     86     #define CL_TRACE_RESTART()  CL_TRACE_RESTART_Lx()
     87 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 1, SUFFIX)
     88 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX)
     89 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX)
     90 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX)
     91 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX)
     92 #elif TIWLAN_CLT_LEVEL == 2
     93     #define CL_TRACE_INIT()     bm_init()
     94     #define CL_TRACE_ENABLE()   bm_enable()
     95     #define CL_TRACE_DISABLE()  bm_disable()
     96     #define CL_TRACE_PRINT(buf) print_out_buffer(buf)
     97 	#define CL_TRACE_START_L1() CL_TRACE_START()
     98 	#define CL_TRACE_START_L2() CL_TRACE_START()
     99 	#define CL_TRACE_START_L3()
    100 	#define CL_TRACE_START_L4()
    101 	#define CL_TRACE_START_L5()
    102     #define CL_TRACE_RESTART()  CL_TRACE_RESTART_Lx()
    103 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 1, SUFFIX)
    104 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 2, SUFFIX)
    105 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX)
    106 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX)
    107 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX)
    108 #elif TIWLAN_CLT_LEVEL == 3
    109     #define CL_TRACE_INIT()     bm_init()
    110     #define CL_TRACE_ENABLE()   bm_enable()
    111     #define CL_TRACE_DISABLE()  bm_disable()
    112     #define CL_TRACE_PRINT(buf) print_out_buffer(buf)
    113 	#define CL_TRACE_START_L1() CL_TRACE_START()
    114 	#define CL_TRACE_START_L2() CL_TRACE_START()
    115 	#define CL_TRACE_START_L3() CL_TRACE_START()
    116 	#define CL_TRACE_START_L4()
    117 	#define CL_TRACE_START_L5()
    118     #define CL_TRACE_RESTART()  CL_TRACE_RESTART_Lx()
    119 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 1, SUFFIX)
    120 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 2, SUFFIX)
    121 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 3, SUFFIX)
    122 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX)
    123 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX)
    124 #elif TIWLAN_CLT_LEVEL == 4
    125     #define CL_TRACE_INIT()     bm_init()
    126     #define CL_TRACE_ENABLE()   bm_enable()
    127     #define CL_TRACE_DISABLE()  bm_disable()
    128     #define CL_TRACE_PRINT(buf) print_out_buffer(buf)
    129 	#define CL_TRACE_START_L1() CL_TRACE_START()
    130 	#define CL_TRACE_START_L2() CL_TRACE_START()
    131 	#define CL_TRACE_START_L3() CL_TRACE_START()
    132 	#define CL_TRACE_START_L4() CL_TRACE_START()
    133 	#define CL_TRACE_START_L5()
    134     #define CL_TRACE_RESTART()  CL_TRACE_RESTART_Lx()
    135 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 1, SUFFIX)
    136 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 2, SUFFIX)
    137 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 3, SUFFIX)
    138 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 4, SUFFIX)
    139 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX)
    140 #elif TIWLAN_CLT_LEVEL == 5
    141     #define CL_TRACE_INIT()     bm_init()
    142     #define CL_TRACE_ENABLE()   bm_enable()
    143     #define CL_TRACE_DISABLE()  bm_disable()
    144     #define CL_TRACE_PRINT(buf) print_out_buffer(buf)
    145 	#define CL_TRACE_START_L1() CL_TRACE_START()
    146 	#define CL_TRACE_START_L1() CL_TRACE_START()
    147 	#define CL_TRACE_START_L2() CL_TRACE_START()
    148 	#define CL_TRACE_START_L3() CL_TRACE_START()
    149 	#define CL_TRACE_START_L4() CL_TRACE_START()
    150 	#define CL_TRACE_START_L5() CL_TRACE_START()
    151     #define CL_TRACE_RESTART()  CL_TRACE_RESTART_Lx()
    152 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 1, SUFFIX)
    153 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 2, SUFFIX)
    154 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 3, SUFFIX)
    155 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 4, SUFFIX)
    156 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX) CL_TRACE_END(MODULE, CONTEXT, GROUP, 5, SUFFIX)
    157 #else
    158     #define CL_TRACE_INIT()
    159     #define CL_TRACE_ENABLE()
    160     #define CL_TRACE_DISABLE()
    161     #define CL_TRACE_RESTART()
    162     #define CL_TRACE_PRINT(buf)
    163 	#define CL_TRACE_START_L1()
    164 	#define CL_TRACE_START_L1()
    165 	#define CL_TRACE_START_L2()
    166 	#define CL_TRACE_START_L3()
    167 	#define CL_TRACE_START_L4()
    168 	#define CL_TRACE_START_L5()
    169 	#define CL_TRACE_END_L1(MODULE, CONTEXT, GROUP, SUFFIX)
    170 	#define CL_TRACE_END_L2(MODULE, CONTEXT, GROUP, SUFFIX)
    171 	#define CL_TRACE_END_L3(MODULE, CONTEXT, GROUP, SUFFIX)
    172 	#define CL_TRACE_END_L4(MODULE, CONTEXT, GROUP, SUFFIX)
    173 	#define CL_TRACE_END_L5(MODULE, CONTEXT, GROUP, SUFFIX)
    174 #endif
    175 
    176 
    177 #endif /* __BM_TRACE_API_H */
    178