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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [reset.S] - Blame information for rev 463

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

Line No. Rev Author Line
1 246 julius
#include "spr-defs.h"
2 2 marcus.erl
#include "board.h"
3
 
4 419 julius
#define TRAP_ON_ERROR 0
5
#define LOOP_ON_ERROR 0
6
#define EXIT_NOP_ON_ERROR 1
7
#define PRINT_AND_RESET_ON_ERROR 1
8
 
9 2 marcus.erl
        .extern _src_beg
10
        .extern _dst_beg
11
        .extern _dst_end
12 375 julius
        .extern int_main
13 406 julius
        .extern int_error
14 375 julius
        .extern tick_interrupt
15 2 marcus.erl
        .extern _crc32
16 463 julius
        .extern _bstart
17
        .extern _bend
18 2 marcus.erl
        .global _calc_mycrc32
19
        .global _mycrc32
20
        .global _mysize
21
 
22
        .section .stack, "aw", @nobits
23
.space  STACK_SIZE
24
_stack:
25
        .section .crc
26
_mycrc32:
27
        .word   0xcccccccc
28
_mysize:
29
        .word 0xdddddddd
30
 
31
.if SELF_CHECK
32
_calc_mycrc32:
33
        l.addi  r3,r0,0
34
        l.movhi r4,hi(_calc_mycrc32)
35
        l.ori   r4,r4,lo(_calc_mycrc32)
36
        l.movhi r5,hi(_mysize)
37
        l.ori   r5,r5,lo(_mysize)
38
        l.lwz   r5,0(r5)
39
        l.addi  r1,r1,-4
40
        l.sw    0(r1),r9
41
 
42
        /* unsigned long crc32 (unsigned long crc, const unsigned char *buf, unsigned long len); */
43
        l.jal           _crc32
44
        l.nop
45
 
46
        l.movhi r3,hi(_mycrc32)
47
        l.ori   r3,r3,lo(_mycrc32)
48
        l.lwz   r3,0(r3)
49
 
50
        l.xor     r11,r3,r11
51
        l.lwz   r9,0(r1)
52
        l.jr    r9
53
        l.addi  r1,r1,4
54
.endif
55
 
56
        .org 0x100
57 140 julius
 
58 2 marcus.erl
        .section .vectors, "ax"
59
 
60
_reset:
61 246 julius
        l.movhi r0, 0
62
        /* Clear status register, set supervisor mode */
63
        l.ori r1, r0, SPR_SR_SM
64
        l.mtspr r0, r1, SPR_SR
65
        /* Clear timer  */
66
        l.mtspr r0, r0, SPR_TTMR
67
        /* Jump to start routine */
68 2 marcus.erl
        l.movhi r3,hi(_start)
69
        l.ori   r3,r3,lo(_start)
70
        l.jr    r3
71
        l.nop
72
 
73 140 julius
        .org (0x200 - 0x100 + _reset)
74 463 julius
 
75 140 julius
_buserr:
76 419 julius
.if TRAP_ON_ERROR
77 246 julius
        /* Just trap */
78 140 julius
        l.trap 0
79 246 julius
.endif
80 419 julius
.if EXIT_NOP_ON_ERROR
81 246 julius
        l.nop 0x1
82 419 julius
.endif
83
.if LOOP_ON_ERROR
84 140 julius
        l.j 0
85
        l.nop
86 406 julius
.endif
87 419 julius
.if PRINT_AND_RESET_ON_ERROR
88
        l.mfspr r4, r0, SPR_EPCR_BASE
89
        l.j     _int_error /* This will reset */
90
        l.ori   r3, r0, 0x2
91
.endif
92 2 marcus.erl
        .org (0x500 - 0x100 + _reset)
93 463 julius
 
94 355 julius
_tickint:
95
#define TIMER_RELOAD_VALUE (SPR_TTMR_IE | SPR_TTMR_RT | ((IN_CLK/TICKS_PER_SEC) & SPR_TTMR_PERIOD))
96
        /* Simply load timer_ticks variable and increment */
