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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orpmon/] [reset.S] - Blame information for rev 824

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

Line No. Rev Author Line
1 809 simons
#include "spr_defs.h"
2
#include "board.h"
3
#include "mc.h"
4
 
5
 
6
 
7
        .extern _reset_support
8
        .extern _eth_int
9
        .extern _src_beg
10
        .extern _dst_beg
11
        .extern _dst_end
12
        .extern _c_reset
13
        .extern _int_main
14 820 markom
        .extern _crc32
15 816 markom
 
16
        /* Used by global.src_addr for default value */
17
        .extern _src_addr
18 809 simons
 
19
        .global _lolev_ie
20
        .global _lolev_idis
21 817 simons
        .global _align
22 820 markom
        .global _calc_mycrc32
23 822 markom
        .global _mycrc32
24
        .global _mysize
25 809 simons
 
26 817 simons
        .section .stack, "aw", @nobits
27
.space  STACK_SIZE
28 809 simons
_stack:
29 820 markom
                                .section .crc
30
_mycrc32:
31
        .word   0xcccccccc
32
_mysize:
33
        .word 0xdddddddd
34 809 simons
 
35 820 markom
_calc_mycrc32:
36
                                l.addi  r3,r0,0
37
        l.movhi r4,hi(_calc_mycrc32)
38
        l.ori   r4,r4,lo(_calc_mycrc32)
39
        l.movhi r5,hi(_mysize)
40
        l.ori   r5,r5,lo(_mysize)
41
        l.lwz   r5,0(r5)
42 822 markom
        l.addi  r1,r1,-4
43
                                l.sw    0(r1),r9
44 820 markom
 
45
        /* unsigned long crc32 (unsigned long crc, const unsigned char *buf, unsigned long len); */
46
                                l.jal           _crc32
47
                                l.nop
48
 
49
                                l.movhi r3,hi(_mycrc32)
50
        l.ori   r3,r3,lo(_mycrc32)
51
        l.lwz   r3,0(r3)
52
 
53 822 markom
        l.xor     r11,r3,r11
54
        l.lwz   r9,0(r1)
55
        l.jr    r9
56
        l.addi  r1,r1,4
57
 
58 820 markom
                                .org 0x100
59
 
60 809 simons
.if IN_FLASH
61
        .section .reset, "ax"
62
.else
63 817 simons
        .section .vectors, "ax"
64 809 simons
.endif
65
 
66
_reset:
67
.if IN_FLASH
68 817 simons
        l.movhi r3,hi(MC_BASE_ADDR)
69 809 simons
        l.ori   r3,r3,MC_BA_MASK
70
        l.addi  r5,r0,0x00
71
        l.sw    0(r3),r5
72
.endif
73 824 markom
        l.movhi r3,hi(_start1)
74
        l.ori   r3,r3,lo(_start1)
75 809 simons
        l.jr    r3
76
 
77
.if IN_FLASH
78
        .section .vectors, "ax"
79 824 markom
        .org 0x600
80
.else
81
        .org (0x600 - 0x100 + _reset)
82 809 simons
.endif
83
 
84 817 simons
        l.j     _align
85
        l.nop
86
 
87 824 markom
.if IN_FLASH
88 817 simons
        .org 0x800
89 824 markom
.else
90
        .org (0x800 - 0x100 + _reset)
91
.endif
92 817 simons
 
93 809 simons
        l.j     _int_wrapper
94
        l.nop
95
 
96
        .section .text
97 824 markom
_start1:
98 809 simons
.if IN_FLASH
99
        l.jal   _init_mc
100
        l.nop
101
 
102
        /* Wait for SDRAM */
103
        l.addi  r3,r0,0x0000  /* igor zmanjsal iz 0x7fff na 0x0000 */
104
1:      l.sfeqi r3,0
105
        l.bnf   1b
106
        l.addi  r3,r3,-1
107
.endif
108 817 simons
        /* Copy form flash to sram */
109 809 simons
.if IN_FLASH
110
        l.movhi r3,hi(_src_beg)
111
        l.ori   r3,r3,lo(_src_beg)
112
        l.movhi r4,hi(_vec_start)
113
        l.ori   r4,r4,lo(_vec_start)
114
        l.movhi r5,hi(_vec_end)
115
        l.ori   r5,r5,lo(_vec_end)
116
        l.sub   r5,r5,r4
117
        l.sfeqi r5,0
118
        l.bf    2f
