PASDK-254:
authorFrank Livingston <frank-livingston@ti.com>
Tue, 9 May 2017 23:36:41 +0000 (18:36 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Tue, 9 May 2017 23:36:41 +0000 (18:36 -0500)
Update PAF mem status print function to account for all heaps in shared regions.
Replace printf w/ System_printf in paf_alg_print.c

pasdk/common/paf_alg_print.c
pasdk/test_arm/framework/audioStreamDecodeProc.c
pasdk/test_arm/framework/audioStreamDecodeProc.h
pasdk/test_dsp/framework/alphaIntervalProc.c
pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/framework/audioStreamInpProc.h
pasdk/test_dsp/framework/audioStreamOutProc.c
pasdk/test_dsp/framework/audioStreamOutProc.h

index 3f9f002582cd7c2ad152ef1812f2071c9c359a02..e93ab087142cdcda5b29a2f87911da86a5a15287 100644 (file)
@@ -38,15 +38,16 @@ All rights reserved.
 //
 
 #include <stdlib.h> // malloc
-#include <stdio.h>  // printf
+//#include <stdio.h>  // printf
 #include <paf_alg_print.h>
 
 #include <xdc/runtime/Memory.h>
 #include <xdc/runtime/IHeap.h>
+#include <xdc/runtime/System.h>
 #include <ti/sysbios/heaps/HeapMem.h>
 
 Int
-PAF_ALG_allocPrint (const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p)
+PAF_ALG_allocPrint(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p)
 {
     IALG_MemRec *memTab;
     Int commonSize[PAF_IALG_COMMON_MEMN+1];
@@ -54,124 +55,154 @@ PAF_ALG_allocPrint (const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Con
     Int commonSpace[PAF_IALG_COMMON_MEMN+1];
     Int i,n;
 
-    for ( ; pInit && pInit->ialg_fxns; 
-        pInit=(const PAF_ALG_AllocInit *)((char *)pInit+sizeofInit)) {
+    for ( ; pInit && pInit->ialg_fxns; pInit=(const PAF_ALG_AllocInit *)((char *)pInit+sizeofInit)) 
+    {
 #ifdef _TMS320C6X
 #pragma UNROLL(1)
 #endif
-        for (i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i) {
+        for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i) 
+        {
             commonSize[i]=0;
             commonCount[i]=0;
             commonSpace[i]=-1;
         }
-        n = pInit->ialg_fxns->algNumAlloc != NULL ? pInit->ialg_fxns->algNumAlloc() 
-                                                  : IALG_DEFMEMRECS;
-        if((memTab = (IALG_MemRec *)malloc(n * sizeof(IALG_MemRec)))){
-            n=pInit->ialg_fxns->algAlloc(pInit->ialg_prms,(IALG_Fxns ** )&(pInit->ialg_fxns),memTab);
-            if(n<=0)
+        n = pInit->ialg_fxns->algNumAlloc != NULL ? pInit->ialg_fxns->algNumAlloc() : IALG_DEFMEMRECS;
+        if ((memTab = (IALG_MemRec *)malloc(n * sizeof(IALG_MemRec))))
+        {
+            n = pInit->ialg_fxns->algAlloc(pInit->ialg_prms, (IALG_Fxns **)&(pInit->ialg_fxns),memTab);
+            if (n <= 0)
+            {
                 return PAF_ALGERR_MEMTAB_COUNT;
+            }
 
-            for(i=0;i<n;++i){
-                if((((Int)memTab[i].attrs >= PAF_IALG_COMMON_MEM0) && ((Int)memTab[i].attrs <= PAF_IALG_COMMON_MEMN))) {
+            for (i=0; i<n; ++i)
+            {
+                if ((((Int)memTab[i].attrs >= PAF_IALG_COMMON_MEM0) && ((Int)memTab[i].attrs <= PAF_IALG_COMMON_MEMN))) 
+                {
                     commonSize[memTab[i].attrs] += memTab[i].size + 
-                (commonCount[memTab[i].attrs] ? memTab[i].alignment : 0);
+                        (commonCount[memTab[i].attrs] ? memTab[i].alignment : 0);
                     commonCount[memTab[i].attrs]++;
                 }
                 // (***) FL: this is broken for printout of persistent memory
-                // The code was broken before addition of persist memory in MSMC SHM.
+                // The code was broken before addition of persist memory in INT1 SHM (MSMC).
                 // commonSize[] and commonCount[] are correct, but here persist is treated like common memory, i.e.
                 //     persistent memory is treated as through it's combined into a single memory space.
                 //     For example, printout can only show persist memory as belonging to one space.
                 //     This isn't true for persistent memory since it can be in multiple spaces.
-                if (commonSpace[memTab[i].attrs] < (Int)memTab[i].space) {
+                if (commonSpace[memTab[i].attrs] < (Int)memTab[i].space) 
+                {
                     commonSpace[memTab[i].attrs] = (Int)memTab[i].space;
                 }
             }
             free(memTab);
 
-            printf("\n0x%-3x\t",((PAF_ASP_LinkInit*)pInit)->thisCode.part.beta);
-            for(i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i){
+            System_printf("\n0x%-3x\t", ((PAF_ASP_LinkInit*)pInit)->thisCode.part.beta);
+            for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i)
+            {
                 if (commonSize[i] == 0)
-                    printf("%9d\t",0);
-                else 
-                    printf("%6d(%1d)\t", 
-                        commonSize[i], PAF_ALG_memSpaceToHeapId(p, (IALG_MemSpace)commonSpace[i]));
+                {
+                    System_printf("%9d\t",0);
+                }
+                else
+                {
+                    System_printf("%6d(%1d)\t", commonSize[i], 
+                        PAF_ALG_memSpaceToHeapId(p, (IALG_MemSpace)commonSpace[i]));                    
+                }                    
             }
+            
             commonSize[IALG_SCRATCH] = commonSize[IALG_PERSIST] = commonSize[IALG_WRITEONCE] = 0;
+            
+            System_flush();
         }
         else
-            return 1;
+        {
+            return 1;            
+        }
     }
     return 0;
 }
 
 Void
-PAF_ALG_commonPrint (IALG_MemRec common[], PAF_IALG_Config *p)
+PAF_ALG_commonPrint(IALG_MemRec common[], PAF_IALG_Config *p)
 {
 
     Int i;
 
-    printf("\n\n");
-    for(i=0;i<130;i++)
-        printf ("--");
+    System_printf("\n\n");
+    for (i=0; i<130; i++)
+    {
+        System_printf ("--");
+    }
 
-    printf ("\nCOMMON                         \t\t\t\t");
-    for (i=PAF_IALG_COMMON_MEM0; i <= PAF_IALG_COMMON_MEMN; i++) {
+    System_printf ("\nCOMMON                         \t\t\t\t");
+    for (i=PAF_IALG_COMMON_MEM0; i <= PAF_IALG_COMMON_MEMN; i++) 
+    {
         if (i <= IALG_WRITEONCE)
-            ; //printf(""); // print empty string??
+        {
+            ; //printf(""); // print empty string??            
+        }
         else if (common[i].size == 0)
-            printf("%9d\t",0);
-        else 
-            printf("%6d(%1d)\t",
-                common[i].size, PAF_ALG_memSpaceToHeapId(p, common[i].space));
+        {
+            System_printf("%9d\t",0);
+        }
+        else
+        {
+            System_printf("%6d(%1d)\t", common[i].size, 
+                PAF_ALG_memSpaceToHeapId(p, common[i].space));
+        }            
     }
+    
+    System_flush();
 }
 
-
-//PAF_ALG_memStatusPrint(Int internal, Int external, Int internal1)
 Void
 PAF_ALG_memStatusPrint(
     HeapMem_Handle hInternalHeap, 
     HeapMem_Handle hInternal1Heap,
     HeapMem_Handle hExternalHeap, 
-    HeapMem_Handle hInternal1HeapShm
+    HeapMem_Handle hInternal1HeapShm,
+    HeapMem_Handle hExternalHeapShm,
+    HeapMem_Handle hExternalNonCachedShm
 )
 {
-    //MEM_Stat statbuf;
     Memory_Stats stats;
 
-    printf("\n\nSegment\tSize\tUsed\tAvailable");
+    System_printf("\n\nHeap\tSize\tUsed\tAvailable");
     
-    //MEM_stat(internal,&statbuf);
-    //printf("\nIRAM\t%d\t%d\t%d",statbuf.size,statbuf.used,statbuf.length);
-    //MEM_stat(external,&statbuf);
-    //printf("\nSDRAM\t%d\t%d\t%d",statbuf.size,statbuf.used,statbuf.length);
-    //MEM_stat(internal1,&statbuf);
-    //printf("\nL3RAM\t%d\t%d\t%d\n",statbuf.size,statbuf.used,statbuf.length);
-
     if (hInternalHeap != NULL)
     {
         Memory_getStats((IHeap_Handle)hInternalHeap, &stats);
-        printf("\nL2\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
+        System_printf("\nINT\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
     }
     if (hInternal1Heap != NULL)
     {
         Memory_getStats((IHeap_Handle)hInternal1Heap, &stats);
-        printf("\nMSMC\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);    
+        System_printf("\nINT1\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);    
     }
     if (hExternalHeap != NULL)
     {
         Memory_getStats((IHeap_Handle)hExternalHeap, &stats);
-        printf("\nDDR3\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
+        System_printf("\nEXT\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
     }
     if (hInternal1HeapShm != NULL)
     {
         Memory_getStats((IHeap_Handle)hInternal1HeapShm, &stats);
-        printf("\nMSMC SHM\t%d\t%d\t%d\n", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
+        System_printf("\nINT1 SHM\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
     }
+    if (hExternalHeapShm != NULL)
+    {
+        Memory_getStats((IHeap_Handle)hExternalHeapShm, &stats);
+        System_printf("\nEXT SHM\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
+    }
+    if (hExternalNonCachedShm != NULL)
+    {
+        Memory_getStats((IHeap_Handle)hExternalNonCachedShm, &stats);
+        System_printf("\nEXT NC SHM\t%d\t%d\t%d\n", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
+    }
+    
+    System_flush();
 }
 
-//PAF_ALG_bufMemPrint(Int z,Int size, Int heap,Int bufType)
 Void
 PAF_ALG_bufMemPrint(
     Int z,
@@ -180,10 +211,12 @@ PAF_ALG_bufMemPrint(
     Int bufType
 )
 {
-      printf("\n\n%s Device Buffer (Zone %d) = %d (%d)", 
-              (bufType==0 ? "Input" : bufType==1 ? "Output" : "Audio Frame"), 
-              z, size, heapId);
-      printf("\n");
+    System_printf("\n\n%s Device Buffer (Zone %d) = %d (%d)", 
+          (bufType==0 ? "Input" : bufType==1 ? "Output" : "Audio Frame"), 
+          z, size, heapId);
+    System_printf("\n");
+      
+    System_flush();
 }
 
 Void
@@ -191,19 +224,35 @@ PAF_ALG_headerPrint()
 {
     Int i;
 
-    printf("\n\nAlgorithm Memory requirement:\n");
-    printf("  Key:  \n");
-    printf("    Beta ID can be decoded from stdbeta.h, oembeta.h or cusbeta.h in pa\\sio\\acp1.\n");
-    printf("    The number in parentheses is the heap.  (0) is L2.  (1) is MSMC.  (2) is DDR3.  (3) is MSMC SHM.  (4) is DDR SHM.  (5) is DDR NON-CACHED SHM.\n");
-    printf("%8s\t","BetaId");
-    for(i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i){
-        if(i==0) printf("%8s\t","SCRATCH");
-        else if(i==1) printf("%8s\t","PERSIST");
-        else if(i==2) printf("%8s \t","WRITEONCE");
-        else if(i<10)
-            printf("%-7s%d  \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
+    System_printf("\n\nAlgorithm Memory requirement:\n");
+    System_printf("  Key:  \n");
+    System_printf("    Beta ID can be decoded from stdbeta.h, oembeta.h or cusbeta.h in pa\\sio\\acp1.\n");
+    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");
+    System_printf("%8s\t","BetaId");
+
+    for (i=PAF_IALG_COMMON_MEM0; i<=PAF_IALG_COMMON_MEMN; ++i)
+    {
+        if (i == 0) 
+        {
+            System_printf("%8s\t","SCRATCH");
+        }
+        else if (i == 1)
+        {
+            System_printf("%8s\t","PERSIST");
+        }            
+        else if (i == 2)
+        {
+            System_printf("%8s \t","WRITEONCE");
+        }            
+        else if (i < 10)
+        {
+            System_printf("%-7s%d  \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
+        }
         else
-            printf("%6s%2d \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
+        {
+            System_printf("%6s%2d \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
+        }
     }
-}
 
+    System_flush();
+}
index 6ff0ea9412ea4e7a1324d1f487f4381c2200ec2a..28bad17a306654f91ab4cd9a97a8eaf6cfb3a3c6 100644 (file)
@@ -273,7 +273,8 @@ Void taskAsdpFxn(
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
     
 #ifdef NON_CACHE_STATUS
index d1dd1cd44710eaca6235cf4b27893b3671339fb1..bd3daa4761310a5d686083f2dc5bdd68f46097e3 100644 (file)
@@ -63,7 +63,12 @@ typedef struct PAF_ASDT_Fxns {
     Int  (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
     Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
     Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
-    Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
+    Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, 
+        HeapMem_Handle hInternal1Heap, 
+        HeapMem_Handle hExternalHeap, 
+        HeapMem_Handle hInternal1HeapShm,
+        HeapMem_Handle hExternalHeapShm,
+        HeapMem_Handle hExternalNonCachedHeapShm);
 } PAF_ASDT_Fxns;
 
 // Audio Stream Decode Task (ASDT) parameters
index fb8fab7c8d4ec42714b8ae3643bde2953c061bcc..292f2a0b4f864638551d165b4e07b541f3c924d4 100644 (file)
@@ -60,10 +60,12 @@ All rights reserved.
 #include "fwkPort.h"
 
 // Symbolic constants for translating heap Ids to handles
-#define HEAP_INTERNAL       (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt)
-#define HEAP_INTERNAL1      (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1)
-#define HEAP_EXTERNAL       (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExt)
-#define HEAP_INTERNAL1_SHM  (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1Shm)
+#define HEAP_INTERNAL                   (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt)
+#define HEAP_INTERNAL1                  (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1)
+#define HEAP_EXTERNAL                   (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExt)
+#define HEAP_INTERNAL1_SHM              (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1Shm)
+#define HEAP_EXTERNAL_SHM               (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExtShm)
+#define HEAP_EXTERNAL_NONCACHED_SHM     (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExtNonCachedShm)
 
 //
 // Alpha code shortcut arrays
@@ -184,7 +186,8 @@ Void taskAipFxn(
 
     if (gEnableRamReport)
     {
-        PAF_ALG_memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        PAF_ALG_memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
     
     // Set default stream
index 2117c9a1a60c26a6a9df91fc2b707a158892f18e..de545a167a5328d652bdfcf606c3b9a8aa51009e 100644 (file)
@@ -469,7 +469,8 @@ Void taskAsipFxn(
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
     
     // (***) FL: revisit
index d3d1e4c1e9f886eff914c395d4bc229c5a91c83e..e2bc5fdcd1772a83265c9a7ead3d875724ce5ec6 100644 (file)
@@ -93,7 +93,13 @@ typedef struct PAF_ASIT_Fxns {
     Int  (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
     Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
     Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
-    Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
+    Void (*memStatusPrint)(HeapMem_Handle 
+        hInternalHeap, 
+        HeapMem_Handle hInternal1Heap, 
+        HeapMem_Handle hExternalHeap, 
+        HeapMem_Handle hInternal1HeapShm, 
+        HeapMem_Handle hExternalHeapShm, 
+        HeapMem_Handle hExternalNoncachedHeapShm);
 } PAF_ASIT_Fxns;
 
 // Audio Stream Input Task (ASIT) parameters
index a0bb48355f2f90c5447a204c53152c9b097d59c0..3eb7f78b8ef8a2655de42922c8d48142ab2a24ca 100644 (file)
@@ -244,7 +244,8 @@ Void taskAsopFxn(
     //
     if (pP->fxns->memStatusPrint)
     {
-        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, HEAP_INTERNAL1_SHM);
+        pP->fxns->memStatusPrint(HEAP_INTERNAL, HEAP_INTERNAL1, HEAP_EXTERNAL, 
+            HEAP_INTERNAL1_SHM, HEAP_EXTERNAL_SHM, HEAP_EXTERNAL_NONCACHED_SHM);
     }
 
     //
index c261a64ce045083672807b164b4a0af090c29924..1714a03b651cf32f27b61f5430542a86d39696f4 100644 (file)
@@ -93,7 +93,12 @@ typedef struct PAF_ASOT_Fxns {
     Int  (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
     Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
     Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
-    Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, HeapMem_Handle hInternal1Heap, HeapMem_Handle hExternalHeap, HeapMem_Handle hInternal1HeapShm);
+    Void (*memStatusPrint)(HeapMem_Handle hInternalHeap, 
+        HeapMem_Handle hInternal1Heap, 
+        HeapMem_Handle hExternalHeap, 
+        HeapMem_Handle hInternal1HeapShm, 
+        HeapMem_Handle hExternalHeapShm, 
+        HeapMem_Handle hExternalNoncachedHeapShm);
 } PAF_ASOT_Fxns;
 
 // Audio Stream Output Task (ASOT) parameters