xref: /freebsd/sys/dev/pms/RefTisa/sallsdk/spc/mpidebug.c (revision 257e70f1d5ee61037c8c59b116538d3b6b1427a2)
1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20 
21 ********************************************************************************/
22 
23 /*******************************************************************************/
24 /*! \file mpidebug.c
25  *  \brief The file is a MPI Libraries to implement the MPI debug and trace functions
26  *
27  * The file implements the MPI functions.
28  *
29  */
30 /*******************************************************************************/
31 #include <sys/cdefs.h>
32 #include <dev/pms/config.h>
33 
34 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
35 #ifdef MPI_DEBUG_TRACE_ENABLE /* enable with CCBUILD_MPI_TRACE*/
36 
37 /*******************************************************************************/
38 
39 #ifdef OSLAYER_USE_HI_RES_TIMER
40 unsigned __int64
41 GetHiResTimeStamp(void);
42 #endif /* OSLAYER_USE_HI_RES_TIMER */
43 /*******************************************************************************/
44 /*******************************************************************************/
45 /* FUNCTIONS                                                                   */
46 /*******************************************************************************/
47 mpiDebugObTrace_t obTraceData;
48 mpiDebugIbTrace_t ibTraceData;
49 
50 void mpiTraceInit(void)
51 {
52 
53   SA_DBG1(("mpiTraceInit:obTraceData @ %p\n",&obTraceData ));
54   SA_DBG1(("mpiTraceInit:ibTraceData @ %p\n",&ibTraceData ));
55   SA_DBG1(("mpiTraceInit: num enties %d Ib Iomb size %d Ob Iomb size %d\n",
56                MPI_DEBUG_TRACE_BUFFER_MAX,
57                MPI_DEBUG_TRACE_IB_IOMB_SIZE,
58                MPI_DEBUG_TRACE_OB_IOMB_SIZE ));
59 
60   si_memset(&obTraceData, 0, sizeof(obTraceData));
61   si_memset(&ibTraceData, 0, sizeof(ibTraceData));
62 }
63 
64 void mpiTraceAdd( bit32 q,bit32 pici,bit32 ib, void *iomb, bit32 numBytes)
65 {
66   bit32                  curIdx;
67   mpiDebugIbTraceEntry_t *curIbTrace;
68   mpiDebugObTraceEntry_t *curObTrace;
69 
70   mpiDebugIbTrace_t * ibTrace = &ibTraceData;
71   mpiDebugObTrace_t * obTrace = &obTraceData;
72 
73   if (ib)
74   {
75     if(ibTrace->Idx >= MPI_DEBUG_TRACE_BUFFER_MAX)
76     {
77       ibTrace->Idx = 0;
78     }
79     curIdx = ibTrace->Idx;
80 
81     curIbTrace = &ibTrace->Data[curIdx];
82     curIbTrace->pEntry =  iomb;
83     curIbTrace->QNum = q;
84     curIbTrace->pici = pici;
85 #ifdef OSLAYER_USE_HI_RES_TIMER
86 #ifdef SA_64BIT_TIMESTAMP
87   curIbTrace->Time = ossaTimeStamp64(agNULL);
88 #else /* SA_64BIT_TIMESTAMP */
89   curIbTrace->Time = ossaTimeStamp(agNULL);
90 #endif /* SA_64BIT_TIMESTAMP */
91 #else /* OSLAYER_USE_HI_RES_TIMER */
92   curIbTrace->Time = 0;
93 #endif
94     si_memcpy(curIbTrace->Iomb, iomb, MIN(numBytes, MPI_DEBUG_TRACE_IB_IOMB_SIZE));
95     ibTrace->Idx++;
96   }
97   else
98   {
99     if(obTrace->Idx >= MPI_DEBUG_TRACE_BUFFER_MAX )
100     {
101       obTrace->Idx = 0;
102     }
103     curIdx = obTrace->Idx;
104     curObTrace = &obTrace->Data[curIdx];
105     curObTrace->pEntry =  iomb;
106     curObTrace->QNum = q;
107     curObTrace->pici = pici;
108 #ifdef OSLAYER_USE_HI_RES_TIMER
109 #ifdef SA_64BIT_TIMESTAMP
110     curObTrace->Time = ossaTimeStamp64(agNULL);
111 #else /* SA_64BIT_TIMESTAMP */
112     curObTrace->Time = ossaTimeStamp(agNULL);
113 #endif /* SA_64BIT_TIMESTAMP */
114 #else /* OSLAYER_USE_HI_RES_TIMER */
115     curObTrace->Time = 0;
116 #endif
117     si_memcpy(curObTrace->Iomb, iomb, MIN(numBytes, MPI_DEBUG_TRACE_OB_IOMB_SIZE));
118     obTrace->Idx++;
119   }
120 
121 
122   return;
123 }
124 
125 #endif /* MPI_DEBUG_TRACE_ENABLE */
126 
127 
128 
129 #ifdef SA_ENABLE_TRACE_FUNCTIONS
130 
131 /**
132  * fiEnableTracing
133  *
134  *    This fucntion is called to initialize tracing of FC layer.
135  *
136  */
137 void siEnableTracing (agsaRoot_t  *agRoot)
138 {
139 
140   agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
141   agsaSwConfig_t    *swC  = &saRoot->swConfig;
142   bit32 count;
143 
144   OS_ASSERT(saRoot != NULL, "");
145 
146   if( saRoot->TraceBlockReInit != 0)
147   {
148     return;
149   }
150 
151 
152   /* Initialize tracing first */
153 
154   for (count = 0; count < 10; count++)
155   {
156       saRoot->traceBuffLookup[count] = (bit8)('0' + count);
157   }
158   for (count = 0; count < 6; count++)
159   {
160       saRoot->traceBuffLookup[(bitptr)count + 10] = (bit8)('a' + count);
161   }
162 
163 
164   saRoot->TraceDestination = swC->TraceDestination;
165   saRoot->TraceMask = swC->TraceMask;
166   saRoot->CurrentTraceIndexWrapCount = 0;
167   saRoot->CurrentTraceIndex = 0;
168   saRoot->TraceBlockReInit = 1;
169 
170 
171   SA_DBG1(("siEnableTracing: \n" ));
172 
173   SA_DBG1 (("      length       = %08x\n", saRoot->TraceBufferLength ));
174   SA_DBG1 (("      virt         = %p\n",   saRoot->TraceBuffer ));
175   SA_DBG1 (("    traceMask        = %08x @ %p\n", saRoot->TraceMask, &saRoot->TraceMask));
176   SA_DBG1 (("    last trace entry @ %p\n", &saRoot->CurrentTraceIndex));
177   SA_DBG1 (("    TraceWrapAround  = %x\n", saRoot->TraceMask & hpDBG_TraceBufferWrapAround ? 1 : 0));
178   SA_DBG1 (("    da %p l %x\n",saRoot->TraceBuffer ,saRoot->TraceBufferLength));
179 
180 #ifdef SA_PRINTOUT_IN_WINDBG
181 #ifndef DBG
182   DbgPrint("siTraceEnable: \n" );
183 
184   DbgPrint("      length       = %08x\n", saRoot->TraceBufferLength );
185   DbgPrint("      virt         = %p\n",   saRoot->TraceBuffer );
186   DbgPrint("    last trace entry @ %p\n", &saRoot->CurrentTraceIndex);
187   DbgPrint("    traceMask      = %08x @ %p\n", saRoot->TraceMask, &saRoot->TraceMask);
188   DbgPrint("    da %p l %x\n",saRoot->TraceBuffer ,saRoot->TraceBufferLength);
189 #endif /* DBG  */
190 #endif /* SA_PRINTOUT_IN_WINDBG  */
191   /*
192   ** Init trace buffer with all spaces
193   */
194   for (count = 0; count < saRoot->TraceBufferLength; count++)
195   {
196       saRoot->TraceBuffer[count] = (bit8)' ';
197   }
198 
199 }
200 
201 
202 
203 /**
204  * IF_DO_TRACE
205  *
206  * PURPOSE:     convenience macro for the "to output or not to output" logic
207  *
208  * PARAMETERS:
209  *
210  * CALLS:
211  *
212  * SIDE EFFECTS & CAVEATS:
213  *
214  * ALGORITHM:
215  *
216  *
217  *
218  *     MODIFICATION HISTORY     ***********************
219  *
220  * ENGINEER NAME      DATE     DESCRIPTION
221  * -------------    --------   -----------
222  */
223 
224 #define IF_DO_TRACE                                     \
225   if ( (saRoot != NULL) &&                              \
226        (saRoot->TraceDestination & siTraceDestMask) &&  \
227        (mask & saRoot->TraceMask) )                     \
228 
229 
230 /* #define TRACE_ENTER_LOCK  ossaSingleThreadedEnter(agRoot, LL_TRACE_LOCK); */
231 /* #define TRACE_LEAVE_LOCK  ossaSingleThreadedLeave(agRoot, LL_TRACE_LOCK); */
232 #define TRACE_ENTER_LOCK
233 #define TRACE_LEAVE_LOCK
234 /**
235  * BUFFER_WRAP_CHECK
236  *
237  * PURPOSE: Checks if the tracing buffer tracing index is too high.  If it is,
238  *          the buffer index gets reset to 0 or tracing stops..
239  */
240 #define BUFFER_WRAP_CHECK                                           \
241     if( (saRoot->CurrentTraceIndex + TMP_TRACE_BUFF_SIZE)               \
242                            >= saRoot->TraceBufferLength )               \
243     {                                                                   \
244         /* Trace wrap-Around is enabled.  */                            \
245         if( saRoot->TraceMask & hpDBG_TraceBufferWrapAround )           \
246         {                                                               \
247             /* Fill the end of the buffer with spaces */                \
248             for( i = saRoot->CurrentTraceIndex;                         \
249                      i < saRoot->TraceBufferLength; i++ )               \
250             {                                                           \
251                 saRoot->TraceBuffer[i] = (bit8)' ';                     \
252             }                                                           \
253             /* Wrap the current trace index back to 0.. */              \
254             saRoot->CurrentTraceIndex = 0;                              \
255             saRoot->CurrentTraceIndexWrapCount++;                       \
256         }                                                               \
257         else                                                            \
258         {                                                               \
259             /* Don't do anything -- trace buffer is filled up */        \
260             return;                                                     \
261         }                                                               \
262     }
263 
264 /**
265  * LOCAL_OS_LOG_DEBUG_STRING
266  *
267  * PURPOSE:     protects against a change in the api for this function
268  *
269  * PARAMETERS:
270  *
271  * CALLS:
272  *
273  * SIDE EFFECTS & CAVEATS:
274  *
275  * ALGORITHM:
276  *
277  *
278  *
279  *     MODIFICATION HISTORY     ***********************
280  *
281  * ENGINEER NAME      DATE     DESCRIPTION
282  * -------------    --------   -----------
283  * Laurent Chavey   03/09/00   - changed cast of 3rd parameter to (char *)
284  */
285     #define LOCAL_OS_LOG_DEBUG_STRING(H,S)  \
286             osLogDebugString(H,hpDBG_ALWAYS,(char *)(S))
287 
288 /******************************************************************************
289 *******************************************************************************
290 **
291 ** copyHex
292 **
293 ** PURPOSE:  Copies a hex version of a bit32 into a bit8 buffer
294 **
295 *******************************************************************************
296 ******************************************************************************/
297 #define copyHex(bit32Val, bitSize)                                     \
298 {                                                                      \
299   bit32 nibbleLen = bitSize / 4;                                       \
300   bit32 scratch = 0;                                                   \
301   for( i = 0; i < nibbleLen; i++ )                                     \
302   {                                                                    \
303     bPtr[pos++] =                                                      \
304         saRoot->traceBuffLookup[0xf & (bit32Val >> ((bitSize - 4) - (i << 2)))];  \
305     i++;                                                               \
306     bPtr[pos++] =                                                      \
307     saRoot->traceBuffLookup[0xf & (bit32Val >> ((bitSize - 4) - (i << 2)))]; \
308     /* Skip leading 0-s to save memory buffer space */                 \
309     if( !scratch                                                       \
310           && (bPtr[pos-2] == '0')                                      \
311           && (bPtr[pos-1] == '0') )                                    \
312     {                                                                  \
313       pos -= 2;                                                        \
314       continue;                                                        \
315     }                                                                  \
316     else                                                               \
317     {                                                                  \
318       scratch = 1;                                                     \
319     }                                                                  \
320   }                                                                    \
321   if( scratch == 0 )                                                   \
322   {                                                                    \
323     /* The value is 0 and nothing got put in the buffer.  Do       */  \
324     /* print at least two zeros.                                   */  \
325     bPtr[pos++] = '0';                                                 \
326     bPtr[pos++] = '0';                                                 \
327   }                                                                    \
328 }
329 
330 
331 /**
332  * TRACE_OTHER_DEST
333  *
334  * PURPOSE:  Check if any other destinations are enabled.  If yes, use them
335  *           for debug log.
336  */
337 #define TRACE_OTHER_DEST                                                \
338     {                                                                   \
339     bit32 bitptrscratch;                                                \
340     if( saRoot->TraceDestination & smTraceDestDebugger )                \
341     {                                                                   \
342         bPtr[pos++] = (bit8)'\n';                                       \
343         bPtr[pos++] = (bit8)0;                                          \
344         LOCAL_OS_LOG_DEBUG_STRING(hpRoot, (char *)bPtr);                \
345     }                                                                   \
346     if( saRoot->TraceDestination & smTraceDestRegister )                \
347     {                                                                   \
348         while( (pos & 0x3) != 0x3 )                                     \
349         {                                                               \
350             bPtr[pos++] = (bit8)' ';                                    \
351         }                                                               \
352         bPtr[pos] = ' ';                                                \
353         for( i = 0; i < pos; i = i + 4 )                                \
354         {                                                               \
355             bitptrscratch =  bPtr[i+0];                                 \
356             bitptrscratch <<= 8;                                        \
357             bitptrscratch |= bPtr[i+1];                                 \
358             bitptrscratch <<= 8;                                        \
359             bitptrscratch |= bPtr[i+2];                                 \
360             bitptrscratch <<= 8;                                        \
361             bitptrscratch |= bPtr[i+3];                                 \
362             osChipRegWrite(hpRoot,                                      \
363                  FC_rFMReceivedALPA, (bit32)bitptrscratch );            \
364         }                                                               \
365     }                                                                   \
366     }
367 
368 
369 
370 /**
371  * siGetCurrentTraceIndex()
372  *
373  * PURPOSE:     Returns the current tracing index ( if tracing buffer is
374  *              used ).
375  *
376  * PARAMETERS:
377  *
378  * CALLS:
379  *
380  * SIDE EFFECTS & CAVEATS:
381  *
382  * ALGORITHM:
383  *
384  *
385  *     MODIFICATION HISTORY     ***********************
386  *
387  * ENGINEER NAME      DATE     DESCRIPTION
388  * -------------    --------   -----------
389  * Tom Nalepa       02/27/03
390  *
391  * @param hpRoot
392  *
393  * @return
394  */
395 GLOBAL bit32 siGetCurrentTraceIndex(agsaRoot_t  *agRoot)
396 {
397     agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
398     return(saRoot->CurrentTraceIndex);
399 }
400 
401 
402 
403 
404 /**
405  * siResetTraceBuffer
406  *
407  * PURPOSE:     Sets saRoot->CurrentTraceIndex to 0.
408  *
409  * @param hpRoot
410  *
411  * @return
412  */
413 GLOBAL void siResetTraceBuffer(agsaRoot_t  *agRoot)
414 {
415     bit32 count;
416     agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
417     saRoot->CurrentTraceIndex = 0;
418 
419     for ( count = 0; count < saRoot->TraceBufferLength; count++ )
420     {
421         saRoot->TraceBuffer[count] = (bit8)' ';
422     }
423 }
424 
425 
426 /**
427  * siTraceFuncEnter
428  *
429  * PURPOSE:     Format a function entry trace and post it to the appropriate
430  *              destination.
431  *
432  * PARAMETERS:
433  *
434  * CALLS:
435  *
436  * SIDE EFFECTS & CAVEATS:
437  *
438  * ALGORITHM:
439  *
440  * siTraceFuncEnter  :    _[Xxxxx_
441  *                 fileid---^  ^------funcid
442  *
443  *
444  *     MODIFICATION HISTORY     ***********************
445  *
446  * ENGINEER NAME      DATE     DESCRIPTION
447  * -------------    --------   -----------
448  *
449  * @param hpRoot
450  * @param mask
451  * @param fileid
452  * @param funcid
453  *
454  * @return
455  */
456 
457 #define TMP_TRACE_BUFF_SIZE 32
458 
459 
460 GLOBAL void siTraceFuncEnter( agsaRoot_t  *agRoot,
461                              bit32        mask,
462                              bit32        fileid,
463                              char       * funcid)
464 {
465 agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
466     bitptr         i;
467     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
468     bit8          *bPtr;
469     bit8           pos = 0;
470 
471     IF_DO_TRACE
472     {
473       TRACE_ENTER_LOCK
474       if ( saRoot->TraceDestination & smTraceDestBuffer )
475       {
476         BUFFER_WRAP_CHECK
477         bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
478       }
479       else
480       {
481         bPtr = tmpB;
482       }
483       bPtr[pos++] = (bit8)'[';
484 
485 #ifndef FC_DO_NOT_INCLUDE_FILE_NAME_TAGS_IN_ENTER_EXIT_TRACE
486         bPtr[pos++] = (bit8)fileid;
487 #endif
488 
489         for ( i=0; i<4; i++ )
490         {
491             if ( funcid[i] == 0 )
492             {
493                 break;
494             }
495             bPtr[pos++] = (bit8)funcid[i];
496         }
497         bPtr[pos++] = ' ';
498         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
499         {
500             bPtr[pos++] = '\r';
501             bPtr[pos++] = '\n';
502             saRoot->traceLineFeedCnt = 0;
503         }
504         saRoot->CurrentTraceIndex += pos;
505 //        TRACE_OTHER_DEST
506     TRACE_LEAVE_LOCK
507 
508     }
509     return;
510 }
511 
512 
513 /**
514  * siTraceFuncExit
515  *
516  * PURPOSE:     Format a function exit trace and post it to the appropriate
517  *              destination.
518  *
519  * PARAMETERS:
520  *
521  * CALLS:
522  *
523  * SIDE EFFECTS & CAVEATS:
524  *
525  * ALGORITHM:
526  *
527  * siTraceFuncExit         _Xxxxx]_
528  *                 fileid---^  ^------funcid
529  *
530  *
531  *     MODIFICATION HISTORY     ***********************
532  *
533  * ENGINEER NAME      DATE     DESCRIPTION
534  * -------------    --------   -----------
535  *
536  * @param hpRoot
537  * @param mask
538  * @param fileid
539  * @param funcid
540  * @param exitId
541  *
542  * @return
543  */
544 GLOBAL void siTraceFuncExit(   agsaRoot_t  *agRoot,  bit32   mask, char  fileid, char  * funcid, char  exitId )
545 {
546     bitptr         i;
547     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
548     bit8          *bPtr;
549     bit8           pos = 0;
550 
551     agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
552 
553     IF_DO_TRACE
554     {
555       TRACE_ENTER_LOCK
556       if ( saRoot->TraceDestination & smTraceDestBuffer )
557       {
558         BUFFER_WRAP_CHECK
559         bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
560       }
561       else
562       {
563         bPtr = tmpB;
564       }
565 
566 #ifndef FC_DO_NOT_INCLUDE_FILE_NAME_TAGS_IN_ENTER_EXIT_TRACE
567         bPtr[pos++] = (bit8)fileid;
568 #endif
569 
570         for ( i=0; i<4; i++ )
571         {
572             if ( funcid[i] == 0 )
573             {
574                 break;
575             }
576             bPtr[pos++] = (bit8)funcid[i];
577         }
578         bPtr[pos++] = (bit8)exitId;
579         bPtr[pos++] = (bit8)']';
580         bPtr[pos++] = (bit8)' ';
581         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
582         {
583             bPtr[pos++] = '\r';
584             bPtr[pos++] = '\n';
585             saRoot->traceLineFeedCnt = 0;
586         }
587         saRoot->CurrentTraceIndex += pos;
588 //        TRACE_OTHER_DEST
589     TRACE_LEAVE_LOCK
590     }
591     return;
592 }
593 
594 /**
595  * siTraceListRemove
596  *
597  * PURPOSE:     Adds a trace tag for an exchange that is removed from a list
598  *
599  * PARAMETERS:
600  *
601  * CALLS:
602  *
603  * SIDE EFFECTS & CAVEATS:
604  *
605  * ALGORITHM:
606  *
607  *
608  *     MODIFICATION HISTORY     ***********************
609  *
610  * ENGINEER NAME      DATE     DESCRIPTION
611  * -------------    --------   -----------
612  * Tom Nalepa       12/16/02   Initial Developmet
613  *
614  * @param hpRoot
615  * @param mask
616  * @param listId
617  * @param exchangeId
618  *
619  * @return
620  */
621 GLOBAL void siTraceListRemove(agsaRoot_t  *agRoot,
622                               bit32        mask,
623                               char         listId,
624                               bitptr       exchangeId)
625 {
626     agsaLLRoot_t      *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
627     bitptr         i;
628     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
629     bit8          *bPtr;
630     bit8           pos = 0;
631 
632     IF_DO_TRACE
633     {
634      TRACE_ENTER_LOCK
635         if ( saRoot->TraceDestination & smTraceDestBuffer )
636         {
637             BUFFER_WRAP_CHECK
638             bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
639         }
640         else
641         {
642             bPtr = tmpB;
643         }
644         bPtr[pos++] = (bit8)'<';
645         bPtr[pos++] = (bit8)listId;
646         copyHex(exchangeId, 32);
647         bPtr[pos++] = (bit8)' ';
648         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
649         {
650             bPtr[pos++] = '\r';
651             bPtr[pos++] = '\n';
652             saRoot->traceLineFeedCnt = 0;
653         }
654         saRoot->CurrentTraceIndex += pos;
655 //        TRACE_OTHER_DEST
656     TRACE_LEAVE_LOCK
657     }
658     return;
659 }
660 
661 /**
662  * siTraceListAdd
663  *
664  * PURPOSE:     Adds a trace tag for an exchange that is added to a list
665  *
666  * PARAMETERS:
667  *
668  * CALLS:
669  *
670  * SIDE EFFECTS & CAVEATS:
671  *
672  * ALGORITHM:
673  *
674  *
675  *     MODIFICATION HISTORY     ***********************
676  *
677  * ENGINEER NAME      DATE     DESCRIPTION
678  * -------------    --------   -----------
679  * Tom Nalepa       12/16/02   Initial Developmet
680  *
681  * @param hpRoot
682  * @param mask
683  * @param listId
684  * @param exchangeId
685  *
686  * @return
687  */
688 GLOBAL void siTraceListAdd(agsaRoot_t      *agRoot,
689                            bit32        mask,
690                            char         listId,
691                            bitptr       exchangeId)
692 {
693 
694   agsaLLRoot_t          *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
695 
696     bitptr         i;
697     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
698     bit8          *bPtr;
699     bit8           pos = 0;
700 
701     IF_DO_TRACE
702     {
703         if ( saRoot->TraceDestination & smTraceDestBuffer )
704         {
705             BUFFER_WRAP_CHECK
706             bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
707         }
708         else
709         {
710             bPtr = tmpB;
711         }
712         bPtr[pos++] = (bit8)'>';
713         bPtr[pos++] = (bit8)listId;
714         copyHex(exchangeId, 32);
715         bPtr[pos++] = (bit8)' ';
716         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
717         {
718             bPtr[pos++] = '\r';
719             bPtr[pos++] = '\n';
720             saRoot->traceLineFeedCnt = 0;
721         }
722         saRoot->CurrentTraceIndex += pos;
723 //        TRACE_OTHER_DEST
724     }
725     return;
726 }
727 
728 /**
729  * siTrace64
730  *
731  * PURPOSE:     Format a function parameter trace and post it to the appropriate
732  *              destination.
733  *
734  * PARAMETERS:
735  *
736  * CALLS:
737  *
738  * SIDE EFFECTS & CAVEATS:
739  *
740  * ALGORITHM:
741  *
742  * siTrace : index is 0 for return value, 1 for first parm after "("
743  *           produces:   _nn" XXXXXXXXXX
744  *           index-----^    value--^
745  *
746  *
747  *     MODIFICATION HISTORY     ***********************
748  *
749  * ENGINEER NAME      DATE     DESCRIPTION
750  * -------------    --------   -----------
751  *
752  * @param hpRoot
753  * @param mask
754  * @param uId
755  * @param value
756  *
757  * @return
758  */
759 GLOBAL void siTrace64(agsaRoot_t      *agRoot,
760                       bit32        mask,
761                       char       * uId,
762                       bit64        value,
763                       bit32        dataSizeInBits)
764 {
765 
766     agsaLLRoot_t  *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
767     bitptr         i;
768     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
769     bit8          *bPtr;
770     bit8           pos = 0;
771 
772     IF_DO_TRACE
773     {
774         if ( saRoot->TraceDestination & smTraceDestBuffer )
775         {
776             BUFFER_WRAP_CHECK
777             bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
778         }
779         else
780         {
781             bPtr = tmpB;
782         }
783         bPtr[pos++] = (bit8)'"';
784         bPtr[pos++] = (bit8)uId[0];
785         bPtr[pos++] = (bit8)uId[1];
786         bPtr[pos++] = (bit8)':';
787         copyHex(value, dataSizeInBits);
788         bPtr[pos++] = (bit8)' ';
789         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
790         {
791             bPtr[pos++] = '\r';
792             bPtr[pos++] = '\n';
793             saRoot->traceLineFeedCnt = 0;
794         }
795         saRoot->CurrentTraceIndex += pos;
796 //        TRACE_OTHER_DEST
797     }
798     return;
799 }
800 
801 
802 
803 /**
804  * siTrace
805  *
806  * PURPOSE:     Format a function parameter trace and post it to the appropriate
807  *              destination.
808  *
809  * PARAMETERS:
810  *
811  * CALLS:
812  *
813  * SIDE EFFECTS & CAVEATS:
814  *
815  * ALGORITHM:
816  *
817  * fiTrace : index is 0 for return value, 1 for first parm after "("
818  *           produces:   _nn" XXXXXXXXXX
819  *           index-----^    value--^
820  *
821  *
822  *     MODIFICATION HISTORY     ***********************
823  *
824  * ENGINEER NAME      DATE     DESCRIPTION
825  * -------------    --------   -----------
826  *
827  * @param hpRoot
828  * @param mask
829  * @param uId
830  * @param value
831  *
832  * @return
833  */
834 GLOBAL void siTrace( agsaRoot_t      *agRoot,
835                     bit32        mask,
836                     char       * uId,
837                     bit32        value,
838                     bit32        dataSizeInBits)
839 {
840 
841    agsaLLRoot_t   *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
842 
843     bitptr         i;
844     bit8           tmpB[TMP_TRACE_BUFF_SIZE];
845     bit8          *bPtr;
846     bit8           pos = 0;
847 
848     IF_DO_TRACE
849     {
850         if ( saRoot->TraceDestination & smTraceDestBuffer )
851         {
852             BUFFER_WRAP_CHECK
853             bPtr = &saRoot->TraceBuffer[saRoot->CurrentTraceIndex];
854         }
855         else
856         {
857             bPtr = tmpB;
858         }
859         bPtr[pos++] = (bit8)'"';
860         bPtr[pos++] = (bit8)uId[0];
861         bPtr[pos++] = (bit8)uId[1];
862         bPtr[pos++] = (bit8)':';
863         copyHex(value, dataSizeInBits);
864         bPtr[pos++] = (bit8)' ';
865         if ( saRoot->traceLineFeedCnt > FC_TRACE_LINE_SIZE )
866         {
867             bPtr[pos++] = '\r';
868             bPtr[pos++] = '\n';
869             saRoot->traceLineFeedCnt = 0;
870         }
871         saRoot->CurrentTraceIndex += pos;
872 //        TRACE_OTHER_DEST
873     }
874     return;
875 }
876 
877 
878 /*Set Wrap 0 for Wrapping non zero stops when full  */
879 
880 
881 GLOBAL void siTraceGetInfo(agsaRoot_t  *agRoot, hpTraceBufferParms_t * pBParms)
882 {
883     agsaLLRoot_t  *saRoot = (agsaLLRoot_t *)agRoot->sdkData;
884 
885     pBParms->TraceCompiled  =  TRUE;
886 
887     pBParms->TraceWrap                  = saRoot->TraceMask & 0x80000000;
888     pBParms->CurrentTraceIndexWrapCount = saRoot->CurrentTraceIndexWrapCount;
889     pBParms->BufferSize                 = saRoot->TraceBufferLength;
890     pBParms->CurrentIndex               = saRoot->CurrentTraceIndex;
891     pBParms->pTrace                     = saRoot->TraceBuffer;
892     pBParms->pTraceIndexWrapCount       = &saRoot->CurrentTraceIndexWrapCount;
893     pBParms->pTraceMask                 = &saRoot->TraceMask;
894     pBParms->pCurrentTraceIndex         = &saRoot->CurrentTraceIndex;
895 }
896 /**/
897 
898 GLOBAL void siTraceSetMask(agsaRoot_t  *agRoot, bit32 TraceMask  )
899 {
900     agsaLLRoot_t  *saRoot = (agsaLLRoot_t *)agRoot->sdkData;
901     saRoot->TraceMask = TraceMask;
902 }
903 
904 
905 
906 #endif
907 
908 
909