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

Subversion Repositories potato

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

Go to most recent revision | 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
.global _start
14
_start:
15
 
16
// Copies the .data section into the data memory section:
17
.hidden copy_data
18
copy_data:
19
        la x1, __text_end       // Copy source address
20
        la x2, __data_begin     // Copy destination address
21
        la x3, __data_end       // Copy destination end address
22
 
23
        beq x2, x3, 2f          // Skip if there is no data to copy
24
 
25
1:
26
        lw x4, (x1)
27
        sw x4, (x2)
28
        addi x1, x1, 4
29
        addi x2, x2, 4
30
 
31
        bne x2, x3, 1b          // Repeat as long as there is more data to copy
32
2:
33
 
34
.hidden clear_bss
35
clear_bss:
36
        la x1, __bss_begin
37
        la x2, __bss_end
38
        beq x1, x2, 2f          // Skip if there is no .bss section
39
 
40
1:
41
        sw x0, (x1)
42
        addi x1, x1, 4
43
        bne x1, x2, 1b
44
 
45
2:
46
 
47
.hidden set_evec
48
set_evec:
49
        // Set up an exception handler:
50
        la x1, exception_handler_wrapper
51
        csrw evec, x1
52
 
53
.hidden call_main
54
call_main:
55
        la sp, __stack_top
56
        jal main
57
        csrw tohost, a0
58
1:
59
        j 1b
60
 
61
.section .text
62
 
63
.global exception_handler_wrapper
64
exception_handler_wrapper:
65 20 skordal
        // Save all registers (even those that are saved by the IRQ handler
66
        // function, to aid in debugging):
67
        addi sp, sp, -124
68
        sw x1, 0(sp)
69
        sw x2, 4(sp)
70
        sw x3, 8(sp)
71
        sw x4, 12(sp)
72
        sw x5, 16(sp)
73
        sw x6, 20(sp)
74
        sw x7, 24(sp)
75
        sw x8, 28(sp)
76
        sw x9, 32(sp)
77
        sw x10, 36(sp)
78
        sw x11, 40(sp)
79
        sw x12, 44(sp)
80
        sw x13, 48(sp)
81
        sw x14, 52(sp)
82
        sw x15, 56(sp)
83
        sw x16, 60(sp)
84
        sw x17, 64(sp)
85
        sw x18, 68(sp)
86
        sw x19, 72(sp)
87
        sw x20, 76(sp)
88
        sw x21, 80(sp)
89
        sw x22, 84(sp)
90
        sw x23, 88(sp)
91
        sw x24, 92(sp)
92
        sw x25, 96(sp)
93
        sw x26, 100(sp)
94
        sw x27, 104(sp)
95
        sw x28, 108(sp)
96
        sw x29, 112(sp)
97
        sw x30, 116(sp)
98
        sw x31, 120(sp)
99 13 skordal
 
100
        csrr a0, cause
101
        csrr a1, epc
102 20 skordal
        mv a2, sp
103 13 skordal
        jal exception_handler
104
 
105 20 skordal
.hidden exception_return
106
exception_return:
107
        // Restore all registers:
108
        lw x1, 0(sp)
109
        lw x2, 4(sp)
110
        lw x3, 8(sp)
111
        lw x4, 12(sp)
112
        lw x5, 16(sp)
113
        lw x6, 20(sp)
114
        lw x7, 24(sp)
115
        lw x8, 28(sp)
116
        lw x9, 32(sp)
117
        lw x10, 36(sp)
118
        lw x11, 40(sp)
119
        lw x12, 44(sp)
120
        lw x13, 48(sp)
121
        lw x14, 52(sp)
122
        lw x15, 56(sp)
123
        lw x16, 60(sp)
124
        lw x17, 64(sp)
125
        lw x18, 68(sp)
126
        lw x19, 72(sp)
127
        lw x20, 76(sp)
128
        lw x21, 80(sp)
129
        lw x22, 84(sp)
130
        lw x23, 88(sp)
131
        lw x24, 92(sp)
132
        lw x25, 96(sp)
133
        lw x26, 100(sp)
134
        lw x27, 104(sp)
135
        lw x28, 108(sp)
136
        lw x29, 112(sp)
137
        lw x30, 116(sp)
138
        lw x31, 120(sp)
139
        addi sp, sp, 124
140 13 skordal
 
141
        sret
142
 

powered by: WebSVN 2.1.0

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