FreeCalypso > hg > leo2moko-debug
comparison chipsetsw/riviera/rvt/ti_profiler/ti_profiler.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 * ti_profiler.c : contains ti profiling module function * | |
3 * * | |
4 * * | |
5 * Author: Philippe Martinez * | |
6 * * | |
7 * version: 1.0 * | |
8 * * | |
9 * Date: 07/16/2001 * | |
10 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved * | |
11 ************************************************************************************/ | |
12 | |
13 #include "config/debug.cfg" | |
14 | |
15 #if (TI_PROFILER == 1) || (TI_NUC_MONITOR == 1) | |
16 | |
17 /*-------------------------------------------------------*/ | |
18 /* include files */ | |
19 /*-------------------------------------------------------*/ | |
20 | |
21 #include <string.h> | |
22 | |
23 #include "main/sys_types.h" | |
24 | |
25 #include "nucleus.h" | |
26 #include "qu_defs.h" | |
27 #include "tc_defs.h" | |
28 | |
29 #include "rvf/rvf_api.h" | |
30 #include "rvt/rvt_gen.h" | |
31 #include "rvt/rvt_def_i.h" | |
32 | |
33 #include "mem.h" | |
34 #include "iq.h" | |
35 | |
36 #include "rvt/ti_profiler/ti_profiler.h" | |
37 | |
38 #include "timer.h" | |
39 #include "inth.h" | |
40 | |
41 /*-------------------------------------------------------*/ | |
42 /* Global instances */ | |
43 /*-------------------------------------------------------*/ | |
44 | |
45 // task variable instance | |
46 T_RVF_MB_ID prof_mb_id; | |
47 T_RVT_USER_ID prof_trace_id; | |
48 T_RVF_ADDR_ID prof_addr_id; | |
49 | |
50 /*-------------------------------------------------------*/ | |
51 /* internal prototypes */ | |
52 /*-------------------------------------------------------*/ | |
53 | |
54 void ti_prf_init( void ); | |
55 T_RV_RET ti_prf_core(void); | |
56 void ti_profiler_trace_rx_callback( T_RVT_BUFFER trace_msg, UINT16 trace_msg_size ); | |
57 #if (L1_TRACER == 1) | |
58 extern void SendTraces(char *s); | |
59 #endif | |
60 | |
61 #endif | |
62 | |
63 | |
64 #if (TI_PROFILER == 1) | |
65 | |
66 /*-------------------------------------------------------*/ | |
67 /* Global instances */ | |
68 /*-------------------------------------------------------*/ | |
69 | |
70 // Internal state of profiling | |
71 T_PROFILER_STATE profiler_state = PROFILER_STOPPED; | |
72 | |
73 | |
74 // Buffer that contains the Profiling samples. | |
75 // Structure (SYS_UWORD32 buffer): | |
76 // C_OP_CODE_TDMA_BEGIN | |
77 // PC Samples ...... | |
78 // C_OP_CODE_TDMA_END | |
79 // ...... | |
80 // C_OP_CODE_TDMA_BEGIN | |
81 // PC Samples ...... | |
82 // C_OP_CODE_TDMA_END | |
83 | |
84 SYS_UWORD32 pr_buffer[PR_BUFFER_SIZE]; | |
85 // pointer on pr_buffer | |
86 SYS_UWORD32 pos_pr_buffer = 0; | |
87 SYS_UWORD32 pr_buffer_length = PR_BUFFER_SIZE; | |
88 | |
89 T_PROFILER_BUFFER_STATE ti_profiler_buffer_state = LOGGING; | |
90 T_PROFILER_HANDLER ti_profiler_active = NOT_ACTIVE; | |
91 | |
92 // hisr variable instance | |
93 NU_HISR ti_profiler_cb; | |
94 SYS_UWORD8 ti_profiler_hisr_stack[500]; | |
95 | |
96 // Event variables | |
97 // NO_SLEEP_EVENT | |
98 SYS_UWORD32 ti_profiler_nb_sleep_call = 0; | |
99 SYS_UWORD32 ti_profiler_nb_sleep_counter_ref = 0; | |
100 | |
101 T_PROFILER_EVENTS ti_profiler_event_state = NO_EVENT; | |
102 | |
103 /*-------------------------------------------------------*/ | |
104 /* internal prototypes */ | |
105 /*-------------------------------------------------------*/ | |
106 | |
107 void ti_profiler_start( BOOL enable ); | |
108 void ti_profiler_handler( SYS_UWORD32 programCounter ); | |
109 void ti_profiler_freeze( void ); | |
110 void ti_profiler_unfreeze( void ); | |
111 void ti_profiler_tdma_action( void ); | |
112 void ti_profiler_init_profiler_module( void ); | |
113 void ti_profiler_hisr( void ); | |
114 | |
115 void l1_profiler_open( void ); | |
116 void l1_profiler_close( void ); | |
117 void l1_profiler_flush( void ); | |
118 | |
119 /*-------------------------------------------------------*/ | |
120 /* external prototypes */ | |
121 /*-------------------------------------------------------*/ | |
122 | |
123 SYS_UWORD32 l1_get_next_absolute_fn( void ); | |
124 | |
125 /*-------------------------------------------------------*/ | |
126 /* ti_profiler_start() */ | |
127 /*-------------------------------------------------------*/ | |
128 /* */ | |
129 /* Description: Start or Stop the timer */ | |
130 /* ------------ */ | |
131 /* parameters */ | |
132 /* enable = 1 => Unmask + start the timer 1 */ | |
133 /* Initialize buffer. */ | |
134 /* enable = 0 => mask + stop the timer 1 */ | |
135 /* Close Buffer. */ | |
136 /*-------------------------------------------------------*/ | |
137 | |
138 void ti_profiler_start( BOOL enable ) | |
139 { | |
140 if( enable ) | |
141 { | |
142 TM_EnableTimer( PR_TIMER_NUM ); | |
143 IQ_Unmask( IQ_TIM1 ); | |
144 IQ_InitLevel( IQ_TIM1, FIQ, 0, 1 ); | |
145 | |
146 TM_ResetTimer( PR_TIMER_NUM, PR_TIMER_RESET_VALUE, 1, 0 ); | |
147 TM_StartTimer( PR_TIMER_NUM ); | |
148 } | |
149 else | |
150 { | |
151 IQ_Mask( IQ_TIM1 ); | |
152 IQ_InitLevel( IQ_TIM1, 0, 0, 1 ); | |
153 TM_StopTimer( PR_TIMER_NUM ); | |
154 } | |
155 } // ti_profiler_start | |
156 | |
157 | |
158 /*-------------------------------------------------------*/ | |
159 /* ti_profiler_handler() */ | |
160 /*-------------------------------------------------------*/ | |
161 /* */ | |
162 /* Description: */ | |
163 /* ------------ */ | |
164 /* Store the Program counter in a static buffer */ | |
165 /* If buffer is full, deactivate the profiling and */ | |
166 /* activate the ti_profiler_hisr(); */ | |
167 /*-------------------------------------------------------*/ | |
168 | |
169 void ti_profiler_handler( SYS_UWORD32 programCounter ) | |
170 { | |
171 | |
172 // Store the program Counter in log buffer | |
173 pr_buffer[ pos_pr_buffer++ ] = programCounter; | |
174 | |
175 } // ti_profiler_handler | |
176 | |
177 | |
178 /*-------------------------------------------------------*/ | |
179 /* ti_profiler_freeze() ti_profiler_unfreeze() */ | |
180 /*-------------------------------------------------------*/ | |
181 /* */ | |
182 /* Description: */ | |
183 /* ------------ */ | |
184 /* Function to suspend/resume the profiling */ | |
185 /*-------------------------------------------------------*/ | |
186 | |
187 void ti_profiler_freeze() | |
188 { | |
189 TM_StopTimer( PR_TIMER_NUM ); | |
190 } // ti_profiler_freeze | |
191 | |
192 void ti_profiler_unfreeze() | |
193 { | |
194 TM_StartTimer( PR_TIMER_NUM ); | |
195 } // ti_profiler_unfreeze | |
196 | |
197 /*-------------------------------------------------------*/ | |
198 /* ti_profiler_init_profiler_module() */ | |
199 /*-------------------------------------------------------*/ | |
200 /* */ | |
201 /* Description: Initialize profiling task and hisr */ | |
202 /* ------------ */ | |
203 /* Note : this init will changed */ | |
204 /* */ | |
205 /*-------------------------------------------------------*/ | |
206 | |
207 void ti_profiler_init_profiler_module( void ) | |
208 { | |
209 // Fill the entire stack with the pattern 0xFE | |
210 memset( ti_profiler_hisr_stack, 0xFE, sizeof( ti_profiler_hisr_stack ) ); | |
211 | |
212 // Create the HISR which is called from power interrupts | |
213 NU_Create_HISR( &ti_profiler_cb, | |
214 "TI PROF", | |
215 ti_profiler_hisr, | |
216 2, | |
217 ti_profiler_hisr_stack, | |
218 sizeof( ti_profiler_hisr_stack ) ); // lowest prty | |
219 | |
220 } // ti_profiler_init_profiler_module | |
221 | |
222 | |
223 /*-------------------------------------------------------*/ | |
224 /* ti_profiler_hisr() High Interrupt service routine */ | |
225 /*-------------------------------------------------------*/ | |
226 /* */ | |
227 /* Description: */ | |
228 /* ------------ */ | |
229 /* This hisr stands as relay for the profiler LISR. */ | |
230 /* It sends a message to the profiler task to start the */ | |
231 /* buffer extraction. */ | |
232 /*-------------------------------------------------------*/ | |
233 | |
234 void ti_profiler_hisr( void ) | |
235 { | |
236 T_PROFILER_MSG * msg; | |
237 | |
238 //send a message to the ti profiler task | |
239 if( rvf_get_buf( prof_mb_id, sizeof( T_PROFILER_MSG ), ( T_RVF_BUFFER** ) &msg ) == RVF_GREEN ) | |
240 { | |
241 msg->msg_id = TI_PROFILER_OUTPUT_BUFFER; | |
242 rvf_send_msg( prof_addr_id, msg ); | |
243 } | |
244 } // ti_profiler_hisr | |
245 | |
246 /*-------------------------------------------------------*/ | |
247 /* ti_profiler_tdma_action() */ | |
248 /*-------------------------------------------------------*/ | |
249 /* */ | |
250 /* Description: */ | |
251 /* ------------ */ | |
252 /* */ | |
253 /* */ | |
254 /*-------------------------------------------------------*/ | |
255 | |
256 void ti_profiler_tdma_action(void) | |
257 { | |
258 | |
259 switch( profiler_state ) | |
260 { | |
261 case PROFILER_RUNNING : | |
262 { | |
263 SYS_UWORD8 output_buffer_condition = 0; | |
264 | |
265 // suspend the profiler | |
266 //ti_profiler_freeze(); | |
267 ti_profiler_start( FALSE ); | |
268 | |
269 if( ti_profiler_event_state == NO_SLEEP_EVENT ) | |
270 { | |
271 // Need to reach the event to output the buffer | |
272 if( ti_profiler_nb_sleep_call++ >= ti_profiler_nb_sleep_counter_ref ) | |
273 { | |
274 output_buffer_condition = 1; | |
275 ti_profiler_nb_sleep_call = 0; | |
276 // ti_profiler_buffer_state = FLUSH; | |
277 } // End if | |
278 } | |
279 else | |
280 { | |
281 output_buffer_condition = 1; | |
282 } // End if | |
283 | |
284 | |
285 // Check if buffer threshold reached | |
286 if( pos_pr_buffer >= PR_BUFFER_THRESHOLD ) | |
287 { | |
288 // change the status of the buffer | |
289 ti_profiler_buffer_state = LOGGING; | |
290 | |
291 // Insert the End of Buffer OP code | |
292 pr_buffer[ pos_pr_buffer++ ] = C_OP_CODE_END_BUFFER; | |
293 | |
294 // Specifie used length of buffer in SYS_UWORD32 | |
295 pr_buffer_length = pos_pr_buffer; | |
296 | |
297 if( output_buffer_condition == 1 ) | |
298 { | |
299 // Change profiler state to freezed | |
300 profiler_state = PROFILER_FREEZED; | |
301 | |
302 // Activate the hisr in order to start the buffer output | |
303 NU_Activate_HISR( &ti_profiler_cb ); | |
304 } | |
305 else | |
306 { | |
307 // insert TDMA begin OP Code | |
308 pr_buffer[ 0 ] = C_OP_CODE_BEGIN_BUFFER; | |
309 pr_buffer[ 1 ] = C_OP_CODE_TDMA_BEGIN; | |
310 // Insert current fn | |
311 pr_buffer[ 2 ] = l1_get_next_absolute_fn(); | |
312 | |
313 // initialize buffer pointer | |
314 pos_pr_buffer = 3; | |
315 | |
316 ti_profiler_start( TRUE ); | |
317 } // End if | |
318 | |
319 } | |
320 else | |
321 { | |
322 // insert OP Code begining of TDMA | |
323 pr_buffer[pos_pr_buffer++] = C_OP_CODE_TDMA_BEGIN; | |
324 // Insert current fn | |
325 pr_buffer[pos_pr_buffer++] = l1_get_next_absolute_fn(); | |
326 | |
327 // resume profiler | |
328 //ti_profiler_unfreeze(); | |
329 ti_profiler_start( TRUE ); | |
330 } // End if | |
331 | |
332 | |
333 break; | |
334 } // PROFILER_RUNNING | |
335 | |
336 case PROFILER_TO_BE_RAN : | |
337 { | |
338 // insert TDMA begin OP Code | |
339 pr_buffer[ 0 ] = C_OP_CODE_BEGIN_BUFFER; | |
340 pr_buffer[ 1 ] = C_OP_CODE_TDMA_BEGIN; | |
341 // Insert current fn | |
342 pr_buffer[ 2 ] = l1_get_next_absolute_fn(); | |
343 | |
344 // initialize buffer pointer | |
345 pos_pr_buffer = 3; | |
346 // start the profiler | |
347 profiler_state = PROFILER_RUNNING; | |
348 | |
349 // start the profiler | |
350 ti_profiler_start( TRUE ); | |
351 | |
352 break; | |
353 } // PROFILER_TO_BE_RAN | |
354 | |
355 case PROFILER_TO_BE_STOPPED : | |
356 { | |
357 // stop the profiler | |
358 ti_profiler_start( FALSE ); | |
359 | |
360 // Insert End Buffer Op Code. | |
361 pr_buffer[pos_pr_buffer++] = C_OP_CODE_END_BUFFER; | |
362 profiler_state = PROFILER_STOPPED; | |
363 | |
364 // Activate the hisr in order to start the buffer output | |
365 NU_Activate_HISR( &ti_profiler_cb ); | |
366 | |
367 // Returns to inactive | |
368 ti_profiler_active = NOT_ACTIVE; | |
369 | |
370 break; | |
371 } // PROFILER_TO_BE_STOPPED | |
372 | |
373 case PROFILER_TO_BE_UNFREEZED : | |
374 { | |
375 // Init profiling buffer | |
376 // insert TDMA begin OP Code | |
377 pr_buffer[ 0 ] = C_OP_CODE_BEGIN_BUFFER; | |
378 pr_buffer[ 1 ] = C_OP_CODE_TDMA_BEGIN; | |
379 // Insert current fn | |
380 pr_buffer[ 2 ] = l1_get_next_absolute_fn(); | |
381 | |
382 // initialize buffer pointer | |
383 pos_pr_buffer = 3; | |
384 // Insert the TDMA Start Op Code | |
385 profiler_state = PROFILER_RUNNING; | |
386 | |
387 // resume profiler | |
388 //ti_profiler_unfreeze(); | |
389 ti_profiler_start( TRUE ); | |
390 | |
391 break; | |
392 } // PROFILER_TO_BE_UNFREEZED | |
393 | |
394 default : | |
395 { | |
396 // nothing to do | |
397 break; | |
398 } // default | |
399 | |
400 } // End switch | |
401 | |
402 } // ti_profiler_tdma_action | |
403 | |
404 /*-------------------------------------------------------*/ | |
405 /* ti_profiler_open() */ | |
406 /*-------------------------------------------------------*/ | |
407 /* */ | |
408 /* Description: */ | |
409 /* ------------ */ | |
410 /* Start the profiling on the next TDMA occurence */ | |
411 /* */ | |
412 /*-------------------------------------------------------*/ | |
413 | |
414 void ti_profiler_open( void ) | |
415 { | |
416 if( ti_profiler_active == NOT_ACTIVE ) | |
417 { | |
418 | |
419 } // End if | |
420 } // ti_profiler_open | |
421 | |
422 /*-------------------------------------------------------*/ | |
423 /* ti_profiler_close() */ | |
424 /*-------------------------------------------------------*/ | |
425 /* */ | |
426 /* Description: */ | |
427 /* ------------ */ | |
428 /* Stop the profiling on the next TDMA occurence */ | |
429 /* */ | |
430 /*-------------------------------------------------------*/ | |
431 | |
432 void ti_profiler_close( void ) | |
433 { | |
434 if( ti_profiler_active == NOT_ACTIVE ) | |
435 { | |
436 l1_profiler_close(); | |
437 } // End if | |
438 } // ti_profiler_close | |
439 | |
440 /*-------------------------------------------------------*/ | |
441 /* l1_profiler_flush() */ | |
442 /*-------------------------------------------------------*/ | |
443 /* */ | |
444 /* Description: */ | |
445 /* ------------ */ | |
446 /* freeze the profiling and flush the current profiling */ | |
447 /* buffer. Profiling will restart after output of the */ | |
448 /* buffer. */ | |
449 /*-------------------------------------------------------*/ | |
450 | |
451 void ti_profiler_flush( void ) | |
452 { | |
453 if( ti_profiler_active == NOT_ACTIVE ) | |
454 { | |
455 l1_profiler_flush(); | |
456 } // End if | |
457 } // ti_profiler_flush | |
458 | |
459 // To be used only TI internal modules | |
460 | |
461 /*-------------------------------------------------------*/ | |
462 /* ti_profiler_open() */ | |
463 /*-------------------------------------------------------*/ | |
464 /* */ | |
465 /* Description: */ | |
466 /* ------------ */ | |
467 /* Start the profiling on the next TDMA occurence */ | |
468 /* */ | |
469 /*-------------------------------------------------------*/ | |
470 | |
471 void l1_profiler_open( void ) | |
472 { | |
473 | |
474 if( ti_profiler_active != NOT_ACTIVE ) | |
475 { | |
476 // stop profiler timer | |
477 ti_profiler_start( FALSE ); | |
478 // go to idle | |
479 profiler_state = PROFILER_STOPPED; | |
480 } // Endif | |
481 | |
482 // insert TDMA begin OP Code | |
483 pr_buffer[ 0 ] = C_OP_CODE_BEGIN_BUFFER; | |
484 pr_buffer[ 1 ] = C_OP_CODE_TDMA_BEGIN; | |
485 | |
486 // Insert current fn | |
487 pr_buffer[ 2 ] = l1_get_next_absolute_fn(); | |
488 | |
489 // initialize buffer pointer | |
490 pos_pr_buffer = 3; | |
491 | |
492 // change state of profiler | |
493 profiler_state = PROFILER_TO_BE_RAN; | |
494 | |
495 } // ti_profiler_open | |
496 | |
497 /*-------------------------------------------------------*/ | |
498 /* ti_profiler_close() */ | |
499 /*-------------------------------------------------------*/ | |
500 /* */ | |
501 /* Description: */ | |
502 /* ------------ */ | |
503 /* Stop the profiling on the next TDMA occurence */ | |
504 /* */ | |
505 /*-------------------------------------------------------*/ | |
506 | |
507 void l1_profiler_close( void ) | |
508 { | |
509 // stop the profiler | |
510 ti_profiler_start( FALSE ); | |
511 | |
512 // Insert TDMA_BOUNDARY Op Code. | |
513 pr_buffer[pos_pr_buffer++] = C_OP_CODE_END_BUFFER; | |
514 profiler_state = PROFILER_STOPPED; | |
515 | |
516 // Activate the hisr in order to start the buffer output | |
517 NU_Activate_HISR( &ti_profiler_cb ); | |
518 | |
519 } // ti_profiler_close | |
520 | |
521 /*-------------------------------------------------------*/ | |
522 /* l1_profiler_flush() */ | |
523 /*-------------------------------------------------------*/ | |
524 /* */ | |
525 /* Description: */ | |
526 /* ------------ */ | |
527 /* freeze the profiling and flush the current profiling */ | |
528 /* buffer. Profiling will restart after output of the */ | |
529 /* buffer. */ | |
530 /*-------------------------------------------------------*/ | |
531 | |
532 void l1_profiler_flush( void ) | |
533 { | |
534 ti_profiler_buffer_state = FLUSH; | |
535 } // ti_profiler_flush | |
536 | |
537 #endif // PROFILER | |
538 | |
539 #if (TI_NUC_MONITOR == 1) | |
540 | |
541 /*-------------------------------------------------------*/ | |
542 /* Global instances */ | |
543 /*-------------------------------------------------------*/ | |
544 // management of monitoring buffer | |
545 | |
546 // Internal state of nucleus monitoring | |
547 | |
548 T_NUC_MONITOR_STATE ti_nuc_monitor_state = NUC_MONITOR_STOPPED; | |
549 | |
550 // pointers on current buffer | |
551 SYS_UWORD8* ti_nuc_monitor_current_buffer = NULL; | |
552 SYS_UWORD8 ti_nuc_monitor_current_position = 0; | |
553 | |
554 // Create static doubled bufferised LISR buffers (max 10 LISR by TDMA) | |
555 SYS_UWORD8 ti_nuc_monitor_LISR_Buffer[C_NUC_LISR_BUF_PG_NB][C_NUC_MAX_LISR]; | |
556 SYS_UWORD8 ti_nuc_monitor_LISR_current_page = 0; | |
557 SYS_UWORD8 ti_nuc_monitor_LISR_current_pos = 0; | |
558 SYS_UWORD8 ti_nuc_monitor_LISR_next_page = 0; | |
559 SYS_UWORD8 ti_nuc_monitor_LISR_next_pos = 0; | |
560 | |
561 // Create static doubled bufferised LISR buffers (max 10 LISR by TDMA) | |
562 SYS_UWORD8 ti_nuc_monitor_Thread_Buffer[C_NUC_THREAD_BUF_PG_NB][C_NUC_MAX_THREAD]; | |
563 SYS_UWORD8 ti_nuc_monitor_Thread_current_page = 0; | |
564 SYS_UWORD8 ti_nuc_monitor_Thread_current_pos = 0; | |
565 SYS_UWORD8 ti_nuc_monitor_Thread_next_page = 0; | |
566 SYS_UWORD8 ti_nuc_monitor_Thread_next_pos = 0; | |
567 | |
568 // hisr variable instance | |
569 NU_HISR ti_nuc_monitor_cb; | |
570 SYS_UWORD8 ti_nuc_monitor_hisr_stack[ 500 ]; | |
571 | |
572 // Array that store the ID <-> pointer of the Nucleus Components | |
573 //SYS_UWORD32* ti_nuc_monitor_thread_id[ NUC_MONITOR_MAX_ID ]; | |
574 SYS_UWORD32 ti_nuc_monitor_thread_id[ NUC_MONITOR_MAX_ID ]; | |
575 SYS_UWORD8 ti_nuc_monitor_thread_pos = 0; | |
576 | |
577 //SYS_UWORD32* ti_nuc_monitor_queue_id[ NUC_MONITOR_MAX_ID ]; | |
578 SYS_UWORD32 ti_nuc_monitor_queue_id[ NUC_MONITOR_MAX_ID ]; | |
579 SYS_UWORD8 ti_nuc_monitor_queue_pos = 0; | |
580 | |
581 // LISR IRQ value | |
582 SYS_UWORD8 IRQ_value; | |
583 | |
584 // Indicates the nucleus monitor part to switch Thread buffer page | |
585 SYS_UWORD8 ti_nuc_monitor_change_thread_page = 0; | |
586 | |
587 // Indicates that the IDLE mode has been reached | |
588 // (to be reset in LISR or Thread monitor function) | |
589 SYS_UWORD8 ti_nuc_monitor_idle_reached = 0; | |
590 | |
591 // debug | |
592 SYS_UWORD32 ti_nuc_monitor_lost_messages = 0; | |
593 | |
594 /*-------------------------------------------------------*/ | |
595 /* internal prototypes */ | |
596 /*-------------------------------------------------------*/ | |
597 | |
598 void ti_nuc_monitor_tdma_action( void ); | |
599 void ti_nuc_monitor_init_module( void ); | |
600 void ti_nuc_monitor_hisr( void ); | |
601 void ti_nuc_monitor_check_ID_buffer( void ); | |
602 void ti_nuc_monitor_LISR_log( void ); | |
603 void ti_nuc_monitor_LISR_log_end( void ); | |
604 void ti_nuc_monitor_Thread_log( void ); | |
605 void ti_nuc_monitor_Queue_log( SYS_UWORD32* queue_pointer, SYS_UWORD8 status, SYS_UWORD8 Direction ); | |
606 void ti_nuc_monitor_sleep( void ); | |
607 | |
608 T_RVT_RET ti_nuc_monitor_mem_alloc(T_RVT_USER_ID user_id, | |
609 T_RVT_MSG_LG buffer_lenght, | |
610 T_RVT_BUFFER * buff); | |
611 | |
612 /*-------------------------------------------------------*/ | |
613 /* external prototypes */ | |
614 /*-------------------------------------------------------*/ | |
615 | |
616 extern SYS_UWORD16 l1_get_actual_fn_mod42432( void ); | |
617 extern SYS_UWORD32* TCD_Current_Thread; | |
618 | |
619 /*-------------------------------------------------------*/ | |
620 /* ti_nuc_monitor_init_module() */ | |
621 /*-------------------------------------------------------*/ | |
622 /* */ | |
623 /* Description: Initialize hisr */ | |
624 /* ------------ */ | |
625 /* Create hisr and initialize thread/queue structures. */ | |
626 /* */ | |
627 /*-------------------------------------------------------*/ | |
628 | |
629 void ti_nuc_monitor_init_module( void ) | |
630 { | |
631 SYS_UWORD8 i; | |
632 | |
633 // Fill the entire stack with the pattern 0xFE | |
634 memset( ti_nuc_monitor_hisr_stack, 0xFE, sizeof( ti_nuc_monitor_hisr_stack ) ); | |
635 | |
636 // Create the HISR | |
637 NU_Create_HISR( &ti_nuc_monitor_cb, | |
638 "TI MON", | |
639 ti_nuc_monitor_hisr, | |
640 2, | |
641 ti_nuc_monitor_hisr_stack, | |
642 sizeof( ti_nuc_monitor_hisr_stack ) ); // lowest prty | |
643 | |
644 } // ti_nuc_monitor_init_module | |
645 | |
646 | |
647 /*-------------------------------------------------------*/ | |
648 /* ti_nuc_monitor_hisr() High Interrupt service routine */ | |
649 /*-------------------------------------------------------*/ | |
650 /* */ | |
651 /* Description: */ | |
652 /* ------------ */ | |
653 /* It sends a message to the profiler task to start the */ | |
654 /* buffer extraction. */ | |
655 /*-------------------------------------------------------*/ | |
656 | |
657 void ti_nuc_monitor_hisr( void ) | |
658 { | |
659 SYS_UWORD8 remaining_bytes; | |
660 SYS_UWORD16 fn; | |
661 T_PROFILER_MSG *msg; | |
662 SYS_UWORD8 i; | |
663 | |
664 // Allocate a buffer first time | |
665 if(( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_RUN ) || | |
666 ( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_STARTED )) | |
667 { | |
668 if((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
669 NUC_MONITOR_BUFFER_SIZE, | |
670 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
671 == RVT_OK) | |
672 { | |
673 | |
674 ti_nuc_monitor_current_position = 0; | |
675 | |
676 // Insert the interrupt OP Code (0x00 0x00 0x00) | |
677 if( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_RUN ) | |
678 { | |
679 for( i=0; i < 3; i++) | |
680 { | |
681 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = 0x00; | |
682 } // End for | |
683 } // Endif | |
684 | |
685 // Reset intermediate buffer pointers | |
686 ti_nuc_monitor_Thread_current_pos = 0; | |
687 ti_nuc_monitor_LISR_current_pos = 0; | |
688 } | |
689 else | |
690 { | |
691 return; | |
692 } // End if | |
693 | |
694 // Write FN OP CODE : (0x00 | xx) | |
695 | |
696 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
697 (SYS_UWORD8) ( C_OP_CODE_FN_LOG ); | |
698 | |
699 // Insert the fn%42432 | |
700 fn = l1_get_actual_fn_mod42432(); | |
701 | |
702 // insert LSB | |
703 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
704 (SYS_UWORD8) (fn & 0x00ff); | |
705 | |
706 // insert MSB | |
707 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
708 (SYS_UWORD8) ((fn & 0xff00) >> 8); | |
709 | |
710 ti_nuc_monitor_state = NUC_MONITOR_RUNNING; | |
711 | |
712 return; | |
713 } // End if | |
714 | |
715 // Copy the LISR and Thread buffer into current buffer. | |
716 | |
717 // - LISR array | |
718 | |
719 // Check the number of byte remaining in the current | |
720 // log buffer vs LISR buffer. | |
721 | |
722 remaining_bytes = NUC_MONITOR_BUFFER_SIZE - ti_nuc_monitor_current_position; | |
723 | |
724 if( remaining_bytes > ti_nuc_monitor_LISR_next_pos ) | |
725 { | |
726 // Copy ti_nuc_monitor_LISR_next_pos bytes to Nucleus log buffer | |
727 | |
728 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
729 &ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_next_page ][ 0 ], | |
730 ti_nuc_monitor_LISR_next_pos); | |
731 | |
732 ti_nuc_monitor_current_position += ti_nuc_monitor_LISR_next_pos; | |
733 | |
734 } | |
735 else | |
736 { | |
737 | |
738 // Copy remaining_bytes bytes to Nucleus log buffer | |
739 | |
740 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
741 &ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_next_page ][ 0 ], | |
742 remaining_bytes); | |
743 | |
744 ti_nuc_monitor_current_position += remaining_bytes; | |
745 | |
746 // Send current buffer | |
747 | |
748 // send a message to the ti profiler task | |
749 | |
750 if( rvf_get_buf( prof_mb_id, sizeof( T_PROFILER_MSG ), ( T_RVF_BUFFER** ) &msg ) == RVF_GREEN ) | |
751 { | |
752 msg->msg_id = TI_NUC_MONITOR_OUTPUT_BUFFER; | |
753 msg->p_buffer = ti_nuc_monitor_current_buffer; | |
754 msg->buffer_size = ti_nuc_monitor_current_position; | |
755 | |
756 ti_nuc_monitor_current_position = 0; | |
757 | |
758 if( rvf_send_msg( prof_addr_id, msg ) != RV_OK ) | |
759 { | |
760 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
761 return; | |
762 } // End if | |
763 } | |
764 else | |
765 { | |
766 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
767 return; | |
768 } // End if | |
769 | |
770 // Change Nucleus log buffer | |
771 | |
772 if((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
773 NUC_MONITOR_BUFFER_SIZE, | |
774 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
775 != RVT_OK) | |
776 { | |
777 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
778 return; | |
779 } // End if | |
780 | |
781 // Copy remaining_bytes bytes to Nucleus log buffer | |
782 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
783 &ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_next_page ][ remaining_bytes ], | |
784 ( ti_nuc_monitor_LISR_next_pos - remaining_bytes )); | |
785 | |
786 ti_nuc_monitor_current_position += ( ti_nuc_monitor_LISR_next_pos - remaining_bytes ); | |
787 | |
788 } // End if | |
789 | |
790 // - Thread Array | |
791 | |
792 // Check the number of byte remaining in the current | |
793 // log buffer vs Thread buffer. | |
794 | |
795 remaining_bytes = NUC_MONITOR_BUFFER_SIZE - ti_nuc_monitor_current_position; | |
796 | |
797 if( remaining_bytes > ti_nuc_monitor_Thread_next_pos ) | |
798 { | |
799 // Copy ti_nuc_monitor_Thread_next_pos bytes to Nucleus log buffer | |
800 | |
801 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
802 &ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_next_page ][ 0 ], | |
803 ti_nuc_monitor_Thread_next_pos); | |
804 | |
805 ti_nuc_monitor_current_position += ti_nuc_monitor_Thread_next_pos; | |
806 | |
807 } | |
808 else | |
809 { | |
810 | |
811 // Copy remaining_bytes bytes to Nucleus log buffer | |
812 | |
813 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
814 &ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_next_page ][ 0 ], | |
815 remaining_bytes); | |
816 | |
817 ti_nuc_monitor_current_position += remaining_bytes; | |
818 | |
819 // Send current buffer | |
820 | |
821 // send a message to the ti profiler task | |
822 | |
823 if( rvf_get_buf( prof_mb_id, sizeof( T_PROFILER_MSG ), ( T_RVF_BUFFER** ) &msg ) == RVF_GREEN ) | |
824 { | |
825 msg->msg_id = TI_NUC_MONITOR_OUTPUT_BUFFER; | |
826 msg->p_buffer = ti_nuc_monitor_current_buffer; | |
827 msg->buffer_size = ti_nuc_monitor_current_position; | |
828 | |
829 ti_nuc_monitor_current_position = 0; | |
830 | |
831 if( rvf_send_msg( prof_addr_id, msg ) != RV_OK ) | |
832 { | |
833 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
834 return; | |
835 } // End if | |
836 } | |
837 else | |
838 { | |
839 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
840 return; | |
841 } // End if | |
842 | |
843 // Change Nucleus log buffer | |
844 | |
845 if((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
846 NUC_MONITOR_BUFFER_SIZE, | |
847 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
848 != RVT_OK) | |
849 { | |
850 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
851 return; | |
852 } // End if | |
853 | |
854 // Copy remaining_bytes bytes to Nucleus log buffer | |
855 memcpy( &ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position ], | |
856 &ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_next_page ][ remaining_bytes ], | |
857 ( ti_nuc_monitor_Thread_next_pos - remaining_bytes )); | |
858 | |
859 ti_nuc_monitor_current_position += ( ti_nuc_monitor_Thread_next_pos - remaining_bytes ); | |
860 | |
861 } // End if | |
862 | |
863 // Exit if monitoring must be stopped | |
864 | |
865 if( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_STOP ) | |
866 { | |
867 ti_nuc_monitor_state = NUC_MONITOR_STOPPED; | |
868 return; | |
869 } // End if | |
870 | |
871 // Insert actual Frame number | |
872 | |
873 // Check if enough space in current buffer | |
874 if( ti_nuc_monitor_current_position >= (NUC_MONITOR_BUFFER_SIZE - 3) ) | |
875 { | |
876 // send a message to the ti profiler task | |
877 | |
878 if( rvf_get_buf( prof_mb_id, sizeof( T_PROFILER_MSG ), ( T_RVF_BUFFER** ) &msg ) == RVF_GREEN ) | |
879 { | |
880 msg->msg_id = TI_NUC_MONITOR_OUTPUT_BUFFER; | |
881 msg->p_buffer = ti_nuc_monitor_current_buffer; | |
882 msg->buffer_size = ti_nuc_monitor_current_position; | |
883 | |
884 ti_nuc_monitor_current_position = 0; | |
885 | |
886 if( rvf_send_msg( prof_addr_id, msg ) != RV_OK ) | |
887 { | |
888 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
889 return; | |
890 } // End if | |
891 } | |
892 else | |
893 { | |
894 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
895 return; | |
896 } // End if | |
897 | |
898 // Change Nucleus log buffer | |
899 | |
900 if((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
901 NUC_MONITOR_BUFFER_SIZE, | |
902 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
903 != RVT_OK) | |
904 { | |
905 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_RUN; | |
906 return; | |
907 } // End if | |
908 } // End if | |
909 | |
910 // Write FN OP CODE : (0x00 | xx) | |
911 | |
912 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
913 (SYS_UWORD8) ( C_OP_CODE_FN_LOG ); | |
914 | |
915 // Insert the fn%42432 | |
916 fn = l1_get_actual_fn_mod42432(); | |
917 | |
918 // insert LSB | |
919 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
920 (SYS_UWORD8) (fn & 0x00ff); | |
921 | |
922 // insert MSB | |
923 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
924 (SYS_UWORD8) ((fn & 0xff00) >> 8); | |
925 | |
926 } // ti_nuc_monitor_hisr | |
927 | |
928 /*-------------------------------------------------------*/ | |
929 /* ti_nuc_monitor_check_ID_buffer() */ | |
930 /*-------------------------------------------------------*/ | |
931 /* */ | |
932 /* Description: */ | |
933 /* ------------ */ | |
934 /* During the Thread/Queue ID -> names buffer */ | |
935 /* transmission, change current buffer. */ | |
936 /* Send the full buffer and allocate a new one. */ | |
937 /*-------------------------------------------------------*/ | |
938 | |
939 void ti_nuc_monitor_check_ID_buffer( void ) | |
940 { | |
941 // Reset pointer | |
942 ti_nuc_monitor_current_position = 0; | |
943 | |
944 // Send a message to the Riviera Tracer to Output the current buffer. | |
945 if( rvt_send_trace_no_cpy( ( T_RVT_BUFFER ) ti_nuc_monitor_current_buffer, | |
946 prof_trace_id, | |
947 NUC_MONITOR_BUFFER_SIZE, // Length in bytes | |
948 RVT_BINARY_FORMAT ) != RVT_OK ) | |
949 { | |
950 // code to insert a breakpoint if failed. | |
951 ti_nuc_monitor_state = NUC_MONITOR_STOPPED; | |
952 } // End if | |
953 | |
954 | |
955 // Allocate one buffer. | |
956 do | |
957 { | |
958 ti_nuc_monitor_state = NUC_MONITOR_STOPPED; | |
959 | |
960 if ((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
961 NUC_MONITOR_BUFFER_SIZE, | |
962 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
963 != RVT_OK) | |
964 { | |
965 ti_nuc_monitor_state = NUC_MONITOR_WAITING; | |
966 } // End if | |
967 } while (ti_nuc_monitor_state == NUC_MONITOR_WAITING); | |
968 | |
969 } // ti_nuc_monitor_check_ID_buffer | |
970 | |
971 /*-------------------------------------------------------*/ | |
972 /* ti_nuc_monitor_tdma_action() */ | |
973 /*-------------------------------------------------------*/ | |
974 /* */ | |
975 /* Description: */ | |
976 /* ------------ */ | |
977 /* this function activate the HISR monitor */ | |
978 /*-------------------------------------------------------*/ | |
979 | |
980 void ti_nuc_monitor_tdma_action( void ) | |
981 { | |
982 | |
983 if(( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) || | |
984 ( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_RUN ) || | |
985 ( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_STOP ) || | |
986 ( ti_nuc_monitor_state == NUC_MONITOR_TO_BE_STARTED )) | |
987 { | |
988 | |
989 // Activate the hisr in order to start the buffer fill | |
990 NU_Activate_HISR( &ti_nuc_monitor_cb ); | |
991 | |
992 } // End if | |
993 | |
994 } // ti_nuc_monitor_tdma_action | |
995 | |
996 /*-------------------------------------------------------*/ | |
997 /* ti_nuc_monitor_LISR_log() */ | |
998 /*-------------------------------------------------------*/ | |
999 /* */ | |
1000 /* Description: */ | |
1001 /* ------------ */ | |
1002 /* This function permits to include the LISR IRQ and */ | |
1003 /* timer value in the LISR log buffer */ | |
1004 /* Warning : To save cpu, no overflow check is done */ | |
1005 /*-------------------------------------------------------*/ | |
1006 | |
1007 void ti_nuc_monitor_LISR_log( void ) | |
1008 { | |
1009 SYS_UWORD16 timer_value; | |
1010 | |
1011 if( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) | |
1012 { | |
1013 | |
1014 // Exit Idle mode if reached | |
1015 | |
1016 ti_nuc_monitor_idle_reached = 0; | |
1017 | |
1018 IRQ_value = (SYS_UWORD8) ((* (volatile SYS_UWORD16 *) INTH_B_IRQ_REG) & 0x001f); | |
1019 | |
1020 // Write LISR OP CODE and IRQ : (0xC0 | IRQ) | |
1021 | |
1022 ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_current_page ] | |
1023 [ ti_nuc_monitor_LISR_current_pos ] = | |
1024 (SYS_UWORD8) (C_OP_CODE_LISR_FLAG | IRQ_value); | |
1025 | |
1026 // Write the timer value | |
1027 | |
1028 timer_value = TM_ReadTimer(2); // (* (SYS_UWORD16 *) TIMER2_READ_TIM) | |
1029 | |
1030 // insert LSB | |
1031 | |
1032 ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_current_page ] | |
1033 [ ti_nuc_monitor_LISR_current_pos + 1 ] = | |
1034 (SYS_UWORD8) (timer_value & 0x00ff); | |
1035 | |
1036 // insert MSB | |
1037 | |
1038 ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_current_page ] | |
1039 [ ti_nuc_monitor_LISR_current_pos + 2 ] = | |
1040 (SYS_UWORD8) ((timer_value & 0xff00) >> 8); | |
1041 | |
1042 ti_nuc_monitor_LISR_current_pos += 3; | |
1043 | |
1044 } // End if | |
1045 | |
1046 } // ti_nuc_monitor_LISR_log | |
1047 | |
1048 /*-------------------------------------------------------*/ | |
1049 /* ti_nuc_monitor_LISR_log_end() */ | |
1050 /*-------------------------------------------------------*/ | |
1051 /* */ | |
1052 /* Description: */ | |
1053 /* ------------ */ | |
1054 /* This function permits to include the LISR end */ | |
1055 /* timer value in the LISR log buffer */ | |
1056 /* Warning : To save cpu, no overflow check is done */ | |
1057 /*-------------------------------------------------------*/ | |
1058 | |
1059 void ti_nuc_monitor_LISR_log_end( void ) | |
1060 { | |
1061 SYS_UWORD16 timer_value; | |
1062 | |
1063 if( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) | |
1064 { | |
1065 // Write the timer value | |
1066 | |
1067 timer_value = TM_ReadTimer(2); | |
1068 | |
1069 // insert LSB | |
1070 | |
1071 ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_current_page ] | |
1072 [ ti_nuc_monitor_LISR_current_pos ] = | |
1073 (SYS_UWORD8) (timer_value & 0x00ff); | |
1074 | |
1075 // insert MSB | |
1076 | |
1077 ti_nuc_monitor_LISR_Buffer[ ti_nuc_monitor_LISR_current_page ] | |
1078 [ ti_nuc_monitor_LISR_current_pos + 1 ] = | |
1079 (SYS_UWORD8) ((timer_value & 0xff00) >> 8); | |
1080 | |
1081 ti_nuc_monitor_LISR_current_pos += 2; | |
1082 | |
1083 // Switch LISR & thread buffer page if IRQ4 (TDMA) | |
1084 if( IRQ_value == 4 ) | |
1085 { | |
1086 // copy current to next | |
1087 ti_nuc_monitor_LISR_next_pos = ti_nuc_monitor_LISR_current_pos; | |
1088 ti_nuc_monitor_LISR_next_page = ti_nuc_monitor_LISR_current_page; | |
1089 | |
1090 // instead of changing the Thread page here, set a boolean | |
1091 ti_nuc_monitor_change_thread_page = 1; | |
1092 | |
1093 //ti_nuc_monitor_Thread_next_pos = ti_nuc_monitor_Thread_current_pos; | |
1094 //ti_nuc_monitor_Thread_next_page = ti_nuc_monitor_Thread_current_page; | |
1095 | |
1096 // Reset current pointer | |
1097 ti_nuc_monitor_LISR_current_pos = 0; | |
1098 //ti_nuc_monitor_Thread_current_pos = 0; | |
1099 | |
1100 // Change page | |
1101 if( ti_nuc_monitor_LISR_current_page == 0 ) | |
1102 { | |
1103 ti_nuc_monitor_LISR_current_page = 1; | |
1104 // ti_nuc_monitor_Thread_current_page = 1; | |
1105 } | |
1106 else | |
1107 { | |
1108 ti_nuc_monitor_LISR_current_page = 0; | |
1109 // ti_nuc_monitor_Thread_current_page = 0; | |
1110 } // End if | |
1111 | |
1112 // reset IRQ_value | |
1113 IRQ_value = 0; | |
1114 | |
1115 // reset timer | |
1116 TM_ResetTimer (2, 0xFFFF, 1, 0); | |
1117 TM_StartTimer (2); | |
1118 | |
1119 // Doesn't work | |
1120 // * (volatile SYS_UWORD16 *) TIMER2_LOAD_TIM = 0xFFFF; | |
1121 // * (volatile SYS_UWORD16 *) TIMER2_CNTL = 0x0003; | |
1122 | |
1123 } // End if | |
1124 | |
1125 } // End if | |
1126 | |
1127 } // ti_nuc_monitor_LISR_log_end | |
1128 | |
1129 /*-------------------------------------------------------*/ | |
1130 /* ti_nuc_monitor_Thread_log() */ | |
1131 /*-------------------------------------------------------*/ | |
1132 /* */ | |
1133 /* Description: */ | |
1134 /* ------------ */ | |
1135 /* This function permits to include the Thread and */ | |
1136 /* timer value in the log buffer */ | |
1137 /*-------------------------------------------------------*/ | |
1138 | |
1139 void ti_nuc_monitor_Thread_log( void ) | |
1140 { | |
1141 SYS_UWORD16 timer_value; | |
1142 SYS_UWORD8 i; | |
1143 | |
1144 if( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) | |
1145 { | |
1146 | |
1147 // Exit Idle mode if reached | |
1148 | |
1149 ti_nuc_monitor_idle_reached = 0; | |
1150 | |
1151 // Check if page must be changed | |
1152 if( ti_nuc_monitor_change_thread_page == 1 ) | |
1153 { | |
1154 | |
1155 ti_nuc_monitor_change_thread_page = 0; | |
1156 | |
1157 // copy current to next | |
1158 ti_nuc_monitor_Thread_next_pos = ti_nuc_monitor_Thread_current_pos; | |
1159 ti_nuc_monitor_Thread_next_page = ti_nuc_monitor_Thread_current_page; | |
1160 | |
1161 // Reset current pointer | |
1162 ti_nuc_monitor_Thread_current_pos = 0; | |
1163 | |
1164 // Change page | |
1165 if( ti_nuc_monitor_Thread_current_page == 0 ) | |
1166 { | |
1167 ti_nuc_monitor_Thread_current_page = 1; | |
1168 } | |
1169 else | |
1170 { | |
1171 ti_nuc_monitor_Thread_current_page = 0; | |
1172 } // End if | |
1173 | |
1174 } // End if | |
1175 | |
1176 // Search the ID considering the Nucleus_Current_thread Pointer | |
1177 | |
1178 for( i = 0; i < ti_nuc_monitor_thread_pos ; i++ ) | |
1179 { | |
1180 if( ti_nuc_monitor_thread_id[ i ] == (SYS_UWORD32) TCD_Current_Thread ) | |
1181 { | |
1182 // insert the OP Code Thread | ID | |
1183 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1184 [ ti_nuc_monitor_Thread_current_pos ] = | |
1185 (SYS_UWORD8) (C_OP_CODE_THREAD_FLAG | i); | |
1186 // exit loop | |
1187 break; | |
1188 } // End if | |
1189 } // End for | |
1190 | |
1191 // Write the timer value | |
1192 | |
1193 timer_value = TM_ReadTimer(2); // (* (SYS_UWORD16 *) TIMER2_READ_TIM) | |
1194 | |
1195 // insert LSB | |
1196 | |
1197 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1198 [ ti_nuc_monitor_Thread_current_pos + 1 ] = | |
1199 (SYS_UWORD8) (timer_value & 0x00ff); | |
1200 | |
1201 // insert MSB | |
1202 | |
1203 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1204 [ ti_nuc_monitor_Thread_current_pos + 2 ] = | |
1205 (SYS_UWORD8) ((timer_value & 0xff00) >> 8); | |
1206 | |
1207 ti_nuc_monitor_Thread_current_pos += 3; | |
1208 | |
1209 } // End if | |
1210 | |
1211 } // ti_nuc_monitor_Thread_log | |
1212 | |
1213 /*-------------------------------------------------------*/ | |
1214 /* ti_nuc_monitor_Queue_log() */ | |
1215 /*-------------------------------------------------------*/ | |
1216 /* */ | |
1217 /* Description: */ | |
1218 /* ------------ */ | |
1219 /* This function permits to include the Queue ID and */ | |
1220 /* status value in the log buffer */ | |
1221 /* Direction = 0 => Send message */ | |
1222 /* Direction = 1 => Receive message */ | |
1223 /* status = 0 => OK */ | |
1224 /* status = 1 => Queue full */ | |
1225 /*-------------------------------------------------------*/ | |
1226 | |
1227 void ti_nuc_monitor_Queue_log( SYS_UWORD32* queue_pointer, SYS_UWORD8 status, SYS_UWORD8 Direction ) | |
1228 { | |
1229 SYS_UWORD8 status_word; | |
1230 SYS_UWORD8 i; | |
1231 | |
1232 | |
1233 | |
1234 if( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) | |
1235 { | |
1236 | |
1237 // Exit Idle mode if reached | |
1238 | |
1239 ti_nuc_monitor_idle_reached = 0; | |
1240 | |
1241 // Check if page must be changed | |
1242 if( ti_nuc_monitor_change_thread_page == 1 ) | |
1243 { | |
1244 | |
1245 ti_nuc_monitor_change_thread_page = 0; | |
1246 | |
1247 // copy current to next | |
1248 ti_nuc_monitor_Thread_next_pos = ti_nuc_monitor_Thread_current_pos; | |
1249 ti_nuc_monitor_Thread_next_page = ti_nuc_monitor_Thread_current_page; | |
1250 | |
1251 // Reset current pointer | |
1252 ti_nuc_monitor_Thread_current_pos = 0; | |
1253 | |
1254 // Change page | |
1255 if( ti_nuc_monitor_Thread_current_page == 0 ) | |
1256 { | |
1257 ti_nuc_monitor_Thread_current_page = 1; | |
1258 } | |
1259 else | |
1260 { | |
1261 ti_nuc_monitor_Thread_current_page = 0; | |
1262 } // End if | |
1263 | |
1264 } // End if | |
1265 | |
1266 // Search the ID considering the Nucleus_Current_thread Pointer | |
1267 for( i = 0; i < ti_nuc_monitor_queue_pos ; i++ ) | |
1268 { | |
1269 if( ti_nuc_monitor_queue_id[ i ] == (SYS_UWORD32) queue_pointer) | |
1270 { | |
1271 // insert the OP Code Thread | ID | |
1272 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1273 [ ti_nuc_monitor_Thread_current_pos ] = | |
1274 (SYS_UWORD8) (C_OP_CODE_QUEUE_FLAG | i); | |
1275 | |
1276 // exit loop | |
1277 break; | |
1278 | |
1279 } // End if | |
1280 } // End for | |
1281 | |
1282 // Write the status value and Receive/send flag | |
1283 | |
1284 status_word = (Direction << 8) | (status << 7) | i; // Direction | Status | ID | |
1285 | |
1286 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1287 [ ti_nuc_monitor_Thread_current_pos + 1 ] = | |
1288 (SYS_UWORD8) (status_word); | |
1289 | |
1290 ti_nuc_monitor_Thread_current_pos += 2; | |
1291 | |
1292 } // End if | |
1293 | |
1294 } // ti_nuc_monitor_Queue_log | |
1295 | |
1296 | |
1297 | |
1298 /*-------------------------------------------------------*/ | |
1299 /* ti_nuc_monitor_sleep() */ | |
1300 /*-------------------------------------------------------*/ | |
1301 /* */ | |
1302 /* Description: */ | |
1303 /* ------------ */ | |
1304 /* This function permits to include the sleep and */ | |
1305 /* timer value in the log buffer */ | |
1306 /*-------------------------------------------------------*/ | |
1307 | |
1308 void ti_nuc_monitor_sleep( void ) | |
1309 { | |
1310 | |
1311 SYS_UWORD16 timer_value; | |
1312 SYS_UWORD8 i; | |
1313 | |
1314 if(( ti_nuc_monitor_state == NUC_MONITOR_RUNNING ) && | |
1315 ( ti_nuc_monitor_idle_reached == 0 )) | |
1316 { | |
1317 | |
1318 ti_nuc_monitor_idle_reached = 1; | |
1319 | |
1320 // insert the OP Code Thread | ID | |
1321 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1322 [ ti_nuc_monitor_Thread_current_pos ] = | |
1323 (SYS_UWORD8) (0xBF); | |
1324 | |
1325 // Write the timer value | |
1326 | |
1327 timer_value = TM_ReadTimer(2); // (* (SYS_UWORD16 *) TIMER2_READ_TIM) | |
1328 | |
1329 // insert LSB | |
1330 | |
1331 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1332 [ ti_nuc_monitor_Thread_current_pos + 1 ] = | |
1333 (SYS_UWORD8) (timer_value & 0x00ff); | |
1334 | |
1335 // insert MSB | |
1336 | |
1337 ti_nuc_monitor_Thread_Buffer[ ti_nuc_monitor_Thread_current_page ] | |
1338 [ ti_nuc_monitor_Thread_current_pos + 2 ] = | |
1339 (SYS_UWORD8) ((timer_value & 0xff00) >> 8); | |
1340 | |
1341 ti_nuc_monitor_Thread_current_pos += 3; | |
1342 } // End if | |
1343 | |
1344 } // ti_nuc_monitor_sleep | |
1345 | |
1346 // -------------- RVT Copied function -------------------------------- | |
1347 // --- Modified Memory Bank ---- | |
1348 | |
1349 /********************************************************************************/ | |
1350 /* */ | |
1351 /* Function Name: ti_nuc_monitor_mem_alloc */ | |
1352 /* */ | |
1353 /* Purpose: this function creates a memory bank for the profiler task*/ | |
1354 /* */ | |
1355 /* Input Parameters: */ | |
1356 /* refer to t_rvt_type.h */ | |
1357 /* */ | |
1358 /* Output Parameters: */ | |
1359 /* refer to t_rvt_type.h */ | |
1360 /* */ | |
1361 /* Global Parameters: */ | |
1362 /* None. */ | |
1363 /* */ | |
1364 /* Note: */ | |
1365 /* None. */ | |
1366 /* */ | |
1367 /********************************************************************************/ | |
1368 | |
1369 | |
1370 T_RVT_RET ti_nuc_monitor_mem_alloc(T_RVT_USER_ID user_id, T_RVT_MSG_LG buffer_lenght, T_RVT_BUFFER * buff) | |
1371 { | |
1372 T_RVF_MB_STATUS return_value; | |
1373 | |
1374 return_value = rvf_get_buf (prof_mb_id, (UINT32) buffer_lenght + RVT_HEADER_SIZE, (T_RVF_BUFFER**) buff); | |
1375 | |
1376 if (return_value == RVF_RED) | |
1377 { | |
1378 *buff = NULL; | |
1379 return RVT_MEMORY_ERR; | |
1380 } | |
1381 else | |
1382 { | |
1383 *buff = *buff + RVT_HEADER_SIZE; | |
1384 return RVT_OK; | |
1385 } | |
1386 } // ti_nuc_monitor_mem_alloc | |
1387 | |
1388 // ------------------------------------------------------------------- | |
1389 | |
1390 #endif // TI_NUC_MONITOR | |
1391 | |
1392 #if (TI_PROFILER == 1) || (TI_NUC_MONITOR == 1) | |
1393 | |
1394 /*-------------------------------------------------------*/ | |
1395 /* ti_prf_init() */ | |
1396 /*-------------------------------------------------------*/ | |
1397 /* */ | |
1398 /* Description: Initialize profiling hisrs */ | |
1399 /* ------------ */ | |
1400 /* Register the profiling to rvt */ | |
1401 /* */ | |
1402 /*-------------------------------------------------------*/ | |
1403 | |
1404 void ti_prf_init( void ) | |
1405 { | |
1406 #if (TI_PROFILER == 1) | |
1407 ti_profiler_init_profiler_module(); | |
1408 #endif | |
1409 #if (TI_NUC_MONITOR == 1) | |
1410 ti_nuc_monitor_init_module(); | |
1411 #endif | |
1412 // Register to Trace task module | |
1413 rvt_register_id( "PROF", &prof_trace_id, ti_profiler_trace_rx_callback ); | |
1414 | |
1415 } // ti_prf_init | |
1416 | |
1417 /*-------------------------------------------------------*/ | |
1418 /* ti_prf_core() */ | |
1419 /*-------------------------------------------------------*/ | |
1420 /* */ | |
1421 /* Description: */ | |
1422 /* ------------ */ | |
1423 /* this function : */ | |
1424 /* - start the profiler on PC side message reception */ | |
1425 /* - stop the profiler on PC side message reception */ | |
1426 /* - cut the profiler buffer less than 256 bytes */ | |
1427 /* messages to rvt */ | |
1428 /* */ | |
1429 /*-------------------------------------------------------*/ | |
1430 | |
1431 T_RV_RET ti_prf_core(void) | |
1432 { | |
1433 | |
1434 SYS_UWORD16 i = 0; | |
1435 | |
1436 SYS_UWORD16 event; | |
1437 SYS_UWORD16 message_length; | |
1438 T_PROFILER_MSG *msg; | |
1439 | |
1440 while( INFINITE_LOOP ) | |
1441 { | |
1442 | |
1443 // Suspend the task on empty queue | |
1444 event = rvf_wait( RVF_TASK_MBOX_0_EVT_MASK, 0 ); | |
1445 msg = ( T_PROFILER_MSG* ) rvf_read_mbox( RVF_TASK_MBOX_0 ); | |
1446 | |
1447 // Check the msg ID code | |
1448 switch( msg->msg_id ) | |
1449 { | |
1450 | |
1451 #if (TI_PROFILER == 1) | |
1452 case TI_PROFILER_OUTPUT_BUFFER : | |
1453 // Cut the buffer in small element to be sent to | |
1454 // PC by the RVT. | |
1455 { | |
1456 message_length = TRACE_MESSAGE_SIZE; | |
1457 pos_pr_buffer = 0; | |
1458 | |
1459 // loop until end of buffer | |
1460 while( pos_pr_buffer < pr_buffer_length ) | |
1461 { | |
1462 // Update message length for next loop turn | |
1463 if ( pos_pr_buffer <= ( pr_buffer_length - TRACE_MESSAGE_SIZE ) ) | |
1464 { | |
1465 message_length = TRACE_MESSAGE_SIZE; | |
1466 } | |
1467 else | |
1468 { | |
1469 message_length = pr_buffer_length - pos_pr_buffer; | |
1470 } | |
1471 | |
1472 if( rvt_send_trace_cpy( ( T_RVT_BUFFER ) &pr_buffer[ pos_pr_buffer ], | |
1473 prof_trace_id, | |
1474 message_length * 4, // Length in bytes | |
1475 RVT_BINARY_FORMAT ) == RVT_OK ) | |
1476 { | |
1477 // Update pr_buffer pointer | |
1478 pos_pr_buffer += message_length; | |
1479 | |
1480 } // End if | |
1481 | |
1482 } // End while | |
1483 | |
1484 // Restart the profiling at vitam aeternam unless stop command received. | |
1485 if( profiler_state == PROFILER_FREEZED ) | |
1486 { | |
1487 profiler_state = PROFILER_TO_BE_UNFREEZED; | |
1488 } // End if | |
1489 | |
1490 break; | |
1491 } // TI_PROFILER_OUTPUT_BUFFER | |
1492 | |
1493 case TI_PROFILER_START_PROFILING : | |
1494 { | |
1495 #if (L1_TRACER == 1) | |
1496 SendTraces("TI_PROF: msg TI_PROFILER_START\n\r"); | |
1497 #endif | |
1498 | |
1499 ti_profiler_event_state = (T_PROFILER_EVENTS) (msg->event_number); | |
1500 | |
1501 if( ti_profiler_event_state == NO_SLEEP_EVENT ) | |
1502 { | |
1503 ti_profiler_nb_sleep_counter_ref = msg->arg1; // nb_tdma | |
1504 } // End if | |
1505 | |
1506 // Source of Activation | |
1507 ti_profiler_active = ACTIVE_BY_HOST; | |
1508 | |
1509 // change state of profiler | |
1510 profiler_state = PROFILER_TO_BE_RAN; | |
1511 | |
1512 break; | |
1513 } // TI_PROFILER_START_PROFILING | |
1514 | |
1515 case TI_PROFILER_END_PROFILING : | |
1516 { | |
1517 #if (L1_TRACER == 1) | |
1518 SendTraces("TI_PROF: msg TI_PROFILER_STOP\n\r"); | |
1519 #endif | |
1520 | |
1521 profiler_state = PROFILER_TO_BE_STOPPED; | |
1522 break; | |
1523 } // TI_PROFILER_END_PROFILING | |
1524 | |
1525 #endif | |
1526 | |
1527 #if (TI_NUC_MONITOR == 1) | |
1528 | |
1529 case TI_NUC_MONITOR_START : | |
1530 { | |
1531 SYS_UWORD8 i = 0; | |
1532 SYS_UWORD8 j = 0; | |
1533 #if (L1_TRACER == 1) | |
1534 SendTraces("TI_PROF: msg TI_NUC_MONITOR_START\n\r"); | |
1535 #endif | |
1536 | |
1537 if( ti_nuc_monitor_state == NUC_MONITOR_STOPPED ) | |
1538 { | |
1539 | |
1540 // Output the task and queues create info. | |
1541 // buffer format is following : | |
1542 // C_OP_CODE_NUC_MON_THREAD_IDS | (1 byte) | |
1543 // < Thread ID0 > | (1 byte) | |
1544 // < Thread name > | (8 bytes) | |
1545 // < Thread ID1 > | (1 byte) | |
1546 // < Thread name > | (8 bytes) | |
1547 // .............. | |
1548 // C_OP_CODE_NUC_MON_THREAD_IDS | (1 byte) | |
1549 // < Queue ID0 > | (1 byte) | |
1550 // < Queue name > | (8 bytes) | |
1551 // < Queue ID1 > | (1 byte) | |
1552 // < Queue name > | (8 bytes) | |
1553 // .............. | |
1554 // C_OP_CODE_NUC_MON_THREAD_IDS | (1 byte) | |
1555 | |
1556 // Allocate one buffer. | |
1557 | |
1558 while ((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
1559 NUC_MONITOR_BUFFER_SIZE, | |
1560 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
1561 != RVT_OK); | |
1562 | |
1563 | |
1564 // Output the ID (thread and Queue array) | |
1565 | |
1566 ti_nuc_monitor_current_buffer[ti_nuc_monitor_current_position++] = C_OP_CODE_NUC_MON_THREAD_IDS; | |
1567 | |
1568 // Output the Thread IDs and corresponding Thread name. | |
1569 | |
1570 for( i = 0 ; i < ti_nuc_monitor_thread_pos ; i++ ) | |
1571 { | |
1572 // distinghuish Task and HISR | |
1573 if( (( TC_TCB * ) ( ti_nuc_monitor_thread_id[ i ]))->tc_id == TC_HISR_ID) | |
1574 { | |
1575 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = (0x80 | i); // ID | |
1576 } | |
1577 else | |
1578 { | |
1579 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = i; // ID | |
1580 } // End if | |
1581 | |
1582 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1583 { | |
1584 ti_nuc_monitor_check_ID_buffer(); | |
1585 } // End if | |
1586 | |
1587 // Write task priority | |
1588 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
1589 (SYS_UWORD8) ((( TC_TCB * ) ( ti_nuc_monitor_thread_id[ i ]))->tc_priority); | |
1590 | |
1591 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1592 { | |
1593 ti_nuc_monitor_check_ID_buffer(); | |
1594 } // End if | |
1595 | |
1596 // Write name in the Log buffer. | |
1597 for( j = 0 ; j < NU_MAX_NAME ; j++ ) | |
1598 { | |
1599 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
1600 (SYS_UWORD8) ((( TC_TCB * ) ( ti_nuc_monitor_thread_id[ i ]))->tc_name[ j ]); // Thread_name | |
1601 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1602 { | |
1603 ti_nuc_monitor_check_ID_buffer(); | |
1604 } // End if | |
1605 } // End for | |
1606 | |
1607 } // End for | |
1608 | |
1609 // Output the ID (thread and Queue array) | |
1610 if( ti_nuc_monitor_queue_pos != 0 ) | |
1611 { | |
1612 ti_nuc_monitor_current_buffer[ti_nuc_monitor_current_position++] = C_OP_CODE_NUC_MON_THREAD_IDS; | |
1613 | |
1614 // Output the Queue IDs and corresponding Queue name. | |
1615 | |
1616 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1617 { | |
1618 ti_nuc_monitor_check_ID_buffer(); | |
1619 } // End if | |
1620 | |
1621 for( i = 0 ; i < ti_nuc_monitor_queue_pos ; i++ ) | |
1622 { | |
1623 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = i; // ID | |
1624 | |
1625 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1626 { | |
1627 ti_nuc_monitor_check_ID_buffer(); | |
1628 } // End if | |
1629 | |
1630 // Write name in the Log buffer. | |
1631 for( j = 0 ; j < NU_MAX_NAME ; j++ ) | |
1632 { | |
1633 ti_nuc_monitor_current_buffer[ ti_nuc_monitor_current_position++ ] = | |
1634 (SYS_UWORD8) ((( QU_QCB * ) ( ti_nuc_monitor_queue_id[ i ] ))->qu_name[ j ]); // Thread_name | |
1635 if( ti_nuc_monitor_current_position >= NUC_MONITOR_BUFFER_SIZE ) | |
1636 { | |
1637 ti_nuc_monitor_check_ID_buffer(); | |
1638 } // End if | |
1639 } // End for | |
1640 | |
1641 } // End for | |
1642 } // End if | |
1643 | |
1644 // Insert end op code (same as begin op code) | |
1645 | |
1646 ti_nuc_monitor_current_buffer[ti_nuc_monitor_current_position++] = C_OP_CODE_NUC_MON_THREAD_IDS; | |
1647 | |
1648 // flush the last buffer. | |
1649 | |
1650 // Send a message to the Riviera Tracer to Output the current buffer. | |
1651 if( rvt_send_trace_no_cpy( ( T_RVT_BUFFER ) ti_nuc_monitor_current_buffer, | |
1652 prof_trace_id, | |
1653 ti_nuc_monitor_current_position, // Length in bytes | |
1654 RVT_BINARY_FORMAT ) != RVT_OK ) | |
1655 { | |
1656 // Code to insert break point. | |
1657 ti_nuc_monitor_state = NUC_MONITOR_STOPPED; | |
1658 } // End if | |
1659 | |
1660 // Configuration buffer has been logged out. | |
1661 | |
1662 /* | |
1663 ** Allocate a buffer for Nucleus profiling | |
1664 */ | |
1665 | |
1666 while ((ti_nuc_monitor_mem_alloc (prof_trace_id, | |
1667 NUC_MONITOR_BUFFER_SIZE, | |
1668 (T_RVT_BUFFER*) &ti_nuc_monitor_current_buffer)) | |
1669 != RVT_OK); | |
1670 | |
1671 // reset the current pointer. | |
1672 ti_nuc_monitor_current_position = 0; | |
1673 | |
1674 // Set the new Monitoring state. | |
1675 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_STARTED; | |
1676 } // End if | |
1677 | |
1678 break; | |
1679 | |
1680 } // TI_NUC_MONITOR_START | |
1681 | |
1682 case TI_NUC_MONITOR_OUTPUT_BUFFER : | |
1683 { | |
1684 // The buffer is output only if it is full. | |
1685 | |
1686 // Send a message to the Riviera Tracer to Output the current buffer. | |
1687 if( rvt_send_trace_no_cpy( ( T_RVT_BUFFER ) msg->p_buffer, | |
1688 prof_trace_id, | |
1689 msg->buffer_size, // Length in bytes | |
1690 RVT_BINARY_FORMAT ) != RVT_OK ) | |
1691 { | |
1692 // increment lost messages variable | |
1693 ti_nuc_monitor_lost_messages++; | |
1694 } // End if | |
1695 | |
1696 break; | |
1697 | |
1698 } // TI_NUC_MONITOR_OUTPUT_BUFFER | |
1699 | |
1700 case TI_NUC_MONITOR_STOP : | |
1701 { | |
1702 #if (L1_TRACER == 1) | |
1703 SendTraces("TI_PROF: msg TI_NUC_MONITOR_STOP\n\r"); | |
1704 #endif | |
1705 | |
1706 ti_nuc_monitor_state = NUC_MONITOR_TO_BE_STOP; | |
1707 | |
1708 break; | |
1709 | |
1710 } // TI_NUC_MONITOR_STOP | |
1711 | |
1712 #endif | |
1713 | |
1714 default : | |
1715 { | |
1716 #if (L1_TRACER == 1) | |
1717 SendTraces("TI_PROF: msg default\n\r"); | |
1718 #endif | |
1719 | |
1720 break; | |
1721 } // default | |
1722 | |
1723 } // End switch | |
1724 | |
1725 | |
1726 // Free the msg alloc | |
1727 rvf_free_buf( msg ); | |
1728 | |
1729 } // End while ( INFINITE_LOOP ) | |
1730 | |
1731 } // ti_profiler_task | |
1732 | |
1733 | |
1734 /*-------------------------------------------------------*/ | |
1735 /* ti_profiler_trace_rx_callback() */ | |
1736 /*-------------------------------------------------------*/ | |
1737 /* */ | |
1738 /* Description: */ | |
1739 /* ------------ */ | |
1740 /* callback function called when the trace */ | |
1741 /* module receives a msg for the profiler */ | |
1742 /* or the nucleus monitor. */ | |
1743 /* */ | |
1744 /*-------------------------------------------------------*/ | |
1745 | |
1746 void ti_profiler_trace_rx_callback(T_RVT_BUFFER trace_msg, UINT16 trace_msg_size) | |
1747 { | |
1748 T_PROFILER_MSG * msg; | |
1749 | |
1750 // send a message to the ti profiler received from Rvt | |
1751 if( rvf_get_buf( prof_mb_id, sizeof( T_PROFILER_MSG ), ( T_RVF_BUFFER** ) &msg ) == RVF_GREEN ) | |
1752 { | |
1753 /* | |
1754 if( trace_msg[0] == 1 ) | |
1755 msg->msg_id = TI_PROFILER_START_PROFILING; | |
1756 else if ( trace_msg[0] == 0 ) | |
1757 msg->msg_id = TI_PROFILER_END_PROFILING; | |
1758 else if ( trace_msg[0] == 2 ) | |
1759 msg->msg_id = TI_NUC_MONITOR_START; | |
1760 else if ( trace_msg[0] == 3 ) | |
1761 msg->msg_id = TI_NUC_MONITOR_STOP; | |
1762 */ | |
1763 msg->msg_id = ((T_PROFILER_MSG_UART*) trace_msg)->msg_id; | |
1764 msg->event_number = ((T_PROFILER_MSG_UART*) trace_msg)->event_number; | |
1765 msg->arg1 = ((T_PROFILER_MSG_UART*) trace_msg)->arg1; | |
1766 | |
1767 rvf_send_msg( prof_addr_id, msg ); | |
1768 } | |
1769 | |
1770 } // ti_profiler_trace_rx_callback | |
1771 | |
1772 #endif // NUC_MONITOR || PROFILER | |
1773 |