/* * Copyright (C) 2017-2019 Alibaba Group Holding Limited. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /****************************************************************************** * @file startup.S * @brief startup file. Should use with * GCC for CSKY Embedded Processors * @version V1.0 * @date 29. July 2019 ******************************************************************************/ #include .section .vectors, "aw", @progbits .align 6 .globl __Vectors .type __Vectors, @object __Vectors: #if 0 .rept 256 .long freertos_risc_v_trap_handler .endr #endif #if 1 .long Default_Handler .long Default_Handler .long Default_Handler #ifndef CONFIG_KERNEL_NONE .long freertos_risc_v_trap_handler #else .long Default_Handler #endif .long Default_Handler .long Default_Handler .long Default_Handler .long Default_IRQHandler .long Default_Handler .long Default_Handler .long Default_Handler .long Default_Handler .long Default_Handler .long Default_Handler .long Default_Handler .long Default_Handler /* External interrupts */ .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler .long Default_IRQHandler #endif .text .align 2 _start: .text .align 2 .globl Reset_Handler .type Reset_Handler, %function Reset_Handler: .option push .option norelax la gp, __global_pointer$ .option pop la a0, Default_Handler ori a0, a0, 3 csrw mtvec, a0 la a0, __Vectors csrw mtvt, a0 la sp, g_top_irqstack csrw mscratch, sp /* Load data section */ la a0, __erodata la a1, __data_start__ la a2, __data_end__ bgeu a1, a2, 2f 1: lw t0, (a0) sw t0, (a1) addi a0, a0, 4 addi a1, a1, 4 bltu a1, a2, 1b 2: /* Clear bss section */ la a0, __bss_start__ la a1, __bss_end__ bgeu a0, a1, 2f 1: sw zero, (a0) addi a0, a0, 4 bltu a0, a1, 1b 2: #ifndef __NO_SYSTEM_INIT jal SystemInit #endif #ifndef __NO_BOARD_INIT jal board_init #endif jal main .size Reset_Handler, . - Reset_Handler __exit: j __exit .section .bss .align 3 .global g_base_irqstack .global g_top_irqstack g_base_irqstack: .space CONFIG_ARCH_INTERRUPTSTACK g_top_irqstack: .align 3 .global __freertos_irq_stack_top .space CONFIG_ARCH_INTERRUPTSTACK __freertos_irq_stack_top: