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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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