OpenCores
URL https://opencores.org/ocsvn/potato/potato/trunk

Subversion Repositories potato

[/] [potato/] [trunk/] [benchmarks/] [start.S] - Blame information for rev 65

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 skordal
// The Potato Processor Benchmark Applications
2
// (c) Kristian Klomsten Skordal 2015 
3
// Report bugs and issues on 
4
 
5
// This file contains startup and initialization code for the Potato benchmark
6
// applications.
7
 
8
#include "platform.h"
9 20 skordal
#include "potato.h"
10 13 skordal
 
11
.section .init
12
 
13 58 skordal
.align 6
14
tvec_user: // User mode is not supported by Potato
15
        j tvec_machine
16
.align 6
17
tvec_supervisor: // Supervisor mode is not supported by Potato
18
        j tvec_machine
19
.align 6
20
tvec_hypervisor: // Hypervisor mode is not supported by Potato
21
        j tvec_machine
22
.align 6
23
tvec_machine:
24
        j exception_handler_wrapper
25
 
26
.align 6
27 13 skordal
.global _start
28
_start:
29
 
30
// Copies the .data section into the data memory section:
31
.hidden copy_data
32
copy_data:
33
        la x1, __text_end       // Copy source address
34
        la x2, __data_begin     // Copy destination address
35
        la x3, __data_end       // Copy destination end address
36
 
37
        beq x2, x3, 2f          // Skip if there is no data to copy
38
 
39
1:
40
        lw x4, (x1)
41
        sw x4, (x2)
42
        addi x1, x1, 4
43
        addi x2, x2, 4
44
 
45
        bne x2, x3, 1b          // Repeat as long as there is more data to copy
46
2:
47
 
48
.hidden clear_bss
49
clear_bss:
50
        la x1, __bss_begin
51
        la x2, __bss_end
52
        beq x1, x2, 2f          // Skip if there is no .bss section
53
 
54
1:
55
        sw x0, (x1)
56
        addi x1, x1, 4
57
        bne x1, x2, 1b
58
 
59
2:
60
 
61 65 skordal
.hidden enable_caches
62
enable_caches:
63
        csrsi CSR_PP_CACHECTRL, 1 << CSR_PP_CACHECTRL_ICACHE_EN
64
        fence.i
65
 
66 13 skordal
.hidden call_main
67
call_main:
68
        la sp, __stack_top
69
        jal main
70 58 skordal
        csrw mtohost, a0
71 13 skordal
1:
72
        j 1b
73
 
74
.section .text
75
 
76
.global exception_handler_wrapper
77
exception_handler_wrapper:
78 20 skordal
        // Save all registers (even those that are saved by the IRQ handler
79
        // function, to aid in debugging):
80
        addi sp, sp, -124
81
        sw x1, 0(sp)
82
        sw x2, 4(sp)
83
        sw x3, 8(sp)
84
        sw x4, 12(sp)
85
        sw x5, 16(sp)
86
        sw x6, 20(sp)
87
        sw x7, 24(sp)
88
        sw x8, 28(sp)
89
        sw x9, 32(sp)
90
        sw x10, 36(sp)
91
        sw x11, 40(sp)
92
        sw x12, 44(sp)
93
        sw x13, 48(sp)
94
        sw x14, 52(sp)
95
        sw x15, 56(sp)
96
        sw x16, 60(sp)
97
        sw x17, 64(sp)
98
        sw x18, 68(sp)
99
        sw x19, 72(sp)
100
        sw x20, 76(sp)
101
        sw x21, 80(sp)
102
        sw x22, 84(sp)
103
        sw x23, 88(sp)
104
        sw x24, 92(sp)
105
        sw x25, 96(sp)
106
        sw x26, 100(sp)
107
        sw x27, 104(sp)
108
        sw x28, 108(sp)
109
        sw x29, 112(sp)
110
        sw x30, 116(sp)
111
        sw x31, 120(sp)
112 13 skordal
 
113 58 skordal
        csrr a0, mcause
114
        csrr a1, mepc
115 20 skordal
        mv a2, sp
116 13 skordal
        jal exception_handler
117
 
118 20 skordal
.hidden exception_return
119
exception_return:
120
        // Restore all registers:
121
        lw x1, 0(sp)
122
        lw x2, 4(sp)
123
        lw x3, 8(sp)
124
        lw x4, 12(sp)
125
        lw x5, 16(sp)
126
        lw x6, 20(sp)
127
        lw x7, 24(sp)
128
        lw x8, 28(sp)
129
        lw x9, 32(sp)
130
        lw x10, 36(sp)
131
        lw x11, 40(sp)
132
        lw x12, 44(sp)
133
        lw x13, 48(sp)
134
        lw x14, 52(sp)
135
        lw x15, 56(sp)
136
        lw x16, 60(sp)
137
        lw x17, 64(sp)
138
        lw x18, 68(sp)
139
        lw x19, 72(sp)
140
        lw x20, 76(sp)
141
        lw x21, 80(sp)
142
        lw x22, 84(sp)
143
        lw x23, 88(sp)
144
        lw x24, 92(sp)
145
        lw x25, 96(sp)
146
        lw x26, 100(sp)
147
        lw x27, 104(sp)
148
        lw x28, 108(sp)
149
        lw x29, 112(sp)
150
        lw x30, 116(sp)
151
        lw x31, 120(sp)
152
        addi sp, sp, 124
153 13 skordal
 
154 58 skordal
        eret
155 13 skordal
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.