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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [or1200/] [crt0.S] - Blame information for rev 733

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 349 julius
#include "spr-defs.h"
2
#include "board.h"
3
 
4
/* ======================================================= [ macros ] === */
5
 
6 470 julius
#define REDZONE 128
7
#define EXCEPTION_STACK_SIZE (128 + REDZONE)
8
 
9 349 julius
#define CLEAR_GPR(gpr) \
10
        l.or    gpr, r0, r0
11
 
12
#define ENTRY(symbol)    \
13
        .global symbol ; \
14
symbol:
15
 
16
#define LOAD_SYMBOL_2_GPR(gpr,symbol)  \
17
        .global symbol ;               \
18
        l.movhi gpr, hi(symbol) ;      \
19
        l.ori   gpr, gpr, lo(symbol)
20
 
21
        // Really goes to configurable interrupt handler
22 470 julius
#define EXCEPTION_HANDLER            \
23
        l.addi  r1, r1, -EXCEPTION_STACK_SIZE;          \
24 349 julius
        l.sw    4(r1), r3;             \
25
        l.sw    8(r1), r4;             \
26
        l.mfspr r3,r0,SPR_NPC;          \
27
        l.mfspr r4,r0,SPR_EPCR_BASE;   \
28
        l.j default_exception_handler; \
29
        l.nop
30
 
31
/* =================================================== [ exceptions ] === */
32
        .section .vectors, "ax"
33
 
34
/* ---[ 0x100: RESET exception ]----------------------------------------- */
35
        .org 0x100
36
        l.movhi r0, 0
37 485 julius
        l.movhi r1, 0
38
        l.movhi r2, 0
39
        l.movhi r3, 0
40
        l.movhi r4, 0
41
        l.movhi r5, 0
42
        l.movhi r6, 0
43
        l.movhi r7, 0
44
        l.movhi r8, 0
45
        l.movhi r9, 0
46
        l.movhi r10, 0
47
        l.movhi r11, 0
48
        l.movhi r12, 0
49
        l.movhi r13, 0
50
        l.movhi r14, 0
51
        l.movhi r15, 0
52
        l.movhi r16, 0
53
        l.movhi r17, 0
54
        l.movhi r18, 0
55
        l.movhi r19, 0
56
        l.movhi r20, 0
57
        l.movhi r21, 0
58
        l.movhi r22, 0
59
        l.movhi r23, 0
60
        l.movhi r24, 0
61
        l.movhi r25, 0
62
        l.movhi r26, 0
63
        l.movhi r27, 0
64
        l.movhi r28, 0
65
        l.movhi r29, 0
66
        l.movhi r30, 0
67
        l.movhi r31, 0
68 530 julius
 
69 349 julius
        /* Clear status register, set supervisor mode */
70
        l.ori r1, r0, SPR_SR_SM
71
        l.mtspr r0, r1, SPR_SR
72
        /* Clear timer  */
73
        l.mtspr r0, r0, SPR_TTMR
74
        /* Early Stack initilization */
75
        LOAD_SYMBOL_2_GPR(r1, _stack)
76
        l.addi  r2, r0, -3
77
        l.and   r1, r1, r2
78
 
79
        /* Jump to program initialisation code */
80
        LOAD_SYMBOL_2_GPR(r4, _start)
81
        l.jr    r4
82
        l.nop
83
 
84
/* ---[ 0x200: BUS exception ]------------------------------------------- */
85
        .org 0x200
86 470 julius
        EXCEPTION_HANDLER
87 349 julius
 
88
/* ---[ 0x300: Data Page Fault exception ]------------------------------- */
89
        .org 0x300
90 470 julius
        EXCEPTION_HANDLER
91 349 julius
 
92
/* ---[ 0x400: Insn Page Fault exception ]------------------------------- */
93
        .org 0x400
94 470 julius
        EXCEPTION_HANDLER
95 349 julius
 
96
/* ---[ 0x500: Timer exception ]----------------------------------------- */
97
        .org 0x500
98 488 julius
        EXCEPTION_HANDLER
99
 
100 349 julius
/* ---[ 0x600: Aligment exception ]-------------------------------------- */
101
        .org 0x600
