943c306b1e460d1de187a5f3620a3c6ed22fcfc6
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 idleAudioStream(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_ASIP_PRI ( 2 )//( 3 )
78 #define TASK_ASOP_PRI ( 2 )//( 3 )
80 #define __TASK_NAME__ "TaskSysInit"
82 /*
83 * ======== taskSysInitFxn ========
84 * System Initializations task function
85 */
86 Void taskSysInitFxn(Void)
87 {
88 UInt16 regionId;
89 IHeap_Handle srHeapMsmc, srHeapDdr3, srHeapNonCacheDdr3;
90 UInt16 remoteProcId;
91 Int status;
94 Log_info0("Enter taskSysInitFxn()");
96 //taskPriAfp = Task_setPri(TaskAfp, -1);
97 //taskPriAip = Task_setPri(TaskAip, -1);
98 //taskPriAsip = Task_setPri(TaskAsip, -1);
100 /* Attach IPC */
101 Log_info0("taskSysInitFxn:Ipc_attach()");
102 remoteProcId = MultiProc_getId(SLAVE_NAME);
103 if (remoteProcId == MultiProc_INVALIDID) {
104 System_abort("Improper MultiProc ID\n");
105 }
106 do {
107 status = Ipc_attach(remoteProcId);
108 //} while ((status < 0) && (status == Ipc_E_NOTREADY));
109 } while (status != Ipc_S_SUCCESS);
111 // Create Shared DDR region as non-Cacheable
112 // TODO: remove hardcoded address and get correct values from .bld
113 { // base: 0x81000000, len: 0x01000000,
114 UInt Common2_DDR3_MAR_base = 0x01848204;
115 UInt Common2_DDR3_base = 0x81000000;
116 UInt Common2_DDR3_len = 0x01000000;
117 // disable cache for common2 DDR3
118 Cache_setMar(Common2_DDR3_base, Common2_DDR3_len, Cache_Mar_DISABLE);
119 }
121 /* Initialize (IPC) ASP master messaging */
122 /* Note: MessageQ_open() called in this function.
123 MessageQ_open() blocks. */
124 Log_info0("taskSysInitFxn:AspMsgMaster_init()");
125 status = AspMsgMaster_init(
126 hAspMsgMaster,
127 remoteProcId,
128 ASP_MSG_MASTER_DEF_NUMMSGS);
129 if (status < 0)
130 {
131 Log_info0("TaskSysInit: unable to initialize ASP messaging. Exiting.");
132 return;
133 }
135 /* Initialize decoder output circular buffer control */
136 Log_info0("taskSysInitFxn:cbCtlInit()");
137 status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, &gPAF_AST_config.xDecOpCb);
138 if (status < 0)
139 {
140 Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting.");
141 return;
142 }
144 /* Initialize PAF heap manager */
145 Log_info0("taskSysInitFxn:pafHeapMgr_init()");
146 regionId = SharedRegion_getIdByName("SR_MSMC");
147 srHeapMsmc = (IHeap_Handle)SharedRegion_getHeap(regionId);
148 regionId = SharedRegion_getIdByName("SR_DDR3");
149 srHeapDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
150 regionId = SharedRegion_getIdByName("COMMON2_DDR3");
151 srHeapNonCacheDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
152 pafHeapMgr_init((IHeap_Handle)heapMemL2Sram,
153 (IHeap_Handle)heapMemMsmcSram,
154 (IHeap_Handle)heapMemDdr3,
155 srHeapMsmc,
156 srHeapDdr3,
157 srHeapNonCacheDdr3);
159 /* Initialize HJT */
160 pafhjt = &PAFHJT_RAM;
162 /* Patch sigma tables */
163 Log_info0("taskSysInitFxn:ACP_main_cus()");
164 ACP_main_cus();
166 #ifdef RAM_REPORT // patch RAM report functions
167 PAF_ASIT_params_fxns.headerPrint = PAF_ALG_headerPrint;
168 PAF_ASIT_params_fxns.allocPrint = PAF_ALG_allocPrint;
169 PAF_ASIT_params_fxns.commonPrint = PAF_ALG_commonPrint;
170 PAF_ASIT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
171 PAF_ASIT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
172 PAF_ASOT_params_fxns.headerPrint = PAF_ALG_headerPrint;
173 PAF_ASOT_params_fxns.allocPrint = PAF_ALG_allocPrint;
174 PAF_ASOT_params_fxns.commonPrint = PAF_ALG_commonPrint;
175 PAF_ASOT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
176 PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
177 #endif
179 gSysInit=1;
181 /* This is required to use SYS alpha codes in atboot? */
182 Log_info0("taskSysInitFxn:idleAudioStream()");
183 idleAudioStream();
185 // Circumvent MessageQ_open() blocking.
186 Task_setPri(TaskAfp, TASK_AFP_PRI);
187 Task_setPri(TaskAip, TASK_AIP_PRI);
188 Task_setPri(TaskAsip, TASK_ASIP_PRI);
189 Task_setPri(TaskAsop, TASK_ASOP_PRI);
191 Log_info0("Exit taskSysInitFxn()");
192 }