]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/systemInit.c
PASDK-53: Hard-coding 192 KHz as the IB SampleRate, to aid with SIDK progress.
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / systemInit.c
2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37  *  ======== systemInit.c ========
38  */
40 #include <xdc/std.h>
41 #include <xdc/cfg/global.h>
42 #include <xdc/runtime/IHeap.h>
43 #include <xdc/runtime/Log.h>
44 #include <xdc/runtime/System.h>
45 #include <ti/ipc/SharedRegion.h>
46 #include <ti/ipc/Ipc.h>
47 #include <ti/sysbios/family/c66/Cache.h>
49 #include "pafhjt.h"
50 #include "paf_heapMgr.h"
51 #include "aspMsg_common.h"
52 #include "aspMsg_master.h"
53 #include "aspDecOpCircBuf_master.h"
54 #include "audioStreamProc_master.h" // ASIT/ASOT config
55 #include "audioStreamProc_common.h" // ASIT/ASOT/ASDT config
56 #include "audioStreamInpProc.h"
57 #include "audioStreamOutProc.h"
58 #include "fwkSim.h"
60 extern Void ACP_main_cus(Void);     // (*** ?) FL: revisit -- check method of patching alpha codes
61 extern Void taskSystemStreamFxn(Void);  // (*** ?) FL: revisit -- shouldn't need to call this from system init
63 const PAFHJT_t *pafhjt;
65 #define RAM_REPORT
66 #ifdef RAM_REPORT
67 #include <audioStreamProc_params.h>
68 #include <paf_alg_print.h>
69 extern PAF_ASIT_Fxns PAF_ASIT_params_fxns;
70 extern PAF_ASOT_Fxns PAF_ASOT_params_fxns;
71 #endif
73 Int gSysInit=0;
75 #define TASK_AFP_PRI        ( 1 )//( 1 )  // (***) FL: temporary fix for PASDK-64
76 #define TASK_AIP_PRI        ( 2 )//( 2 )
77 #define TASK_SSP_PRI        ( 1 )
78 #define TASK_ASIP_PRI       ( 3 )//( 3 )
79 #define TASK_ASOP_PRI       ( 3 )//( 3 )
81 #define __TASK_NAME__  "TaskSysInit"
83 #define SYS_INIT_SLEEP  100
85 // FL: debug
86 #include "evmc66x_pinmux.h"
87 #include "evmc66x_gpio_dbg.h"
89 /*
90  *  ======== taskSysInitFxn ========
91  *  System Initializations task function
92  */
93 Void taskSysInitFxn(Void)
94 {
95     UInt16  regionId;
96     IHeap_Handle srHeapMsmc, srHeapDdr3, srHeapNonCacheDdr3;
97     UInt16 remoteProcId;    
98     Int status;
101     Log_info0("Enter taskSysInitFxn()");
103     // Create Shared DDR region as non-Cacheable, Before IPC attach
104     // TODO: remove hardcoded address and get correct values from .bld
105     {   // base: 0x81000000, len: 0x01000000,
106         UInt Common2_DDR3_MAR_base = 0x01848204;
107         UInt Common2_DDR3_base = 0x81000000;
108         UInt Common2_DDR3_len = 0x01000000;
109         // disable cache for common2 DDR3
110         Cache_setMar(Common2_DDR3_base, Common2_DDR3_len, Cache_Mar_DISABLE);
111     }
113     //taskPriAfp = Task_setPri(TaskAfp, -1);
114     //taskPriAip = Task_setPri(TaskAip, -1);
115     //taskPriAsip = Task_setPri(TaskAsip, -1);
117     /* Attach IPC */
118     Log_info0("taskSysInitFxn:Ipc_attach()");
119     remoteProcId = MultiProc_getId(SLAVE_NAME);
120     if (remoteProcId == MultiProc_INVALIDID) {
121         System_abort("Improper MultiProc ID\n");
122     }
123     do {
124         status = Ipc_attach(remoteProcId);
125     //} while ((status < 0) && (status == Ipc_E_NOTREADY));
126     } while (status != Ipc_S_SUCCESS);
128     /* Initialize (IPC) ASP master messaging */
129     /* Note: MessageQ_open() called in this function.
130              MessageQ_open() blocks. */
131     Log_info0("taskSysInitFxn:AspMsgMaster_init()");
132     status = AspMsgMaster_init(
133         hAspMsgMaster, 
134         remoteProcId, 
135         ASP_MSG_MASTER_DEF_NUMMSGS);
136     if (status < 0)
137     {
138         Log_info0("TaskSysInit: unable to initialize ASP messaging. Exiting.");
139         return;
140     }
141     
142     /* Initialize decoder output circular buffer control */
143     Log_info0("taskSysInitFxn:cbCtlInit()");
144     status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, &gPAF_AST_config.xDecOpCb);
145     if (status < 0)
146     {
147         Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting.");
148         return;
149     }
151     /* Initialize PAF heap manager */
152     Log_info0("taskSysInitFxn:pafHeapMgr_init()");
153     regionId = SharedRegion_getIdByName("SR_MSMC");
154     srHeapMsmc = (IHeap_Handle)SharedRegion_getHeap(regionId);
155     regionId = SharedRegion_getIdByName("SR_DDR3");
156     srHeapDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
157     regionId = SharedRegion_getIdByName("COMMON2_DDR3");
158     srHeapNonCacheDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
159     pafHeapMgr_init((IHeap_Handle)heapMemL2Sram, 
160         (IHeap_Handle)heapMemMsmcSram, 
161         (IHeap_Handle)heapMemDdr3, 
162         srHeapMsmc, 
163         srHeapDdr3,
164         srHeapNonCacheDdr3);
165     
166     /* Initialize HJT */
167     pafhjt = &PAFHJT_RAM;
168     
169     /* Patch sigma tables */
170     Log_info0("taskSysInitFxn:ACP_main_cus()");
171     ACP_main_cus();
173 #ifdef RAM_REPORT // patch RAM report functions
174     PAF_ASIT_params_fxns.headerPrint = PAF_ALG_headerPrint;
175     PAF_ASIT_params_fxns.allocPrint = PAF_ALG_allocPrint;
176     PAF_ASIT_params_fxns.commonPrint = PAF_ALG_commonPrint;
177     PAF_ASIT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
178     PAF_ASIT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
179     PAF_ASOT_params_fxns.headerPrint = PAF_ALG_headerPrint;
180     PAF_ASOT_params_fxns.allocPrint = PAF_ALG_allocPrint;
181     PAF_ASOT_params_fxns.commonPrint = PAF_ALG_commonPrint;
182     PAF_ASOT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
183     PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
184 #endif
186     // FL: debug
187     pinMuxSetMode(101,PADCONFIG_MUX_MODE_QUATERNARY); // PAD101 to QUATERNARY, GPIO (B8 on AudioDaughterCard J12)
188     GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_99, GPIO_OUT); // GPIO0,pin99 output
189     GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
190     GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
192     /* This is required to use SYS alpha codes in atboot? */
193     Log_info0("taskSysInitFxn:TaskSystemStream resume");
194     gSysInit = 0;
195     Task_setPri(TaskSystemStream, TASK_SSP_PRI);
196     // Wait until Execution of TaskSystemStream is complete
197     // once.
198     while (gSysInit == 0)  // gSysInit is set to 1 in TaskSystemStream
199     {
200         Task_sleep(SYS_INIT_SLEEP);
201     }
204     Task_setPri(TaskAfp, TASK_AFP_PRI);
205     Task_setPri(TaskAip, TASK_AIP_PRI);
206     Task_setPri(TaskAsip, TASK_ASIP_PRI);
207     Task_setPri(TaskAsop, TASK_ASOP_PRI);
209     Log_info0("Exit taskSysInitFxn()");