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>
48 #include "pafhjt.h"
49 #include "paf_heapMgr.h"
50 #include "aspMsg_common.h"
51 #include "aspMsg_master.h"
52 #include "aspDecOpCircBuf_master.h"
53 #include "audioStreamProc_master.h" // ASIT/ASOT config
54 #include "audioStreamProc_common.h" // ASIT/ASOT/ASDT config
55 #include "audioStreamInpProc.h"
56 #include "audioStreamOutProc.h"
57 #include "fwkSim.h"
59 extern Void ACP_main_cus(Void); // (*** ?) FL: revisit -- check method of patching alpha codes
60 extern Void idleAudioStream(Void); // (*** ?) FL: revisit -- shouldn't need to call this from system init
62 const PAFHJT_t *pafhjt;
64 #define RAM_REPORT
65 #ifdef RAM_REPORT
66 #include <audioStreamProc_params.h>
67 #include <paf_alg_print.h>
68 extern PAF_ASIT_Fxns PAF_ASIT_params_fxns;
69 extern PAF_ASOT_Fxns PAF_ASOT_params_fxns;
70 #endif
72 Int gSysInit=0;
74 #define TASK_AFP_PRI ( 1 )
75 #define TASK_AIP_PRI ( 2 )
76 #define TASK_ASIP_PRI ( 3 )
77 #define TASK_ASOP_PRI ( 3 )
79 #define __TASK_NAME__ "TaskSysInit"
81 /*
82 * ======== taskSysInitFxn ========
83 * System Initializations task function
84 */
85 Void taskSysInitFxn(Void)
86 {
87 UInt16 regionId;
88 IHeap_Handle srHeapMsmc, srHeapDdr3;
89 UInt16 remoteProcId;
90 Int status;
93 Log_info0("Enter taskSysInitFxn()");
95 //taskPriAfp = Task_setPri(TaskAfp, -1);
96 //taskPriAip = Task_setPri(TaskAip, -1);
97 //taskPriAsip = Task_setPri(TaskAsip, -1);
99 /* Attach IPC */
100 Log_info0("taskSysInitFxn:Ipc_attach()");
101 remoteProcId = MultiProc_getId(SLAVE_NAME);
102 if (remoteProcId == MultiProc_INVALIDID) {
103 System_abort("Improper MultiProc ID\n");
104 }
105 do {
106 status = Ipc_attach(remoteProcId);
107 //} while ((status < 0) && (status == Ipc_E_NOTREADY));
108 } while (status != Ipc_S_SUCCESS);
110 /* Initialize (IPC) ASP master messaging */
111 /* Note: MessageQ_open() called in this function.
112 MessageQ_open() blocks. */
113 Log_info0("taskSysInitFxn:AspMsgMaster_init()");
114 status = AspMsgMaster_init(
115 hAspMsgMaster,
116 remoteProcId,
117 ASP_MSG_MASTER_DEF_NUMMSGS);
118 if (status < 0)
119 {
120 Log_info0("TaskSysInit: unable to initialize ASP messaging. Exiting.");
121 return;
122 }
124 /* Initialize decoder output circular buffer control */
125 Log_info0("taskSysInitFxn:cbCtlInit()");
126 status = cbCtlInit(&gPAF_ASPM_config.decOpCircBufCtl, &gPAF_AST_config.xDecOpCb);
127 if (status < 0)
128 {
129 Log_info0("TaskSysInit: unable to initialize Decoder Output Circular Buffer Control. Exiting.");
130 return;
131 }
133 /* Initialize PAF heap manager */
134 Log_info0("taskSysInitFxn:pafHeapMgr_init()");
135 regionId = SharedRegion_getIdByName("SR_MSMC");
136 srHeapMsmc = (IHeap_Handle)SharedRegion_getHeap(regionId);
137 regionId = SharedRegion_getIdByName("SR_DDR3");
138 srHeapDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
139 pafHeapMgr_init((IHeap_Handle)heapMemL2Sram,
140 (IHeap_Handle)heapMemMsmcSram,
141 (IHeap_Handle)heapMemDdr3,
142 srHeapMsmc,
143 srHeapDdr3);
145 /* Initialize HJT */
146 pafhjt = &PAFHJT_RAM;
148 /* Patch sigma tables */
149 Log_info0("taskSysInitFxn:ACP_main_cus()");
150 ACP_main_cus();
152 #ifdef RAM_REPORT // patch RAM report functions
153 PAF_ASIT_params_fxns.headerPrint = PAF_ALG_headerPrint;
154 PAF_ASIT_params_fxns.allocPrint = PAF_ALG_allocPrint;
155 PAF_ASIT_params_fxns.commonPrint = PAF_ALG_commonPrint;
156 PAF_ASIT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
157 PAF_ASIT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
158 PAF_ASOT_params_fxns.headerPrint = PAF_ALG_headerPrint;
159 PAF_ASOT_params_fxns.allocPrint = PAF_ALG_allocPrint;
160 PAF_ASOT_params_fxns.commonPrint = PAF_ALG_commonPrint;
161 PAF_ASOT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
162 PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
163 #endif
165 gSysInit=1;
167 /* This is required to use SYS alpha codes in atboot? */
168 Log_info0("taskSysInitFxn:idleAudioStream()");
169 idleAudioStream();
171 // Circumvent MessageQ_open() blocking.
172 Task_setPri(TaskAfp, TASK_AFP_PRI);
173 Task_setPri(TaskAip, TASK_AIP_PRI);
174 Task_setPri(TaskAsip, TASK_ASIP_PRI);
175 Task_setPri(TaskAsop, TASK_ASOP_PRI);
177 Log_info0("Exit taskSysInitFxn()");
178 }