[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / 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>
48 #include "pafhjt.h"
49 #include "paf_heapMgr.h"
50 #include "aspMsg_common.h"
51 #include "aspMsg_master.h"
52 #include "fwkSim.h"
54 extern Void ACP_main_cus(Void); // (*** ?) FL: revisit -- check method of patching alpha codes
55 extern Void idleAudioStream(Void); // (*** ?) FL: revisit -- shouldn't need to call this from system init
57 const PAFHJT_t *pafhjt;
59 #define RAM_REPORT
60 #ifdef RAM_REPORT
61 #include <audioStreamProc_params.h>
62 #include <paf_alg_print.h>
63 extern PAF_AST_Fxns PAF_ASIT_params_fxns;
64 extern PAF_AST_Fxns PAF_ASOT_params_fxns;
65 #endif
67 Int gSysInit=0;
69 #define TASK_AFP_PRI ( 1 )
70 #define TASK_AIP_PRI ( 2 )
71 #define TASK_ASIP_PRI ( 3 )
72 #define TASK_ASOP_PRI ( 3 )
74 #define __TASK_NAME__ "TaskSysInit"
76 /*
77 * ======== taskSysInitFxn ========
78 * System Initializations task function
79 */
80 Void taskSysInitFxn(Void)
81 {
82 UInt16 regionId;
83 IHeap_Handle srHeapMsmc, srHeapDdr3;
84 UInt16 remoteProcId;
85 Int status;
88 Log_info0("Enter taskSysInitFxn()");
90 //taskPriAfp = Task_setPri(TaskAfp, -1);
91 //taskPriAip = Task_setPri(TaskAip, -1);
92 //taskPriAsip = Task_setPri(TaskAsip, -1);
94 /* Attach IPC */
95 Log_info0("taskSysInitFxn:Ipc_attach()");
96 remoteProcId = MultiProc_getId(SLAVE_NAME);
97 if (remoteProcId == MultiProc_INVALIDID) {
98 System_abort("Improper MultiProc ID\n");
99 }
100 do {
101 status = Ipc_attach(remoteProcId);
102 //} while ((status < 0) && (status == Ipc_E_NOTREADY));
103 } while (status != Ipc_S_SUCCESS);
105 /* Initialize (IPC) ASP master messaging */
106 /* Note: MessageQ_open() called in this function.
107 MessageQ_open() blocks. */
108 Log_info0("taskSysInitFxn:AspMsgMaster_init()");
109 status = AspMsgMaster_init(
110 hAspMsgMaster,
111 remoteProcId,
112 ASP_MSG_MASTER_DEF_NUMMSGS);
113 if (status < 0)
114 {
115 Log_info0("TaskSysInit: unable to initialize ASP messaging. Exiting.");
116 return;
117 }
119 /* Initialize PAF heap manager */
120 Log_info0("taskSysInitFxn:pafHeapMgr_init()");
121 regionId = SharedRegion_getIdByName("SR_MSMC");
122 srHeapMsmc = (IHeap_Handle)SharedRegion_getHeap(regionId);
123 regionId = SharedRegion_getIdByName("SR_DDR3");
124 srHeapDdr3 = (IHeap_Handle)SharedRegion_getHeap(regionId);
125 pafHeapMgr_init((IHeap_Handle)heapMemL2Sram,
126 (IHeap_Handle)heapMemMsmcSram,
127 (IHeap_Handle)heapMemDdr3,
128 srHeapMsmc,
129 srHeapDdr3);
131 /* Initialize HJT */
132 pafhjt = &PAFHJT_RAM;
134 /* Patch sigma tables */
135 Log_info0("taskSysInitFxn:ACP_main_cus()");
136 ACP_main_cus();
138 #ifdef RAM_REPORT // patch RAM report functions
139 PAF_ASIT_params_fxns.headerPrint = PAF_ALG_headerPrint;
140 PAF_ASIT_params_fxns.allocPrint = PAF_ALG_allocPrint;
141 PAF_ASIT_params_fxns.commonPrint = PAF_ALG_commonPrint;
142 PAF_ASIT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
143 PAF_ASIT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
144 PAF_ASOT_params_fxns.headerPrint = PAF_ALG_headerPrint;
145 PAF_ASOT_params_fxns.allocPrint = PAF_ALG_allocPrint;
146 PAF_ASOT_params_fxns.commonPrint = PAF_ALG_commonPrint;
147 PAF_ASOT_params_fxns.bufMemPrint = PAF_ALG_bufMemPrint;
148 PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
149 #endif
151 gSysInit=1;
153 /* This is required to use SYS alpha codes in atboot? */
154 Log_info0("taskSysInitFxn:idleAudioStream()");
155 idleAudioStream();
157 // Circumvent MessageQ_open() blocking.
158 Task_setPri(TaskAfp, TASK_AFP_PRI);
159 Task_setPri(TaskAip, TASK_AIP_PRI);
160 Task_setPri(TaskAsip, TASK_ASIP_PRI);
161 Task_setPri(TaskAsop, TASK_ASOP_PRI);
163 Log_info0("Exit taskSysInitFxn()");
164 }