-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.S
45 lines (39 loc) · 1.22 KB
/
boot.S
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
.include "assembly-helpers.s"
.section .text, "ax", @progbits
.zero 0x80
.globl start
.p2align 2
.type start,@function
start:
// ca0 (first argument) contains the read-write root
cspecialr ca0, mtdc
// Zero the tag memory
li a1, 0x200fe000
csetaddr ca0, ca0, a1
li a1, 0x20100000
cjal zero_memory
// No bounds on stack, grows down from the end of IRAM
li sp, 0x20080000
csetaddr csp, ca0, sp
auipcc cra, 0
// Call the C++ entry point
la_abs t0, rom_loader_entry
csetaddr cra, cra, t0
cjalr cra
// Zero all of the memory that we haven't loaded into.
cspecialr ca1, mtdc
csetaddr ca0, ca1, a0
li a1, 0x20080000
cjal zero_memory
// Jump to the newly loaded binary.
// This could be a relative jump, but I'd need to get the relocations right
// and we have 32 KiB of IROM so wasting a few bytes doesn't really matter.
auipcc cra, 0
li t0, 0x20040000
csetaddr ct0, cra, t0
cjr ct0
zero_memory:
csw zero, 0(ca0)
cincoffset ca0, ca0, 4
blt a0, a1, zero_memory;
cret