-
Notifications
You must be signed in to change notification settings - Fork 2
/
freeloader.S
107 lines (81 loc) · 1.61 KB
/
freeloader.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
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
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (C) 2020 Ruigang Wan <[email protected]>
* Copyright (C) 2020 Nuclei System Technologies
*/
#define OPENSBI_START_BASE 0xa0000000
#define UBOOT_START_BASE 0xa0200000
#define FDT_START_BASE 0xa8000000
#define ITCM_START_BASE 0x80000000
.global _start
.section .text
_start:
/* configure nuspi to maximum speed */
la t0, 0x10014000
la t1, 0x01
sw t1, 0(t0)
/* move _copy_data() to ITCM region */
li t0, ITCM_START_BASE
la t1, _copy_data
la t2, _copy_data + 4 * 8
call _copy_data
/* move data from NOR to DDR */
li t0, OPENSBI_START_BASE
la t1, sbi
la t2, _end_sbi
/* call faraway function */
li t3, ITCM_START_BASE
//call _copy_data
jalr ra, t3, 0
/* U-Boot section */
li t0, UBOOT_START_BASE
la t1, uboot
la t2, _end_uboot
/* call faraway function */
li t3, ITCM_START_BASE
//call _copy_data
jalr ra, t3, 0
/* FDT section */
li t0, FDT_START_BASE
la t1, fdt
la t2, _end_fdt
/* call faraway function */
li t3, ITCM_START_BASE
//call _copy_data
jalr ra, t3, 0
/* Flush cache */
fence
fence.i
sfence.vma
li a0, 0 /* hart ID */
li a1, 0 /* fdt offset, reserved */
li a2, 0 /* Reserved */
/* Goto OpenSBI */
li t0, OPENSBI_START_BASE
jr t0
_deadloop:
j .
/* copy_data(void *dst, void *src, void *end) */
.align 4
_copy_data:
_loop:
ld t3, 0(t1)
sd t3, 0(t0)
addi t0, t0, 8
addi t1, t1, 8
blt t1, t2, _loop
ret
.section .sbipayload
.global sbi
.type sbi, @object
sbi:
.incbin "fw_jump.bin"
.section .ubootpayload
.global uboot
.type uboot, @object
uboot:
.incbin "u-boot.bin"
.section .fdtpayload
.global fdt
.type fdt, @object
fdt:
.incbin "fdt.dtb"