1/* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 * Description: main 15 * 16 * Create: 2021-03-09 17 */ 18 19 .section .text.entry 20 .global _start 21 .option norvc 22_start: 23 j Reset_Handler 24 25Reset_Handler: 26 li t0,0x0 27 csrw pmpcfg0,t0 28 li t0,0x0 29 csrw pmpcfg1,t0 30 li t0,0x0 31 csrw pmpcfg2,t0 32 li t0,0x0 33 csrw pmpcfg3,t0 34 li t0,0x0 35 csrw 0x7d9,t0 36 la t0, __flash_boot_flag_begin__ 37 mv t1, a0 38 lw t3, (t1) 39 sw t3, (t0) 40 la t0, trap_vector 41 addi t0, t0, 1 42 csrw mtvec, t0 43 csrwi mstatus, 0 44 csrwi mie, 0 45 46 # initialize global pointer 47 la gp, _gp_ 48 49 # initialize stack pointer 50 la sp, __stack_top__ 51 52 /* init stack */ 53 la t0, g_system_stack_begin 54 la t1, g_system_stack_end 55 beq t0, t1, end_set_stack_loop 56 li t2, 0xefbeadde 57 58set_stack_loop: 59 sw t2, (t0) 60 addi t0, t0, 4 61 blt t0, t1, set_stack_loop 62end_set_stack_loop: 63 64 /* clear reg */ 65 li ra, 0 66 li tp, 0 67 li s0, 0 68 li s1, 0 69 li a0, 0 70 li a1, 0 71 li a2, 0 72 li a3, 0 73 li a4, 0 74 li a5, 0 75 li a6, 0 76 li a7, 0 77 li s2, 0 78 li s3, 0 79 li s4, 0 80 li s5, 0 81 li s6, 0 82 li s7, 0 83 li s8, 0 84 li s9, 0 85 li s10, 0 86 li s11, 0 87 li t3, 0 88 li t4, 0 89 li t5, 0 90 li t6, 0 91 92 /* clear bss section */ 93 la t0, __bss_begin__ 94 la t1, __bss_end__ 95 beq t0, t1, end_clear_bss_loop 96 li t2, 0x00000000 97 98clear_bss_loop: 99 sw t2, (t0) 100 addi t0, t0, 4 101 blt t0, t1, clear_bss_loop 102end_clear_bss_loop: 103 104 j start_fastboot 105