6d4efe0347ccfc8c76ae4a062bf88fe3a5c25d6c
1 /*
2 * Copyright (c) 2017 Texas Instruments Incorporated - http://www.ti.com
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 distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== Main[object Object].c ========
35 */
37 /* xdctools header files */
38 #include <xdc/std.h>
39 #include <xdc/runtime/Diags.h>
40 #include <xdc/runtime/Error.h>
41 #include <xdc/runtime/Log.h>
42 #include <xdc/runtime/System.h>
44 /* package header files */
45 #include <ti/ipc/Ipc.h>
46 #include <ti/ipc/MultiProc.h>
48 #include <ti/sysbios/BIOS.h>
49 #include <ti/sysbios/knl/Task.h>
51 /* Board and UART header files */
52 #include "ti/board/board.h"
53 #include <ti/drv/uart/UART_stdio.h>
55 /* local header files */
56 #include "App.h"
58 /* private functions */
59 Void App_taskFxn(UArg arg0, UArg arg1);
61 #define HOST_UART_PRINT
62 #ifdef HOST_UART_PRINT
63 #define host_printf(X) UART_printf(X)
64 #else
65 #define host_printf(X)
66 #endif
68 /*
69 * ======== main ========
70 */
71 int main(int argc, char* argv[])
72 {
73 Error_Block eb;
74 Task_Params taskParams;
76 Log_print0(Diags_ENTRY, "main: -->");
78 /* create main thread (interrupts not enabled in main on BIOS) */
79 Task_Params_init(&taskParams);
80 taskParams.instance->name = "App_taskFxn";
81 taskParams.arg0 = (UArg)argc;
82 taskParams.arg1 = (UArg)argv;
83 taskParams.stackSize = 0x1000;
84 Error_init(&eb);
86 Task_create(App_taskFxn, &taskParams, &eb);
88 if (Error_check(&eb)) {
89 System_abort("main: failed to create application startup thread");
90 }
92 /* start scheduler, this never returns */
93 BIOS_start();
95 /* should never get here */
96 Log_print0(Diags_EXIT, "main: <--");
97 return (0);
98 }
100 /*
101 * ======== App_taskFxn ========
102 */
103 Void App_taskFxn(UArg arg0, UArg arg1)
104 {
105 Int status;
106 UInt16 remoteProcId;
107 #ifdef HOST_UART_PRINT
108 Board_STATUS boardStatus;
109 Board_initCfg boardCfg;
111 boardCfg = BOARD_INIT_UNLOCK_MMR
112 | BOARD_INIT_UART_STDIO
113 | BOARD_INIT_MODULE_CLOCK
114 #if ((!defined(PLATFORM_66AK2E)) && (!defined(PLATFORM_C6678)))
115 | BOARD_INIT_PINMUX_CONFIG
116 #endif
117 ;
118 boardStatus = Board_init(boardCfg);
119 if (boardStatus < 0) {
120 status = -1;
121 goto leave;
122 }
123 #endif
124 Log_print0(Diags_INFO, "App_taskFxn: -->");
126 /*
127 * initialize the ipc layer
128 */
129 status = Ipc_start();
131 if (status < 0) {
132 System_abort("Ipc_start failed\n");
133 }
135 remoteProcId = MultiProc_getId(SERVER);
136 if (remoteProcId == MultiProc_INVALIDID) {
137 System_abort("Improper MultiProc ID\n");
138 }
139 do {
140 status = Ipc_attach(remoteProcId);
142 } while ((status < 0) && (status == Ipc_E_NOTREADY));
144 Log_print0(Diags_INFO, "App_taskFxn: ipc ready");
146 /* application create phase */
147 status = App_create(remoteProcId);
149 if (status < 0) {
150 goto leave;
151 }
153 /* application execute phase */
154 status = App_exec();
156 if (status < 0) {
157 goto leave;
158 }
160 /* application delete phase */
161 status = App_delete();
163 if (status < 0) {
164 goto leave;
165 }
167 leave:
168 Log_print1(Diags_INFO, "App_taskFxn: <-- status=%d", (IArg)status);
170 #ifdef HOST_UART_PRINT
171 if (status < 0)
172 host_printf("\n Host: Test Failed \n");
173 else
174 host_printf("\n Host: Test Passed \n");
175 #endif
176 return;
177 }