119
        l.nop
120
1:      l.lwz   r6,0(r3)
121
        l.sw    0(r4),r6
122
        l.addi  r3,r3,4
123
        l.addi  r4,r4,4
124
        l.addi  r5,r5,-4
125
        l.sfgtsi r5,0
126 817 simons
        l.bf    1b
127 809 simons
        l.nop
128
2:
129
        l.movhi r4,hi(_dst_beg)
130
        l.ori   r4,r4,lo(_dst_beg)
131
        l.movhi r5,hi(_dst_end)
132
        l.ori   r5,r5,lo(_dst_end)
133
1:      l.sfgeu r4,r5
134
        l.bf    1f
135
        l.nop
136
        l.lwz   r8,0(r3)
137
        l.sw    0(r4),r8
138
        l.addi  r3,r3,4
139
        l.bnf   1b
140
        l.addi  r4,r4,4
141
1:
142
        l.addi  r3,r0,0
143
        l.addi  r4,r0,0
144
3:
145
.endif
146
 
147
.if IC_ENABLE
148 817 simons
  l.jal _ic_enable
149
  l.nop
150 809 simons
.endif
151
 
152
.if DC_ENABLE
153 817 simons
  l.jal _dc_enable
154
  l.nop
155 809 simons
.endif
156
 
157
        l.movhi r1,hi(_stack-4)
158
        l.addi  r1,r1,lo(_stack-4)
159 817 simons
  l.addi  r2,r0,-3
160
  l.and r1,r1,r2
161 809 simons
 
162
        l.movhi r2,hi(_main)
163
        l.ori   r2,r2,lo(_main)
164
        l.jr    r2
165
        l.addi  r2,r0,0
166
 
167
_ic_enable:
168
 
169
        /* Flush IC */
170
        l.addi  r10,r0,0
171
        l.addi  r11,r0,IC_SIZE
172
1:
173
        l.mtspr r0,r10,SPR_ICBIR
174
        l.sfne  r10,r11
175
        l.bf    1b
176
        l.addi  r10,r10,16
177
 
178
        /* Enable IC */
179
        l.addi  r10,r0,(SPR_SR_ICE|SPR_SR_SM)
180
        l.mtspr r0,r10,SPR_SR
181
        l.nop
182
        l.nop
183
        l.nop
184
        l.nop
185
        l.nop
186
 
187 817 simons
  l.jr  r9
188
  l.nop
189 809 simons
 
190
_dc_enable:
191
 
192
        /* Flush DC */
193
        l.addi  r10,r0,0
194
        l.addi  r11,r0,DC_SIZE
195
1:
196
        l.mtspr r0,r10,SPR_DCBIR
197
        l.sfne  r10,r11
198
        l.bf    1b
199
        l.addi  r10,r10,16
200
 
201
        /* Enable DC */
202
        l.addi  r10,r0,(SPR_SR_DCE|SPR_SR_SM)
203
        l.mtspr r0,r10,SPR_SR
204
 
205 817 simons
  l.jr  r9
206
  l.nop
207 809 simons
 
208
.if IN_FLASH
209
_init_mc:
210
 
211 817 simons
        l.movhi r3,hi(MC_BASE_ADDR)
212
        l.ori   r3,r3,lo(MC_BASE_ADDR)
213 809 simons
 
214
        l.addi  r4,r3,MC_CSC(0)
215 817 simons
        l.movhi r5,hi(FLASH_BASE_ADDR)
216 809 simons
        l.srai  r5,r5,5
217
        l.ori   r5,r5,0x0025
218
        l.sw    0(r4),r5
219
 
220
        l.addi  r4,r3,MC_TMS(0)
221
        l.movhi r5,hi(FLASH_TMS_VAL)
222
        l.ori   r5,r5,lo(FLASH_TMS_VAL)
223
        l.sw    0(r4),r5
224
 
225
        l.addi  r4,r3,MC_BA_MASK
226
        l.addi  r5,r0,MC_MASK_VAL
227
        l.sw    0(r4),r5
228
 
229
        l.addi  r4,r3,MC_CSR
230
        l.movhi r5,hi(MC_CSR_VAL)
231
        l.ori   r5,r5,lo(MC_CSR_VAL)
232
        l.sw    0(r4),r5
233
 
234
        l.addi  r4,r3,MC_TMS(1)
235
        l.movhi r5,hi(SDRAM_TMS_VAL)
