comparison gpf/FRAME/prf_func.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +------------------------------------------------------------------------------
3 | File: prf_func.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Modul defines the profiler interface functions.
17 +-----------------------------------------------------------------------------
18 */
19
20
21
22 #ifndef __PRF_FUNC_C__
23 #define __PRF_FUNC_C__
24 #endif
25
26 /*==== INCLUDES ===================================================*/
27
28 #include "typedefs.h"
29 #include "glob_defs.h"
30 #include "vsi.h"
31 #include "os.h"
32 #include "prf_func.h"
33 #include "string.h"
34
35 /*==== TYPES ======================================================*/
36
37
38 /*==== CONSTANTS ==================================================*/
39
40
41 /*==== EXTERNALS ==================================================*/
42
43 extern ULONG TraceMask[];
44 extern T_HANDLE e_running[];
45
46 /*==== VARIABLES ==================================================*/
47
48 #ifndef RUN_INT_RAM
49 T_PROFILER_FUNC prf_func;
50 #else
51 extern T_PROFILER_FUNC prf_func;
52 extern void prf_register ( T_PROFILER_FUNC * func );
53 #endif
54
55 /*==== LINT =======================================================*/
56
57
58 /*==== FUNCTIONS ==================================================*/
59
60 #ifndef RUN_INT_RAM
61 /*
62 +------------------------------------------------------------------------------
63 | Function : prf_init
64 +------------------------------------------------------------------------------
65 | Description : initialize profiler API function pointer table.
66 |
67 | Parameters : void
68 |
69 | Return : void
70 +------------------------------------------------------------------------------
71 */
72 void prf_init ( void )
73 {
74 if ( prf_func.magic_nr != PRF_INITIALIZED )
75 {
76 memset ( &prf_func, 0, sizeof ( T_PROFILER_FUNC ) );
77 }
78 }
79 #endif
80
81
82 #ifndef RUN_INT_RAM
83 /*
84 +------------------------------------------------------------------------------
85 | Function : prf_register
86 +------------------------------------------------------------------------------
87 | Description : register the profiler API functions.
88 |
89 | Parameters : func - pointer to API function pointer table
90 |
91 | Return : void
92 +------------------------------------------------------------------------------
93 */
94 void prf_register ( T_PROFILER_FUNC * func )
95 {
96 prf_func.log_entity_create = func->log_entity_create;
97 prf_func.log_entity_delete = func->log_entity_delete;
98 prf_func.log_entity_activate = func->log_entity_activate;
99 prf_func.log_function_entry = func->log_function_entry;
100 prf_func.log_function_exit = func->log_function_exit;
101 prf_func.log_point_of_interest = func->log_point_of_interest;
102 prf_func.magic_nr = PRF_INITIALIZED;
103 }
104 #endif
105
106 #ifndef RUN_FLASH
107 /*
108 +------------------------------------------------------------------------------
109 | Function : prf_log_entity_create
110 +------------------------------------------------------------------------------
111 | Description : log entity create
112 |
113 | Parameters : entity - unique entity indentifier
114 | name - entity name
115 |
116 | Return : void
117 +------------------------------------------------------------------------------
118 */
119 void prf_log_entity_create ( void * entity, const char * name )
120 {
121 if ( prf_func.log_entity_create != NULL )
122 {
123 prf_func.log_entity_create ( entity, name );
124 }
125 }
126 #endif
127
128 #ifndef RUN_FLASH
129 /*
130 +------------------------------------------------------------------------------
131 | Function : prf_log_entity_delete
132 +------------------------------------------------------------------------------
133 | Description : log entity delete
134 |
135 | Parameters : entity - unique entity indentifier
136 |
137 | Return : void
138 +------------------------------------------------------------------------------
139 */
140 void prf_log_entity_delete ( void * entity )
141 {
142 if ( prf_func.log_entity_delete != NULL )
143 {
144 prf_func.log_entity_delete ( entity );
145 }
146 }
147 #endif
148
149 #ifndef RUN_FLASH
150 /*
151 +------------------------------------------------------------------------------
152 | Function : prf_log_entity_activate
153 +------------------------------------------------------------------------------
154 | Description : log entity activate
155 |
156 | Parameters : entity - unique entity indentifier
157 |
158 | Return : void
159 +------------------------------------------------------------------------------
160 */
161 void prf_log_entity_activate ( void * entity )
162 {
163 if ( prf_func.log_entity_activate != NULL )
164 {
165 prf_func.log_entity_activate ( entity );
166 }
167 }
168 #endif
169
170 #ifndef RUN_FLASH
171 /*
172 +------------------------------------------------------------------------------
173 | Function : prf_log_function_entry
174 +------------------------------------------------------------------------------
175 | Description : log function entry
176 |
177 | Parameters : function - unique function indentifier
178 |
179 | Return : void
180 +------------------------------------------------------------------------------
181 */
182 void prf_log_function_entry ( void * function )
183 {
184 T_HANDLE caller;
185
186 caller = e_running [ os_MyHandle() ];
187 if ( TraceMask [ caller ] & TC_PROFILER )
188 {
189 if ( prf_func.log_function_entry != NULL )
190 {
191 prf_func.log_function_entry ( function );
192 }
193 }
194 }
195 #endif
196
197 #ifndef RUN_FLASH
198 /*
199 +------------------------------------------------------------------------------
200 | Function : prf_log_function_exit
201 +------------------------------------------------------------------------------
202 | Description : log function exit
203 |
204 | Parameters : function - unique function indentifier
205 |
206 | Return : void
207 +------------------------------------------------------------------------------
208 */
209 void prf_log_function_exit ( void * function )
210 {
211 T_HANDLE caller;
212
213 caller = e_running [ os_MyHandle() ];
214 if ( TraceMask [ caller ] & TC_PROFILER )
215 {
216 if ( prf_func.log_function_exit != NULL )
217 {
218 prf_func.log_function_exit ( function );
219 }
220 }
221 }
222 #endif
223
224 #ifndef RUN_FLASH
225 /*
226 +------------------------------------------------------------------------------
227 | Function : prf_log_point_of_interest
228 +------------------------------------------------------------------------------
229 | Description : log point of interest
230 |
231 | Parameters : poi - unique function indentifier
232 |
233 | Return : void
234 +------------------------------------------------------------------------------
235 */
236 void prf_log_point_of_interest ( const char * poi )
237 {
238 T_HANDLE caller;
239
240 caller = e_running [ os_MyHandle() ];
241 if ( TraceMask [ caller ] & TC_PROFILER )
242 {
243 if ( prf_func.log_point_of_interest != NULL )
244 {
245 prf_func.log_point_of_interest ( poi );
246 }
247 }
248 }
249 #endif
250
251 //#define TEST_PROFILER_API
252 #ifdef TEST_PROFILER_API
253
254 #ifndef RUN_FLASH
255 /*
256 +------------------------------------------------------------------------------
257 | Function : prf_register
258 +------------------------------------------------------------------------------
259 | Description : register the profiler API functions.
260 |
261 | Parameters : func - pointer to API function pointer table
262 |
263 | Return : void
264 +------------------------------------------------------------------------------
265 */
266 void log_entity_create ( void * entity, const char * name )
267 {
268 vsi_o_ttrace ( e_running[os_MyHandle()], TC_SYSTEM, "PRF: Create entity %s, id=%d", name, entity );
269 }
270 #endif
271
272 #ifndef RUN_FLASH
273 /*
274 +------------------------------------------------------------------------------
275 | Function : prf_log_entity_delete
276 +------------------------------------------------------------------------------
277 | Description : log entity delete
278 |
279 | Parameters : entity - unique entity indentifier
280 |
281 | Return : void
282 +------------------------------------------------------------------------------
283 */
284 void log_entity_delete ( void * entity )
285 {
286 vsi_o_ttrace ( e_running[os_MyHandle()], TC_SYSTEM, "PRF: Delete entity id=%d", entity );
287 }
288 #endif
289
290 #ifndef RUN_FLASH
291 /*
292 +------------------------------------------------------------------------------
293 | Function : prf_log_entity_activate
294 +------------------------------------------------------------------------------
295 | Description : log entity activate
296 |
297 | Parameters : entity - unique entity indentifier
298 |
299 | Return : void
300 +------------------------------------------------------------------------------
301 */
302 void log_entity_activate ( void * entity )
303 {
304 T_HANDLE caller;
305 extern T_HANDLE TST_Handle;
306
307 caller = e_running[os_MyHandle()];
308 if ( caller != TST_Handle )
309 vsi_o_ttrace ( caller, TC_SYSTEM, "PRF: Activate entity %d", entity );
310 }
311 #endif
312
313 #ifndef RUN_FLASH
314 /*
315 +------------------------------------------------------------------------------
316 | Function : prf_log_function_entry
317 +------------------------------------------------------------------------------
318 | Description : log function entry
319 |
320 | Parameters : function - unique function indentifier
321 |
322 | Return : void
323 +------------------------------------------------------------------------------
324 */
325 void log_function_entry ( void * function )
326 {
327 vsi_o_ttrace ( e_running[os_MyHandle()], TC_SYSTEM, "PRF: Function entry %s", function );
328 }
329 #endif
330
331 #ifndef RUN_FLASH
332 /*
333 +------------------------------------------------------------------------------
334 | Function : prf_log_function_exit
335 +------------------------------------------------------------------------------
336 | Description : log function exit
337 |
338 | Parameters : function - unique function indentifier
339 |
340 | Return : void
341 +------------------------------------------------------------------------------
342 */
343 void log_function_exit ( void * function )
344 {
345 vsi_o_ttrace ( e_running[os_MyHandle()], TC_SYSTEM, "PRF: Function exit %s", function );
346 }
347 #endif
348
349 #ifndef RUN_FLASH
350 /*
351 +------------------------------------------------------------------------------
352 | Function : prf_log_point_of_interest
353 +------------------------------------------------------------------------------
354 | Description : log point of interest
355 |
356 | Parameters : poi - unique function indentifier
357 |
358 | Return : void
359 +------------------------------------------------------------------------------
360 */
361 void log_point_of_interest ( const char * poi )
362 {
363 vsi_o_ttrace ( e_running[os_MyHandle()], TC_SYSTEM, "PRF: POI %s", poi );
364 }
365 #endif
366
367 #ifndef RUN_FLASH
368 T_PROFILER_FUNC profiler_functions =
369 {
370 PRF_INITIALIZED,
371 log_entity_create,
372 log_entity_delete,
373 log_entity_activate,
374 log_function_entry,
375 log_function_exit,
376 log_point_of_interest,
377 };
378 #endif
379
380 #endif /* TEST_PROFILER_API */