2 /*
3 Copyright (c) 2018, 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 "params.h"
49 #include "pafhjt.h"
50 #include "paf_heapMgr.h"
51 #include "ipc_common.h"
52 #include "aspMsg_common.h"
53 #include "aspMsg_slave.h"
54 #include "aspDecOpCircBuf_slave.h"
55 #include "audioStreamProc_common.h"
56 #include "audioStreamDecodeProc.h"
58 const PAFHJT_t *pafhjt;
60 #define RAM_REPORT
61 #ifdef RAM_REPORT
62 #include <audioStreamProc_params.h>
63 #include <paf_alg_print.h>
64 extern PAF_ASDT_Fxns PAF_ASDT_params_fxns;
65 #endif
67 #define TASK_ASDP_PRI ( 3 )
69 #define __TASK_NAME__ "TaskSysInit"
71 /*
72 * ======== taskSysInitFxn ========
73 * System Initializations task function
74 */
75 Void taskSysInitFxn(Void)
76 {
77 UInt16 remoteProcId;
78 Int status;
79 UInt16 regionId;
80 IHeap_Handle srHeapNonCacheDdr3;
83 Log_info0("Enter taskSysInitFxn()");
85 /* Attach IPC */
86 Log_info0("taskSysInitFxn:Ipc_attach()");
87 remoteProcId = MultiProc_getId(IPC_MASTER_NAME);
88 if (remoteProcId == MultiProc_INVALIDID) {
89 System_abort("Improper MultiProc ID\n");
90 }
91 do {
92 status = Ipc_attach(remoteProcId);
93 //} while ((status < 0) && (status == Ipc_E_NOTREADY));
94 } while (status != Ipc_S_SUCCESS);
96 /* Initialize (IPC) ASP slave messaging */
97 Log_info0("taskSysInitFxn:AspMsgSlave_init()");
98 status = AspMsgSlave_init(
99 hAspMsgSlave,
100 remoteProcId);
101 if (status < 0)
102 {
103 Log_info1("%s: Unable to initialize ASP messaging. Exiting.", (IArg)__TASK_NAME__);
104 return;
105 }
107 /* Initialize decoder output circular buffer control */
108 Log_info0("taskSysInitFxn:cbCtlInit()");
109 status = cbCtlInit(&gPAF_ASDT_config.decOpCircBufCtl, asdp_params.zone.decodeN, &gPAF_AST_config.xDecOpCb);
110 if (status < 0)
111 {
112 Log_info1("%s: unable to initialize Decoder Output Circular Buffer Control. Exiting.", (IArg)__TASK_NAME__);
113 return;
114 }
115 /* Initialize Output Processing Init-Sync control */
116 Log_info0("taskSysInitFxn:outIsCtlInit()");
117 status = outIsCtlInit(&gPAF_ASDT_config.outIsCtl, &gPAF_AST_config.xOutIsi);
118 if (status < 0)
119 {
120 Log_info1("%s: unable to initialize Output Init-Sync Control. Exiting.", (IArg)__TASK_NAME__);
121 return;
122 }
124 regionId = SharedRegion_getIdByName("COMMON2_DDR3");
125 srHeapNonCacheDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
126 /* Initialize PAF heap manager */
127 Log_info0("taskSysInitFxn:pafHeapMgr_init()");
128 pafHeapMgr_init((IHeap_Handle)heapMemL2Sram,
129 (IHeap_Handle)heapMemMsmcSram,
130 (IHeap_Handle)heapMemDdr3,
131 NULL,
132 NULL,
133 srHeapNonCacheDdr3);
135 /* Initialize HJT */
136 pafhjt = &PAFHJT_RAM;
138 #ifdef RAM_REPORT
139 PAF_ASDT_params_fxns.headerPrint = PAF_ALG_headerPrint;
140 PAF_ASDT_params_fxns.allocPrint = PAF_ALG_allocPrint;
141 PAF_ASDT_params_fxns.commonPrint = PAF_ALG_commonPrint;
142 PAF_ASDT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
143 PAF_ASDT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
144 #endif
146 Task_setPri(TaskAsdp, TASK_ASDP_PRI);
148 Log_info0("Exit taskSysInitFxn()");
149 }