diff options
Diffstat (limited to 'utils/atj2137/adfuload/test_binary/timer_no_irq/crt0.S')
-rw-r--r-- | utils/atj2137/adfuload/test_binary/timer_no_irq/crt0.S | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/utils/atj2137/adfuload/test_binary/timer_no_irq/crt0.S b/utils/atj2137/adfuload/test_binary/timer_no_irq/crt0.S new file mode 100644 index 0000000000..e03b8b5439 --- /dev/null +++ b/utils/atj2137/adfuload/test_binary/timer_no_irq/crt0.S | |||
@@ -0,0 +1,79 @@ | |||
1 | #include "mips.h" | ||
2 | |||
3 | .extern main | ||
4 | .global start | ||
5 | |||
6 | .set mips32r2 | ||
7 | .set noreorder | ||
8 | .set noat | ||
9 | |||
10 | .section .init.text,"ax",%progbits | ||
11 | |||
12 | start: | ||
13 | di # disable interrupts | ||
14 | bltzal zero, load_addr # ra = PC + 8, branch not taken | ||
15 | nop | ||
16 | |||
17 | load_addr: | ||
18 | addiu v0, ra, -12 # calc real load address | ||
19 | # account for branch delay slot | ||
20 | # and very first 'di' instruction | ||
21 | la t0, relocstart | ||
22 | la t1, relocend | ||
23 | beq t0, v0, entry_point # no relocation needed | ||
24 | nop | ||
25 | |||
26 | reloc_loop: | ||
27 | lw t2, 0(v0) # src | ||
28 | addiu v0, 4 # inc src addr | ||
29 | sw t2, 0(t0) # dst | ||
30 | bne t0, t1, reloc_loop | ||
31 | addiu t0, 4 # inc dst addr | ||
32 | |||
33 | entry_point_jump: | ||
34 | la t0, entry_point | ||
35 | jr t0 | ||
36 | nop | ||
37 | |||
38 | entry_point: | ||
39 | # setup caches | ||
40 | # 4-way, 256 sets, 16 bytes cacheline I/D | ||
41 | li t0, 3 # enable cache for kseg0 accesses | ||
42 | mtc0 t0, C0_CONFIG | ||
43 | |||
44 | la t0, 0x80000000 # an idx op should use an unmappable address | ||
45 | ori t1, t0, 0x4000 # 16kB cache | ||
46 | mtc0 zero, C0_TAGLO | ||
47 | mtc0 zero, C0_TAGHI | ||
48 | |||
49 | cache_init_loop: | ||
50 | cache 8, 0(t0) # index store icache tag | ||
51 | cache 9, 0(t0) # index store dcache tag | ||
52 | bne t0, t1, cache_init_loop | ||
53 | addiu t0, t0, 0x10 | ||
54 | |||
55 | # clear bss | ||
56 | la t0, bssbegin | ||
57 | la t1, bssend | ||
58 | |||
59 | clear_bss_loop: | ||
60 | sw zero, 0(t0) | ||
61 | bne t0, t1, clear_bss_loop | ||
62 | addiu t0, 4 | ||
63 | |||
64 | # setup stack | ||
65 | la sp, stackend | ||
66 | la t0, stackbegin | ||
67 | li t1, 0xdeadbeef | ||
68 | |||
69 | stack_munge_loop: | ||
70 | sw t1, 0(t0) | ||
71 | bne t0, sp, stack_munge_loop | ||
72 | addiu t0, 4 | ||
73 | |||
74 | # jump to C code | ||
75 | j main | ||
76 | nop | ||
77 | |||
78 | .set at | ||
79 | .set reorder | ||