PASDK-71:Add PFP component to ARM & DSP.
authorFrank Livingston <frank-livingston@ti.com>
Wed, 26 Apr 2017 23:21:37 +0000 (18:21 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Wed, 26 Apr 2017 23:21:37 +0000 (18:21 -0500)
PFP used for INFO/DECODE profile on ARM.
PFP used for ASP profile on DSP.

Need to add alpha interface for e.g.:
- Change ASP being profiled
- Reset PFP statistics
- Read PFP statistics

17 files changed:
pasdk/common/asp0.c
pasdk/common/components/clk.c [new file with mode: 0644]
pasdk/common/components/clk.h [new file with mode: 0644]
pasdk/common/pfp/pfp.c [new file with mode: 0644]
pasdk/common/pfp/pfp.h [new file with mode: 0644]
pasdk/common/pfp_app.h [new file with mode: 0644]
pasdk/test_arm/.cproject
pasdk/test_arm/application/app.cfg
pasdk/test_arm/application/board_utils.c [new file with mode: 0644]
pasdk/test_arm/application/main.c
pasdk/test_arm/framework/audioStreamDecodeProc.c
pasdk/test_dsp/.cproject
pasdk/test_dsp/application/app.cfg
pasdk/test_dsp/application/main.c
pasdk/test_dsp/framework/alphaFuncProc.c
pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/framework/audioStreamOutProc.c

index edb1213914e4db36bdc459ba43252b1eb5bd43f3..a958ea96b34d8e2e916c37f726bf3f44ca009ccc 100644 (file)
@@ -51,6 +51,16 @@ All rights reserved.
 #include <xdc/runtime/IHeap.h>
 #include <ti/sysbios/heaps/HeapMem.h>
 
+#include "asp0.h"
+//#include <paf_alg.h>
+//#include <pafhjt.h>
+#include <acp.h>
+#include "logp.h"
+
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+
+
 #include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
 //
 // Performing PCM high-sampling rate + SRC + CAR benchmarking
@@ -78,15 +88,12 @@ UInt32 aspNumberToProfile = NUM_ASP_PROFILE; // ASP number in chain starting fro
 volatile UInt32 time32_1, time32_2;
 #endif
 
-//
-#include "asp0.h"
-//#include <paf_alg.h>
-//#include <pafhjt.h>
-
-#include <acp.h>
-
-#include "logp.h"
-
+#ifdef _TMS320C6X
+#define ASP_NUM_PROFILE  ( 0 )              // Profile CAR; As we have DEC->CAR(0)->OAR(1)->BMDA(2)->ENC
+UInt32 gAspProfileEnable = 0;               // ASP profile enable flag
+UInt32 gAspNumProfile = ASP_NUM_PROFILE;    // ASP number in chain starting from 0
+UInt32 gAspCurCount = 0;                    // ASP number in chain starting from 0
+#endif // _TMS320C6X
 
 
 //
@@ -301,7 +308,6 @@ PAF_ASP_chainApply_ (PAF_ASP_Chain *this, PAF_AudioFrame *pAudioFrame)
 {
     Int errno;
     int i = 0;
-
     PAF_ASP_Link *pLink;
 
     for (pLink=this->head; pLink; pLink=pLink->next)
@@ -318,42 +324,57 @@ PAF_ASP_chainApply_ (PAF_ASP_Chain *this, PAF_AudioFrame *pAudioFrame)
 
         if (alg->fxns->apply /*&& (errno = alg->fxns->apply(alg, pAudioFrame))*/)
         {
-
 #ifdef PROFILER
-        if (aspNumberToProfile == currentAspCount)  // only profile the selected ASP
-        {
-            time32_1 = Timestamp_get32();
-        }
+            if (aspNumberToProfile == currentAspCount)  // only profile the selected ASP
+            {
+                time32_1 = Timestamp_get32();
+            }
 #endif
+
+#ifdef _TMS320C6X
+            if ((gAspProfileEnable == 1) && (gAspNumProfile == gAspCurCount))  // only profile the selected ASP
+            {                
+                pfpBegin(PFP_ID_TASK1_2, Task_self());
+            }
+#endif            
+
             errno = alg->fxns->apply(alg, pAudioFrame);
+            
+#ifdef _TMS320C6X
+            if ((gAspProfileEnable == 1) && (gAspNumProfile == gAspCurCount))  // only profile the selected ASP
+            {
+                pfpEnd(PFP_ID_TASK1_2, PFP_FINISH_MEAS);
+            }
+            gAspCurCount++;
+#endif            
 
 #ifdef PROFILER
-        if (aspNumberToProfile == currentAspCount)  // only profile the selected ASP
-        {
-            time32_2 = Timestamp_get32();
-            //Load_Stat stat;
-            //Load_getTaskLoad (Task_getIdleTask(), &stat);
-            //UInt32 intLoad = Load_calculateLoad (&stat);
-            if (start_profiling == 1)
+            if (aspNumberToProfile == currentAspCount)  // only profile the selected ASP
             {
-                if (profile_index < MAX_NUM)
+                time32_2 = Timestamp_get32();
+                //Load_Stat stat;
+                //Load_getTaskLoad (Task_getIdleTask(), &stat);
+                //UInt32 intLoad = Load_calculateLoad (&stat);
+                if (start_profiling == 1)
                 {
-                    profile_array_dsp_cycles[profile_index] = (time32_2 - time32_1);
-                    //profile_array_dsp_cpuload[profile_index] = (100   - intLoad);
-                    profile_array_dsp_cpuload[profile_index] =  Load_getCPULoad();
-                    profile_index++;
+                    if (profile_index < MAX_NUM)
+                    {
+                        profile_array_dsp_cycles[profile_index] = (time32_2 - time32_1);
+                        //profile_array_dsp_cpuload[profile_index] = (100   - intLoad);
+                        profile_array_dsp_cpuload[profile_index] =  Load_getCPULoad();
+                        profile_index++;
+                    }
+                    else
+                    {
+                        //SW_BREAKPOINT;
+                    }
                 }
-                else
-                {
-                    //SW_BREAKPOINT;
-                }
-            }
 
-            //TRACE_TERSE1("profiler: Timestamp_get32() cycles: %u", (time32_2 - time32_1) * factor);
-            //TRACE_TERSE2("profiler: CPU load: idle: %d other: %d", intLoad, (100 - intLoad));
-        }
-        // increase ASP count
-        currentAspCount++;
+                //TRACE_TERSE1("profiler: Timestamp_get32() cycles: %u", (time32_2 - time32_1) * factor);
+                //TRACE_TERSE2("profiler: CPU load: idle: %d other: %d", intLoad, (100 - intLoad));
+            }
+            // increase ASP count
+            currentAspCount++;
 #endif
 
             if (errno && this->log)
@@ -362,14 +383,25 @@ PAF_ASP_chainApply_ (PAF_ASP_Chain *this, PAF_AudioFrame *pAudioFrame)
                     this->stream, pLink->code.full, errno);
                 LOG_printf(&trace, "AS%d: ASP code 0x%08x apply error 0x%x.",
                     this->stream, pLink->code.full, errno);
-                #ifdef PROFILER
+
+#ifdef _TMS320C6X
+                // Reset ASP count for next frame
+                gAspCurCount = 0;
+#endif
+#ifdef PROFILER
                 // Reset ASP count for next frame
                 currentAspCount = 0;
-                #endif
+#endif
+
                 return errno;
             }
         }
     }
+    
+#ifdef _TMS320C6X    
+    // Reset ASP count for next frame
+    gAspCurCount = 0;
+#endif    
 #ifdef PROFILER
     // Reset ASP count for next frame
     currentAspCount = 0;