97
        .extern _timer_ticks
98 419 julius
        l.addi  r1, r1, -136 /* 128 + what we need (8),avoid area used by gcc*/
99 355 julius
        l.sw    0(r1), r25
100
        l.sw    4(r1), r26
101 375 julius
        l.movhi r25, hi(timestamp)
102
        l.ori   r25, r25, lo(timestamp)
103 355 julius
        l.lwz   r26, 0(r25)                     /* Load variable addr.*/
104
        l.addi  r26, r26, 1                     /* Increment variable */
105
        l.sw    0(r25), r26                     /* Store variable */
106
        l.movhi r25, hi(TIMER_RELOAD_VALUE)     /* Load timer value */
107
        l.ori   r25, r25, lo(TIMER_RELOAD_VALUE)
108
        l.mtspr r0, r25, SPR_TTMR               /* Reset timer */
109
        l.lwz   r25, 0(r1)
110
        l.lwz   r26, 4(r1)
111 419 julius
        l.addi  r1, r1, 136
112 355 julius
        l.rfe
113 375 julius
 
114 2 marcus.erl
        .org (0x600 - 0x100 + _reset)
115 463 julius
 
116 140 julius
_alignerr:
117 419 julius
.if TRAP_ON_ERROR
118
        /* Just trap */
119 140 julius
        l.trap 0
120 246 julius
.endif
121 419 julius
.if EXIT_NOP_ON_ERROR
122 246 julius
        l.nop 0x1
123 419 julius
.endif
124
.if LOOP_ON_ERROR
125 140 julius
        l.j 0
126
        l.nop
127 406 julius
.endif
128 419 julius
.if PRINT_AND_RESET_ON_ERROR
129
        l.mfspr r4, r0, SPR_EPCR_BASE
130
        l.j _int_error /* This will reset */
131 406 julius
        l.ori r3, r0, 0x6
132 419 julius
.endif
133 140 julius
 
134
        .org (0x700 - 0x100 + _reset)
135 463 julius
 
136 246 julius
_illinsn:
137 419 julius
.if TRAP_ON_ERROR
138
        /* Just trap */
139 140 julius
        l.trap 0
140 246 julius
.endif
141 419 julius
.if EXIT_NOP_ON_ERROR
142 246 julius
        l.nop 0x1
143 419 julius
.endif
144
.if LOOP_ON_ERROR
145 140 julius
        l.j 0
146
        l.nop
147 406 julius
.endif
148 419 julius
.if PRINT_AND_RESET_ON_ERROR
149
        l.mfspr r4, r0, SPR_EPCR_BASE
150
        l.j _int_error /* This will reset */
151 406 julius
        l.ori r3, r0, 0x7
152 419 julius
.endif
153 2 marcus.erl
        .org (0x800 - 0x100 + _reset)
154 463 julius
 
155 140 julius
_userint:
156 419 julius
        l.addi  r1,r1,-256  /*(128 + 128) */
157 246 julius
        l.sw    0x0(r1),r2
158 419 julius
        l.addi  r2, r1, 256
159 246 julius
        l.sw    0x4(r1), r3
160
        l.movhi r3,hi(_int_wrapper)
161
        l.ori   r3,r3,lo(_int_wrapper)
162
        l.jr    r3
163 2 marcus.erl
        l.nop
164
 
165
        .section .text
166
_start:
167
 
168 246 julius
        /* Instruction cache enable */
169
        /* Check if IC present and skip enabling otherwise */
170
        l.mfspr r24,r0,SPR_UPR
171
        l.andi  r26,r24,SPR_UPR_ICP
172
        l.sfeq  r26,r0
173
        l.bf    .L8
174
        l.nop
175
 
176
        /* Disable IC */
177
        l.mfspr r6,r0,SPR_SR
178
        l.addi  r5,r0,-1
179
        l.xori  r5,r5,SPR_SR_ICE
180
        l.and   r5,r6,r5
181
        l.mtspr r0,r5,SPR_SR
