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)
87 #if defined(CHIP_LPC1343)
90 void TIMER16_0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
91 void TIMER16_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
93 void TIMER32_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
94 void SSP0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
96 void USB_IRQHandler (
void)
ALIAS(IntDefaultHandler);
97 void USB_FIQHandler (
void)
ALIAS(IntDefaultHandler);
101 void FMC_IRQHandler (
void)
ALIAS(IntDefaultHandler);
102 void PIOINT3_IRQHandler (
void)
ALIAS(IntDefaultHandler);
103 void PIOINT2_IRQHandler (
void)
ALIAS(IntDefaultHandler);
104 void PIOINT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
105 void PIOINT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
107 #elif defined(CHIP_LPC1347)
108 void PIN_INT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
109 void PIN_INT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
110 void PIN_INT2_IRQHandler (
void)
ALIAS(IntDefaultHandler);
111 void PIN_INT3_IRQHandler (
void)
ALIAS(IntDefaultHandler);
112 void PIN_INT4_IRQHandler (
void)
ALIAS(IntDefaultHandler);
113 void PIN_INT5_IRQHandler (
void)
ALIAS(IntDefaultHandler);
114 void PIN_INT6_IRQHandler (
void)
ALIAS(IntDefaultHandler);
115 void PIN_INT7_IRQHandler (
void)
ALIAS(IntDefaultHandler);
116 void GINT0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
117 void GINT1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
119 void SSP1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
121 void TIMER16_0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
122 void TIMER16_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
124 void TIMER32_1_IRQHandler (
void)
ALIAS(IntDefaultHandler);
125 void SSP0_IRQHandler (
void)
ALIAS(IntDefaultHandler);
127 void USB_IRQHandler (
void)
ALIAS(IntDefaultHandler);
128 void USB_FIQHandler (
void)
ALIAS(IntDefaultHandler);
132 void FMC_IRQHandler (
void)
ALIAS(IntDefaultHandler);
133 void OSCFAIL_IRQHandler (
void)
ALIAS(IntDefaultHandler);
134 void PVTCIRCUIT_IRQHandler (
void)
ALIAS(IntDefaultHandler);
135 void USBWakeup_IRQHandler (
void)
ALIAS(IntDefaultHandler);
138 #error No CHIP_134* device defined
154 #if defined (__REDLIB__)
155 extern void __main(
void);
157 extern int main(
void);
163 extern void _vStackTop(
void);
166 #if defined (__cplusplus)
176 extern void (*
const g_pfnVectors[])(void);
177 __attribute__ ((section(
".isr_vector")))
178 void (* const g_pfnVectors[])(
void) = {
196 #if defined(CHIP_LPC1343)
238 TIMER16_0_IRQHandler,
239 TIMER16_1_IRQHandler,
241 TIMER32_1_IRQHandler,
255 #elif defined(CHIP_LPC1347)
272 TIMER16_0_IRQHandler,
273 TIMER16_1_IRQHandler,
275 TIMER32_1_IRQHandler,
285 PVTCIRCUIT_IRQHandler,
286 USBWakeup_IRQHandler,
290 #error No CHIP_13* device defined
300 __attribute__ ((section(
".after_vectors")))
301 void data_init(
unsigned int romstart,
unsigned int start,
unsigned int len) {
302 unsigned int *pulDest = (
unsigned int*) start;
303 unsigned int *pulSrc = (
unsigned int*) romstart;
305 for (loop = 0; loop < len; loop = loop + 4)
306 *pulDest++ = *pulSrc++;
309 __attribute__ ((section(
".after_vectors")))
310 void bss_init(
unsigned int start,
unsigned int len) {
311 unsigned int *pulDest = (
unsigned int*) start;
313 for (loop = 0; loop < len; loop = loop + 4)
317 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
325 extern unsigned int __data_section_table;
326 extern unsigned int __data_section_table_end;
327 extern unsigned int __bss_section_table;
328 extern unsigned int __bss_section_table_end;
341 extern unsigned int _etext;
342 extern unsigned int _data;
343 extern unsigned int _edata;
344 extern unsigned int _bss;
345 extern unsigned int _ebss;
354 __attribute__ ((section(
".after_vectors")))
358 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
362 unsigned int LoadAddr, ExeAddr, SectionLen;
363 unsigned int *SectionTableAddr;
366 SectionTableAddr = &__data_section_table;
369 while (SectionTableAddr < &__data_section_table_end) {
370 LoadAddr = *SectionTableAddr++;
371 ExeAddr = *SectionTableAddr++;
372 SectionLen = *SectionTableAddr++;
373 data_init(LoadAddr, ExeAddr, SectionLen);
377 while (SectionTableAddr < &__bss_section_table_end) {
378 ExeAddr = *SectionTableAddr++;
379 SectionLen = *SectionTableAddr++;
380 bss_init(ExeAddr, SectionLen);
385 unsigned int * LoadAddr, *ExeAddr, *EndAddr, SectionLen;
391 SectionLen = (
void*)EndAddr - (
void*)ExeAddr;
392 data_init((
unsigned int)LoadAddr, (
unsigned int)ExeAddr, SectionLen);
396 SectionLen = (
void*)EndAddr - (
void*)ExeAddr;
397 bss_init ((
unsigned int)ExeAddr, SectionLen);
403 #if defined (__cplusplus)
410 #if defined (__REDLIB__)
428 __attribute__ ((section(
".after_vectors")))
435 __attribute__ ((section(
".after_vectors")))
442 __attribute__ ((section(
".after_vectors")))
449 __attribute__ ((section(
".after_vectors")))
456 __attribute__ ((section(
".after_vectors")))
470 __attribute__ ((section(
".after_vectors")))
471 void IntDefaultHandler(
void)