102 470 julius
        EXCEPTION_HANDLER
103 349 julius
 
104
/* ---[ 0x700: Illegal insn exception ]---------------------------------- */
105
        .org 0x700
106 470 julius
        EXCEPTION_HANDLER
107 349 julius
 
108
/* ---[ 0x800: External interrupt exception ]---------------------------- */
109
        .org 0x800
110 470 julius
        EXCEPTION_HANDLER
111 349 julius
 
112
/* ---[ 0x900: DTLB miss exception ]------------------------------------- */
113
        .org 0x900
114 470 julius
        EXCEPTION_HANDLER
115 349 julius
 
116
/* ---[ 0xa00: ITLB miss exception ]------------------------------------- */
117
        .org 0xa00
118 470 julius
        EXCEPTION_HANDLER
119
 
120 349 julius
/* ---[ 0xb00: Range exception ]----------------------------------------- */
121
        .org 0xb00
122 470 julius
        EXCEPTION_HANDLER
123 349 julius
 
124
/* ---[ 0xc00: Syscall exception ]--------------------------------------- */
125
        .org 0xc00
126 470 julius
        EXCEPTION_HANDLER
127 349 julius
 
128 470 julius
/* ---[ 0xd00: FPU exception ]------------------------------------------- */
129 349 julius
        .org 0xd00
130 470 julius
        EXCEPTION_HANDLER
131 349 julius
 
132
/* ---[ 0xe00: Trap exception ]------------------------------------------ */
133
        .org 0xe00
134 470 julius
        EXCEPTION_HANDLER
135 349 julius
 
136 470 julius
/* ---[ 0xf00 - 0x1400: Reserved exceptions ]---------------------------- */
137
/*
138 349 julius
        .org 0xf00
139 470 julius
        EXCEPTION_HANDLER
140
 
141 349 julius
        .org 0x1000
142 470 julius
        EXCEPTION_HANDLER
143 349 julius
 
144
        .org 0x1100
145 470 julius
        EXCEPTION_HANDLER
146 349 julius
 
147
        .org 0x1200
148 470 julius
        EXCEPTION_HANDLER
149 349 julius
 
150
        .org 0x1300
151 470 julius
        EXCEPTION_HANDLER
152 349 julius
 
153
        .org 0x1400
154 470 julius
        EXCEPTION_HANDLER
155 349 julius
 
156 470 julius
*/
157
/* ---[ 0x1500 - 0x1800: Implementation-specific exceptions ]------------ */
158
/*
159 349 julius
        .org 0x1500
160 470 julius
        EXCEPTION_HANDLER
161 349 julius
 
162
        .org 0x1600
163 470 julius
        EXCEPTION_HANDLER
164 349 julius
 
165
        .org 0x1700
166 470 julius
        EXCEPTION_HANDLER
167 349 julius
 
168
        .org 0x1800
169 470 julius
        EXCEPTION_HANDLER
170
*/
171
/* ---[ 0x1500 - 0x1F00: Custom exceptions ]----------------------------- */
172
/*
173 349 julius
        .org 0x1900
174 470 julius
        EXCEPTION_HANDLER
175 349 julius
 
176
        .org 0x1a00
177 470 julius
        EXCEPTION_HANDLER
178 349 julius
 
179
        .org 0x1b00
180 470 julius
        EXCEPTION_HANDLER
181 349 julius
 
182
        .org 0x1c00
183 470 julius
        EXCEPTION_HANDLER
184 349 julius
 
185
        .org 0x1d00
186 470 julius
        EXCEPTION_HANDLER
187 349 julius
 
188
        .org 0x1e00
189 470 julius
        EXCEPTION_HANDLER
190 349 julius
 
191
        .org 0x1f00
192 470 julius
        EXCEPTION_HANDLER
193 349 julius
*/
194
 
195
/* ========================================================= [ entry ] === */
196
        .section .text
197
 
198
ENTRY(_start)
199
 
200 530 julius
        /* Cache initialisation */
201
        l.jal _cache_init
202 349 julius
        l.nop
203
 
204
        /* Clear BSS */
205 530 julius
        LOAD_SYMBOL_2_GPR(r5, _bss_start)
