2 * Copyright © 2012 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.
24 extern void main(void);
25 extern char __stack__;
26 extern char __text_start__, __text_end__;
27 extern char _start__, _end__;
28 extern char __bss_start__, __bss_end__;
30 /* Interrupt functions */
32 void stm_halt_isr(void)
34 ao_panic(AO_PANIC_CRASH);
37 void stm_ignore_isr(void)
41 const void *stm_interrupt_vector[];
44 stm_flash_size(void) {
45 uint16_t dev_id = stm_dev_id();
49 case 0x416: /* cat 1 */
50 kbytes = stm_flash_size_medium.f_size;
52 case 0x429: /* cat 2 */
53 kbytes = stm_flash_size_medium.f_size & 0xff;
55 case 0x427: /* cat 3 */
56 kbytes = stm_flash_size_large.f_size;
58 case 0x436: /* cat 4 */
59 switch (stm_flash_size_large.f_size) {
68 case 0x437: /* cat 5 */
69 kbytes = stm_flash_size_large.f_size;
72 return (uint32_t) kbytes * 1024;
78 if (ao_boot_check_chain()) {
84 /* Set interrupt vector table offset */
85 stm_nvic.vto = (uint32_t) &stm_interrupt_vector;
86 memcpy(&_start__, &__text_end__, &_end__ - &_start__);
87 memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__);
91 #define STRINGIFY(x) #x
94 void __attribute__ ((weak)) stm_ ## name ## _isr(void); \
95 _Pragma(STRINGIFY(weak stm_ ## name ## _isr = stm_ignore_isr))
97 #define isr_halt(name) \
98 void __attribute__ ((weak)) stm_ ## name ## _isr(void); \
99 _Pragma(STRINGIFY(weak stm_ ## name ## _isr = stm_halt_isr))
156 #define i(addr,name) [(addr)/4] = stm_ ## name ## _isr
158 __attribute__ ((section(".interrupt")))
159 const void *stm_interrupt_vector[] = {
173 i(0x48, tamper_stamp),
182 i(0x6c, dma1_channel1),
183 i(0x70, dma1_channel2),
184 i(0x74, dma1_channel3),
185 i(0x78, dma1_channel4),
186 i(0x7c, dma1_channel5),
187 i(0x80, dma1_channel6),
188 i(0x84, dma1_channel7),
213 i(0xe8, usb_fs_wkup),