1/*
2 * Copyright (C) 2016-2020 Bouffalo Lab
3 */
4
5    .section .init
6    .align  2
7    .globl  __start
8    .type   __start, %function
9__start:
10.option push
11.option norelax
12    la      gp, __global_pointer$
13.option pop
14    csrci   mstatus, 8
15
16    /* mtvec: for all exceptions and non-vector mode IRQs */
17    la      a0, default_trap_handler
18    ori     a0, a0, 3
19    csrw    mtvec, a0
20
21    /* mtvt: for all vector mode IRQs */
22    la      a0, __Vectors
23    csrw    mtvt, a0
24
25#if defined(__riscv_flen)
26    /* FP: initial state */
27    csrr    t0, mstatus
28    li      t1, ~0x6000
29    and     t0, t0, t1
30    li      t1, 0x2000
31    or      t0, t0, t1
32    csrw    mstatus, t0
33    /* csrwi   fcsr, 0 */
34#endif
35
36    .weak __StackTop
37    la      sp, __StackTop
38    csrw    mscratch, sp
39
40    /* Load data section removed */
41
42    /* Clear bss section removed */
43
44    jal     SystemInit
45
46    /* start load code to itcm like. */
47    jal     start_load
48
49    jal     System_Post_Init
50
51    jal     entry
52
53    .size   __start, . - __start
54
55__exit:
56    j      __exit
57
58