]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_dsp/framework/systemInit.c
b8d82156136c87a972d995d305275fd5adae776f
[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        ( 3 )//( 1 )  // (***) FL: temporary fix for PASDK-64
76 #define TASK_AIP_PRI        ( 1 )//( 2 ) 
77 #define TASK_SSP_PRI        ( 1 )
78 #define TASK_ASIP_PRI       ( 2 )//( 3 ) 
79 #define TASK_ASOP_PRI       ( 2 )//( 3 ) 
81 #define __TASK_NAME__  "TaskSysInit"
83 #define SYS_INIT_SLEEP  100
85 /*
86  *  ======== taskSysInitFxn ========
87  *  System Initializations task function
88  */
89 Void taskSysInitFxn(Void)
90 {
91     UInt16  regionId;
92     IHeap_Handle srHeapMsmc, srHeapDdr3, srHeapNonCacheDdr3;
93     UInt16 remoteProcId;    
94     Int status;
97     Log_info0("Enter taskSysInitFxn()");
99     //taskPriAfp = Task_setPri(TaskAfp, -1);
100     //taskPriAip = Task_setPri(TaskAip, -1);
101     //taskPriAsip = Task_setPri(TaskAsip, -1);
103     /* Attach IPC */
104     Log_info0("taskSysInitFxn:Ipc_attach()");
105     remoteProcId = MultiProc_getId(SLAVE_NAME);
106     if (remoteProcId == MultiProc_INVALIDID) {
107         System_abort("Improper MultiProc ID\n");
108     }
109     do {
110         status = Ipc_attach(remoteProcId);
111     //} while ((status < 0) && (status == Ipc_E_NOTREADY));
112     } while (status != Ipc_S_SUCCESS);
114     // Create Shared DDR region as non-Cacheable
115     // TODO: remove hardcoded address and get correct values from .bld
116     {   // base: 0x81000000, len: 0x01000000,
117         UInt Common2_DDR3_MAR_base = 0x01848204;
118         UInt Common2_DDR3_base = 0x81000000;
119         UInt Common2_DDR3_len = 0x01000000;
120         // disable cache for common2 DDR3
121         Cache_setMar(Common2_DDR3_base, Common2_DDR3_len, Cache_Mar_DISABLE);
122     }
124     /* Initialize (IPC) ASP master messaging */
125     /* Note: MessageQ_open() called in this function.
126              MessageQ_open() blocks. */
127     Log_info0("taskSysInitFxn:AspMsgMaster_init()");
128     status = AspMsgMaster_init(
129         hAspMsgMaster, 
130         remoteProcId, 
131         ASP_MSG_MASTER_DEF_NUMMSGS);
132     if (status < 0)
133     {
134         Log_info0("TaskSysInit: unable to initialize ASP messaging. Exiting.");
135         return;
136     }
137     
138     /* Initialize decoder output circular buffer control */
139     Log_info0("taskSysInitFxn:cbCtlInit()");
140     status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, &gPAF_AST_config.xDecOpCb);
141     if (status < 0)
142     {
143         Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting.");
144         return;
145     }
147     /* Initialize PAF heap manager */
148     Log_info0("taskSysInitFxn:pafHeapMgr_init()");
149     regionId = SharedRegion_getIdByName("SR_MSMC");
150     srHeapMsmc = (IHeap_Handle)SharedRegion_getHeap(regionId);
151     regionId = SharedRegion_getIdByName("SR_DDR3");
152     srHeapDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
153     regionId = SharedRegion_getIdByName("COMMON2_DDR3");
154     srHeapNonCacheDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
155     pafHeapMgr_init((IHeap_Handle)heapMemL2Sram, 
156         (IHeap_Handle)heapMemMsmcSram, 
157         (IHeap_Handle)heapMemDdr3, 
158         srHeapMsmc, 
159         srHeapDdr3,
160         srHeapNonCacheDdr3);
161     
162     /* Initialize HJT */
163     pafhjt = &PAFHJT_RAM;
164     
165     /* Patch sigma tables */
166     Log_info0("taskSysInitFxn:ACP_main_cus()");
167     ACP_main_cus();
169 #ifdef RAM_REPORT // patch RAM report functions
170     PAF_ASIT_params_fxns.headerPrint = PAF_ALG_headerPrint;
171     PAF_ASIT_params_fxns.allocPrint = PAF_ALG_allocPrint;
172     PAF_ASIT_params_fxns.commonPrint = PAF_ALG_commonPrint;
173     PAF_ASIT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
174     PAF_ASIT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
175     PAF_ASOT_params_fxns.headerPrint = PAF_ALG_headerPrint;
176     PAF_ASOT_params_fxns.allocPrint = PAF_ALG_allocPrint;
177     PAF_ASOT_params_fxns.commonPrint = PAF_ALG_commonPrint;
178     PAF_ASOT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
179     PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
180 #endif
183     /* This is required to use SYS alpha codes in atboot? */
184     Log_info0("taskSysInitFxn:TaskSystemStream resume");
185     gSysInit = 0;
186     Task_setPri(TaskSystemStream, TASK_SSP_PRI);
187     // Wait until Execution of TaskSystemStream is complete
188     // once.
189     while (gSysInit == 0)  // gSysInit is set to 1 in TaskSystemStream
190     {
191         Task_sleep(SYS_INIT_SLEEP);
192     }
195     Task_setPri(TaskAfp, TASK_AFP_PRI);
196     Task_setPri(TaskAip, TASK_AIP_PRI);
197     Task_setPri(TaskAsip, TASK_ASIP_PRI);
198     Task_setPri(TaskAsop, TASK_ASOP_PRI);
200     Log_info0("Exit taskSysInitFxn()");