182
 
183
        /* Establish cache block size
184
        If BS=0, 16;
185
        If BS=1, 32;
186
        r14 contain block size
187
        */
188
        l.mfspr r24,r0,SPR_ICCFGR
189
        l.andi  r26,r24,SPR_ICCFGR_CBS
190
        l.srli  r28,r26,7
191
        l.ori   r30,r0,16
192
        l.sll   r14,r30,r28
193
 
194
        /* Establish number of cache sets
195
        r16 contains number of cache sets
196
        r28 contains log(# of cache sets)
197
        */
198
        l.andi  r26,r24,SPR_ICCFGR_NCS
199
        l.srli  r28,r26,3
200
        l.ori   r30,r0,1
201
        l.sll   r16,r30,r28
202
 
203
        /* Invalidate IC */
204
        l.addi  r6,r0,0
205
        l.sll   r5,r14,r28
206
 
207
.L7:
208
        l.mtspr r0,r6,SPR_ICBIR
209
        l.sfne  r6,r5
210
        l.bf    .L7
211
        l.add   r6,r6,r14
212
 
213
        /* Enable IC */
214
        l.mfspr r6,r0,SPR_SR
215
        l.ori   r6,r6,SPR_SR_ICE
216
        l.mtspr r0,r6,SPR_SR
217
        l.nop
218
        l.nop
219
        l.nop
220
        l.nop
221
        l.nop
222
        l.nop
223
        l.nop
224
        l.nop
225
 
226
.L8:
227
        /* Data cache enable */
228
        /* Check if DC present and skip enabling otherwise */
229
        l.mfspr r24,r0,SPR_UPR
230
        l.andi  r26,r24,SPR_UPR_DCP
231
        l.sfeq  r26,r0
232
        l.bf    .L10
233 2 marcus.erl
        l.nop
234 246 julius
        /* Disable DC */
235
        l.mfspr r6,r0,SPR_SR
236
        l.addi  r5,r0,-1
237
        l.xori  r5,r5,SPR_SR_DCE
238
        l.and   r5,r6,r5
239
        l.mtspr r0,r5,SPR_SR
240
        /* Establish cache block size
241
           If BS=0, 16;
242
           If BS=1, 32;
243
           r14 contain block size
244
        */
245
        l.mfspr r24,r0,SPR_DCCFGR
246
        l.andi  r26,r24,SPR_DCCFGR_CBS
247
        l.srli  r28,r26,7
248
        l.ori   r30,r0,16
249
        l.sll   r14,r30,r28
250
        /* Establish number of cache sets
251
           r16 contains number of cache sets
252
           r28 contains log(# of cache sets)
253
        */
254
        l.andi  r26,r24,SPR_DCCFGR_NCS
255
        l.srli  r28,r26,3
256
        l.ori   r30,r0,1
257
        l.sll   r16,r30,r28
258
        /* Invalidate DC */
259
        l.addi  r6,r0,0
260
        l.sll   r5,r14,r28
261
.L9:
262
        l.mtspr r0,r6,SPR_DCBIR
263
        l.sfne  r6,r5
264
        l.bf    .L9
265
        l.add   r6,r6,r14
266
        /* Enable DC */
267
        l.mfspr r6,r0,SPR_SR
268
        l.ori   r6,r6,SPR_SR_DCE
269
        l.mtspr r0,r6,SPR_SR
270 2 marcus.erl
 
271 246 julius
.L10:
272
        /* Set up stack */
273 2 marcus.erl
        l.movhi r1,hi(_stack-4)
274
        l.ori   r1,r1,lo(_stack-4)
275
        l.addi  r2,r0,-3
276
        l.and   r1,r1,r2
277 463 julius
 
278
        /* Clear BSS */
279
        l.movhi r3, hi(_bstart)
280
        l.ori   r3, r3, lo(_bstart)
281
        l.movhi r4, hi(_bend)
282
        l.ori   r4, r4, lo(_bend)
283
.L11:
284
        l.sw    0(r3),r0
