2 * Copyright © 2013 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 #ifndef IS_FLASH_LOADER
24 #error Should define IS_FLASH_LOADER
25 #define IS_FLASH_LOADER 0
29 #define RELOCATE_INTERRUPT 1
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__;
41 /* Interrupt functions */
43 void lpc_halt_isr(void)
45 ao_panic(AO_PANIC_CRASH);
48 void lpc_ignore_isr(void)
54 if (ao_boot_check_chain()) {
56 if (ao_boot_check_pin())
59 ao_boot_chain(AO_BOOT_APPLICATION_BASE);
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;
67 memcpy(&_start__, &__text_end__, &_end__ - &_start__);
68 memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__);
72 #define STRINGIFY(x) #x
75 void __attribute__ ((weak)) lpc_ ## name ## _isr(void); \
76 _Pragma(STRINGIFY(weak lpc_ ## name ## _isr = lpc_ignore_isr))
78 #define isr_halt(name) \
79 void __attribute__ ((weak)) lpc_ ## name ## _isr(void); \
80 _Pragma(STRINGIFY(weak lpc_ ## name ## _isr = lpc_halt_isr))
92 isr(pin_int0) /* IRQ0 */
96 isr(pin_int4) /* IRQ4 */
101 isr(gint0) /* IRQ8 */
106 isr(ct16b0) /* IRQ16 */
110 isr(ssp0) /* IRQ20 */
122 #define i(addr,name) [(addr)/4] = lpc_ ## name ## _isr
123 #define c(addr,value) [(addr)/4] = (value)
125 __attribute__ ((section(".interrupt")))
126 const void *lpc_interrupt_vector[] = {
144 i(0x40, pin_int0), /* IRQ0 */
148 i(0x50, pin_int4), /* IRQ4 */
153 i(0x60, gint0), /* IRQ8 */
157 i(0x70, hardfault), /* IRQ12 */
162 i(0x80, ct16b0), /* IRQ16 */
166 i(0x90, ssp0), /* IRQ20 */
171 i(0xa0, adc), /* IRQ24 */
176 i(0xb0, hardfault), /* IRQ28 */