236
        l.ori   r5,r5,lo(SDRAM_TMS_VAL)
237
        l.sw    0(r4),r5
238
 
239
        l.addi  r4,r3,MC_CSC(1)
240 817 simons
        l.movhi r5,hi(SDRAM_BASE_ADDR)
241 809 simons
        l.srai  r5,r5,5
242
        l.ori   r5,r5,0x0411
243
        l.sw    0(r4),r5
244
 
245
        l.jr    r9
246
        l.nop
247
.endif
248
 
249
_int_wrapper:
250
        l.addi  r1,r1,-128
251
 
252
        l.sw    0x4(r1),r2
253
        l.sw    0x8(r1),r4
254
        l.sw    0xc(r1),r5
255
        l.sw    0x10(r1),r6
256
        l.sw    0x14(r1),r7
257
        l.sw    0x18(r1),r8
258
        l.sw    0x1c(r1),r9
259
        l.sw    0x20(r1),r10
260
        l.sw    0x24(r1),r11
261
        l.sw    0x28(r1),r12
262
        l.sw    0x2c(r1),r13
263
        l.sw    0x30(r1),r14
264
        l.sw    0x34(r1),r15
265
        l.sw    0x38(r1),r16
266
        l.sw    0x3c(r1),r17
267
        l.sw    0x40(r1),r18
268
        l.sw    0x44(r1),r19
269
        l.sw    0x48(r1),r20
270
        l.sw    0x4c(r1),r21
271
        l.sw    0x50(r1),r22
272
        l.sw    0x54(r1),r23
273
        l.sw    0x58(r1),r24
274
        l.sw    0x5c(r1),r25
275
        l.sw    0x60(r1),r26
276
        l.sw    0x64(r1),r27
277
        l.sw    0x68(r1),r28
278
        l.sw    0x6c(r1),r29
279
        l.sw    0x70(r1),r30
280
        l.sw    0x74(r1),r31
281
        l.sw    0x78(r1),r3
282
 
283
        l.movhi r3,hi(_eth_int)
284
        l.ori   r3,r3,lo(_eth_int)
285
        l.jalr  r3
286
        l.nop
287
 
288
        l.lwz   r2,0x4(r1)
289
        l.lwz   r4,0x8(r1)
290
        l.lwz   r5,0xc(r1)
291
        l.lwz   r6,0x10(r1)
292
        l.lwz   r7,0x14(r1)
293
        l.lwz   r8,0x18(r1)
294
        l.lwz   r9,0x1c(r1)
295
        l.lwz   r10,0x20(r1)
296
        l.lwz   r11,0x24(r1)
297
        l.lwz   r12,0x28(r1)
298
        l.lwz   r13,0x2c(r1)
299
        l.lwz   r14,0x30(r1)
300
        l.lwz   r15,0x34(r1)
301
        l.lwz   r16,0x38(r1)
302
        l.lwz   r17,0x3c(r1)
303
        l.lwz   r18,0x40(r1)
304
        l.lwz   r19,0x44(r1)
305
        l.lwz   r20,0x48(r1)
306
        l.lwz   r21,0x4c(r1)
307
        l.lwz   r22,0x50(r1)
308
        l.lwz   r23,0x54(r1)
309
        l.lwz   r24,0x58(r1)
310
        l.lwz   r25,0x5c(r1)
311
        l.lwz   r26,0x60(r1)
312
        l.lwz   r27,0x64(r1)
313
        l.lwz   r28,0x68(r1)
314
        l.lwz   r29,0x6c(r1)
315
        l.lwz   r30,0x70(r1)
316
        l.lwz   r31,0x74(r1)
317
#        l.lwz   r3,0x78(r1)
318
 
319
        l.mtspr r0,r0,SPR_PICSR
320
 
321
        l.mfspr r3,r0,SPR_ESR_BASE
322
        l.ori   r3,r3,SPR_SR_IEE
323
        l.mtspr r0,r3,SPR_ESR_BASE
324
 
325
        l.lwz   r3,0x78(r1)
326
 
327
        l.addi  r1,r1,128
328
        l.rfe
329
        l.nop
330
 
331 817 simons
_align:
332
        l.addi  r1,r1,-128
333
        l.sw    0x08(r1),r2
334
        l.sw    0x0c(r1),r3
335
        l.sw    0x10(r1),r4
336
        l.sw    0x14(r1),r5
337
        l.sw    0x18(r1),r6
