]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_NXP / TARGET_LPC11UXX / TOOLCHAIN_GCC_CR / startup_LPC11xx.cpp
1 extern "C" {
2
3 #include "LPC11Uxx.h"
4
5 #define WEAK __attribute__ ((weak))
6 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
7 #define AFTER_VECTORS __attribute__ ((section(".after_vectors")))
8
9 void ResetISR (void);
10 WEAK void NMI_Handler (void);
11 WEAK void HardFault_Handler (void);
12 WEAK void SVC_Handler (void);
13 WEAK void PendSV_Handler (void);
14 WEAK void SysTick_Handler (void);
15 WEAK void IntDefaultHandler (void);
16 void FLEX_INT0_IRQHandler(void) ALIAS(IntDefaultHandler);
17 void FLEX_INT1_IRQHandler(void) ALIAS(IntDefaultHandler);
18 void FLEX_INT2_IRQHandler(void) ALIAS(IntDefaultHandler);
19 void FLEX_INT3_IRQHandler(void) ALIAS(IntDefaultHandler);
20 void FLEX_INT4_IRQHandler(void) ALIAS(IntDefaultHandler);
21 void FLEX_INT5_IRQHandler(void) ALIAS(IntDefaultHandler);
22 void FLEX_INT6_IRQHandler(void) ALIAS(IntDefaultHandler);
23 void FLEX_INT7_IRQHandler(void) ALIAS(IntDefaultHandler);
24 void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
25 void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
26 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
27 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
28 void TIMER16_0_IRQHandler(void) ALIAS(IntDefaultHandler);
29 void TIMER16_1_IRQHandler(void) ALIAS(IntDefaultHandler);
30 void TIMER32_0_IRQHandler(void) ALIAS(IntDefaultHandler);
31 void TIMER32_1_IRQHandler(void) ALIAS(IntDefaultHandler);
32 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
33 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
34 void USB_IRQHandler (void) ALIAS(IntDefaultHandler);
35 void USB_FIQHandler (void) ALIAS(IntDefaultHandler);
36 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
37 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
38 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
39 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
40 void USBWakeup_IRQHandler(void) ALIAS(IntDefaultHandler);
41
42 extern void __libc_init_array(void);
43 extern int main(void);
44 extern void _vStackTop(void);
45
46 extern void (* const g_pfnVectors[])(void);
47 __attribute__ ((section(".isr_vector")))
48 void (* const g_pfnVectors[])(void) = {
49 &_vStackTop,
50 ResetISR,
51 NMI_Handler,
52 HardFault_Handler,
53 0,
54 0,
55 0,
56 0,
57 0,
58 0,
59 0,
60 SVC_Handler,
61 0,
62 0,
63 PendSV_Handler,
64 SysTick_Handler,
65 FLEX_INT0_IRQHandler,
66 FLEX_INT1_IRQHandler,
67 FLEX_INT2_IRQHandler,
68 FLEX_INT3_IRQHandler,
69 FLEX_INT4_IRQHandler,
70 FLEX_INT5_IRQHandler,
71 FLEX_INT6_IRQHandler,
72 FLEX_INT7_IRQHandler,
73 GINT0_IRQHandler,
74 GINT1_IRQHandler,
75 0,
76 0,
77 0,
78 0,
79 SSP1_IRQHandler,
80 I2C_IRQHandler,
81 TIMER16_0_IRQHandler,
82 TIMER16_1_IRQHandler,
83 TIMER32_0_IRQHandler,
84 TIMER32_1_IRQHandler,
85 SSP0_IRQHandler,
86 UART_IRQHandler,
87 USB_IRQHandler,
88 USB_FIQHandler,
89 ADC_IRQHandler,
90 WDT_IRQHandler,
91 BOD_IRQHandler,
92 FMC_IRQHandler,
93 0,
94 0,
95 USBWakeup_IRQHandler,
96 0,
97 };
98
99 AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
100 unsigned int *pulDest = (unsigned int*) start;
101 unsigned int *pulSrc = (unsigned int*) romstart;
102 unsigned int loop;
103 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++;
104 }
105
106 AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) {
107 unsigned int *pulDest = (unsigned int*) start;
108 unsigned int loop;
109 for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0;
110 }
111
112 extern unsigned int __data_section_table;
113 extern unsigned int __data_section_table_end;
114 extern unsigned int __bss_section_table_end;
115
116 extern "C" void software_init_hook(void) __attribute__((weak));
117
118 AFTER_VECTORS void ResetISR(void) {
119 unsigned int LoadAddr, ExeAddr, SectionLen;
120 unsigned int *SectionTableAddr;
121
122 // Data Init
123 SectionTableAddr = &__data_section_table;
124 while (SectionTableAddr < &__data_section_table_end) {
125 LoadAddr = *SectionTableAddr++;
126 ExeAddr = *SectionTableAddr++;
127 SectionLen = *SectionTableAddr++;
128 data_init(LoadAddr, ExeAddr, SectionLen);
129 }
130
131 // BSS Init
132 while (SectionTableAddr < &__bss_section_table_end) {
133 ExeAddr = *SectionTableAddr++;
134 SectionLen = *SectionTableAddr++;
135 bss_init(ExeAddr, SectionLen);
136 }
137
138 SystemInit();
139 if (software_init_hook) // give control to the RTOS
140 software_init_hook(); // this will also call __libc_init_array
141 else {
142 __libc_init_array();
143 main();
144 }
145 while (1) {;}
146 }
147
148 AFTER_VECTORS void NMI_Handler (void) {while(1){}}
149 AFTER_VECTORS void HardFault_Handler(void) {while(1){}}
150 AFTER_VECTORS void SVC_Handler (void) {while(1){}}
151 AFTER_VECTORS void PendSV_Handler (void) {while(1){}}
152 AFTER_VECTORS void SysTick_Handler (void) {while(1){}}
153 AFTER_VECTORS void IntDefaultHandler(void) {while(1){}}
154
155 #include <stdlib.h>
156
157 void *operator new (size_t size) {return malloc(size);}
158 void *operator new[](size_t size) {return malloc(size);}
159
160 void operator delete (void *p) {free(p);}
161 void operator delete[](void *p) {free(p);}
162
163 int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) {
164 return 0;
165 }
166
167 }
Imprint / Impressum