1 | /* |
---|
2 | * Copyright (c) 2015 University of York. |
---|
3 | * Hesham Almatary <hesham@alumni.york.ac.uk> |
---|
4 | * |
---|
5 | * Copyright (c) 2013, The Regents of the University of California (Regents). |
---|
6 | * All Rights Reserved. |
---|
7 | * |
---|
8 | * Redistribution and use in source and binary forms, with or without |
---|
9 | * modification, are permitted provided that the following conditions |
---|
10 | * are met: |
---|
11 | * 1. Redistributions of source code must retain the above copyright |
---|
12 | * notice, this list of conditions and the following disclaimer. |
---|
13 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
14 | * notice, this list of conditions and the following disclaimer in the |
---|
15 | * documentation and/or other materials provided with the distribution. |
---|
16 | * |
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
---|
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
---|
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
27 | * SUCH DAMAGE. |
---|
28 | */ |
---|
29 | #include <bsp/linker-symbols.h> |
---|
30 | #include <rtems/score/riscv-utility.h> |
---|
31 | #include <rtems/score/cpu.h> |
---|
32 | #include <rtems/asm.h> |
---|
33 | |
---|
34 | EXTERN(bsp_section_bss_begin) |
---|
35 | EXTERN(bsp_section_bss_end) |
---|
36 | EXTERN(ISR_Handler) |
---|
37 | EXTERN(bsp_start_vector_table_size) |
---|
38 | EXTERN(bsp_vector_table_size) |
---|
39 | EXTERN(bsp_section_stack_begin) |
---|
40 | |
---|
41 | PUBLIC(bsp_start_vector_table_begin) |
---|
42 | PUBLIC(bsp_start_vector_table_end) |
---|
43 | PUBLIC(_start) |
---|
44 | |
---|
45 | .section .start, "wax" |
---|
46 | TYPE_FUNC(_start) |
---|
47 | SYM(_start): |
---|
48 | li x2, 0 |
---|
49 | li x3, 0 |
---|
50 | li x4, 0 |
---|
51 | li x5, 0 |
---|
52 | li x6, 0 |
---|
53 | li x7, 0 |
---|
54 | li x8, 0 |
---|
55 | li x9, 0 |
---|
56 | li x10, 0 |
---|
57 | li x11, 0 |
---|
58 | li x12, 0 |
---|
59 | li x13, 0 |
---|
60 | li x14, 0 |
---|
61 | li x15, 0 |
---|
62 | li x16, 0 |
---|
63 | li x17, 0 |
---|
64 | li x18, 0 |
---|
65 | li x19, 0 |
---|
66 | li x20, 0 |
---|
67 | li x21, 0 |
---|
68 | li x22, 0 |
---|
69 | li x23, 0 |
---|
70 | li x24, 0 |
---|
71 | li x25, 0 |
---|
72 | li x26, 0 |
---|
73 | li x27, 0 |
---|
74 | li x28, 0 |
---|
75 | li x29, 0 |
---|
76 | li x30, 0 |
---|
77 | li x31, 0 |
---|
78 | |
---|
79 | la t0, ISR_Handler |
---|
80 | csrw mtvec, t0 |
---|
81 | |
---|
82 | /* load stack and frame pointers */ |
---|
83 | la sp, _Configuration_Interrupt_stack_area_end |
---|
84 | |
---|
85 | /* Clearing .bss */ |
---|
86 | la t0, bsp_section_bss_begin |
---|
87 | la t1, bsp_section_bss_end |
---|
88 | |
---|
89 | _loop_clear_bss: |
---|
90 | bge t0, t1, _end_clear_bss |
---|
91 | SREG x0, 0(t0) |
---|
92 | addi t0, t0, CPU_SIZEOF_POINTER |
---|
93 | j _loop_clear_bss |
---|
94 | _end_clear_bss: |
---|
95 | |
---|
96 | /* Init FPU unit if it's there */ |
---|
97 | li t0, MSTATUS_FS |
---|
98 | csrs mstatus, t0 |
---|
99 | |
---|
100 | j boot_card |
---|
101 | |
---|
102 | .align 4 |
---|
103 | bsp_start_vector_table_begin: |
---|
104 | .word _RISCV_Exception_default /* User int */ |
---|
105 | .word _RISCV_Exception_default /* Supervisor int */ |
---|
106 | .word _RISCV_Exception_default /* Reserved */ |
---|
107 | .word _RISCV_Exception_default /* Machine int */ |
---|
108 | .word _RISCV_Exception_default /* User timer int */ |
---|
109 | .word _RISCV_Exception_default /* Supervisor Timer int */ |
---|
110 | .word _RISCV_Exception_default /* Reserved */ |
---|
111 | .word _RISCV_Exception_default /* Machine Timer int */ |
---|
112 | .word _RISCV_Exception_default /* User external int */ |
---|
113 | .word _RISCV_Exception_default /* Supervisor external int */ |
---|
114 | .word _RISCV_Exception_default /* Reserved */ |
---|
115 | .word _RISCV_Exception_default /* Machine external int */ |
---|
116 | .word _RISCV_Exception_default |
---|
117 | .word _RISCV_Exception_default |
---|
118 | .word _RISCV_Exception_default |
---|
119 | .word _RISCV_Exception_default |
---|
120 | bsp_start_vector_table_end: |
---|