29
29
#define RELOCATE_INTERRUPT 1
30
30
#endif
31
31
32
- extern void main (void );
33
- extern char __stack__ ;
34
- extern char __text_start__ , __text_end__ ;
35
- extern char _start__ , _end__ ;
36
- extern char __bss_start__ , __bss_end__ ;
37
- #if RELOCATE_INTERRUPT
38
- extern char __interrupt_rom__ , __interrupt_start__ , __interrupt_end__ ;
39
- #endif
40
-
41
32
/* Interrupt functions */
42
33
43
34
void lpc_halt_isr (void )
@@ -49,26 +40,6 @@ void lpc_ignore_isr(void)
49
40
{
50
41
}
51
42
52
- void start (void ) {
53
- #ifdef AO_BOOT_CHAIN
54
- if (ao_boot_check_chain ()) {
55
- #ifdef AO_BOOT_PIN
56
- if (ao_boot_check_pin ())
57
- #endif
58
- {
59
- ao_boot_chain (AO_BOOT_APPLICATION_BASE );
60
- }
61
- }
62
- #endif
63
- #if RELOCATE_INTERRUPT
64
- memcpy (& __interrupt_start__ , & __interrupt_rom__ , & __interrupt_end__ - & __interrupt_start__ );
65
- lpc_scb .sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP ;
66
- #endif
67
- memcpy (& _start__ , & __text_end__ , & _end__ - & _start__ );
68
- memset (& __bss_start__ , '\0' , & __bss_end__ - & __bss_start__ );
69
- main ();
70
- }
71
-
72
43
#define STRINGIFY (x ) #x
73
44
74
45
#define isr (name ) \
@@ -122,10 +93,13 @@ isr(usb_wakeup)
122
93
#define i (addr ,name ) [(addr )/4 ] = lpc_ ## name ## _isr
123
94
#define c (addr ,value ) [(addr )/4 ] = (value )
124
95
125
- __attribute__ ((section (".interrupt" )))
126
- const void * lpc_interrupt_vector [] = {
127
- [0 ] = & __stack__ ,
128
- [1 ] = start ,
96
+ extern char __stack [];
97
+ void _start (void ) __attribute__((__noreturn__ ));
98
+
99
+ __attribute__ ((section (".init" )))
100
+ const void * const __interrupt_vector [0x30 ] = {
101
+ [0 ] = __stack ,
102
+ [1 ] = _start ,
129
103
i (0x08 , nmi ),
130
104
i (0x0c , hardfault ),
131
105
c (0x10 , 0 ),
@@ -178,3 +152,43 @@ const void *lpc_interrupt_vector[] = {
178
152
i (0xb8 , usb_wakeup ),
179
153
i (0xbc , hardfault ),
180
154
};
155
+
156
+ /*
157
+ * Previous versions of this code had a 256 byte interupt vector. Add
158
+ * some padding to make sure the other low ROM variables land at the
159
+ * same address
160
+ */
161
+
162
+ __attribute__ ((section (".init.0" )))
163
+ const void * const __interrupt_pad [0x10 ];
164
+
165
+ void main (void ) __attribute__((__noreturn__ ));
166
+
167
+ void * __interrupt_ram [sizeof (__interrupt_vector )/sizeof (__interrupt_vector [0 ])] __attribute((section (".preserve.1" )));
168
+
169
+ extern char __data_source [];
170
+ extern char __data_start [];
171
+ extern char __data_size [];
172
+ extern char __bss_start [];
173
+ extern char __bss_size [];
174
+
175
+ void _start (void ) {
176
+ memcpy (__data_start , __data_source , (uintptr_t ) __data_size );
177
+ memset (__bss_start , '\0' , (uintptr_t ) __bss_size );
178
+
179
+ #ifdef AO_BOOT_CHAIN
180
+ if (ao_boot_check_chain ()) {
181
+ #ifdef AO_BOOT_PIN
182
+ if (ao_boot_check_pin ())
183
+ #endif
184
+ {
185
+ ao_boot_chain (AO_BOOT_APPLICATION_BASE );
186
+ }
187
+ }
188
+ #endif
189
+ #if RELOCATE_INTERRUPT
190
+ memcpy (__interrupt_ram , __interrupt_vector , sizeof (__interrupt_ram ));
191
+ lpc_scb .sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP ;
192
+ #endif
193
+ main ();
194
+ }
0 commit comments