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