]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/common/paf_alg_print.c
PASDK-319:Update headers to 2017
[processor-sdk/performance-audio-sr.git] / pasdk / common / paf_alg_print.c
2 /*
3 Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 //
37 // Algorithm RAM_REPORT definitions
38 //
40 #include <stdlib.h> // malloc
41 //#include <stdio.h>  // printf
42 #include <paf_alg_print.h>
44 #include <xdc/runtime/Memory.h>
45 #include <xdc/runtime/IHeap.h>
46 #include <xdc/runtime/System.h>
47 #include <ti/sysbios/heaps/HeapMem.h>
49 Int
50 PAF_ALG_allocPrint(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p)
51 {
52     IALG_MemRec *memTab;
53     Int commonSize[PAF_IALG_COMMON_MEMN+1];
54     Int commonCount[PAF_IALG_COMMON_MEMN+1];
55     Int commonSpace[PAF_IALG_COMMON_MEMN+1];
56     Int i,n;
58     for ( ; pInit && pInit->ialg_fxns; pInit=(const PAF_ALG_AllocInit *)((char *)pInit+sizeofInit)) 
59     {
60 #ifdef _TMS320C6X
61 #pragma UNROLL(1)
62 #endif
63         for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i) 
64         {
65             commonSize[i]=0;
66             commonCount[i]=0;
67             commonSpace[i]=-1;
68         }
69         n = pInit->ialg_fxns->algNumAlloc != NULL ? pInit->ialg_fxns->algNumAlloc() : IALG_DEFMEMRECS;
70         if ((memTab = (IALG_MemRec *)malloc(n * sizeof(IALG_MemRec))))
71         {
72             n = pInit->ialg_fxns->algAlloc(pInit->ialg_prms, (IALG_Fxns **)&(pInit->ialg_fxns),memTab);
73             if (n <= 0)
74             {
75                 return PAF_ALGERR_MEMTAB_COUNT;
76             }
78             for (i=0; i<n; ++i)
79             {
80                 if ((((Int)memTab[i].attrs >= PAF_IALG_COMMON_MEM0) && ((Int)memTab[i].attrs <= PAF_IALG_COMMON_MEMN))) 
81                 {
82                     commonSize[memTab[i].attrs] += memTab[i].size + 
83                         (commonCount[memTab[i].attrs] ? memTab[i].alignment : 0);
84                     commonCount[memTab[i].attrs]++;
85                 }
86                 // (***) FL: this is broken for printout of persistent memory
87                 // The code was broken before addition of persist memory in INT1 SHM (MSMC).
88                 // commonSize[] and commonCount[] are correct, but here persist is treated like common memory, i.e.
89                 //     persistent memory is treated as through it's combined into a single memory space.
90                 //     For example, printout can only show persist memory as belonging to one space.
91                 //     This isn't true for persistent memory since it can be in multiple spaces.
92                 if (commonSpace[memTab[i].attrs] < (Int)memTab[i].space) 
93                 {
94                     commonSpace[memTab[i].attrs] = (Int)memTab[i].space;
95                 }
96             }
97             free(memTab);
99             System_printf("\n0x%-3x\t", ((PAF_ASP_LinkInit*)pInit)->thisCode.part.beta);
100             for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i)
101             {
102                 if (commonSize[i] == 0)
103                 {
104                     System_printf("%9d\t",0);
105                 }
106                 else
107                 {
108                     System_printf("%6d(%1d)\t", commonSize[i], 
109                         PAF_ALG_memSpaceToHeapId(p, (IALG_MemSpace)commonSpace[i]));                    
110                 }                    
111             }
112             
113             commonSize[IALG_SCRATCH] = commonSize[IALG_PERSIST] = commonSize[IALG_WRITEONCE] = 0;
114             
115             System_flush();
116         }
117         else
118         {
119             return 1;            
120         }
121     }
122     return 0;
125 Void
126 PAF_ALG_commonPrint(IALG_MemRec common[], PAF_IALG_Config *p)
129     Int i;
131     System_printf("\n\n");
132     for (i=0; i<130; i++)
133     {
134         System_printf ("--");
135     }
137     System_printf ("\nCOMMON                         \t\t\t\t");
138     for (i=PAF_IALG_COMMON_MEM0; i <= PAF_IALG_COMMON_MEMN; i++) 
139     {
140         if (i <= IALG_WRITEONCE)
141         {
142             ; //printf(""); // print empty string??            
143         }
144         else if (common[i].size == 0)
145         {
146             System_printf("%9d\t",0);
147         }
148         else
149         {
150             System_printf("%6d(%1d)\t", common[i].size, 
151                 PAF_ALG_memSpaceToHeapId(p, common[i].space));
152         }            
153     }
154     
155     System_flush();
158 Void
159 PAF_ALG_memStatusPrint(
160     CString header, 
161     HeapMem_Handle hInternalHeap, 
162     HeapMem_Handle hInternal1Heap,
163     HeapMem_Handle hExternalHeap, 
164     HeapMem_Handle hInternal1HeapShm,
165     HeapMem_Handle hExternalHeapShm,
166     HeapMem_Handle hExternalNonCachedShm
169     Memory_Stats stats;
171     System_printf("\n\n%s\n", header);
172     System_printf("%-12s%-12s%-12s%-12s", "Heap", "Size", "Used", "Available");
173     
174     if (hInternalHeap != NULL)
175     {
176         Memory_getStats((IHeap_Handle)hInternalHeap, &stats);
177         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "INT", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
178     }
179     if (hInternal1Heap != NULL)
180     {
181         Memory_getStats((IHeap_Handle)hInternal1Heap, &stats);
182         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "INT1", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);    
183     }
184     if (hExternalHeap != NULL)
185     {
186         Memory_getStats((IHeap_Handle)hExternalHeap, &stats);
187         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "EXT", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
188     }
189     if (hInternal1HeapShm != NULL)
190     {
191         Memory_getStats((IHeap_Handle)hInternal1HeapShm, &stats);
192         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "INT1 SHM", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
193     }
194     if (hExternalHeapShm != NULL)
195     {
196         Memory_getStats((IHeap_Handle)hExternalHeapShm, &stats);
197         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "EXT SHM", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
198     }
199     if (hExternalNonCachedShm != NULL)
200     {
201         Memory_getStats((IHeap_Handle)hExternalNonCachedShm, &stats);
202         System_printf("\n%-12s0x%08x  0x%08x  0x%08x", "EXT NC SHM", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
203     }
204     
205     System_flush();
208 Void
209 PAF_ALG_bufMemPrint(
210     Int z,
211     Int size, 
212     Int heapId,
213     Int bufType
216     System_printf("\n\n%s Device Buffer (Zone %d) = %d (%d)", 
217           (bufType==0 ? "Input" : bufType==1 ? "Output" : "Audio Frame"), 
218           z, size, heapId);
219     System_printf("\n");
220       
221     System_flush();
224 Void
225 PAF_ALG_headerPrint()
227     Int i;
229     System_printf("\n\nAlgorithm Memory requirement:\n");
230     System_printf("  Key:  \n");
231     System_printf("    Beta ID can be decoded from stdbeta.h, oembeta.h or cusbeta.h in pa\\sio\\acp1.\n");
232     System_printf("    The number in parentheses is the heap.  (0) is INT.  (1) is INT1.  (2) is EXT.  (3) is INT1 SHM.  (4) is EXT SHM.  (5) is EXT NC SHM.\n");
233     System_printf("%8s\t","BetaId");
235     for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i)
236     {
237         if (i == 0) 
238         {
239             System_printf("%8s\t","SCRATCH");
240         }
241         else if (i == 1)
242         {
243             System_printf("%8s\t","PERSIST");
244         }            
245         else if (i == 2)
246         {
247             System_printf("%8s \t","WRITEONCE");
248         }            
249         else if (i < 10)
250         {
251             System_printf("%-7s%d  \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
252         }
253         else
254         {
255             System_printf("%6s%2d \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
256         }
257     }
259     System_flush();