338
        l.sw    0x1c(r1),r7
339
        l.sw    0x20(r1),r8
340
        l.sw    0x24(r1),r9
341
        l.sw    0x28(r1),r10
342
        l.sw    0x2c(r1),r11
343
        l.sw    0x30(r1),r12
344
        l.sw    0x34(r1),r13
345
        l.sw    0x38(r1),r14
346
        l.sw    0x3c(r1),r15
347
        l.sw    0x40(r1),r16
348
        l.sw    0x44(r1),r17
349
        l.sw    0x48(r1),r18
350
        l.sw    0x4c(r1),r19
351
        l.sw    0x50(r1),r20
352
        l.sw    0x54(r1),r21
353
        l.sw    0x58(r1),r22
354
        l.sw    0x5c(r1),r23
355
        l.sw    0x60(r1),r24
356
        l.sw    0x64(r1),r25
357
        l.sw    0x68(r1),r26
358
        l.sw    0x6c(r1),r27
359
        l.sw    0x70(r1),r28
360
        l.sw    0x74(r1),r29
361
        l.sw    0x78(r1),r30
362
        l.sw    0x7c(r1),r31
363
 
364
        l.mfspr r2,r0,SPR_EEAR_BASE /* Load the efective addres */
365
        l.mfspr r5,r0,SPR_EPCR_BASE /* Load the insn address */
366
 
367
        l.lwz r3,0(r5)      /* Load insn */
368
        l.srli  r4,r3,26    /* Shift left to get the insn opcode */
369
 
370
        l.sfeqi r4,0x00     /* Check if the load/store insn is in delay slot */
371
        l.bf  jmp
372
        l.sfeqi r4,0x01
373
        l.bf  jmp
374
        l.sfeqi r4,0x03
375
        l.bf  jmp
376
        l.sfeqi r4,0x04
377
        l.bf  jmp
378
        l.sfeqi r4,0x11
379
        l.bf  jr
380
        l.sfeqi r4,0x12
381
        l.bf  jr
382
        l.nop
383
        l.j 1f
384
        l.addi  r5,r5,4     /* Increment PC to get return insn address */
385
 
386
jmp:
387
        l.slli  r4,r3,6     /* Get the signed extended jump length */
388
        l.srai  r4,r4,4
389
 
390
        l.lwz r3,4(r5)      /* Load the real load/store insn */
391
 
392
        l.add r5,r5,r4      /* Calculate jump target address */
393
 
394
        l.j 1f
395
        l.srli  r4,r3,26    /* Shift left to get the insn opcode */
396
 
397
jr:
398
        l.slli  r4,r3,9     /* Shift to get the reg nb */
399
        l.andi  r4,r4,0x7c
400
 
401
        l.lwz r3,4(r5)    /* Load the real load/store insn */
402
 
403
        l.add r4,r4,r1    /* Load the jump register value from the stack */
404
        l.lwz r5,0(r4)
405
 
406
        l.srli  r4,r3,26    /* Shift left to get the insn opcode */
407
 
408
 
409
1:      l.mtspr r0,r5,SPR_EPCR_BASE
410
 
411
        l.sfeqi r4,0x26
412
        l.bf  lhs
413
        l.sfeqi r4,0x25
414
        l.bf  lhz
415
        l.sfeqi r4,0x22
416
        l.bf  lws
417
        l.sfeqi r4,0x21
418
        l.bf  lwz
419
        l.sfeqi r4,0x37
420
        l.bf  sh
421
        l.sfeqi r4,0x35
422
        l.bf  sw
423
        l.nop
424
 
425
1:      l.j 1b      /* I don't know what to do */
426
        l.nop
427
 
428
lhs:    l.lbs r5,0(r2)
429
        l.slli  r5,r5,8
430
        l.lbz r6,1(r2)
431
        l.or  r5,r5,r6
432
        l.srli  r4,r3,19
433
        l.andi  r4,r4,0x7c
434
        l.add r4,r4,r1
435
        l.j align_end
436
        l.sw  0(r4),r5
437
 
438
lhz:    l.lbz r5,0(r2)
439
        l.slli  r5,r5,8
440
        l.lbz r6,1(r2)
441
        l.or  r5,r5,r6
442
        l.srli  r4,r3,19
443
        l.andi  r4,r4,0x7c
444
        l.add r4,r4,r1
445
        l.j align_end
446
        l.sw  0(r4),r5
447
 
