9ef88a8f9b23b48304dc5bb2e10b469e0637571b
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 * ======== main.c ========
38 */
40 #include <xdc/std.h>
41 #include <xdc/cfg/global.h>
42 #include <xdc/runtime/Log.h>
43 #include <xdc/runtime/System.h>
44 #include <ti/sysbios/BIOS.h>
45 #include <ti/ipc/Ipc.h>
47 #include "components/clk.h" /* PFP testing */
48 #include "pfp/pfp.h"
49 #include "pfp_app.h" /* contains all PFP ID's */
51 //
52 // FL: Temporary code for ARM image size reduction
53 //
54 #include <string.h>
55 #include <ti/sysbios/hal/Cache.h>
56 #include <ti/sysbios/heaps/HeapMem.h>
57 // Number of control bytes used in heap buffer after heap initialized by SYSBIOS before main()
58 #define HEAP_CONTROL_SZ ( 8 )
60 extern void BOARD_initPerfCounters();
61 extern uint32_t readTime32(void);
63 /*
64 * ======== main ========
65 */
66 Int main()
67 {
68 Int status;
69 Int k;
70 //UInt32 tsStart, tsEnd, delta; // debug: check ARM SYS/BIOS timestamp provider
71 HeapMem_ExtendedStats heapmem_stats;
72 Ptr buf;
73 SizeT size;
75 Log_info0("Enter main()");
77 // FL: Temporary code for ARM image size reduction
78 // Clear ARM dedicated heap buffers
79 // If heaps aren't cleared:
80 // 1) DSP:ASIT: IPC state is corrupted because of incorrect memory segments for PCM2, DDP2 & THD2 beta table entries.
81 // 2) DSP:ASIT: DSP hangs in GateMP_open() inside first call to statusOp_Init().
82 HeapMem_getExtendedStats(heapMemMsmcSram, &heapmem_stats);
83 buf = (Ptr)heapmem_stats.buf+HEAP_CONTROL_SZ;
84 size = (SizeT)heapmem_stats.size-HEAP_CONTROL_SZ;
85 memset(buf, 0, size);
86 Cache_wb(buf, size, Cache_Type_ALLD, 0);
87 Cache_wait();
88 HeapMem_getExtendedStats(heapMemDdr3, &heapmem_stats);
89 buf = (Ptr)heapmem_stats.buf+HEAP_CONTROL_SZ;
90 size = (SizeT)heapmem_stats.size-HEAP_CONTROL_SZ;
91 memset(buf, 0, size);
92 Cache_wb(buf, size, Cache_Type_ALLD, 0);
93 Cache_wait();
95 #if 0 // debug: check ARM SYS/BIOS timestamp provider
96 BOARD_initPerfCounters();
97 #endif
99 /* Setup Profile Points (PFP) */
100 Log_info0("enter PFP Setup");
101 pfpCreate();
102 pfpCalibrate(1000, 1);
103 for (k = 0; k <= PFP_ID_LAST; k++)
104 {
105 pfpEnable(k); /* Enable profile point #k */
106 }
107 for (k = 1; k <= PFP_ID_LAST; k++)
108 {
109 pfpSetAlpha(k, PFP_DEF_ALPHA); /* Set default exp. avg. time const. */
110 }
111 #if 0 // debug: dummy load
112 for (k = 0; k < 1000; k++)
113 {
114 tsStart=readTime32();
115 pfpBegin(PFP_ID_MAIN,0);
116 clkWorkDelay(CLK_WORKCNT_PER_MS); /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
117 pfpEnd(PFP_ID_MAIN,0);
118 tsEnd=readTime32();
119 }
120 delta = tsEnd-tsStart;
121 #endif
123 // Initialize IPC
124 status = Ipc_start();
125 if (status < 0)
126 {
127 System_abort("Ipc_start failed\n");
128 }
130 BIOS_start(); /* does not return */
131 return(0);
132 }