285
        l.sfgtu r3, r4
286
        l.bnf   .L11
287
        l.addi  r3, r3, 4
288
 
289 140 julius
 
290 375 julius
        l.movhi r3,hi(main)
291
        l.ori   r3,r3,lo(main)
292 246 julius
        l.jr    r3
293
        l.nop
294 140 julius
 
295 2 marcus.erl
_int_wrapper:
296
 
297 246 julius
        l.sw    0x8(r1), r4
298
        l.sw    0xc(r1), r5
299
        l.sw    0x10(r1), r6
300
        l.sw    0x14(r1), r7
301
        l.sw    0x18(r1), r8
302
        l.sw    0x1c(r1), r9
303
        l.sw    0x20(r1), r10
304
        l.sw    0x24(r1), r11
305
        l.sw    0x28(r1), r12
306
        l.sw    0x2c(r1), r13
307
        l.sw    0x30(r1), r14
308
        l.sw    0x34(r1), r15
309
        l.sw    0x38(r1), r16
310
        l.sw    0x3c(r1), r17
311
        l.sw    0x40(r1), r18
312
        l.sw    0x44(r1), r19
313
        l.sw    0x48(r1), r20
314
        l.sw    0x4c(r1), r21
315
        l.sw    0x50(r1), r22
316
        l.sw    0x54(r1), r23
317
        l.sw    0x58(r1), r24
318
        l.sw    0x5c(r1), r25
319
        l.sw    0x60(r1), r26
320
        l.sw    0x64(r1), r27
321
        l.sw    0x68(r1), r28
322
        l.sw    0x6c(r1), r29
323
        l.sw    0x70(r1), r30
324
        l.sw    0x74(r1), r31
325
 
326 375 julius
        l.movhi r3,hi(int_main)
327
        l.ori   r3,r3,lo(int_main)
328 2 marcus.erl
        l.jalr  r3
329
        l.nop
330
 
331 246 julius
        l.lwz   r3,0x4(r1)
332 2 marcus.erl
        l.lwz   r4,0x8(r1)
333
        l.lwz   r5,0xc(r1)
334
        l.lwz   r6,0x10(r1)
335
        l.lwz   r7,0x14(r1)
336
        l.lwz   r8,0x18(r1)
337
        l.lwz   r9,0x1c(r1)
338
        l.lwz   r10,0x20(r1)
339
        l.lwz   r11,0x24(r1)
340
        l.lwz   r12,0x28(r1)
341
        l.lwz   r13,0x2c(r1)
342
        l.lwz   r14,0x30(r1)
343
        l.lwz   r15,0x34(r1)
344
        l.lwz   r16,0x38(r1)
345
        l.lwz   r17,0x3c(r1)
346
        l.lwz   r18,0x40(r1)
347
        l.lwz   r19,0x44(r1)
348
        l.lwz   r20,0x48(r1)
349
        l.lwz   r21,0x4c(r1)
350
        l.lwz   r22,0x50(r1)
351
        l.lwz   r23,0x54(r1)
352
        l.lwz   r24,0x58(r1)
353
        l.lwz   r25,0x5c(r1)
354
        l.lwz   r26,0x60(r1)
355
        l.lwz   r27,0x64(r1)
356
        l.lwz   r28,0x68(r1)
357
        l.lwz   r29,0x6c(r1)
358
        l.lwz   r30,0x70(r1)
359 246 julius
        l.lwz   r31,0x74(r1)
360 2 marcus.erl
 
361 246 julius
        l.lwz   r2, 0x0(r1)
362 419 julius
        l.addi  r1,r1,256
363 2 marcus.erl
        l.rfe
364
        l.nop
365 246 julius
 
366 2 marcus.erl
 
367 406 julius
        /* Jump to error function. Clobber r2 */
368
_int_error:
369
        l.movhi r2,hi(int_error)
370
        l.ori   r2,r2,lo(int_error)
371
        l.jr  r2
372
        l.nop

powered by: WebSVN 2.1.0

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