448
lws:    l.lbs r5,0(r2)
449
        l.slli  r5,r5,24
450
        l.lbz r6,1(r2)
451
        l.slli  r6,r6,16
452
        l.or  r5,r5,r6
453
        l.lbz r6,2(r2)
454
        l.slli  r6,r6,8
455
        l.or  r5,r5,r6
456
        l.lbz r6,3(r2)
457
        l.or  r5,r5,r6
458
        l.srli  r4,r3,19
459
        l.andi  r4,r4,0x7c
460
        l.add r4,r4,r1
461
        l.j align_end
462
        l.sw  0(r4),r5
463
 
464
lwz:    l.lbz r5,0(r2)
465
        l.slli  r5,r5,24
466
        l.lbz r6,1(r2)
467
        l.slli  r6,r6,16
468
        l.or  r5,r5,r6
469
        l.lbz r6,2(r2)
470
        l.slli  r6,r6,8
471
        l.or  r5,r5,r6
472
        l.lbz r6,3(r2)
473
        l.or  r5,r5,r6
474
        l.srli  r4,r3,19
475
        l.andi  r4,r4,0x7c
476
        l.add r4,r4,r1
477
        l.j align_end
478
        l.sw  0(r4),r5
479
 
480
sh:
481
        l.srli  r4,r3,9
482
        l.andi  r4,r4,0x7c
483
        l.add r4,r4,r1
484
        l.lwz r5,0(r4)
485
        l.sb  1(r2),r5
486
        l.slli  r5,r5,8
487
        l.j align_end
488
        l.sb  0(r2),r5
489
 
490
sw:
491
        l.srli  r4,r3,9
492
        l.andi  r4,r4,0x7c
493
        l.add r4,r4,r1
494
        l.lwz r5,0(r4)
495
        l.sb  3(r2),r5
496
        l.slli  r5,r5,8
497
        l.sb  2(r2),r5
498
        l.slli  r5,r5,8
499
        l.sb  1(r2),r5
500
        l.slli  r5,r5,8
501
        l.j align_end
502
        l.sb  0(r2),r5
503
 
504
align_end:
505
        l.lwz   r2,0x08(r1)
506
        l.lwz   r3,0x0c(r1)
507
        l.lwz   r4,0x10(r1)
508
        l.lwz   r5,0x14(r1)
509
        l.lwz   r6,0x18(r1)
510
        l.lwz   r7,0x1c(r1)
511
        l.lwz   r8,0x20(r1)
512
        l.lwz   r9,0x24(r1)
513
        l.lwz   r10,0x28(r1)
514
        l.lwz   r11,0x2c(r1)
515
        l.lwz   r12,0x30(r1)
516
        l.lwz   r13,0x34(r1)
517
        l.lwz   r14,0x38(r1)
518
        l.lwz   r15,0x3c(r1)
519
        l.lwz   r16,0x40(r1)
520
        l.lwz   r17,0x44(r1)
521
        l.lwz   r18,0x48(r1)
522
        l.lwz   r19,0x4c(r1)
523
        l.lwz   r20,0x50(r1)
524
        l.lwz   r21,0x54(r1)
525
        l.lwz   r22,0x58(r1)
526
        l.lwz   r23,0x5c(r1)
527
        l.lwz   r24,0x60(r1)
528
        l.lwz   r25,0x64(r1)
529
        l.lwz   r26,0x68(r1)
530
        l.lwz   r27,0x6c(r1)
531
        l.lwz   r28,0x70(r1)
532
        l.lwz   r29,0x74(r1)
533
        l.lwz   r30,0x78(r1)
534
        l.lwz   r31,0x7c(r1)
535
        l.addi  r1,r1,128
536
        l.rfe
537
 
538 809 simons
        .section .text
539
_lolev_ie:
540
        l.mfspr r3,r0,SPR_SR
541
        l.ori   r3,r3,SPR_SR_IEE
542
        l.mtspr r0,r3,SPR_SR
543 817 simons
        l.movhi r3,hi(ETH0_INT)
544
  l.ori r3,r3,lo(ETH0_INT)
545 809 simons
        l.mtspr r0,r3,SPR_PICMR
546
 
547
        l.jr    r9
548
        l.nop
549
 
550
_lolev_idis:
551
        l.mtspr r0,r0,SPR_PICMR
552
 
553
        l.jr    r9
554
        l.nop

powered by: WebSVN 2.1.0

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