]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/test_arm/application/main.c
PASDK-432:Increase ARM open loop delay for HS boot.
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / application / main.c
2 /*
3 Copyright (c) 2017, 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 )
59 // ARM open loop delay count
60 #define OPEN_LOOP_DELAY_CNT ( 10000000 )
62 extern void BOARD_initPerfCounters();
63 extern uint32_t readTime32(void);
65 /*
66  *  ======== main ========
67  */
68 Int main()
69
70     Int status;
71     Int k;
72     //UInt32 tsStart, tsEnd, delta; // debug: check ARM SYS/BIOS timestamp provider
73     HeapMem_ExtendedStats heapmem_stats;
74     Ptr buf;
75     SizeT size;
76     
77     Log_info0("Enter main()");
79     // (***) FL: clear ARM dedicated heap buffers
80     // Temporary workaround to avoid including 0's in ARM image.
81     // If heaps aren't cleared:
82     //   1) DSP:ASIT: IPC state is corrupted because of incorrect memory segments for PCM2, DDP2 & THD2 beta table entries.
83     //   2) DSP:ASIT: DSP hangs in GateMP_open() inside first call to statusOp_Init().
84     HeapMem_getExtendedStats(heapMemMsmcSram, &heapmem_stats);
85     buf = (Ptr)heapmem_stats.buf+HEAP_CONTROL_SZ;
86     size = (SizeT)heapmem_stats.size-HEAP_CONTROL_SZ;
87     memset(buf, 0, size);
88     Cache_wb(buf, size, Cache_Type_ALLD, 0);
89     Cache_wait();
90     HeapMem_getExtendedStats(heapMemDdr3, &heapmem_stats);
91     buf = (Ptr)heapmem_stats.buf+HEAP_CONTROL_SZ;
92     size = (SizeT)heapmem_stats.size-HEAP_CONTROL_SZ;
93     memset(buf, 0, size);
94     Cache_wb(buf, size, Cache_Type_ALLD, 0);
95     Cache_wait();
97 #if 0 // debug: check ARM SYS/BIOS timestamp provider
98     BOARD_initPerfCounters();
99 #endif
100     
101     /* Setup Profile Points (PFP) */
102     Log_info0("enter PFP Setup");
103     pfpCreate();
104     pfpCalibrate(1000, 1);
105     for (k = 0; k <= PFP_ID_LAST; k++) 
106     {
107         pfpEnable(k);   /* Enable profile point #k */
108     }
109     for (k = 1; k <= PFP_ID_LAST; k++)
110     {
111         pfpSetAlpha(k, PFP_DEF_ALPHA);  /* Set default exp. avg. time const. */
112     }
113 #if 0 // debug: dummy load
114     for (k = 0; k < 1000; k++) 
115     {
116         tsStart=readTime32();
117         pfpBegin(PFP_ID_MAIN,0);
118         clkWorkDelay(CLK_WORKCNT_PER_MS);     /* This should take about 750,000 cycles to execute, or 750e3/600e6=1.25 msec. */
119         pfpEnd(PFP_ID_MAIN,0);
120         tsEnd=readTime32();
121     }
122     delta = tsEnd-tsStart;
123 #endif
125     // (***) FL: insert "open-loop" delay before start of ARM application.
126     //  Temporary workaround to avoid exit in IPC_attach().
127     //  ARM exits in taskSysInitFxn:IPC_attach() when bootloading from MMC/SD unless delay is added.
128         for (k = 0; k < OPEN_LOOP_DELAY_CNT; k++)
129             asm("   nop");
131     // Initialize IPC
132     status = Ipc_start();
133     if (status < 0) 
134     {
135         System_abort("Ipc_start failed\n");
136     }
138     BIOS_start();    /* does not return */
139     return(0);