1/* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "soc.h" 17 18.macro PUSH_CALLER_REG 19 addi sp, sp, -(INT_SIZE_ON_STACK) 20 SREG t6, 16 * REGBYTES(sp) 21 SREG t5, 17 * REGBYTES(sp) 22 SREG t4, 18 * REGBYTES(sp) 23 SREG t3, 19 * REGBYTES(sp) 24 SREG a7, 20 * REGBYTES(sp) 25 SREG a6, 21 * REGBYTES(sp) 26 SREG a5, 22 * REGBYTES(sp) 27 SREG a4, 23 * REGBYTES(sp) 28 SREG a3, 24 * REGBYTES(sp) 29 SREG a2, 25 * REGBYTES(sp) 30 SREG a1, 26 * REGBYTES(sp) 31 SREG a0, 27 * REGBYTES(sp) 32 SREG t2, 28 * REGBYTES(sp) 33 SREG t1, 29 * REGBYTES(sp) 34 SREG t0, 30 * REGBYTES(sp) 35 SREG ra, 31 * REGBYTES(sp) 36.endm 37 38.extern memset 39.global _start 40.section .start.text 41.align 4 42_start: 43 li t0, RISCV_MSTATUS_MPP 44 csrw mstatus, t0 45 csrw mie, zero 46 la t0, HalTrapVector 47 csrw mtvec, t0 # direct mode 48 49 .option push 50 .option norelax 51 la gp, __global_pointer$ 52 .option pop 53 54 la t0, __bss_start 55 la t1, __bss_end 562: 57 sw zero, 0x0(t0) 58 addi t0, t0, 0x4 59 bgtu t1, t0, 2b 60 61 la sp, __start_and_irq_stack_top 62 63 tail main 64