]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blobdiff - pasdk/test_dsp/framework/systemInit.c
PASDK-516:Add updates for PCE
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / systemInit.c
index d0f746fd04388681fba6845f15b9e8b960930908..9dfc363e4fbfe5bbca0a309e079b00616048b6ea 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
-Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
+Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
 All rights reserved.
 
 * Redistribution and use in source and binary forms, with or without 
@@ -46,6 +46,7 @@ All rights reserved.
 #include <ti/ipc/Ipc.h>
 #include <ti/sysbios/family/c66/Cache.h>
 
+#include "params.h"
 #include "pafhjt.h"
 #include "paf_heapMgr.h"
 #include "aspMsg_common.h"
@@ -55,32 +56,52 @@ All rights reserved.
 #include "audioStreamProc_common.h" // ASIT/ASOT/ASDT config
 #include "audioStreamInpProc.h"
 #include "audioStreamOutProc.h"
-#include "fwkSim.h"
+#include "systemInit.h"
 
-extern Void ACP_main_cus(Void);     // (*** ?) FL: revisit -- check method of patching alpha codes
-extern Void taskSystemStreamFxn(Void);  // (*** ?) FL: revisit -- shouldn't need to call this from system init
+// debug
+#include "evmc66x_pinmux.h"
+#include "evmc66x_gpio_dbg.h"
 
-const PAFHJT_t *pafhjt;
+
+#define __TASK_NAME__  "TaskSysInit"
+
+#define TASK_AFP_PRI        ( 2 )
+#define TASK_AIP_PRI        ( 3 )
+#define TASK_SSP_PRI        ( 1 )
+#define TASK_ASIP_PRI       ( 4 ) //( 4 )
+#define TASK_ASOP_PRI       ( 4 )
+
+#define SYS_INIT_SLEEP      ( 100 )
+
+// For patching alpha codes
+extern Void ACP_main_cus(Void);
+
+//#define MEMSTAT_REPORT
+#ifdef MEMSTAT_REPORT
+#include "paf_alg_print.h"
+#endif
 
 #define RAM_REPORT
 #ifdef RAM_REPORT
-#include <audioStreamProc_params.h>
-#include <paf_alg_print.h>
+#include "audioStreamProc_params.h"
+#include "paf_alg_print.h"
 extern PAF_ASIT_Fxns PAF_ASIT_params_fxns;
 extern PAF_ASOT_Fxns PAF_ASOT_params_fxns;
 #endif
 
-Int gSysInit=0;
-
-#define TASK_AFP_PRI        ( 3 )//( 1 )  // (***) FL: temporary fix for PASDK-64
-#define TASK_AIP_PRI        ( 1 )//( 2 ) 
-#define TASK_SSP_PRI        ( 1 )
-#define TASK_ASIP_PRI       ( 2 )//( 3 ) 
-#define TASK_ASOP_PRI       ( 2 )//( 3 ) 
+// Task initialization flag array.
+// Each flag indicates whether Task has been initialized.
+//   0: uninitialized
+//   1: initialized
+Int gTaskInitFlag[NUM_SYS_TASKS];
 
-#define __TASK_NAME__  "TaskSysInit"
+// PAF Hidden Jump Table (HJT) pointer
+const PAFHJT_t *pafhjt;
 
-#define SYS_INIT_SLEEP  100
+/* Semaphore handles for Tx and Rx - to put in structures */
+Semaphore_Handle asipSemRx;
+Semaphore_Handle asopSemTx;
+void sysCreateSemaphores(void);
 
 /*
  *  ======== taskSysInitFxn ========
@@ -99,11 +120,11 @@ Void taskSysInitFxn(Void)
     // Create Shared DDR region as non-Cacheable, Before IPC attach
     // TODO: remove hardcoded address and get correct values from .bld
     {   // base: 0x81000000, len: 0x01000000,
-        UInt Common2_DDR3_MAR_base = 0x01848204;
+        //UInt Common2_DDR3_MAR_base = 0x01848204;
         UInt Common2_DDR3_base = 0x81000000;
         UInt Common2_DDR3_len = 0x01000000;
         // disable cache for common2 DDR3
-        Cache_setMar(Common2_DDR3_base, Common2_DDR3_len, Cache_Mar_DISABLE);
+        Cache_setMar((xdc_Ptr)Common2_DDR3_base, Common2_DDR3_len, Cache_Mar_DISABLE);
     }
 
     //taskPriAfp = Task_setPri(TaskAfp, -1);
@@ -137,12 +158,20 @@ Void taskSysInitFxn(Void)
     
     /* Initialize decoder output circular buffer control */
     Log_info0("taskSysInitFxn:cbCtlInit()");
-    status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, &gPAF_AST_config.xDecOpCb);
+    status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, asip_params.zone.decodeN, &gPAF_AST_config.xDecOpCb);
     if (status < 0)
     {
         Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting.");
         return;
     }
+    /* Initialize Output Processing Init-Sync control */
+    Log_info0("taskSysInitFxn:outIsCtlInit()");
+    status = outIsCtlInit(&gPAF_ASPM_config.outIsCtl, &gPAF_AST_config.xOutIsi);
+    if (status < 0)
+    {
+        Log_info0("TaskSysInit: unable to initialize Output Init-Sync Control. Exiting.");
+        return;
+    }
 
     /* Initialize PAF heap manager */
     Log_info0("taskSysInitFxn:pafHeapMgr_init()");
@@ -158,6 +187,13 @@ Void taskSysInitFxn(Void)
         srHeapMsmc, 
         srHeapDdr3,
         srHeapNonCacheDdr3);
+
+#ifdef MEMSTAT_REPORT
+    // Output current heap memory usage
+    PAF_ALG_memStatusPrint("System Initialization, Initial MEMSTAT REPORT",
+        PAF_HEAP_INT, PAF_HEAP_INT1, PAF_HEAP_EXT, 
+        PAF_HEAP_INT1_SHM, PAF_HEAP_EXT_SHM, PAF_HEAP_EXT_NONCACHED_SHM);
+#endif        
     
     /* Initialize HJT */
     pafhjt = &PAFHJT_RAM;
@@ -179,23 +215,58 @@ Void taskSysInitFxn(Void)
     PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
 #endif
 
-
+#if 1 // debug
+    // Any of these can be used on ARM, but DSP must configure the GPIO since pinMuxSetMode() is only available on DSP
+    audk2g_pinMuxSetMode(101,AUDK2G_PADCONFIG_MUX_MODE_QUATERNARY); // PAD101 to QUATERNARY, GPIO (B5 on AudioDaughterCard J12)
+    GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_99, GPIO_OUT); // GPIO0,pin99 output
+    GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+    GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+    audk2g_pinMuxSetMode(117,AUDK2G_PADCONFIG_MUX_MODE_QUATERNARY); // PAD117 to QUATERNARY, GPIO (B8 on AudioDaughterCard J12)
+    GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_106, GPIO_OUT); // GPIO0,pin106 output
+    GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);
+    GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
+    audk2g_pinMuxSetMode(118,AUDK2G_PADCONFIG_MUX_MODE_QUATERNARY); // PAD118 to QUATERNARY, GPIO (B9 on AudioDaughterCard J12)
+    GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_107, GPIO_OUT); // GPIO0,pin107 output
+    GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+    GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+#endif
+    
     /* This is required to use SYS alpha codes in atboot? */
     Log_info0("taskSysInitFxn:TaskSystemStream resume");
-    gSysInit = 0;
+    gTaskInitFlag[TASK_SSP_INIT_FLAG_IDX] = 0;
     Task_setPri(TaskSystemStream, TASK_SSP_PRI);
     // Wait until Execution of TaskSystemStream is complete
     // once.
-    while (gSysInit == 0)  // gSysInit is set to 1 in TaskSystemStream
+    while (gTaskInitFlag[TASK_SSP_INIT_FLAG_IDX] == 0)  // System Stream initialization flag is set to 1 in TaskSystemStream
     {
-       Task_sleep(SYS_INIT_SLEEP);
+        Task_sleep(SYS_INIT_SLEEP);
     }
 
-
     Task_setPri(TaskAfp, TASK_AFP_PRI);
     Task_setPri(TaskAip, TASK_AIP_PRI);
     Task_setPri(TaskAsip, TASK_ASIP_PRI);
     Task_setPri(TaskAsop, TASK_ASOP_PRI);
 
+    // Create ASIT/ASOT semaphores
+    sysCreateSemaphores();
+
+#ifdef MEMSTAT_REPORT
+    // Output current heap memory usage
+    PAF_ALG_memStatusPrint("System Initialization, Final MEMSTAT REPORT",
+        PAF_HEAP_INT, PAF_HEAP_INT1, PAF_HEAP_EXT, 
+        PAF_HEAP_INT1_SHM, PAF_HEAP_EXT_SHM, PAF_HEAP_EXT_NONCACHED_SHM);
+#endif           
+    
     Log_info0("Exit taskSysInitFxn()");
 }
+
+// Create ASIT/ASOT events
+void sysCreateSemaphores(void)
+{
+    Semaphore_Params SemParams;
+
+    Semaphore_Params_init(&SemParams);
+
+    asipSemRx = Semaphore_create(0, &SemParams, NULL);
+    //asopSemTx = Semaphore_create(0, &SemParams, NULL);
+}