30 #if defined (__cplusplus)
32 #error Redlib does not support C++
40 extern void __libc_init_array(
void);
45 #define WEAK __attribute__ ((weak))
46 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
48 #include "sys_config.h"
55 #if defined (__cplusplus)
83 #if defined(CHIP_LPC1343)
86 void TIMER16_0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
87 void TIMER16_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
89 void TIMER32_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
90 void SSP0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
92 void USB_IRQHandler (
void)
ALIAS(IntDefaultHandler);
93 void USB_FIQHandler (
void)
ALIAS(IntDefaultHandler);
97 void FMC_IRQHandler (
void)
ALIAS(IntDefaultHandler);
98 void PIOINT3_IRQHandler (
void)
ALIAS(IntDefaultHandler);
99 void PIOINT2_IRQHandler (
void)
ALIAS(IntDefaultHandler);
100 void PIOINT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
101 void PIOINT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
103 #elif defined(CHIP_LPC1347)
104 void PIN_INT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
105 void PIN_INT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
106 void PIN_INT2_IRQHandler (
void)
ALIAS(IntDefaultHandler);
107 void PIN_INT3_IRQHandler (
void)
ALIAS(IntDefaultHandler);
108 void PIN_INT4_IRQHandler (
void)
ALIAS(IntDefaultHandler);
109 void PIN_INT5_IRQHandler (
void)
ALIAS(IntDefaultHandler);
110 void PIN_INT6_IRQHandler (
void)
ALIAS(IntDefaultHandler);
111 void PIN_INT7_IRQHandler (
void)
ALIAS(IntDefaultHandler);
112 void GINT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
113 void GINT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
115 void SSP1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
117 void TIMER16_0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
118 void TIMER16_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
120 void TIMER32_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
121 void SSP0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
123 void USB_IRQHandler (
void)
ALIAS(IntDefaultHandler);
124 void USB_FIQHandler (
void)
ALIAS(IntDefaultHandler);
128 void FMC_IRQHandler (
void)
ALIAS(IntDefaultHandler);
129 void OSCFAIL_IRQHandler (
void)
ALIAS(IntDefaultHandler);
130 void PVTCIRCUIT_IRQHandler (
void)
ALIAS(IntDefaultHandler);
131 void USBWakeup_IRQHandler (
void)
ALIAS(IntDefaultHandler);
134 #error No CHIP_134* device defined
150 #if defined (__REDLIB__)
151 extern void __main(
void);
153 extern int main(
void);
159 extern void _vStackTop(
void);
162 #if defined (__cplusplus)
172 extern void (*
const g_pfnVectors[])(void);
173 __attribute__ ((section(
".isr_vector")))
174 void (* const g_pfnVectors[])(
void) = {
192 #if defined(CHIP_LPC1343)
234 TIMER16_0_IRQHandler,
235 TIMER16_1_IRQHandler,
237 TIMER32_1_IRQHandler,
251 #elif defined(CHIP_LPC1347)
268 TIMER16_0_IRQHandler,
269 TIMER16_1_IRQHandler,
271 TIMER32_1_IRQHandler,
281 PVTCIRCUIT_IRQHandler,
282 USBWakeup_IRQHandler,
286 #error No CHIP_13* device defined
296 __attribute__ ((section(
".after_vectors")))
297 void data_init(
unsigned int romstart,
unsigned int start,
unsigned int len) {
298 unsigned int *pulDest = (
unsigned int*) start;
299 unsigned int *pulSrc = (
unsigned int*) romstart;
301 for (loop = 0; loop < len; loop = loop + 4)
302 *pulDest++ = *pulSrc++;
305 __attribute__ ((section(
".after_vectors")))
306 void bss_init(
unsigned int start,
unsigned int len) {
307 unsigned int *pulDest = (
unsigned int*) start;
309 for (loop = 0; loop < len; loop = loop + 4)
313 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
321 extern unsigned int __data_section_table;
322 extern unsigned int __data_section_table_end;
323 extern unsigned int __bss_section_table;
324 extern unsigned int __bss_section_table_end;
337 extern unsigned int _etext;
338 extern unsigned int _data;
339 extern unsigned int _edata;
340 extern unsigned int _bss;
341 extern unsigned int _ebss;
350 __attribute__ ((section(
".after_vectors")))
354 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
358 unsigned int LoadAddr, ExeAddr, SectionLen;
359 unsigned int *SectionTableAddr;
362 SectionTableAddr = &__data_section_table;
365 while (SectionTableAddr < &__data_section_table_end) {
366 LoadAddr = *SectionTableAddr++;
367 ExeAddr = *SectionTableAddr++;
368 SectionLen = *SectionTableAddr++;
369 data_init(LoadAddr, ExeAddr, SectionLen);
373 while (SectionTableAddr < &__bss_section_table_end) {
374 ExeAddr = *SectionTableAddr++;
375 SectionLen = *SectionTableAddr++;
376 bss_init(ExeAddr, SectionLen);
381 unsigned int * LoadAddr, *ExeAddr, *EndAddr, SectionLen;
387 SectionLen = (
void*)EndAddr - (
void*)ExeAddr;
388 data_init((
unsigned int)LoadAddr, (
unsigned int)ExeAddr, SectionLen);
392 SectionLen = (
void*)EndAddr - (
void*)ExeAddr;
393 bss_init ((
unsigned int)ExeAddr, SectionLen);
399 #if defined (__cplusplus)
406 #if defined (__REDLIB__)
424 __attribute__ ((section(
".after_vectors")))
431 __attribute__ ((section(
".after_vectors")))
438 __attribute__ ((section(
".after_vectors")))
445 __attribute__ ((section(
".after_vectors")))
452 __attribute__ ((section(
".after_vectors")))
466 __attribute__ ((section(
".after_vectors")))
467 void IntDefaultHandler(
void)