mbed SDK library sources
Fork of mbed-src by
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp@67:78dfdb5b4d9e, 2013-12-24 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Dec 24 21:15:05 2013 +0000
- Revision:
- 67:78dfdb5b4d9e
- Parent:
- 13:0645d8841f51
Synchronized with git revision 82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57
Full URL: https://github.com/mbedmicro/mbed/commit/82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57/
1. Provide the required __end__ symbol
2. Call software_init_hook() if present, which in turn starts the RTOS
The fix was applied for all targets with a TOOLCHAIN_GCC_CR folder,
but it only works with LPC1768 and LPC4088 because of incomplete or
missing support for GCC_CR and/or the RTOS for the other targets.
Tested by running RTOS_1, RTOS_2 and RTOS_3 with LPC1768 and LPC4088.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 10:3bc89ef62ce7 | 1 | extern "C" { |
emilmont | 10:3bc89ef62ce7 | 2 | |
emilmont | 10:3bc89ef62ce7 | 3 | #include "LPC11Uxx.h" |
emilmont | 10:3bc89ef62ce7 | 4 | |
emilmont | 10:3bc89ef62ce7 | 5 | #define WEAK __attribute__ ((weak)) |
emilmont | 10:3bc89ef62ce7 | 6 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) |
emilmont | 10:3bc89ef62ce7 | 7 | #define AFTER_VECTORS __attribute__ ((section(".after_vectors"))) |
emilmont | 10:3bc89ef62ce7 | 8 | |
emilmont | 10:3bc89ef62ce7 | 9 | void ResetISR (void); |
emilmont | 10:3bc89ef62ce7 | 10 | WEAK void NMI_Handler (void); |
emilmont | 10:3bc89ef62ce7 | 11 | WEAK void HardFault_Handler (void); |
mbed_official | 67:78dfdb5b4d9e | 12 | WEAK void SVC_Handler (void); |
emilmont | 10:3bc89ef62ce7 | 13 | WEAK void PendSV_Handler (void); |
emilmont | 10:3bc89ef62ce7 | 14 | WEAK void SysTick_Handler (void); |
emilmont | 10:3bc89ef62ce7 | 15 | WEAK void IntDefaultHandler (void); |
emilmont | 10:3bc89ef62ce7 | 16 | void FLEX_INT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 17 | void FLEX_INT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 18 | void FLEX_INT2_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 19 | void FLEX_INT3_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 20 | void FLEX_INT4_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 21 | void FLEX_INT5_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 22 | void FLEX_INT6_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 23 | void FLEX_INT7_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 24 | void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 25 | void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 26 | void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 27 | void I2C_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 28 | void TIMER16_0_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 29 | void TIMER16_1_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 30 | void TIMER32_0_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 31 | void TIMER32_1_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 32 | void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 33 | void UART_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 34 | void USB_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 35 | void USB_FIQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 36 | void ADC_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 37 | void WDT_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 38 | void BOD_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 39 | void FMC_IRQHandler (void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 40 | void USBWakeup_IRQHandler(void) ALIAS(IntDefaultHandler); |
emilmont | 10:3bc89ef62ce7 | 41 | |
emilmont | 10:3bc89ef62ce7 | 42 | extern void __libc_init_array(void); |
emilmont | 10:3bc89ef62ce7 | 43 | extern int main(void); |
emilmont | 10:3bc89ef62ce7 | 44 | extern void _vStackTop(void); |
emilmont | 10:3bc89ef62ce7 | 45 | |
emilmont | 10:3bc89ef62ce7 | 46 | extern void (* const g_pfnVectors[])(void); |
emilmont | 10:3bc89ef62ce7 | 47 | __attribute__ ((section(".isr_vector"))) |
emilmont | 10:3bc89ef62ce7 | 48 | void (* const g_pfnVectors[])(void) = { |
emilmont | 10:3bc89ef62ce7 | 49 | &_vStackTop, |
emilmont | 10:3bc89ef62ce7 | 50 | ResetISR, |
emilmont | 10:3bc89ef62ce7 | 51 | NMI_Handler, |
emilmont | 10:3bc89ef62ce7 | 52 | HardFault_Handler, |
emilmont | 10:3bc89ef62ce7 | 53 | 0, |
emilmont | 10:3bc89ef62ce7 | 54 | 0, |
emilmont | 10:3bc89ef62ce7 | 55 | 0, |
emilmont | 10:3bc89ef62ce7 | 56 | 0, |
emilmont | 10:3bc89ef62ce7 | 57 | 0, |
emilmont | 10:3bc89ef62ce7 | 58 | 0, |
emilmont | 10:3bc89ef62ce7 | 59 | 0, |
mbed_official | 67:78dfdb5b4d9e | 60 | SVC_Handler, |
emilmont | 10:3bc89ef62ce7 | 61 | 0, |
emilmont | 10:3bc89ef62ce7 | 62 | 0, |
emilmont | 10:3bc89ef62ce7 | 63 | PendSV_Handler, |
emilmont | 10:3bc89ef62ce7 | 64 | SysTick_Handler, |
emilmont | 10:3bc89ef62ce7 | 65 | FLEX_INT0_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 66 | FLEX_INT1_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 67 | FLEX_INT2_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 68 | FLEX_INT3_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 69 | FLEX_INT4_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 70 | FLEX_INT5_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 71 | FLEX_INT6_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 72 | FLEX_INT7_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 73 | GINT0_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 74 | GINT1_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 75 | 0, |
emilmont | 10:3bc89ef62ce7 | 76 | 0, |
emilmont | 10:3bc89ef62ce7 | 77 | 0, |
emilmont | 10:3bc89ef62ce7 | 78 | 0, |
emilmont | 10:3bc89ef62ce7 | 79 | SSP1_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 80 | I2C_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 81 | TIMER16_0_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 82 | TIMER16_1_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 83 | TIMER32_0_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 84 | TIMER32_1_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 85 | SSP0_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 86 | UART_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 87 | USB_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 88 | USB_FIQHandler, |
emilmont | 10:3bc89ef62ce7 | 89 | ADC_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 90 | WDT_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 91 | BOD_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 92 | FMC_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 93 | 0, |
emilmont | 10:3bc89ef62ce7 | 94 | 0, |
emilmont | 10:3bc89ef62ce7 | 95 | USBWakeup_IRQHandler, |
emilmont | 10:3bc89ef62ce7 | 96 | 0, |
emilmont | 10:3bc89ef62ce7 | 97 | }; |
emilmont | 10:3bc89ef62ce7 | 98 | |
emilmont | 10:3bc89ef62ce7 | 99 | AFTER_VECTORS void data_init(unsigned int romstart, unsigned int start, unsigned int len) { |
emilmont | 10:3bc89ef62ce7 | 100 | unsigned int *pulDest = (unsigned int*) start; |
emilmont | 10:3bc89ef62ce7 | 101 | unsigned int *pulSrc = (unsigned int*) romstart; |
emilmont | 10:3bc89ef62ce7 | 102 | unsigned int loop; |
emilmont | 10:3bc89ef62ce7 | 103 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++; |
emilmont | 10:3bc89ef62ce7 | 104 | } |
emilmont | 10:3bc89ef62ce7 | 105 | |
emilmont | 10:3bc89ef62ce7 | 106 | AFTER_VECTORS void bss_init(unsigned int start, unsigned int len) { |
emilmont | 10:3bc89ef62ce7 | 107 | unsigned int *pulDest = (unsigned int*) start; |
emilmont | 10:3bc89ef62ce7 | 108 | unsigned int loop; |
emilmont | 10:3bc89ef62ce7 | 109 | for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0; |
emilmont | 10:3bc89ef62ce7 | 110 | } |
emilmont | 10:3bc89ef62ce7 | 111 | |
emilmont | 10:3bc89ef62ce7 | 112 | extern unsigned int __data_section_table; |
emilmont | 10:3bc89ef62ce7 | 113 | extern unsigned int __data_section_table_end; |
emilmont | 10:3bc89ef62ce7 | 114 | extern unsigned int __bss_section_table_end; |
emilmont | 10:3bc89ef62ce7 | 115 | |
mbed_official | 67:78dfdb5b4d9e | 116 | extern "C" void software_init_hook(void) __attribute__((weak)); |
mbed_official | 67:78dfdb5b4d9e | 117 | |
emilmont | 10:3bc89ef62ce7 | 118 | AFTER_VECTORS void ResetISR(void) { |
emilmont | 10:3bc89ef62ce7 | 119 | unsigned int LoadAddr, ExeAddr, SectionLen; |
emilmont | 10:3bc89ef62ce7 | 120 | unsigned int *SectionTableAddr; |
emilmont | 10:3bc89ef62ce7 | 121 | |
emilmont | 10:3bc89ef62ce7 | 122 | // Data Init |
emilmont | 10:3bc89ef62ce7 | 123 | SectionTableAddr = &__data_section_table; |
emilmont | 10:3bc89ef62ce7 | 124 | while (SectionTableAddr < &__data_section_table_end) { |
emilmont | 10:3bc89ef62ce7 | 125 | LoadAddr = *SectionTableAddr++; |
emilmont | 10:3bc89ef62ce7 | 126 | ExeAddr = *SectionTableAddr++; |
emilmont | 10:3bc89ef62ce7 | 127 | SectionLen = *SectionTableAddr++; |
emilmont | 10:3bc89ef62ce7 | 128 | data_init(LoadAddr, ExeAddr, SectionLen); |
emilmont | 10:3bc89ef62ce7 | 129 | } |
emilmont | 10:3bc89ef62ce7 | 130 | |
emilmont | 10:3bc89ef62ce7 | 131 | // BSS Init |
emilmont | 10:3bc89ef62ce7 | 132 | while (SectionTableAddr < &__bss_section_table_end) { |
emilmont | 10:3bc89ef62ce7 | 133 | ExeAddr = *SectionTableAddr++; |
emilmont | 10:3bc89ef62ce7 | 134 | SectionLen = *SectionTableAddr++; |
emilmont | 10:3bc89ef62ce7 | 135 | bss_init(ExeAddr, SectionLen); |
emilmont | 10:3bc89ef62ce7 | 136 | } |
emilmont | 10:3bc89ef62ce7 | 137 | |
emilmont | 10:3bc89ef62ce7 | 138 | SystemInit(); |
mbed_official | 67:78dfdb5b4d9e | 139 | if (software_init_hook) // give control to the RTOS |
mbed_official | 67:78dfdb5b4d9e | 140 | software_init_hook(); // this will also call __libc_init_array |
mbed_official | 67:78dfdb5b4d9e | 141 | else { |
mbed_official | 67:78dfdb5b4d9e | 142 | __libc_init_array(); |
mbed_official | 67:78dfdb5b4d9e | 143 | main(); |
mbed_official | 67:78dfdb5b4d9e | 144 | } |
emilmont | 10:3bc89ef62ce7 | 145 | while (1) {;} |
emilmont | 10:3bc89ef62ce7 | 146 | } |
emilmont | 10:3bc89ef62ce7 | 147 | |
emilmont | 10:3bc89ef62ce7 | 148 | AFTER_VECTORS void NMI_Handler (void) {while(1){}} |
emilmont | 10:3bc89ef62ce7 | 149 | AFTER_VECTORS void HardFault_Handler(void) {while(1){}} |
mbed_official | 67:78dfdb5b4d9e | 150 | AFTER_VECTORS void SVC_Handler (void) {while(1){}} |
emilmont | 10:3bc89ef62ce7 | 151 | AFTER_VECTORS void PendSV_Handler (void) {while(1){}} |
emilmont | 10:3bc89ef62ce7 | 152 | AFTER_VECTORS void SysTick_Handler (void) {while(1){}} |
emilmont | 10:3bc89ef62ce7 | 153 | AFTER_VECTORS void IntDefaultHandler(void) {while(1){}} |
emilmont | 10:3bc89ef62ce7 | 154 | |
emilmont | 10:3bc89ef62ce7 | 155 | #include <stdlib.h> |
emilmont | 10:3bc89ef62ce7 | 156 | |
emilmont | 10:3bc89ef62ce7 | 157 | void *operator new (size_t size) {return malloc(size);} |
emilmont | 10:3bc89ef62ce7 | 158 | void *operator new[](size_t size) {return malloc(size);} |
emilmont | 10:3bc89ef62ce7 | 159 | |
emilmont | 10:3bc89ef62ce7 | 160 | void operator delete (void *p) {free(p);} |
emilmont | 10:3bc89ef62ce7 | 161 | void operator delete[](void *p) {free(p);} |
emilmont | 10:3bc89ef62ce7 | 162 | |
emilmont | 10:3bc89ef62ce7 | 163 | int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) { |
emilmont | 10:3bc89ef62ce7 | 164 | return 0; |
emilmont | 10:3bc89ef62ce7 | 165 | } |
emilmont | 10:3bc89ef62ce7 | 166 | |
emilmont | 10:3bc89ef62ce7 | 167 | } |