1 /*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include "rk3399_mcu.h"
8
9 /* Stack configuration */
10 #define STACK_SIZE 0x00000100
11 __attribute__ ((section(".co_stack")))
12 unsigned long pstack[STACK_SIZE];
13
14 /* Macro definition */
15 #define WEAK __attribute__ ((weak))
16
17 /* System exception vector handler */
18 __attribute__ ((used))
19 void WEAK reset_handler(void);
20 void WEAK nmi_handler(void);
21 void WEAK hardware_fault_handler(void);
22 void WEAK svc_handler(void);
23 void WEAK pend_sv_handler(void);
24 void WEAK systick_handler(void);
25
26 extern int main(void);
27
28 /* Function prototypes */
29 static void default_reset_handler(void);
30 static void default_handler(void);
31
32 /*
33 * The minimal vector table for a Cortex M3. Note that the proper constructs
34 * must be placed on this to ensure that it ends up at physical address
35 * 0x00000000.
36 */
37 __attribute__ ((used, section(".isr_vector")))
38 void (* const g_pfnVectors[])(void) = {
39 /* core Exceptions */
40 (void *)&pstack[STACK_SIZE], /* the initial stack pointer */
41 reset_handler,
42 nmi_handler,
43 hardware_fault_handler,
44 0, 0, 0, 0, 0, 0, 0,
45 svc_handler,
46 0, 0,
47 pend_sv_handler,
48 systick_handler,
49
50 /* external exceptions */
51 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0
56 };
57
58 /**
59 * This is the code that gets called when the processor first
60 * starts execution following a reset event. Only the absolutely
61 * necessary set is performed, after which the application
62 * supplied main() routine is called.
63 */
default_reset_handler(void)64 static void default_reset_handler(void)
65 {
66 /* call the application's entry point */
67 main();
68 }
69
70 /**
71 * Provide weak aliases for each Exception handler to the Default_Handler.
72 * As they are weak aliases, any function with the same name will override
73 * this definition.
74 */
75 #pragma weak reset_handler = default_reset_handler
76 #pragma weak nmi_handler = default_handler
77 #pragma weak hardware_fault_handler = default_handler
78 #pragma weak svc_handler = default_handler
79 #pragma weak pend_sv_handler = default_handler
80 #pragma weak systick_handler = default_handler
81
82 /**
83 * This is the code that gets called when the processor receives
84 * an unexpected interrupt. This simply enters an infinite loop,
85 * preserving the system state for examination by a debugger.
86 */
default_handler(void)87 static void default_handler(void)
88 {
89 /* go into an infinite loop. */
90 while (1)
91 ;
92 }
93