bootu.s
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <regdef.h>
#include <asm.h>
#include <PR/R4300.h>
#include <PR/bcp.h>
#include "boot.h"
// XXX: t7 is reserved for use in TRACE macros, do not use.
.text
.align 2
.set noreorder
.globl __start
__start:
# write config register
mfc0 t1, C0_CONFIG
and t1, t1, ~CONFIG_K0
and t1, t1, ~CONFIG_CU
mtc0 t1, C0_CONFIG
# other initialization
mtc0 zero, C0_INX
mtc0 zero, C0_ENTRYHI
mtc0 zero, C0_ENTRYLO0
mtc0 zero, C0_ENTRYLO1
mtc0 zero, C0_PAGEMASK
mtc0 zero, C0_LLADDR
# two lines below now done in entry.s
# mtc0 zero, C0_WATCHLO
# mtc0 zero, C0_WATCHHI
mtc0 zero, C0_CAUSE
mtc0 zero, C0_COUNT
mtc0 zero, C0_COMPARE
li t0, (SR_CU0 | SR_CU1 | SR_FR | SR_BEV)
mtc0 t0, C0_SR
nop
TRACE_VAL(0x24)
# Invalidate I cache
mtc0 zero,C0_TAGLO
mtc0 zero,C0_TAGHI
la t0,K0BASE
addu t1,t0,ICACHE_SIZE
subu t1,8*ICACHE_LINESIZE
init_icache:
cache CACH_PI|C_IST,0(t0)
cache CACH_PI|C_IST,ICACHE_LINESIZE(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*2)(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*3)(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*4)(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*5)(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*6)(t0)
cache CACH_PI|C_IST,(ICACHE_LINESIZE*7)(t0)
bltu t0,t1,init_icache # on entire cache
addu t0,(8*ICACHE_LINESIZE)
# indicate progress
TRACE_VAL(0x26)
# Invalidate D cache
la t0,K0BASE
addu t1,t0,DCACHE_SIZE
subu t1,8*DCACHE_LINESIZE
init_dcache:
cache CACH_PD|C_IST,0(t0)
cache CACH_PD|C_IST,DCACHE_LINESIZE(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*2)(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*3)(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*4)(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*5)(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*6)(t0)
cache CACH_PD|C_IST,(DCACHE_LINESIZE*7)(t0)
bltu t0,t1,init_dcache # on entire cache.
addu t0,(8*DCACHE_LINESIZE)
# setup stack pointer and gp
li sp, PHYS_TO_K0(INTERNAL_RAM_END-16)
la gp, _gp
# setup jump to cached space
la t0, __start_cached
and t0, t0, 0xdfffffff
# debug output
TRACE_REG(t0)
# jump to cached space
j t0
nop