diff --git a/pasdk/common/components/clk.c b/pasdk/common/components/clk.c
new file mode 100644 (file)
index 0000000..dd88a31
--- /dev/null
@@ -0,0 +1,255 @@
+/*
+ * clk.c
+ *
+ *  Created on: Apr 2, 2017
+ *      Author: a0216546
+ */
+
+#define KERNEL_BUG    0     /* Put it to 1 if you want to test for kernel bug (clock module configuration) */
+
+#include <stdint.h>
+
+#include <xdc/runtime/System.h>       /* for System_printf() */
+
+/* BIOS Header files */
+#include <ti/sysbios/BIOS.h>          /* mandatory - if you call APIs like BIOS_start() */
+#include <ti/sysbios/knl/Semaphore.h> /* this looks obvious */
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Swi.h>
+#include <ti/sysbios/hal/Hwi.h>
+
+/* Build configurations like semaphore handles, etc. */
+#include <xdc/cfg/global.h>           /* header file for statically defined objects/handles */
+
+/* Local Header files */
+#include "clk.h"
+#include "../pfp/pfp.h"
+#include "../pfp_app.h"
+
+/* Macros */
+#define loop  while(1)
+
+#include <xdc/runtime/Timestamp.h>    /* for benchmarking/profiling */
+#define Timestamp_get Timestamp_get32 /* use 32-bit time stamps */
+
+volatile int GET_STATS_COUNT = 3000;  /* Get stats after 3000 iterations */
+
+/*----------------------------------------------------------------------------------- 
+  clkWorkDelay: Waste time based on actial work
+ *-----------------------------------------------------------------------------------*/
+
+#include <math.h>
+
+void clkWorkDelay(int loopcnt)
+{
+  int k;
+  volatile double x, y, z;
+
+  x = 3.14/6;
+  y = 3.14/3;
+  for (k = 0; k < loopcnt; k++) {
+      z = sin(x)+cos(y);
+  }
+} /* clkWorkDelay */
+
+/*----------------------------------------------------------------------------------- 
+  clkDelay: Waste time based on time stamp
+ *-----------------------------------------------------------------------------------*/
+
+void clkDelay(uint32_t pause)
+{
+  volatile uint32_t now,then;
+
+  now = then = Timestamp_get();
+  while( (now-then) < pause ) {
+    now = Timestamp_get();
+  }
+} /* clkDelay */
+
+#if 0
+/*------------------------------------------------------------ 
+  clk0Fun: Wakes up task0 which runs every 100ms
+ *------------------------------------------------------------*/
+
+#if KERNEL_BUG
+int clk0prev = 0;
+#endif
+
+void clk0Fun(void)
+{
+  Semaphore_post(semTask0WakeUp);
+
+#if KERNEL_BUG
+  if (clk0prev == GET_STATS_COUNT) {
+    clk0prev = -1;
+  }
+  else {
+    clk0prev = GET_STATS_COUNT;
+  }
+#endif
+} /* clk0Fun */
+
+/*------------------------------------------------------------ 
+  clk1Fun: Wakes up task1 which runs every 100ms
+ *------------------------------------------------------------*/
+
+#if KERNEL_BUG
+int clk1prev = 0;
+#endif
+
+void clk1Fun(void)
+{
+  Semaphore_post(semTask1WakeUp);
+
+#if KERNEL_BUG
+  if (clk1prev == GET_STATS_COUNT) {    /* This was used for chasing SYS/BIOS Kernel bug */
+    clk1prev = -1;
+  }
+  else {
+    clk1prev = GET_STATS_COUNT;
+  }
+#endif
+
+} /* clk1Fun */
+
+/*------------------------------------------------------------- 
+  task0Fun: Task0 runs every 100ms and uses 30ms of time
+ *-------------------------------------------------------------*/
+
+#include <stdio.h>
+
+int reset_hangover = -1;
+
+//#pragma CODE_SECTION(task0Fun,".pfpsection")
+
+void task0Fun(void)
+{
+  int k;
+  pfpStats_t pfp_stats;
+  IArg swiKey, hwiKey;
+  Task_Handle myHandle;
+
+  /* Task initialization */
+  myHandle = Task_self();
+
+  reset_hangover = -1;          /* No need for stat reset */
+
+  /* Main loop */
+  loop {
+
+    pfpEnd(PFP_ID_TASK0_2,0);     /* This is OK to do since the first time it would be ignored! */
+    /* We placed the end of measurement here since we do not want to measure the printf's below
+       which are only used at the end of the test after which we would hit a break point */
+
+    if (GET_STATS_COUNT > 0) {
+      GET_STATS_COUNT--;
+    }
+    else {
+      hwiKey=Hwi_disable();
+      swiKey=Swi_disable();
+
+      for (k = 0; k <= PFP_ID_LAST; k++) {
+        pfpGetStats(k, &pfp_stats);
+        printf("ID: %02d, n=%u, C=%lld, Cmin=%u, Cmax=%u, C-avg=%g, Avg-T=%gms, Alpha=%g, C_eavg=%g, EAvg-T=%gms\n", k,
+               pfp_stats.n_count,
+               pfp_stats.c_total,
+               pfp_stats.c_min,
+               pfp_stats.c_max,
+               (double)pfp_stats.c_total/pfp_stats.n_count,
+               (double)pfp_stats.c_total/pfp_stats.n_count/CLK_CLOCKS_PER_MS,
+               pfp_stats.alpha,
+               pfp_stats.c_average,
+               pfp_stats.c_average/CLK_CLOCKS_PER_MS);
+      }
+
+      GET_STATS_COUNT = 3000;
+      reset_hangover = 3;     /* <----------- you may put Breakpoint here! */
+      Swi_restore(swiKey);
+      Hwi_restore(hwiKey);
+    }
+
+    /* This code "recovers" after the breakpoint in order to "ignore" pending interrupts */
+    if (reset_hangover > 0) {
+      reset_hangover--;
+    }
+    else if (reset_hangover == 0) {
+      reset_hangover = -1;
+
+      hwiKey=Hwi_disable();
+      swiKey=Swi_disable();
+
+      for (k = 2; k <= PFP_ID_LAST; k++) {      /* Do not reset the first two PP's */
+        pfpResetStats(k);
+      }
+
+      Swi_restore(swiKey);
+      Hwi_restore(hwiKey);
+    }
+
+    pfpBegin(PFP_ID_TASK0_2, myHandle);
+
+    /*-------------------------------------------------------------------------------------*/
+    Semaphore_pend(semTask0WakeUp, BIOS_WAIT_FOREVER);  /* wait for clk0Fun to wake you up */
+    /*-------------------------------------------------------------------------------------*/
+
+    /* Waste time for 20ms */
+    pfpBegin(PFP_ID_TASK0_1, myHandle);
+      clkWorkDelay(20*CLK_WORKCNT_PER_MS);
+    pfpEnd(PFP_ID_TASK0_1,0);
+
+    /* Spend another 10ms but outside of previous profile point */
+    clkWorkDelay(10*CLK_WORKCNT_PER_MS);
+
+  }
+
+  /* Never come here */
+
+} /* task0Fun */
+
+/*------------------------------------------------------------- 
+  task1Fun: Task1 runs every 100ms and uses 23ms of time
+ *-------------------------------------------------------------*/
+
+//#pragma CODE_SECTION(task1Fun,".pfpsection")
+
+void task1Fun(void)
+{
+  Task_Handle myHandle;
+
+  /* Task initialization */
+  myHandle = Task_self();
+
+  /* Main loop */
+  loop {
+
+    pfpEnd(PFP_ID_TASK1_3, 0);
+    pfpBegin(PFP_ID_TASK1_3, myHandle);          /* Measure "everything else" in this task! */
+
+    /*-------------------------------------------------------------------------------------*/
+    Semaphore_pend(semTask1WakeUp, BIOS_WAIT_FOREVER);  /* wait for clk1Fun to wake you up */
+    /*-------------------------------------------------------------------------------------*/
+
+    /* Waste time for 13ms */
+    pfpBegin(PFP_ID_TASK1_1, myHandle);
+      clkWorkDelay(13*CLK_WORKCNT_PER_MS);
+    pfpEnd(PFP_ID_TASK1_1, 0);
+
+    pfpBegin(PFP_ID_TASK1_2, myHandle);
+      clkWorkDelay(8*CLK_WORKCNT_PER_MS);
+    pfpEnd(PFP_ID_TASK1_2, 1);      /* latch this measurement */
+
+    pfpBegin(PFP_ID_TASK1_2, myHandle);
+      clkWorkDelay(2*CLK_WORKCNT_PER_MS);
+    pfpEnd(PFP_ID_TASK1_2, 0);      /* Complete this measurement */
+
+  }
+
+
+  /* Never come here */
+
+} /* task1Fun */
+
+#endif
+
+/* nothing past this point */
+
diff --git a/pasdk/common/components/clk.h b/pasdk/common/components/clk.h
new file mode 100644 (file)
index 0000000..a603fd3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * clk.h
+ *
+ *  Created on: Apr 2, 2017
+ *      Author: a0216546
+ */
+
+#ifndef _CLK_H
+#define _CLK_H
+
+#include <stdint.h>
+
+/* Some useful constants */
+/* These constants may need calibration if platform properties change */
+/* Measurement was done with optimizatoin disabled for the clk.c and main.c */
+#define CLK_WORKCNT_PER_MS  3000          /* Number of iterations of clkWorkDelay() to 
+                                             achieve 1ms work on 750MHz CPU Clock */
+#define CLK_CLOCKS_PER_MS   750000UL      /* for 750MHz */
+
+/* Functions in clk.c */
+extern void clkWorkDelay(int loopcnt);
+extern void clkDelay(uint32_t pause);
+extern void clk0Fun(void);
+extern void clk1Fun(void);
+extern void task0Fun(void);
+extern void task1Fun(void);
+
+#endif /* _CLK_H */
+/* nothing past this point */
+
diff --git a/pasdk/common/pfp/pfp.c b/pasdk/common/pfp/pfp.c
new file mode 100644 (file)
index 0000000..acab806
--- /dev/null
@@ -0,0 +1,905 @@
+/*
+ * pfp.c
+ * 
+ * NOTE: Throughout this code we may refer to the "active queue" or list. That is actually
+ *       a queue of Profile Points (PP's) where we are currently "inside". Only one of them
+ *       can be really "active" since a CPU core can only execute one task at a time. In short,
+ *       whenever we enter the Begin-End bracket we place that profile point on this queue.
+ *       The most recent one that is or was executing should be at the tail of the queue.
+ *
+ *  Created on: Apr 1, 2017
+ *      Author: a0216546
+ */
+
+/* DEBUG Flags */
+#define PFP_DBG_HOOKS   0
+
+#include "pfp.h"
+
+#define PFP_MIN(a,b)    (((a)>(b))?(b):(a))     /* Min/Max macros */
+#define PFP_MAX(a,b)    (((a)<(b))?(b):(a))
+
+#include <xdc/runtime/Error.h>
+#include <xdc/runtime/System.h>
+
+#include <xdc/runtime/Timestamp.h>    /* for benchmarking/profiling */
+#define Timestamp_get Timestamp_get32 /* use 32-bit time stamps */
+
+#include <ti/sysbios/BIOS.h> 
+#include <ti/sysbios/gates/GateAll.h> /* For Critical Sections */
+
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Swi.h>
+#include <ti/sysbios/hal/Hwi.h>
+
+/* Global Variables */
+pfpInst_t       pfpInst;          /* Define pfpInst globally. Only one can exist. */
+GateAll_Params  pfpGateParams;    /* Gate Parameters for PFP */
+
+/* Critical Section macros */
+#define PFP_GATE_ENTER()      GateAll_enter(pfpInst.ghandle);
+#define PFP_GATE_LEAVE(key)   GateAll_leave(pfpInst.ghandle,key)
+
+int pfpTaskHookSetId;     /* used for Task hooks */
+int pfpSwiHookSetId;      /* used for Swi hooks */
+int pfpHwiHookSetId;      /* used for Hwi hooks */
+
+/*==================================================================================*/
+/* PFP Functions that are used for profile point management and actual measurements */
+/*==================================================================================*/
+
+/*============================================================================*/
+/* pfpCreate: initialize all profile point descriptors and instance structure */
+/*============================================================================*/
+
+void pfpCreate (void)
+{
+  int k;
+  pfpDescriptor_t *pfp;
+  GateAll_Params  *params = &pfpGateParams;
+
+  GateAll_Params_init(params);
+  pfpInst.ghandle = GateAll_create(params,NULL);
+  if (pfpInst.ghandle == NULL) {
+    BIOS_exit(1);
+  }
+  pfpInst.head      = NULL;
+  pfpInst.tail      = NULL;
+  pfpInst.overhead  = 0;
+  pfpInst.depth     = 0;
+  pfpInst.active_id = -1;
+
+  for (k = 0; k < PFP_PPCNT_MAX; k++) {
+    pfp = &pfpInst.pfpVector[k];      /* fetch current pp-descriptor */
+
+    pfp->exhandle   = NULL;
+    pfp->id         = -1;
+    pfp->scope      = BIOS_ThreadType_Main;
+    pfp->enable     = 0;
+    pfp->inside     = 0;
+    pfp->active     = 0;
+    pfp->latch      = 0;
+    pfp->reset      = 0;
+    pfp->c_total    = 0;
+    pfp->n_count    = 0;
+    pfp->c_partial  = 0;
+    pfp->c_0        = 0;
+    pfp->c_min      = (~0UL);      /* very large integer */
+    pfp->c_max      = 0;
+    pfp->alpha      = 0.0;
+    pfp->c_average  = 0.0;
+    pfp->next       = NULL;
+    pfp->prev       = NULL;
+  }
+} /* pfpCreate */
+
+/*===================================================================================*/
+/* pfpSetAlpha: initialize exponential averaging constant for a single profile point */
+/*
+      alpha must be in [0,1] range. When 0, exponantial averaging will not be calculated.
+      When 1, the average would equal to the most recent cycle measurement.
+      If a profile point is executed every T seconds and we want our time constant to be
+      tau, alpha should be T/tau. Clearly, tau > T for meaningful measurements.
+*/
+/*===================================================================================*/
+
+void pfpSetAlpha (int id, float alpha)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  pfp = &pfpInst.pfpVector[id];             /* fetch the PFP descriptor */
+
+  pfp->alpha = alpha;       /* Store new value of exponantial averating constant */
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+
+} /* pfpSetAlpha */
+
+/*============================================================================*/
+/* pfpResetStats: Reset statistics for one profile point                      */
+/* 
+ *      Preferably, this should be done from the lowest execution priority
+ *      in order to ensure active list is empty. This should not be
+ *      done in the middle of a profile point bracket.
+ */ 
+/*============================================================================*/
+
+void pfpResetStats (int id)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  pfp = &pfpInst.pfpVector[id];             /* fetch the PFP descriptor */
+  /* We cannot reset stats for currently running or latched profile point. We will do it
+     in next pfpBegin() making sure measurement is not latched. */
+  if (pfp->inside || pfp->latch) {
+    pfp->reset = 1;             /* this PP will be reset in pfpBegin() when convenient */
+    if (scope != BIOS_ThreadType_Main) {
+      PFP_GATE_LEAVE(key);
+    }
+    return;
+  }
+
+  pfp->c_total    = 0;
+  pfp->n_count    = 0;
+  pfp->c_partial  = 0;
+  pfp->c_0        = 0;
+  pfp->c_min      = (~0UL);      /* very large integer */
+  pfp->c_max      = 0;
+  pfp->c_average  = 0.0;
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+
+} /* pfpResetStats */
+
+/*============================================================================*/
+/* pfpGetStats: Return statistics for one profile point                       */
+/*============================================================================*/
+
+void pfpGetStats(int id, pfpStats_t *pStats)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  pfp = &pfpInst.pfpVector[id];             /* fetch the PFP descriptor */
+
+  pStats->c_total   = pfp->c_total;
+  pStats->n_count   = pfp->n_count;
+  pStats->c_min     = pfp->c_min;
+  pStats->c_max     = pfp->c_max;
+  pStats->alpha     = pfp->alpha;
+  pStats->c_average = pfp->c_average;
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+} /* pfpGetStats */
+
+/*============================================================================*/
+/* pfpEnable: Enable one profile point                                        */
+/*============================================================================*/
+
+void pfpEnable (int id)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  pfp = &pfpInst.pfpVector[id];     /* fetch the PFP descriptor */
+
+  pfp->enable = 1;          /* Enable this profile point */
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+
+} /* pfpEnable */
+
+/*============================================================================*/
+/* pfpDisable: Disable one profile point                                      */
+/*============================================================================*/
+
+void pfpDisable (int id)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  pfp = &pfpInst.pfpVector[id];     /* fetch the PFP descriptor */
+
+  pfp->enable = 0;          /* Disable this profile point */
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+} /* pfpDisable */
+
+/*============================================================================*/
+/* pfpBegin: Begin profile point measurement                                  */
+/*============================================================================*/
+
+void pfpBegin (int id, void *exhandle)
+{
+  volatile uint_least32_t t1;
+  uint_least32_t          dt;
+  pfpDescriptor_t         *pfp;
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  t1 = Timestamp_get();             /* fetch the current time stamp */
+  pfp = &pfpInst.pfpVector[id];     /* fetch the PFP descriptor */
+
+  if (!pfp->enable) {
+    if (scope != BIOS_ThreadType_Main) {
+      PFP_GATE_LEAVE(key);
+    }
+    return;               /* do nothing if disabled */
+  }
+
+  /* First check to see if the current tail element is nesting this one */
+  if (pfpInst.tail != NULL) {
+    if (pfpInst.tail->exhandle == exhandle) { /* are we nested? */
+       pfpInst.tail->active     = 0;            /* mark as not-active */
+       dt                       = t1 - pfpInst.tail->c_0;
+       pfpInst.tail->c_partial += dt;
+       /* c_0 will have to be initialized before coming back! (see pfpEnd()) */
+    }
+  }
+
+  /* Now we can focus on the new profile point */
+  pfp->exhandle   = exhandle;   /* record execution object handle */
+  pfp->id         = id;         /* record your ID */
+  pfp->scope      = scope;      /* record the scope */
+  if (!pfp->latch) {          /* if not latched */
+    pfp->c_partial  = 0;      /*   initialize partial sum */
+    if (pfp->reset) {             /* execute delayed reset if necessary */
+      pfp->reset      = 0;        /* no need to do it again */
+      pfp->c_total    = 0;
+      pfp->n_count    = 0;
+      pfp->c_min      = (~0UL);
+      pfp->c_max      = 0;
+      pfp->c_average  = 0.0;
+    }
+  }
+
+  /* Link this PP to the end of active list */
+  pfp->prev = pfpInst.tail;   /* Previous is the current last element */
+  pfp->next = NULL;           /* nobody after this one */
+  if (pfpInst.head == NULL) {
+    pfpInst.head = pfpInst.tail = pfp;    /* now we are not empty */
+  }
+  else {
+    pfpInst.tail->next = pfp;     /* current last now has a next one */
+    pfpInst.tail       = pfp;     /* move the last to point to this one */
+  }
+  pfpInst.depth++;        /* record new depth of the list */
+
+  pfp->inside = 1;        /* indicate that we entered this PP now */
+  pfp->active = 1;        /* and we are about to start running through it */
+  pfpInst.active_id = id; /* record the currently active id */
+
+  /* Recrod time as late as possible to reduce overhead during measurement */
+  pfp->c_0 = Timestamp_get();   /* fetch the current time stamp */
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+} /* pfpBegin */
+
+/*============================================================================*/
+/* pfpEnd: Complete profile point measurement                                 */
+/*============================================================================*/
+
+void pfpEnd (int id, int latch)
+{
+  volatile uint_least32_t t1;       /* completion time */
+  uint_least32_t          dt;       /* completion time and delta time */
+  uint_least32_t          partial;  /* partial sum */
+  float                   alpha;    /* exponential averaging constant */
+  pfpDescriptor_t *pfp;
+  void            *exhandle;        /* Execution handle pointer which may be used */
+  volatile IArg key;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main) {
+    key=PFP_GATE_ENTER();
+  }
+  /* Record time ASAP to minimize measurement overhead */
+  t1 = Timestamp_get();               /* fetch the current time stamp */
+  pfp = &pfpInst.pfpVector[id];       /* fetch the PFP descriptor */
+
+  if (!pfp->enable || !pfp->inside) {     /* if disabled or we had "end" before "begin" */
+    if (scope != BIOS_ThreadType_Main) {
+      PFP_GATE_LEAVE(key);
+    }
+    return;               /* do nothing if disabled */
+  }
+
+  pfp->active = 0;        /* We are going to stop running this measurement */
+  pfp->inside = 0;        /* getting out after this */
+
+  /* This has to be done in case we are not nested. It will be fixed below in case of nesting */
+  pfpInst.active_id = -1; /* we were most likely the currently active PP, but not any more */
+
+  dt            = t1 - pfp->c_0;
+  partial       = pfp->c_partial + dt - pfpInst.overhead;
+  if (!latch) {
+    pfp->c_total += partial;              /* complete this measurement */
+    pfp->n_count++;                       /* count it */
+    pfp->c_min = PFP_MIN(pfp->c_min, partial);
+    pfp->c_max = PFP_MAX(pfp->c_max, partial);
+    /* do the exponential averaging */
+    alpha = pfp->alpha;
+    if (alpha > 0.0) {
+      pfp->c_average += alpha*(partial - pfp->c_average);
+    }
+  }
+  else {
+    pfp->c_partial = partial;         /* latch the partial sum */
+  }
+  pfp->latch = latch;           /* record the latch flag */
+
+  /* Remove this PP from the active list */
+  if (pfpInst.head == pfp) {
+    pfpInst.head = pfp->next;
+  }
+  else {
+    pfp->prev->next = pfp->next;      /* previous element should point forward to my next */
+  }
+  if (pfpInst.tail == pfp) {
+    pfpInst.tail = pfp->prev;
+  }
+  else {
+    pfp->next->prev = pfp->prev;      /* next element should point back to my previous */
+  }
+  pfpInst.depth--;        /* record new depth of the list */
+
+  /* Now check to see if the queue has a region nesting this one within the same task */
+  /* We cannot look only at the tail since the tail could be from different task and
+   *  it may be currently blocked without ability to run! */
+
+  /* IMPORTANT: Here we will move the nesting region to the tail of the QUEUE
+     if it is not there already!!!!! */
+
+  exhandle = pfp->exhandle;       /* Remember current execution handle */
+  pfp = pfpInst.tail;             /* Start from the tail */
+  while (pfp != NULL) {           /* Do this until we hit the head */
+    if (pfp->exhandle == exhandle) {  /* were we nested with this one? */
+       pfp->active        = 1;                /* mark it as active */
+       pfpInst.active_id  = pfp->id;          /* fix the active id */
+
+       /* Take the new one we found and move it to the tail if it was not there */
+       /* Order is A -> PFP -> B */
+       if (pfpInst.tail != pfp) {
+         pfp->prev->next = pfp->next;   /* A->next = B */
+         pfp->next->prev = pfp->prev;   /* B->prev = A */
+         pfp->prev = pfpInst.tail;      /* pfp->prev = TAIL */
+         pfp->next = NULL;              /* pfp is now going to be at the tail! */
+         pfpInst.tail->next = pfp;      /* TAIL->next = pfp (old tail points to pfp now) */
+         pfpInst.tail = pfp;            /* new tail is pfp finally */
+       }
+
+       pfp->c_0           = Timestamp_get();  /* Record new time */
+
+       break;       /* stop looking */
+    }
+    pfp = pfp->prev;      /* move back through the queue */
+  }
+
+  if (scope != BIOS_ThreadType_Main) {
+    PFP_GATE_LEAVE(key);
+  }
+} /* pfpEnd */
+
+/*============================================================================*/
+/* pfpCalibrate: Calibrate Begin-End pair.
+   This must run with all interrupts disabled. The best would be to run it
+   during boot or in main. Although one could argue more precise measurement
+   could be obtained if the GATE execution would be included.
+   Currently, that is not supported. This must be called after pfpCreate.
+   If the loopcnt is less than 16 calibration will not be done.
+*/
+/*============================================================================*/
+
+void pfpCalibrate(int loopcnt)
+{
+  int k, enable;
+  float alpha;
+  BIOS_ThreadType scope = BIOS_getThreadType();
+
+  if (scope != BIOS_ThreadType_Main || loopcnt < 16) {
+    pfpInst.overhead = 0;
+    return;                   /* must be run before BIOS start */
+  }
+
+  /* Use PP #0 for this purpose */
+  enable  = pfpInst.pfpVector[0].enable;
+  alpha   = pfpInst.pfpVector[0].alpha;
+  pfpInst.pfpVector[0].enable = 1;
+  pfpInst.pfpVector[0].alpha  = 0.25;
+  for (k = 0; k < loopcnt; k++) {
+    pfpBegin(0,0);
+    pfpEnd(0,0);
+  }
+  pfpInst.pfpVector[0].alpha  = alpha;
+  pfpInst.pfpVector[0].enable = enable;
+
+  /* Take the minimum and call it overhead */
+  pfpInst.overhead = pfpInst.pfpVector[0].c_min;
+} /* pfpCalibrate */
+
+/*==================================================================================*/
+/* PFP Functions that are used for scheduling hooks within BIOS.                    */
+/*==================================================================================*/
+
+/*============================================================================*/
+/* pfpHwiPause: Stop measurement during HWI.                                  */
+/*============================================================================*/
+
+static void pfpHwiPause(void)
+{
+  volatile uint_least32_t t1;
+  uint_least32_t          dt;
+  pfpDescriptor_t         *pfp;
+
+  /* Find if any measurement is in progress? */
+  t1 = Timestamp_get();               /* fetch the current time stamp */
+  if (pfpInst.active_id < 0) {
+    return;
+  }
+  pfp = pfpInst.tail;         /* This should be the active one! */
+
+  pfpInst.active_id = -1;     /* all measurement brackets are inactive now */
+
+  /* It would be nice to know if we need to accumulate dt here! (e.g. did we come from another HWI? */
+  pfp->active     = 0;                /* this may be redundant */
+  dt              = t1 - pfp->c_0;
+  pfp->c_partial += dt;
+  /* pfp->c_0 will have to be initialized before coming back! */
+
+} /* pfpHwiPause */
+
+/*============================================================================*/
+/* pfpHwiResume: Resume measurement after HWI.                                */
+/*============================================================================*/
+
+static inline void pfpHwiResume(Hwi_Handle hwi)
+{
+  pfpDescriptor_t *pfp;
+
+  /* Find the last PP in the list */
+  if (pfpInst.depth < 1) {
+    return;
+  }
+  pfp = pfpInst.tail;
+
+  if (pfp->scope == BIOS_ThreadType_Task) {     /* Check the task mode */
+    Task_Mode mode;
+    mode = Task_getMode(pfp->exhandle);
+    if (mode != Task_Mode_RUNNING) {    /* If not running do not take c_0, do not make it active */
+      return;
+    }
+  }
+
+  pfp->active       = 1;                /* this should be done only if task is not blocked! */
+  pfpInst.active_id = pfp->id;
+  pfp->c_0          = Timestamp_get();
+
+} /* pfpHwiResume */
+
+/*============================================================================*/
+/* pfpSwiPause: Stop measurement during SWI.                                  */
+/*============================================================================*/
+
+static void pfpSwiPause(void)
+{
+  volatile uint_least32_t t1;
+  uint_least32_t          dt;
+  pfpDescriptor_t         *pfp;
+  volatile IArg key;
+
+  key=Hwi_disable();      /* Disable all HWI's */
+
+  /* Find if any measurement is in progress? */
+  t1 = Timestamp_get();               /* fetch the current time stamp */
+  if (pfpInst.active_id < 0) {
+    Hwi_restore(key);
+    return;
+  }
+  pfp = pfpInst.tail;         /* This should be the active one! */
+
+  pfpInst.active_id = -1;     /* all measurement brackets are inactive now */
+
+  /* It would be nice to know if we have to accumulate dt here. (e.g. did we come from Hwi? */
+  /* If we always come from HWI when entering SWI, we should not accumulate */
+  pfp->active     = 0;                /* this may be redundant */
+  dt              = t1 - pfp->c_0;
+  pfp->c_partial += dt;
+  /* pfp->c_0 will have to be initialized before coming back! */
+
+  Hwi_restore(key);      /* restore the HWI's */
+
+} /* pfpSwiPause */
+
+/*============================================================================*/
+/* pfpSwiResume: Resume measurement after SWI.                                */
+/*============================================================================*/
+
+static inline void pfpSwiResume(Swi_Handle swi)
+{
+  pfpDescriptor_t *pfp;
+  volatile IArg key;
+
+  key=Hwi_disable();      /* Disable all HWI's */
+
+  /* Find the last PP in the list */
+  if (pfpInst.depth < 1) {
+    Hwi_restore(key);
+    return;
+  }
+  pfp = pfpInst.tail;
+
+  if (pfp->scope == BIOS_ThreadType_Task) {     /* Check the task mode */
+    Task_Mode mode;
+    mode = Task_getMode(pfp->exhandle);
+    if (mode != Task_Mode_RUNNING) {      /* If not running do not take c_0, do not make it active */
+      Hwi_restore(key);
+      return;
+    }
+  }
+
+  pfp->active       = 1;
+  pfpInst.active_id = pfp->id;
+  pfp->c_0          = Timestamp_get();
+
+  Hwi_restore(key);      /* restore the HWI's */
+
+} /* pfpSwiResume */
+
+/*============================================================================*/
+/* pfpTaskRegister: Task registration hook. Stores hook set ID.               */
+/*============================================================================*/
+
+void pfpTaskRegister(int hookSetId)
+{
+#if PFP_DBG_HOOKS
+  System_printf("T-Register: id=%d\n", hookSetId);
+  pfpTaskHookSetId = hookSetId;
+#endif
+} /* pfpTaskRegister */
+
+/*============================================================================*/
+/* pfpTaskCreate: Task creation hook. Sets the hook set context.              */
+/*============================================================================*/
+
+void pfpTaskCreate(Task_Handle task, Error_Block *eb)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Task_Handle_name(task);
+  pEnv = Task_getHookContext(task, pfpTaskHookSetId);   /* We have set the hook set ID during registration */
+
+  System_printf("T-Create: name='%s', pEnv=0x%x\n", name, pEnv);
+  Task_setHookContext(task, pfpTaskHookSetId, (void*)0xdead);
+#endif
+} /* pfpTaskCreate */
+
+/*============================================================================*/
+/* pfpTaskReady: Task ready hook. Prepares task for run.                      */
+/*============================================================================*/
+
+void pfpTaskReady(Task_Handle task)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Task_Handle_name(task);
+  pEnv = Task_getHookContext(task, pfpTaskHookSetId);   /* We have set the hook set ID during registration */
+
+  System_printf("T-Ready: name='%s', pEnv=0x%x\n", name, pEnv);
+  Task_setHookContext(task, pfpTaskHookSetId, (void*)0xc0de);
+#endif
+} /* pfpTaskReady */
+
+/*============================================================================*/
+/* pfpTaskSwitch: Task switch hook. Facilitates task switch operation.        */
+/*============================================================================*/
+
+void pfpTaskSwitch(Task_Handle prev, Task_Handle next)
+{
+#if PFP_DBG_HOOKS
+  char *prevName;
+  char *nextName;
+  void *pPrevEnv;
+  void *pNextEnv;
+#endif
+
+ volatile uint_least32_t t1;
+  uint_least32_t          dt;
+  int                     prev_id, next_id;
+
+  volatile IArg key;
+  pfpDescriptor_t *pfp;
+
+  /* Using GATE has more overhead, but using just HWI disabling may not be safe if SWI's can
+     be posted by the tasks. However, once inside the task hook, no other task can run until
+     we're done and since we are not in SWI we are actually safe to use HWI disabling only! */
+
+  key=Hwi_disable();        /* Enter Critical Section */
+  t1 = Timestamp_get();
+
+#if PFP_DBG_HOOKS
+  if (prev == NULL) {
+    System_printf("T-Switch: ignore 1st prev Task\n");
+  }
+  else {
+    prevName = Task_Handle_name(prev);
+    pPrevEnv = Task_getHookContext(prev, pfpTaskHookSetId);
+
+    System_printf("T-Switch: prev name='%s', pPrevEnv=0x%x\n", prevName, pPrevEnv);
+    Task_setHookContext(prev, pfpTaskHookSetId, (void*)0xcafec0de);
+  }
+
+  nextName = Task_Handle_name(next);
+  pNextEnv = Task_getHookContext(next, pfpTaskHookSetId);
+
+  System_printf("T-Switch: next name='%s', pNextEnv=0x%x\n", nextName, pNextEnv);
+  Task_setHookContext(next, pfpTaskHookSetId, (void*)0xc001c0de);
+#endif
+
+  if (pfpInst.depth < 1) {
+    Hwi_restore(key);       /* Exit critical section and return */
+    return;
+  }
+
+  /* There are some active measurement PP's but we do not know where yet
+     It may not be in prev nor next task so we have to do some investigation */
+
+  /* Go through the list and find prev_id and next_id if they are inside any PP */
+  prev_id = next_id = -1;
+  pfp = pfpInst.tail;         /* This should be the one with the highest priority */
+  while (pfp != NULL && (prev_id < 0 || next_id < 0)) {
+    if (prev_id < 0 && pfp->exhandle == prev) { /* stop looking after you find the first match */
+      prev_id = pfp->id;
+    }
+    if (next_id < 0 && pfp->exhandle == next) { /* stop looking after you find the first match */
+      next_id = pfp->id;
+    }
+    pfp = pfp->prev;
+  }
+
+  /* Check to see if any of the two tasks are in the middle of a measurement */
+  if (prev_id < 0 && next_id < 0) {
+    Hwi_restore(key);
+    return;
+
+  }
+
+  if (prev_id >= 0) {     /* Previous task may have been measuring and it has to be stopped */
+    pfp = &pfpInst.pfpVector[prev_id];
+
+    pfpInst.active_id = -1;     /* all measurement brackets are inactive now */
+
+    if (pfp->active) {          /* This if is required in case we went through HWI/SWI */
+      pfp->active     = 0;
+      dt              = t1 - pfp->c_0;
+      pfp->c_partial += dt;
+    }
+  }
+  if (next_id >= 0) {     /* Next task was in the middle of measurement */
+    pfp = &pfpInst.pfpVector[next_id];
+
+    pfp->active       = 1;          /* We are about to continue measurement */
+    pfpInst.active_id = next_id;
+
+    /* Take the new one and move it to the tail if it was not there */
+    if (pfpInst.tail->id != next_id) {
+      pfp->prev->next = pfp->next;
+      pfp->next->prev = pfp->prev;
+      pfp->prev = pfpInst.tail;
+      pfp->next = NULL;
+      pfpInst.tail->next = pfp;
+      pfpInst.tail = pfp;
+    }
+    pfp->c_0          = Timestamp_get(); /* Record time */
+  }
+  Hwi_restore(key);
+} /* pfpTaskSwitch */
+
+/*============================================================================*/
+/* pfpSwiRegister: Swi registration hook. Stores hook set ID.                 */
+/*============================================================================*/
+
+void pfpSwiRegister(int hookSetId)
+{
+#if PFP_DBG_HOOKS
+  System_printf("S-Register: id=%d\n", hookSetId);
+  pfpSwiHookSetId = hookSetId;
+#endif
+} /* pfpSwiRegister */
+
+/*============================================================================*/
+/* pfpSwiCreate: Swi creation hook. Sets the hook set context.                */
+/*============================================================================*/
+
+void pfpSwiCreate(Swi_Handle swi, Error_Block *eb)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Swi_Handle_name(swi);
+  pEnv = Swi_getHookContext(swi, pfpSwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("S-Create: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Swi_setHookContext(swi, pfpSwiHookSetId, (void*)0xdead1);
+#endif
+} /* pfpSwiCreate */
+
+/*============================================================================*/
+/* pfpSwiReady: Swi ready hook. Prepares Swi for run.                         */
+/*============================================================================*/
+
+void pfpSwiReady(Swi_Handle swi)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Swi_Handle_name(swi);
+  pEnv = Swi_getHookContext(swi, pfpSwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("S-Ready: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Swi_setHookContext(swi, pfpSwiHookSetId, (void*)0xbeef1);
+#endif
+} /* pfpSwiReady */
+
+/*============================================================================*/
+/* pfpSwiBegin: Swi begin hook. Start Swi.                                    */
+/*============================================================================*/
+
+void pfpSwiBegin(Swi_Handle swi)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+#endif
+
+  pfpSwiPause();
+
+#if PFP_DBG_HOOKS
+  name = Swi_Handle_name(swi);
+  pEnv = Swi_getHookContext(swi, pfpSwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("S-Begin: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Swi_setHookContext(swi, pfpSwiHookSetId, (void*)0xfeeb1);
+#endif
+} /* pfpSwiBegin */
+
+/*============================================================================*/
+/* pfpSwiEnd: Swi end hook. End Swi.                                          */
+/*============================================================================*/
+
+void pfpSwiEnd(Swi_Handle swi)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Swi_Handle_name(swi);
+  pEnv = Swi_getHookContext(swi, pfpSwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("S-End: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Swi_setHookContext(swi, pfpSwiHookSetId, (void*)0xc0de1);
+#endif
+
+  pfpSwiResume(swi);
+
+} /* pfpSwiEnd */
+
+/*============================================================================*/
+/* pfpHwiRegister: Hwi registration hook. Stores hook set ID.                 */
+/*============================================================================*/
+
+void pfpHwiRegister(int hookSetId)
+{
+#if PFP_DBG_HOOKS
+  System_printf("H-Register: id=%d\n", hookSetId);
+  pfpHwiHookSetId = hookSetId;
+#endif
+} /* pfpHwiRegister */
+
+/*============================================================================*/
+/* pfpHwiCreate: Hwi creation hook. Sets the hook set context.                */
+/*============================================================================*/
+
+void pfpHwiCreate(Hwi_Handle hwi, Error_Block *eb)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Hwi_Handle_name(hwi);
+  pEnv = Hwi_getHookContext(hwi, pfpHwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("H-Create: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Hwi_setHookContext(hwi, pfpHwiHookSetId, (void*)0xdead2);
+#endif
+} /* pfpHwiCreate */
+
+/*============================================================================*/
+/* pfpHwiBegin: Hwi begin hook. Start Hwi.                                    */
+/*============================================================================*/
+
+void pfpHwiBegin(Hwi_Handle hwi)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+#endif
+
+  pfpHwiPause();
+
+#if PFP_DBG_HOOKS
+  name = Hwi_Handle_name(hwi);
+  pEnv = Hwi_getHookContext(hwi, pfpHwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("H-Begin: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Hwi_setHookContext(hwi, pfpHwiHookSetId, (void*)0xfeeb2);
+#endif
+} /* pfpHwiBegin */
+
+/*============================================================================*/
+/* pfpHwiEnd: Hwi end hook. End Hwi.                                          */
+/*============================================================================*/
+
+void pfpHwiEnd(Hwi_Handle hwi)
+{
+#if PFP_DBG_HOOKS
+  char *name;
+  void *pEnv;
+
+  name = Hwi_Handle_name(hwi);
+  pEnv = Hwi_getHookContext(hwi, pfpHwiHookSetId);  /* We have set the hook set ID during registration */
+
+  System_printf("H-End: name='%s', pEnv=0x%x, time=%d\n", name, pEnv, Timestamp_get());
+  Hwi_setHookContext(hwi, pfpHwiHookSetId, (void*)0xc0de2);
+#endif
+
+  pfpHwiResume(hwi);
+
+} /* pfpHwiEnd */
+
+/* nothing past this point */
+
diff --git a/pasdk/common/pfp/pfp.h b/pasdk/common/pfp/pfp.h
new file mode 100644 (file)
index 0000000..4e391d7
--- /dev/null
@@ -0,0 +1,109 @@
+/* 
+ *  pfp.h: Definitions for Profile Points functions
+ */
+#ifndef _PFP_H
+#define _PFP_H
+
+#include <stdint.h>
+
+#include <xdc/runtime/Error.h>
+
+#include <ti/sysbios/knl/Task.h>
+#include <ti/sysbios/knl/Swi.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <ti/sysbios/gates/GateAll.h>
+
+/* PFP latch macros */ // FL: added these
+#define PFP_FINISH_MEAS     ( 0 )
+#define PFP_LATCH_MEAS      ( 1 )
+
+/* Chaging this definition would change how many profile points can be used */
+#define PFP_PPCNT_MAX   32      /* this is the maximum number of profile points */
+
+/* Profile Point Descriptor Type */
+struct pfpDescriptor_stc {
+  void            *exhandle;    /* Execution object handle (hwi/swi/task) */
+  int             id;           /* PP id which is the index into the pfpInst->pfpVector[] */
+  int             scope;        /* BIOS_ThreadType */
+  int             enable;       /* 1: enabled, 0: disabled */
+  int             inside;       /* 1: inside (inside the measurement bracket), 0: outside */
+  int             active;       /* 1: clock is active, 0: clock has been "paused" */
+  int             latch;        /* 1: Latch the c_partial to spread over multiple PP regions */
+  int             reset;        /* 1: reset stats in pfpBegin(), 0: do not reset */
+  long long       c_total;      /* Total cycles (full count) */
+  uint_least32_t  n_count;      /* Number of completed measurements */
+  uint_least32_t  c_partial;    /* Current measurement */
+  uint_least32_t  c_0;          /* Starting point time stamp */
+  uint_least32_t  c_min;        /* Minimum measurement */
+  uint_least32_t  c_max;        /* Maximum measurement */
+  float           alpha;        /* Exponential averaging constant */
+  float           c_average;    /* Exponentially averaged cycles */
+  struct pfpDescriptor_stc *next;    /* Next element when in the active list */
+  struct pfpDescriptor_stc *prev;    /* Previous element when in the active list */
+};
+typedef struct pfpDescriptor_stc pfpDescriptor_t;
+
+/* Profile point instance type */
+struct pfpInst_stc {
+  GateAll_Handle    ghandle;    /* Gate handle for Critical Section */
+  pfpDescriptor_t   *head;      /* head of active profile points list */
+  pfpDescriptor_t   *tail;      /* tail of active profile points list */
+  uint_least32_t    overhead;   /* 0: if not calibrated */
+  int               depth;      /* Current length of the active profile points list */
+  int               active_id;  /* id of currently active PP */
+
+  pfpDescriptor_t   pfpVector[PFP_PPCNT_MAX]; /* Statically allocated profile point vector */
+};
+typedef struct pfpInst_stc pfpInst_t;
+
+/* Statistics reporting structure */
+struct pfpStats_stc {
+  long long       c_total;
+  uint_least32_t  n_count;
+  uint_least32_t  c_min;
+  uint_least32_t  c_max;
+  float           alpha;
+  float           c_average;
+};
+typedef struct pfpStats_stc pfpStats_t;
+
+/* Global variables */
+extern pfpInst_t      pfpInst;
+extern GateAll_Params pfpGateParams;    /* This may not be necessary */
+
+extern int pfpTaskHookSetId;            /* Used for Task hook functions */
+extern int pfpSwiHookSetId;             /* Used for Swi hook functions */
+extern int pfpHwiHookSetId;             /* Used for Hwi hook functions */
+
+/* PFP Functions */
+extern void pfpCalibrate(int loopcnt);
+extern void pfpCreate(void);
+extern void pfpBegin(int id, void *exhandle);
+extern void pfpDisable(int id);
+extern void pfpEnable(int id);
+extern void pfpEnd(int id, int latch);
+extern void pfpGetStats(int id, pfpStats_t *pStats);
+extern void pfpResetStats(int id);
+extern void pfpSetAlpha(int id, float alpha);
+
+/* PFP Hook Functions */
+extern void pfpTaskRegister(int hookSetId);
+extern void pfpTaskCreate(Task_Handle task, Error_Block *eb);
+extern void pfpTaskReady(Task_Handle task);
+extern void pfpTaskSwitch(Task_Handle prev, Task_Handle next);
+
+extern void pfpSwiRegister(int hookSetId);
+extern void pfpSwiCreate(Swi_Handle swi, Error_Block *eb);
+extern void pfpSwiReady(Swi_Handle swi);
+extern void pfpSwiBegin(Swi_Handle swi);
+extern void pfpSwiEnd(Swi_Handle swi);
+
+extern void pfpHwiRegister(int hookSetId);
+extern void pfpHwiCreate(Hwi_Handle hwi, Error_Block *eb);
+extern void pfpHwiReady(Hwi_Handle hwi);
+extern void pfpHwiBegin(Hwi_Handle hwi);
+extern void pfpHwiEnd(Hwi_Handle hwi);
+
+#endif
+/* nothing past this point */
+
diff --git a/pasdk/common/pfp_app.h b/pasdk/common/pfp_app.h
new file mode 100644 (file)
index 0000000..e5d3525
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * pfp_app.h
+ *
+ *  PFP application definitions, including:
+ *      - PFP IDs
+ *      - PFP default exponential time constant
+ */
+
+#ifndef _PFP_APP_H
+#define _PFP_APP_H
+
+#include "pfp/pfp.h"
+
+#ifdef _TMS320C6X
+/* Define all PFP ID's */
+#define PFP_ID_MAIN     0
+#define PFP_ID_TASK0_1  1   /* ASIT, input processing */
+#define PFP_ID_TASK0_2  2   
+#define PFP_ID_TASK1_1  3   /* ASOT, output processing */
+#define PFP_ID_TASK1_2  4   /* ASP */
+#define PFP_ID_LAST PFP_ID_TASK1_2
+
+#if PFP_ID_LAST >= PFP_PPCNT_MAX
+#error too many PP IDs
+#endif
+
+/* PFP default exponential averaging time constant */
+#define PFP_DEF_TAU_MS      (500.0)
+#define PFP_DEF_PERIOD_MS   (100.0)
+#define PFP_DEF_ALPHA       (PFP_DEF_PERIOD_MS/PFP_DEF_TAU_MS)
+
+#else /* _TMS320C6X */
+
+/* Define all PFP ID's */
+#define PFP_ID_MAIN     0
+#define PFP_ID_TASK0_1  1   /* INFO */
+#define PFP_ID_TASK0_2  2   /* DECODE */
+#define PFP_ID_TASK0_3  3
+#define PFP_ID_LAST PFP_ID_TASK0_2
+
+#if PFP_ID_LAST >= PFP_PPCNT_MAX
+#error too many PP IDs
+#endif
+
+/* PFP default exponential averaging time constant */
+#define PFP_DEF_TAU_MS      (500.0)
+#define PFP_DEF_PERIOD_MS   (100.0)
+#define PFP_DEF_ALPHA       (PFP_DEF_PERIOD_MS/PFP_DEF_TAU_MS)
+
+#endif /* _TMS320C6X */
+
+#endif /* _PFP_APP_H */
+/* nothing past this point */
+
+
index c5d3e8a3dc5ae93b0d2364b4b5922dcbf31857c0..419d20df40fba767727c49fc5cf7216a8a89a0b5 100644 (file)
@@ -11,8 +11,8 @@
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
+                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/common&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/shared&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_arm/framework&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_arm/application&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio_dev2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/dolby_ip/ddp/Dolby_Digital_Plus_Decoder_Imp/Source_Code/alg&quot;"/>
                                                        <tool id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.1926416484" name="XDCtools" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.1108422400"/>
                                                </toolChain>
                                        </folderInfo>
+                                       <fileInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1859149112.763196952" name="pfp.c" rcbsApplicability="disable" resourcePath="common/pfp/pfp.c" toolsToInvoke="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.exe.compilerDebug.1212267112.918634850">
+                                               <tool id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.exe.compilerDebug.1212267112.918634850" name="GNU Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.exe.compilerDebug.1212267112">
+                                                       <option id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compilerID.OPT_LEVEL.1699808898" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compilerID.OPT_LEVEL.3" valueType="enumerated"/>
+                                                       <inputType id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__C_SRCS.289636932" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__C_SRCS"/>
+                                                       <inputType id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__CPP_SRCS.454915412" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__CPP_SRCS"/>
+                                                       <inputType id="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__ASM_SRCS.1285572722" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_GNU_4.0.compiler.inputType__ASM_SRCS"/>
+                                               </tool>
+                                       </fileInfo>
                                        <sourceEntries>
                                                <entry excluding="application/app_pkgs.cmd|application/src|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
                                        </sourceEntries>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
+                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
index 69f87dd0485ccb5cffae04e0d45f29e94931d5d5..e05e68132b3c83b98d399abbb16b804062b4fd0f 100644 (file)
@@ -56,9 +56,12 @@ var System          = xdc.useModule('xdc.runtime.System');
 var Text            = xdc.useModule('xdc.runtime.Text');
 
 var BIOS            = xdc.useModule('ti.sysbios.BIOS');
+var GateAll         = xdc.useModule('ti.sysbios.gates.GateAll');    // Added for PFP
 var Hwi             = xdc.useModule('ti.sysbios.hal.Hwi');
 var Timer           = xdc.useModule('ti.sysbios.hal.Timer');
 var Clock           = xdc.useModule('ti.sysbios.knl.Clock');
+var Idle            = xdc.useModule('ti.sysbios.knl.Idle');
+var Swi             = xdc.useModule('ti.sysbios.knl.Swi');          // Added for PFP, no SWIs on ARM
 var Task            = xdc.useModule('ti.sysbios.knl.Task');
 var Semaphore       = xdc.useModule('ti.sysbios.knl.Semaphore');
 var HeapMem         = xdc.useModule('ti.sysbios.heaps.HeapMem');
@@ -272,7 +275,7 @@ Task.idleTaskStackSize = 2048;
 /* Add Audio Stream Decode Processing (ASDP) task */
 var task0Params = new Task.Params();
 task0Params.instance.name = "TaskAsdp";
-task0Params.stackSize = 0x4000;
+task0Params.stackSize = 0x8000;
 task0Params.stackSection = ".far:taskStackSectionAsdp";
 //task0Params.arg0 = 0;
 task0Params.arg0 = $externPtr("asdp_params_PA" + topo);
@@ -316,3 +319,37 @@ Program.global.heapMemL2Sram = Program.global.heapMemMsmcSram;
 
 //Program.sectMap[".globalSectionPafAstConfig"] = "COMMON_DDR3";
 //Program.sectMap[".globalSectionAcpStdBetaTable"] = "COMMON_DDR3";
+
+/* Define HWI Hook Set for PFP */
+Hwi.addHookSet({
+    registerFxn:    '&pfpHwiRegister',
+    createFxn:      '&pfpHwiCreate',
+    beginFxn:       '&pfpHwiBegin',
+    endFxn:         '&pfpHwiEnd',
+    deleteFxn:      null,
+});
+
+/* Define SWI Hook Set for PFP */
+Swi.addHookSet({
+    registerFxn:    '&pfpSwiRegister', // need this for Id for Hook context
+    createFxn:      '&pfpSwiCreate',   // malloc context storage space
+    readyFxn:       '&pfpSwiReady',
+    beginFxn:       '&pfpSwiBegin',
+    endFxn:         '&pfpSwiEnd',
+    deleteFxn:      null,
+});
+
+/* Define Task Hook Set for PFP */
+Task.addHookSet({
+    registerFxn:    '&pfpTaskRegister',
+    createFxn:      '&pfpTaskCreate',
+    readyFxn:       '&pfpTaskReady',
+    switchFxn:      '&pfpTaskSwitch',
+    exitFxn:        null,
+    deleteFxn:      null,
+});
+
+/* Added for PFP, not necessary */
+Hwi.common$.namedInstance=true;
+Swi.common$.namedInstance=true;
+Task.common$.namedInstance=true;
diff --git a/pasdk/test_arm/application/board_utils.c b/pasdk/test_arm/application/board_utils.c
new file mode 100644 (file)
index 0000000..98cd563
--- /dev/null
@@ -0,0 +1,232 @@
+// FL: Obtained this code from Ivan Pang, 
+//     https://bitbucket.itg.ti.com/projects/PROCESSOR-SDK/repos/board/browse/src/evmKeystone/board_utils.c
+//
+
+// FL: added this locally
+#include <xdc/std.h>
+#define uint32_t UInt32
+
+#if 0 // FL: remove everything but code for PMCR
+/**
+ * @file   board_utils.c
+ *
+ * @brief  This file includes the Keystone board level functions
+ */
+/*
+ * Copyright (c) 2015, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <ti/csl/csl_bootcfg.h>
+#include <ti/csl/csl_bootcfgAux.h>
+#if defined (_TMS320C6X)
+#include <ti/csl/csl_chipAux.h>
+#endif
+
+#include "board_utils.h"
+
+/**
+* \brief  This API gets the input clock frequency.
+*
+* \param  pll         PLL controller type.
+*
+* \return input clock to the PLL controller.
+*
+* \note   This API gets the input clock frequency based on the
+*         PLL controller type.\n
+*/
+/** ============================================================================
+ *   @n@b BOARD_getExternalClk
+ *
+ *   @b Description
+ *   @n  This function is used to get the exteranl clock frequency.
+ *
+ *
+ *   @b Arguments
+ *   @verbatim
+            pll             Specifies the PLL controller type.
+      @endverbatim
+ *
+ *   <b> Return Value </b>
+ *   @n external clock frequency to the PLL controller, if 0, means failure
+ *
+ *   <b> Pre Condition </b>
+ *   @n  None
+ *
+ *   <b> Post Condition </b>
+ *   @n   None
+ *
+ *   @b Affects
+ *   @n None.
+ *
+ *   @b Example
+ *   @verbatim
+        uint32_t     ext_clk;
+
+        ext_clk = BOARD_getExternalClk(CSL_PLL_SYS);
+
+    @endverbatim
+ * ===========================================================================
+ */
+uint32_t BOARD_getExternalClk(CSL_PllcType pll)
+{
+    return Board_ext_clk[pll];
+}
+#endif
+
+/** ============================================================================
+ *   @n@b BOARD_initPerfCounters
+ *
+ *   @b Description
+ *   @n  This function enables the A15 performance counters.
+ *
+ *
+ *   @b Arguments
+
+ *   <b> Return Value </b>
+ *   @n None
+ *
+ *   <b> Pre Condition </b>
+ *   @n  None
+ *
+ *   <b> Post Condition </b>
+ *   @n   None
+ *
+ *   @b Affects
+ *   @n None.
+ *
+ *   @b Example
+ *   @verbatim
+        BOARD_initPerfCounters();
+    @endverbatim
+ * ===========================================================================
+ */
+void BOARD_initPerfCounters()
+{
+#if defined (_TMS320C6X) || defined(__TI_ARM_V7M4__)
+    // Do nothing for C6x and M4 cores
+#else
+    /* PMCR
+    31......24 23......16 15....11 10.....6  5 4 3 2 1 0
+        IMP      IDCODE       N       Res   DP X D C P E
+    [31:24] IMP: Implementer code; read-only
+    [23:16] IDCODE: Identification code; read-only
+    [15:11] N: Number of event counters; read-only
+    [10:6] Reserved
+    [5] DP: Disable cycle counter in prohibited regions; r/w
+    [4] X: Export enable; r/w
+    [3] D: Clock divider - PMCCNTR counts every 64 clock cycles when enabled; r/w
+    [2] C: Clock counter reset; write-only
+    [1] P: Event counter reset; write-only
+    [0] E: Enable all counters; r/w
+    */
+    __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 0\t\n" :: "r"(0x17));
+
+    /* PMCNTENSET - Count Enable Set Register */
+    __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 1\t\n" :: "r"(0x8000000f));
+
+    /* PMOVSR - Overflow Flag Status Register */
+    __asm__ __volatile__ ("MCR p15, 0, %0, c9, c12, 3\t\n" :: "r"(0x8000000f));
+#endif
+}
+
+//static uint32_t readTime32(void) // FL: static function??
+uint32_t readTime32(void)
+{
+    uint32_t timeVal;
+
+#if defined (_TMS320C6X)
+    timeVal = TSCL;
+#else
+    __asm__ __volatile__ ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(timeVal));
+#endif
+    return timeVal;
+}
+
+#if 0 // FL: remove everything but code for PMCR
+/** ============================================================================
+ *   @n@b BOARD_delay
+ *
+ *   @b Description
+ *   @n  This function delays a certain period of time in micro seconds.
+ *
+ *
+ *   @b Arguments
+ *   @verbatim
+            usecs           Specifies the time to delay in micro second.
+      @endverbatim
+ *   @n To prevent 32-bit counter roll over, the delay time should be less than 2^32/freq_in_mhz (usec)
+ *      e.g. for 1000Mhz PLL clock, delay time should be less than ~4.2 seconds.
+ *
+ *   <b> Return Value </b>
+ *   @n None
+ *
+ *   <b> Pre Condition </b>
+ *   @n  None
+ *
+ *   <b> Post Condition </b>
+ *   @n   None
+ *
+ *   @b Affects
+ *   @n None.
+ *
+ *   @b Example
+ *   @verbatim
+        uint32_t     delay = 5;
+
+        BOARD_delay(delay);
+
+    @endverbatim
+ * ===========================================================================
+ */
+void BOARD_delay(uint32_t usecs)
+{
+    uint32_t ext_clk, freq, start, delayCount;
+    CSL_PllcType pllType;
+
+#if defined (_TMS320C6X)
+    pllType = CSL_PLL_SYS;
+    CSL_chipWriteTSCL(0);
+#else
+#if defined(SOC_K2E)
+    pllType = CSL_PLL_SYS;
+#else
+    pllType = CSL_PLL_ARM;
+#endif
+#endif
+
+    start = readTime32();
+    ext_clk = BOARD_getExternalClk(pllType);
+    freq = CSL_BootCfgGetPllFreq(pllType, ext_clk);
+
+    delayCount = usecs * (freq / 1000000);
+    while ((readTime32() - start) < delayCount);
+}
+#endif
index c16b6b7b0e26a5f4f3e468a863e4b2db5a3cc3eb..065147c298d9f1ac8941f008d49d267b196b0d78 100644 (file)
@@ -44,15 +44,50 @@ All rights reserved.
 #include <ti/sysbios/BIOS.h>
 #include <ti/ipc/Ipc.h>
 
+#include "components/clk.h" /* PFP testing */
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+
+extern void BOARD_initPerfCounters();
+extern uint32_t readTime32(void);
+
 /*
  *  ======== main ========
  */
 Int main()
 { 
     Int status;
+    Int k;
+    UInt32 tsStart, tsEnd, delta;
     
     Log_info0("Enter main()");
 
+    BOARD_initPerfCounters();
+    
+    /* Setup Profile Points (PFP) */
+    Log_info0("enter PFP Setup");
+    pfpCreate();
+    pfpCalibrate(1000);
+    pfpResetStats(0); // FL: this is currently required to reset stats for PFP #0 after calibration.
+    for (k = 0; k <= PFP_ID_LAST; k++) 
+    {
+        pfpEnable(k);   /* Enable profile point #k */
+    }
+    for (k = 1; k <= PFP_ID_LAST; k++)
+    {
+        pfpSetAlpha(k, PFP_DEF_ALPHA);  /* Set default exp. avg. time const. */
+    }
+    // debug: dummy load
+    for (k = 0; k < 1000; k++) 
+    {
+        tsStart=readTime32();
+        pfpBegin(PFP_ID_MAIN,0);
+        clkWorkDelay(CLK_WORKCNT_PER_MS);     /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
+        pfpEnd(PFP_ID_MAIN,0);
+        tsEnd=readTime32();
+    }
+    delta = tsEnd-tsStart;
+
     // Initialize IPC
     status = Ipc_start();
     if (status < 0) 
index 2cb1b352339cd28346cf54ddf33e76f99471a7b7..b3c2b44aed40f2563bbc363e8b9d68c8da95e55a 100644 (file)
@@ -60,15 +60,15 @@ All rights reserved.
 #include "aspDecOpCircBuf_slave.h"
 #include "audioStreamProc_common.h"
 #include "audioStreamDecodeProc.h"
-
 #include "statusOp_common.h"
 
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
 
 // FL: debug
-//#include "fwkSim.h"
 #include "dbgCapAf.h"
 #include "dbgDib.h"
-
+#include "evmc66x_gpio_dbg.h"
 
 //
 // Decoder Definitions
@@ -121,10 +121,6 @@ UInt32 gSlaveDecDecodeCnt       =0;
 UInt32 gSlaveDecDeactivateCnt   =0;
 
 
-// FL: (***) debug
-#include "evmc66x_gpio_dbg.h"
-
-
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -165,10 +161,12 @@ Void taskAsdpFxn(
     Int zI;
     Int bufEnd, wrapSize, currentBufSize, chunkSize;
     Int8 temp8;
+    Task_Handle asdtHandle; // For PFP
 
-    
     Log_info0("Enter taskAsdpFxn()");
     
+    asdtHandle = Task_self(); // get task handle for PFP
+    
     //
     // Audio Framework Parameters & Patch (*pP, *pQ):
     //
@@ -625,7 +623,9 @@ Void taskAsdpFxn(
                     errno = 0;
                     if (dec->fxns->info)
                     {
+                        pfpBegin(PFP_ID_TASK0_1, asdtHandle);
                         errno = dec->fxns->info(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
+                        pfpEnd(PFP_ID_TASK0_1, PFP_FINISH_MEAS);
                     }
                     
                     // write back Dec configuration
@@ -697,7 +697,9 @@ Void taskAsdpFxn(
                         // FL: debug, capture input buffer
                         //capIb(pAstCfg->xInp[z].pInpBuf);
                     
+                        pfpBegin(PFP_ID_TASK0_2, asdtHandle);
                         errno = dec->fxns->decode(dec, NULL, &pAstCfg->xDec[z].decodeInStruct, &pAstCfg->xDec[z].decodeOutStruct);
+                        pfpEnd(PFP_ID_TASK0_2, PFP_FINISH_MEAS);
                         if (errno < 0)
                         {
                             //SW_BREAKPOINT;
index c2962b0a584f6927b93ec888642d715481f9be39..e32714429d3a927af9ab2db9f0fabcc167e59fe5 100644 (file)
@@ -11,8 +11,8 @@
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
+                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
@@ -88,7 +88,6 @@
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.1.compilerID.DIAG_WRAP.844860326" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.1.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.C6000_8.1.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
                                                                <option id="com.ti.ccstudio.buildDefinitions.C6000_8.1.compilerID.INCLUDE_PATH.1905793105" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C6000_8.1.compilerID.INCLUDE_PATH" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/boards/d10/drivers&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PDK_INSTALL_PATH}/ti/drv/mcasp&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PDK_INSTALL_PATH}/ti/platform&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PDK_INSTALL_PATH}/ti/csl&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/f/alpha&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/util/da10x_misc&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/util/statusop_common&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/framework&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/application/itopo/evmk2g/alpha&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/common&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/shared&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/boards/k2g/drivers&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/dolby_ip/ddp/Dolby_Digital_Plus_Decoder_Imp/Source_Code/alpha&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/dolby_ip/mat-thd/Dolby_MAT_Decoder_Imp/Source_Code/alpha&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/dolby_ip/oar/Source_Code&quot;"/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
+                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
+                                       <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_02/psdk_cust/pdk_k2g_1_0_1_1_eng/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="PKTLIB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SRIO_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="DFE_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="PRUSS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="FATFS_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="SBL_BOOT_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="UART_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="NWAL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
+                                       <stringMacro name="BOARD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="SPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                </macros>
                                <externalSettings/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/f/alpha&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/util/da10x_misc&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/paf/pa/util/statusop_common&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/framework&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/application/itopo/evmk2g/alpha&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/sio&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/common&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/shared&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${PROC_AUDIO_SDK_ROOT}/pasdk/test_dsp/boards/k2g/drivers&quot;"/>
index 535dd7c6ba703493a10ddabbc31572539b6be920..5472cb075f133420b16bddcad7e647cba9c3a2fe 100644 (file)
@@ -55,10 +55,12 @@ var SysMin          = xdc.useModule('xdc.runtime.SysMin');
 var System          = xdc.useModule('xdc.runtime.System');
 var Text            = xdc.useModule('xdc.runtime.Text');
 
+
 var BIOS            = xdc.useModule('ti.sysbios.BIOS');
+var GateAll         = xdc.useModule('ti.sysbios.gates.GateAll');    // Added for PFP
 var Hwi             = xdc.useModule('ti.sysbios.hal.Hwi');
 var Cache           = xdc.useModule('ti.sysbios.hal.Cache');
-var Cachec66       = xdc.useModule('ti.sysbios.family.c66.Cache');
+var Cachec66        = xdc.useModule('ti.sysbios.family.c66.Cache');
 var Timer           = xdc.useModule('ti.sysbios.hal.Timer');
 var HeapBuf         = xdc.useModule('ti.sysbios.heaps.HeapBuf');
 var HeapMem         = xdc.useModule('ti.sysbios.heaps.HeapMem');
@@ -66,6 +68,7 @@ var Clock           = xdc.useModule('ti.sysbios.knl.Clock');
 var Idle            = xdc.useModule('ti.sysbios.knl.Idle');
 var Queue           = xdc.useModule('ti.sysbios.knl.Queue');
 var Semaphore       = xdc.useModule('ti.sysbios.knl.Semaphore');
+var Swi             = xdc.useModule('ti.sysbios.knl.Swi');          // Added for PFP
 var Task            = xdc.useModule('ti.sysbios.knl.Task');
 var Load            = xdc.useModule('ti.sysbios.utils.Load');
 
@@ -452,3 +455,37 @@ else
     //// Map event 1 (combine events 32-63) to vector 7
     //EventCombiner.eventGroupHwiNum[1] = 7;
 }
+
+/* Define HWI Hook Set for PFP */
+Hwi.addHookSet({
+    registerFxn:    '&pfpHwiRegister',
+    createFxn:      '&pfpHwiCreate',
+    beginFxn:       '&pfpHwiBegin',
+    endFxn:         '&pfpHwiEnd',
+    deleteFxn:      null,
+});
+
+/* Define SWI Hook Set for PFP */
+Swi.addHookSet({
+    registerFxn:    '&pfpSwiRegister', // need this for Id for Hook context
+    createFxn:      '&pfpSwiCreate',   // malloc context storage space
+    readyFxn:       '&pfpSwiReady',
+    beginFxn:       '&pfpSwiBegin',
+    endFxn:         '&pfpSwiEnd',
+    deleteFxn:      null,
+});
+
+/* Define Task Hook Set for PFP */
+Task.addHookSet({
+    registerFxn:    '&pfpTaskRegister',
+    createFxn:      '&pfpTaskCreate',
+    readyFxn:       '&pfpTaskReady',
+    switchFxn:      '&pfpTaskSwitch',
+    exitFxn:        null,
+    deleteFxn:      null,
+});
+
+/* Added for PFP, not necessary */
+Hwi.common$.namedInstance=true;
+Swi.common$.namedInstance=true;
+Task.common$.namedInstance=true;
index 0505ab6f071c4763db696c45cfe34b0edab36b2f..613d657a31e3418961b4d6802864de3df2c2b1e3 100644 (file)
@@ -45,12 +45,15 @@ All rights reserved.
 #include <ti/ipc/Ipc.h>
 #include <ti/sysbios/hal/Cache.h>
 
-
 #include <platform.h>
 #include <platform_audio.h>
 #include "audio_dc_cfg.h"
 #include "edma_cfg.h"
 
+#include "components/clk.h" /* PFP testing */
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+
 extern Void initDev2(Void);
 
 
@@ -61,10 +64,31 @@ Int main()
 {
     Int status;
     Platform_STATUS pfStatus;
+    Int k;
 
-    //System_printf("Enter main()\n");
     Log_info0("Enter main()");
-
+    
+    /* Setup Profile Points (PFP) */
+    Log_info0("enter PFP Setup");
+    pfpCreate();
+    pfpCalibrate(1000);
+    pfpResetStats(0); // FL: this is currently required to reset stats for PFP #0 after calibration.
+    for (k = 0; k <= PFP_ID_LAST; k++) 
+    {
+        pfpEnable(k);   /* Enable profile point #k */
+    }
+    for (k = 1; k <= PFP_ID_LAST; k++)
+    {
+        pfpSetAlpha(k, PFP_DEF_ALPHA);  /* Set default exp. avg. time const. */
+    }    
+    // debug: dummy load
+    for (k = 0; k < 1000; k++) 
+    {
+        pfpBegin(PFP_ID_MAIN,0);
+        clkWorkDelay(CLK_WORKCNT_PER_MS);     /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
+        pfpEnd(PFP_ID_MAIN,0);
+    }    
+    
     //Platform setup!!!
     /*
      * use ROV->SysMin to view the characters in the circular buffer
index f7a40b73c6f127a8aa99e4411e5ad7cced3d5f3d..e32bb9e4e58db85a24e22098b0670609c5bb3fbf 100644 (file)
@@ -45,7 +45,6 @@ All rights reserved.
 #include <ti/sysbios/knl/Clock.h>
 #include <ti/sysbios/knl/Semaphore.h>
 #include <stdlib.h>
-//#include "fwkSim.h"
 
 #include "paf_heapMgr.h"
 #include "alphaFuncProc.h"
index 64db994d84a427a94cbacbd35585292c79e91ac0..cae5dbbbdc9c63cde0659b5b45c41d336ab7a951 100644 (file)
@@ -255,6 +255,8 @@ All rights reserved.
 extern UInt32 start_profiling;
 #endif
 
+extern UInt32 gAspProfileEnable;
+
 //
 // Audio Stream Definitions
 //
@@ -385,6 +387,8 @@ Void taskAsipFxn(
         return;
     }    
     
+    taskHandle = Task_self();
+    
     //
     // Audio Framework Configuration (*pC):
     //
@@ -396,8 +400,6 @@ Void taskAsipFxn(
     pAstCfg->as = as;    
     TRACE_TERSE1("TaskAsip: Started with AS%d.", as);
 
-    taskHandle = Task_self();
-    
     //
     // Initialize message log trace and line number reporting
     //
@@ -947,6 +949,8 @@ Void taskAsipFxn(
         // Reduce priority level since autodetection complete
         Task_setPri(taskHandle, Task_getPri(taskHandle)-1);
         
+        gAspProfileEnable=1; // start ASP profiling
+        
         TRACE_VERBOSE0("TaskAsip: calling decodeProcessing.");
         errno = pP->fxns->decodeProcessing(pP, pQ, pC, sourceSelect);
         if (errno) 
@@ -958,6 +962,8 @@ Void taskAsipFxn(
             TRACE_VERBOSE0("TaskAsip: decodeProcessing complete with no error.");
         }        
 
+        gAspProfileEnable=0; // stop ASP profiling
+        
         // Increase priority level since decoding complete
         Task_setPri(taskHandle, Task_getPri(taskHandle)+1);
 
@@ -2135,7 +2141,7 @@ PAF_ASIT_decodeProcessing(
         {
             case INIT: // initial state
                 gAsipInitCnt++;
-                Log_info0("TaskAsip: state=INIT");
+                Log_info0("TaskAsip: state=INIT");               
 
 #if 0 // Not necessary since decoder status is in uncached memory
                 // status for shared beta units can change (e.g. at-boot or alpha)
@@ -2407,7 +2413,7 @@ PAF_ASIT_decodeProcessing(
         {
             /* ignored? */;
         }
-
+        
         TRACE_TIME((&TIME_MOD, "as1-f2: ... + %d = ?? (final? %d)", dtime(), state == FINAL));
 
         return errno;
index d3156465d01276a7ca8ad4614e837f3053cccece..74be20318b3b5a108f82ea0ed7df3a575427c0c9 100644 (file)
@@ -60,6 +60,13 @@ All rights reserved.
 #include "audioStreamProc_common.h"
 #include "audioStreamOutProc.h"
 
+#include "pfp/pfp.h"
+#include "pfp_app.h"        /* contains all PFP ID's */
+
+// FL: debug
+#include "evmc66x_gpio_dbg.h"
+
+
 #define TRACE_TIME(a)
 
 //
@@ -133,8 +140,6 @@ UInt32 gAsopEncodeCnt       =0;
 UInt32 gAsopFinalCnt        =0;
 UInt32 gAsopQuitCnt         =0;
 
-// FL: (***) debug
-#include "evmc66x_gpio_dbg.h"
 
 /*
  *  ======== taskAsopFxn ========