blob: dba031370ce8d15a46e8cef849eb2ce6e07a922c [file] [log] [blame]
Caesar Wangb4003742016-10-12 08:10:12 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Caesar Wangb4003742016-10-12 08:10:12 +08005 */
6
7#include "rk3399_mcu.h"
8
9/* Stack configuration */
Lin Huang00960ba2018-04-20 15:55:21 +080010#define STACK_SIZE 0x00000040
Caesar Wangb4003742016-10-12 08:10:12 +080011__attribute__ ((section(".co_stack")))
12unsigned long pstack[STACK_SIZE];
13
14/* Macro definition */
15#define WEAK __attribute__ ((weak))
16
17/* System exception vector handler */
18__attribute__ ((used))
19void WEAK reset_handler(void);
20void WEAK nmi_handler(void);
21void WEAK hardware_fault_handler(void);
22void WEAK svc_handler(void);
23void WEAK pend_sv_handler(void);
24void WEAK systick_handler(void);
25
26extern int main(void);
27
28/* Function prototypes */
29static void default_reset_handler(void);
30static 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")))
38void (* 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 */
64static 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 */
87static void default_handler(void)
88{
89 /* go into an infinite loop. */
90 while (1)
91 ;
92}