1 /*
2  * Copyright (c) 2012 Travis Geiselbrecht
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #include <compiler.h>
24 #include <stdint.h>
25 
26 /*
27  * Make a nice 8 byte aligned stack to run on before the threading system is up.
28  * Put it in the .bss.prebss.* section to make sure it doesn't get wiped
29  * when bss is cleared a little ways into boot.
30  */
31 static uint8_t initial_stack[1024] __SECTION(".bss.prebss.initial_stack") __ALIGNED(8);
32 
33 extern void _start(void);
34 extern void _nmi(void);
35 extern void _hardfault(void);
36 extern void _memmanage(void);
37 extern void _busfault(void);
38 extern void _usagefault(void);
39 extern void _svc(void);
40 extern void _debugmonitor(void);
41 extern void _pendsv(void);
42 extern void _systick(void);
43 
44 #if defined(WITH_DEBUGGER_INFO)
45 extern struct __debugger_info__ _debugger_info;
46 #endif
47 
48 const void *const __SECTION(".text.boot.vectab1") vectab[] = {
49     /* arm exceptions */
50     initial_stack + sizeof(initial_stack),
51     _start,
52     _nmi, // nmi
53     _hardfault, // hard fault
54     _memmanage, // mem manage
55     _busfault, // bus fault
56     _usagefault, // usage fault
57     0, // reserved
58 #if defined(WITH_DEBUGGER_INFO)
59     (void *) 0x52474244,
60     &_debugger_info,
61 #else
62     0, // reserved
63     0, // reserved
64 #endif
65     0, // reserved
66     _svc, // svcall
67     _debugmonitor, // debug monitor
68     0, // reserved
69     _pendsv, // pendsv
70     _systick, // systick
71 };
72 
73 
74 
75