30 #if defined (__cplusplus)
32 #error Redlib does not support C++
40 extern void __libc_init_array(
void);
52 #define STACK_SIZE 0x200
55 #define WEAK __attribute__ ((weak))
56 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
63 #if defined (__cplusplus)
98 void TIMER3_IRQHandler(
void)
ALIAS(IntDefaultHandler);
101 void UART2_IRQHandler(
void)
ALIAS(IntDefaultHandler);
102 void UART3_IRQHandler(
void)
ALIAS(IntDefaultHandler);
103 void PWM1_IRQHandler(
void)
ALIAS(IntDefaultHandler);
106 void I2C2_IRQHandler(
void)
ALIAS(IntDefaultHandler);
107 void SPI_IRQHandler(
void)
ALIAS(IntDefaultHandler);
108 void SSP0_IRQHandler(
void)
ALIAS(IntDefaultHandler);
109 void SSP1_IRQHandler(
void)
ALIAS(IntDefaultHandler);
110 void PLL0_IRQHandler(
void)
ALIAS(IntDefaultHandler);
112 void EINT0_IRQHandler(
void)
ALIAS(IntDefaultHandler);
113 void EINT1_IRQHandler(
void)
ALIAS(IntDefaultHandler);
114 void EINT2_IRQHandler(
void)
ALIAS(IntDefaultHandler);
115 void EINT3_IRQHandler(
void)
ALIAS(IntDefaultHandler);
118 void USB_IRQHandler(
void)
ALIAS(IntDefaultHandler);
124 void MCPWM_IRQHandler(
void)
ALIAS(IntDefaultHandler);
125 void QEI_IRQHandler(
void)
ALIAS(IntDefaultHandler);
126 void PLL1_IRQHandler(
void)
ALIAS(IntDefaultHandler);
127 void USBActivity_IRQHandler(
void)
ALIAS(IntDefaultHandler);
128 void CANActivity_IRQHandler(
void)
ALIAS(IntDefaultHandler);
130 void UART4_IRQHandler(
void)
ALIAS(IntDefaultHandler);
131 void SSP2_IRQHandler(
void)
ALIAS(IntDefaultHandler);
133 void GPIO_IRQHandler(
void)
ALIAS(IntDefaultHandler);
134 void PWM0_IRQHandler(
void)
ALIAS(IntDefaultHandler);
135 void EEPROM_IRQHandler(
void)
ALIAS(IntDefaultHandler);
144 #if defined (__REDLIB__)
145 extern void __main(
void);
147 extern int main(
void);
153 extern void _vStackTop(
void);
156 #if defined (__cplusplus)
165 extern void (*
const g_pfnVectors[])(void);
166 __attribute__ ((section(
".isr_vector")))
167 void (* const g_pfnVectors[])(
void) = {
220 USBActivity_IRQHandler,
221 CANActivity_IRQHandler,
238 __attribute__ ((section(
".after_vectors")))
239 void data_init(
unsigned int romstart,
unsigned int start,
unsigned int len) {
240 unsigned int *pulDest = (
unsigned int*) start;
241 unsigned int *pulSrc = (
unsigned int*) romstart;
243 for (loop = 0; loop < len; loop = loop + 4)
244 *pulDest++ = *pulSrc++;
247 __attribute__ ((section(
".after_vectors")))
248 void bss_init(
unsigned int start,
unsigned int len) {
249 unsigned int *pulDest = (
unsigned int*) start;
251 for (loop = 0; loop < len; loop = loop + 4)
262 extern unsigned int __data_section_table;
263 extern unsigned int __data_section_table_end;
264 extern unsigned int __bss_section_table;
265 extern unsigned int __bss_section_table_end;
275 __attribute__ ((section(
".after_vectors")))
282 unsigned int LoadAddr, ExeAddr, SectionLen;
283 unsigned int *SectionTableAddr;
289 SectionTableAddr = &__data_section_table;
292 while (SectionTableAddr < &__data_section_table_end) {
293 LoadAddr = *SectionTableAddr++;
294 ExeAddr = *SectionTableAddr++;
295 SectionLen = *SectionTableAddr++;
296 data_init(LoadAddr, ExeAddr, SectionLen);
300 while (SectionTableAddr < &__bss_section_table_end) {
301 ExeAddr = *SectionTableAddr++;
302 SectionLen = *SectionTableAddr++;
303 bss_init(ExeAddr, SectionLen);
306 #if defined (__cplusplus)
313 #if defined (__REDLIB__)
332 __attribute__ ((section(
".after_vectors")))
339 __attribute__ ((section(
".after_vectors")))
346 __attribute__ ((section(
".after_vectors")))
353 __attribute__ ((section(
".after_vectors")))
360 __attribute__ ((section(
".after_vectors")))
368 __attribute__ ((section(
".after_vectors")))
383 __attribute__ ((section(
".after_vectors")))
397 unsigned int __check_heap_overflow (
void * new_end_of_heap)
399 return (new_end_of_heap >= (
unsigned int)&_vStackTop -
STACK_SIZE);