1 /******************************************************************************
3 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
33 ******************************************************************************/
37 /******************************************************************************
39 * The entry point for the application startup code.
41 ******************************************************************************/
42 extern int main(void);
44 /******************************************************************************
46 * Reserve space for the system stack.
48 ******************************************************************************/
49 __attribute__ ((section(".stack")))
50 static uint32_t stack[100];
51 const uint32_t stack_pntr = (uint32_t)stack + sizeof(stack);
53 /******************************************************************************
55 * The following are constructs created by the linker indicating where
56 * the "bss" and "ebss" segments reside in memory.
58 ******************************************************************************/
60 extern uint32_t _ebss;
62 /******************************************************************************
64 * This is the entry point that handles setting the stack within the allowed
65 * workspace, initializing the .bss segment, and then jumping to main.
67 ******************************************************************************/
68 __attribute__ ((section(".entry")))
71 /* Workaround for ITT instructions. */
77 /* Initialize stack pointer */
78 __asm(" ldr sp, =stack_pntr");
80 /* Zero fill the bss segment. */
81 __asm(" ldr r0, =_bss\n"
88 " strlt r2, [r0], #4\n"
91 /* Call the application's entry point. */
94 /* If we ever return, enter an infinite loop */