1 //*****************************************************************************
3 // startup.c - Boot code for Stellaris.
5 // Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
7 // Software License Agreement
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
10 // exclusively on LMI's Stellaris Family of microcontroller products.
12 // The software is owned by LMI and/or its suppliers, and is protected under
13 // applicable copyright laws. All rights are reserved. Any use in violation
14 // of the foregoing restrictions may subject the user to criminal sanctions
15 // under applicable laws, as well as to civil liability for the breach of the
16 // terms and conditions of this license.
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
24 //*****************************************************************************
26 //*****************************************************************************
28 // Forward declaration of the default fault handlers.
30 //*****************************************************************************
32 static void NmiSR(void);
34 extern void xPortPendSVHandler(void);
35 extern void xPortSysTickHandler(void);
36 extern void vUART_ISR( void );
37 extern void vPortSVCHandler( void );
39 //*****************************************************************************
41 // The entry point for the application.
43 //*****************************************************************************
44 extern void entry(void);
46 //*****************************************************************************
48 // Reserve space for the system stack.
50 //*****************************************************************************
54 static unsigned long pulMainStack[STACK_SIZE];
56 //*****************************************************************************
58 // The minimal vector table for a Cortex-M3. Note that the proper constructs
59 // must be placed on this to ensure that it ends up at physical address
62 //*****************************************************************************
63 __attribute__ ((section("vectors")))
64 void (* const g_pfnVectors[])(void) =
66 (void (*)(void))((unsigned long)pulMainStack + sizeof(pulMainStack)),
70 0, // The MPU fault handler
71 0, // The bus fault handler
72 0, // The usage fault handler
77 vPortSVCHandler, // SVCall handler
78 0, // Debug monitor handler
80 xPortPendSVHandler, // The PendSV handler
81 xPortSysTickHandler, // The SysTick handler
87 vUART_ISR // UART0 Rx and Tx
90 //*****************************************************************************
92 // The following are constructs created by the linker, indicating where the
93 // the "data" and "bss" segments reside in memory. The initializers for the
94 // for the "data" segment resides immediately following the "text" segment.
96 //*****************************************************************************
97 extern unsigned long _etext;
98 extern unsigned long _data;
99 extern unsigned long _edata;
100 extern unsigned long _bss;
101 extern unsigned long _ebss;
103 //*****************************************************************************
105 // This is the code that gets called when the processor first starts execution
106 // following a reset event. Only the absolutely necessary set is performed,
107 // after which the application supplied entry() routine is called. Any fancy
108 // actions (such as making decisions based on the reset cause register, and
109 // resetting the bits in that register) are left solely in the hands of the
112 //*****************************************************************************
116 unsigned long *pulSrc, *pulDest;
119 // Copy the data segment initializers from flash to SRAM.
122 for(pulDest = &_data; pulDest < &_edata; )
124 *pulDest++ = *pulSrc++;
128 // Zero fill the bss segment.
130 for(pulDest = &_bss; pulDest < &_ebss; )
136 // Call the application's entry point.
141 //*****************************************************************************
143 // This is the code that gets called when the processor receives a NMI. This
144 // simply enters an infinite loop, preserving the system state for examination
147 //*****************************************************************************
152 // Enter an infinite loop.
159 //*****************************************************************************
161 // This is the code that gets called when the processor receives a fault
162 // interrupt. This simply enters an infinite loop, preserving the system state
163 // for examination by a debugger.
165 //*****************************************************************************
170 // Enter an infinite loop.