1 /*
2 * Copyright (c) Texas Instruments Incorporated 2019
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
34 /**
35 * \file main_tirtos.c
36 *
37 * \brief Main file for TI-RTOS build
38 */
40 /* ========================================================================== */
41 /* Include Files */
42 /* ========================================================================== */
44 #include <stdio.h>
45 #include <stdint.h>
47 /* XDCtools Header files */
48 #include <xdc/std.h>
49 #include <xdc/runtime/Error.h>
50 #include <xdc/runtime/System.h>
51 /* BIOS Header files */
52 #include <ti/sysbios/BIOS.h>
53 #include <ti/sysbios/knl/Task.h>
55 #include <ti/csl/soc.h>
56 #include <ti/board/board.h>
57 #include <ti/drv/sciclient/sciclient.h>
59 #include "ipc_apputils.h"
61 #if (defined (BUILD_MCU1_0) && (defined (SOC_J721E) || defined (SOC_J7200)))
62 #include <ti/drv/sciclient/sciserver_tirtos.h>
63 #endif
65 /* ========================================================================== */
66 /* Macros & Typedefs */
67 /* ========================================================================== */
69 /* Test application stack size */
70 #define APP_TSK_STACK_MAIN (16U * 1024U)
71 /* Priority for IPC task */
72 #define IPC_SETUP_TASK_PRI (3)
73 /* High Priority for SCI Server */
74 #define IPC_SETUP_SCISERVER_TASK_PRI_HIGH (IPC_SETUP_TASK_PRI + 1)
75 /* Low Priority for SCI Server */
76 #define IPC_SETUP_SCISERVER_TASK_PRI_LOW (1)
78 /* ========================================================================== */
79 /* Structure Declarations */
80 /* ========================================================================== */
82 /* None */
84 /* ========================================================================== */
85 /* Function Declarations */
86 /* ========================================================================== */
88 static Void taskFxn(UArg a0, UArg a1);
89 extern int32_t Ipc_perf_test(void);
90 /* Initialize SCI Server, to process RM/PM Requests by other cores */
91 void Ipc_setupSciServer(void);
93 /* ========================================================================== */
94 /* Global Variables */
95 /* ========================================================================== */
97 /* Test application stack */
98 static uint8_t gAppTskStackMain[APP_TSK_STACK_MAIN]
99 __attribute__ ((aligned(8192)));
101 /* ========================================================================== */
102 /* Function Definitions */
103 /* ========================================================================== */
106 void ipc_initSciclient()
107 {
108 Sciclient_ConfigPrms_t config;
110 /* Now reinitialize it as default parameter */
111 Sciclient_configPrmsInit(&config);
113 Sciclient_init(&config);
115 }
117 int main(void)
118 {
119 Task_Handle task;
120 Error_Block eb;
121 Task_Params taskParams;
122 Board_initCfg boardCfg;
124 /* Initialize SCI Client Server */
125 Ipc_setupSciServer();
127 /* It must be called before BoardInit() */
128 ipc_initSciclient();
130 boardCfg = BOARD_INIT_PINMUX_CONFIG |
131 BOARD_INIT_UART_STDIO;
132 Board_init(boardCfg);
134 Error_init(&eb);
136 /* Initialize the task params */
137 Task_Params_init(&taskParams);
139 /* Set the task priority higher than the default priority (1) */
140 taskParams.priority = IPC_SETUP_TASK_PRI;
141 taskParams.stack = gAppTskStackMain;
142 taskParams.stackSize = sizeof (gAppTskStackMain);
144 task = Task_create(taskFxn, &taskParams, &eb);
145 if(NULL == task)
146 {
147 BIOS_exit(0);
148 }
149 BIOS_start(); /* does not return */
151 return(0);
152 }
154 static Void taskFxn(UArg a0, UArg a1)
155 {
156 Ipc_perf_test();
157 return;
158 }
160 #if defined(BUILD_MPU) || defined (__C7100__)
161 extern void Osal_initMmuDefault(void);
162 void InitMmu(void)
163 {
164 Osal_initMmuDefault();
165 }
166 #endif
168 void Ipc_setupSciServer(void)
169 {
171 #if (defined (BUILD_MCU1_0) && (defined (SOC_J721E) || defined (SOC_J7200)))
172 Sciserver_TirtosCfgPrms_t appPrms;
173 int32_t ret = CSL_PASS;
175 ret = Sciserver_tirtosInitPrms_Init(&appPrms);
177 appPrms.taskPriority[SCISERVER_TASK_USER_LO] =
178 IPC_SETUP_SCISERVER_TASK_PRI_LOW;
179 appPrms.taskPriority[SCISERVER_TASK_USER_HI] =
180 IPC_SETUP_SCISERVER_TASK_PRI_HIGH;
182 if (ret == CSL_PASS)
183 {
184 ret = Sciserver_tirtosInit(&appPrms);
185 }
187 if (ret == CSL_PASS)
188 {
189 System_printf("Starting Sciserver..... PASSED\n");
190 }
191 else
192 {
193 System_printf("Starting Sciserver..... FAILED\n");
194 }
196 #endif
197 return;
198 }