1 
2 /*
3  * Copyright (C) Texas Instruments - http://www.ti.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 /* NOTE: This header should be only included from perf_obj.h */
22 
23 /*=============================================================================
24     CUSTOMIZABLE INTERFACE
25 
26     If __PERF_CUSTOMIZABLE__ is defined, each PERF API is routed to a method
27     that can be customized (set) upon creation of the PERF object.
28 
29     Currently we support 3 customizable interfaces that can be each enabled or
30     disabled independently:
31         - logging into a buffer (default behavior)
32         - printing a message on STDOUT, STDERR or a file immediately at each
33           instrumentation point
34         - replaying logs from a file (this will repeat all the interface calls
35           as they happened in the log file, but the time stamps will be set from
36           the log file.  Currently, we do not allow logging a replayed session.
37 =============================================================================*/
38 
39 typedef struct PERF_Custom_Interface
40 {
41     /** Customizable PERF interfaces.  These correspond to the
42  *  __PERF and PERF macros */
43     void (*Boundary)(PERF_OBJHANDLE hObject,
44                      PERF_BOUNDARYTYPE eBoundary);
45 
46     void (*Buffer)(PERF_OBJHANDLE hObject,
47                    unsigned long ulAddress1,
48                    unsigned long ulAddress2,
49                    unsigned long ulSize,
50                    unsigned long ulModuleAndFlags);
51 
52     void (*Command)(PERF_OBJHANDLE hObject,
53                     unsigned long ulCommand,
54                     unsigned long ulArgument,
55                     unsigned long ulModuleAndFlags);
56 
57     void (*Log)(PERF_OBJHANDLE hObject,
58                 unsigned long ulData1,
59                 unsigned long ulData2,
60                 unsigned long ulData3);
61 
62     void (*SyncAV)(PERF_OBJHANDLE hObject,
63                    float fTimeAudio,
64                    float fTimeVideo,
65                    PERF_SYNCOPTYPE eSyncOperation);
66 
67     void (*ThreadCreated)(PERF_OBJHANDLE hObject,
68                           unsigned long ulThreadID,
69                           unsigned long ulThreadName);
70 #ifdef __PERF_LOG_LOCATION__
71     void (*Location)(PERF_OBJHANDLE hObject,
72                      char const *szFile,
73                      unsigned long ulLine,
74                      char const *szFunc);
75 #endif
76 } PERF_Custom_Interface;
77 
78 /** In the customizable instrumentation, each call will be
79  *  routed to the corresponding call as defined by the
80  *  instrumentation module. */
81 
82 #define __PERF_CUSTOM_Boundary(                \
83         hObject,                               \
84         eBoundary)                             \
85     PERF_check((hObject),                      \
86      ((PERF_OBJHANDLE)(hObject))->ci.Boundary( \
87         (PERF_OBJHANDLE)(hObject),             \
88         eBoundary) )  /* Macro End */
89 
90 #define __PERF_CUSTOM_Buffer(                                 \
91         hObject,                                              \
92         ulFlagSending,                                        \
93         ulFlagMultiple,                                       \
94         ulFlagFrame,                                          \
95         ulAddress1,                                           \
96         ulAddress2,                                           \
97         ulSize,                                               \
98         eModule1,                                             \
99         eModule2)                                             \
100     PERF_check((hObject),                                     \
101      ((PERF_OBJHANDLE)(hObject))->ci.Buffer(                  \
102         (PERF_OBJHANDLE)(hObject),                            \
103         ((unsigned long) (ulAddress1)),                       \
104         ((unsigned long) (ulAddress2)),                       \
105         ((unsigned long) (ulSize)),                           \
106         ((unsigned long) (eModule1)) |                        \
107         ( ((unsigned long) (eModule2)) << PERF_ModuleBits ) | \
108         (ulFlagSending) | (ulFlagMultiple) | (ulFlagFrame)) ) /* Macro End */
109 
110 #define __PERF_CUSTOM_Command(                \
111         hObject,                              \
112         ulFlagSending,                        \
113         ulCommand,                            \
114         ulArgument,                           \
115         eModule)                              \
116     PERF_check((hObject),                     \
117      ((PERF_OBJHANDLE)(hObject))->ci.Command( \
118         (PERF_OBJHANDLE)(hObject),            \
119         ((unsigned long) (ulCommand)),        \
120         ((unsigned long) (ulArgument)),       \
121         ((unsigned long) (eModule)) | (ulFlagSending)) ) /* Macro End */
122 
123 #define __PERF_CUSTOM_Log(                \
124         hObject,                          \
125         ulData1,                          \
126         ulData2,                          \
127         ulData3)                          \
128     PERF_check((hObject),                 \
129      ((PERF_OBJHANDLE)(hObject))->ci.Log( \
130         (PERF_OBJHANDLE)(hObject),        \
131         ((unsigned long) (ulData1)),      \
132         ((unsigned long) (ulData2)),      \
133         ((unsigned long) (ulData3)) ) ) /* Macro End */
134 
135 #define __PERF_CUSTOM_SyncAV(                \
136         hObject,                             \
137         fTimeAudio,                          \
138         fTimeVideo,                          \
139         eSyncOperation)                      \
140     PERF_check((hObject),                    \
141      ((PERF_OBJHANDLE)(hObject))->ci.SyncAV( \
142         (PERF_OBJHANDLE)(hObject),           \
143         fTimeAudio,                          \
144         fTimeVideo,                          \
145         eSyncOperation) ) /* Macro End */
146 
147 #define __PERF_CUSTOM_ThreadCreated(                \
148         hObject,                                    \
149         ulThreadID,                                 \
150         ulThreadName)                               \
151     PERF_check((hObject),                           \
152      ((PERF_OBJHANDLE)(hObject))->ci.ThreadCreated( \
153         (PERF_OBJHANDLE)(hObject),                  \
154         ((unsigned long) (ulThreadID)),             \
155         ((unsigned long) (ulThreadName)) ) )   /* Macro End */
156 
157 #ifdef __PERF_LOG_LOCATION__
158 #define __PERF_CUSTOM_Location(                \
159         hObject,                               \
160         szFile,                                \
161         ulLine,                                \
162         szFunc)                                \
163     PERF_check((hObject),                      \
164      ((PERF_OBJHANDLE)(hObject))->ci.Location( \
165         (PERF_OBJHANDLE)(hObject),             \
166         (szFile),                              \
167         ((unsigned long) (ulLine)),            \
168         (szFunc)) )   /* Macro End */
169 #endif
170 
171 /*=============================================================================
172     OUTSIDE INTERFACES
173 =============================================================================*/
174 
175 typedef struct PERF_Custom_Private
176 {
177     /* debug interface */
178     struct PERF_PRINT_Private *pDebug;
179 
180     /* real-time interface */
181     struct PERF_RT_Private *pRT;
182 } PERF_Custom_Private;
183 
184 /* PERF Custom instrumentation modes */
185 enum PERF_CUSTOM_MODE
186 {
187     PERF_Mode_Print           =  0x2,
188     PERF_Mode_Replay          =  0x4,
189     PERF_Mode_RealTime        =  0x8,
190 };
191 
192