206
        LOAD_SYMBOL_2_GPR(r6, _bss_end)
207 349 julius
1:
208 530 julius
        l.sw    (0)(r5), r0
209
        l.sfltu r5, r6
210 349 julius
        l.bf    1b
211 530 julius
        l.addi  r5, r5, 4
212 349 julius
 
213
        /* Jump to main program entry point (argc = argv = 0) */
214
        CLEAR_GPR(r3)
215
        CLEAR_GPR(r4)
216 373 julius
        l.jal   main
217 349 julius
        l.nop
218
 
219
        /* If program exits, call exit routine */
220
        l.addi  r3, r11, 0
221 373 julius
        l.jal   exit
222 349 julius
        l.nop
223
 
224
 
225
/* ====================================== [ default exception handler ] === */
226
 
227
default_exception_handler:
228
        l.sw    0x00(r1), r2
229
        l.sw    0x0c(r1), r5
230
        l.sw    0x10(r1), r6
231
        l.sw    0x14(r1), r7
232
        l.sw    0x18(r1), r8
233
        l.sw    0x1c(r1), r9
234
        l.sw    0x20(r1), r10
235
        l.sw    0x24(r1), r11
236
        l.sw    0x28(r1), r12
237
        l.sw    0x2c(r1), r13
238
        l.sw    0x30(r1), r14
239
        l.sw    0x34(r1), r15
240
        l.sw    0x38(r1), r16
241
        l.sw    0x3c(r1), r17
242
        l.sw    0x40(r1), r18
243
        l.sw    0x44(r1), r19
244
        l.sw    0x48(r1), r20
245
        l.sw    0x4c(r1), r21
246
        l.sw    0x50(r1), r22
247
        l.sw    0x54(r1), r23
248
        l.sw    0x58(r1), r24
249
        l.sw    0x5c(r1), r25
250
        l.sw    0x60(r1), r26
251
        l.sw    0x64(r1), r27
252
        l.sw    0x68(r1), r28
253
        l.sw    0x6c(r1), r29
254
        l.sw    0x70(r1), r30
255
        l.sw    0x74(r1), r31
256
        l.sw    0x78(r1), r32
257 530 julius
 
258 373 julius
        l.jal   default_exception_handler_c
259 349 julius
        l.nop
260
 
261
        l.lwz    r2, 0x00(r1)
262
        l.lwz    r3, 0x04(r1)
263
        l.lwz    r4, 0x08(r1)
264
        l.lwz    r5, 0x0c(r1)
265
        l.lwz    r6, 0x10(r1)
266
        l.lwz    r7, 0x14(r1)
267
        l.lwz    r8, 0x18(r1)
268
        l.lwz    r9, 0x1c(r1)
269
        l.lwz    r10, 0x20(r1)
270
        l.lwz    r11, 0x24(r1)
271
        l.lwz    r12, 0x28(r1)
272
        l.lwz    r13, 0x2c(r1)
273
        l.lwz    r14, 0x30(r1)
274
        l.lwz    r15, 0x34(r1)
275
        l.lwz    r16, 0x38(r1)
276
        l.lwz    r17, 0x3c(r1)
277
        l.lwz    r18, 0x40(r1)
278
        l.lwz    r19, 0x44(r1)
279
        l.lwz    r20, 0x48(r1)
280
        l.lwz    r21, 0x4c(r1)
281
        l.lwz    r22, 0x50(r1)
282
        l.lwz    r23, 0x54(r1)
283
        l.lwz    r24, 0x58(r1)
284
        l.lwz    r25, 0x5c(r1)
285
        l.lwz    r26, 0x60(r1)
286
        l.lwz    r27, 0x64(r1)
287
        l.lwz    r28, 0x68(r1)
288
        l.lwz    r29, 0x6c(r1)
289
        l.lwz    r30, 0x70(r1)
290
        l.lwz    r31, 0x74(r1)
291
        l.lwz    r32, 0x78(r1)
292
 
293 470 julius
        l.addi  r1, r1, EXCEPTION_STACK_SIZE
294 349 julius
 
295
        l.rfe
296
        l.nop
297
 

powered by: WebSVN 2.1.0

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