summaryrefslogtreecommitdiff
path: root/boards/qemu-virt/qemu-virt.s
blob: a2618d2415a2dc268eec635f6c8ff4dd22829583 (plain)
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
.section .text.start

.extern main
.extern CONSOLE_STRICT_FLUSH

.global _start
.type _start, STT_FUNC
_start:
	# Have harts other than 0 spin until hart0 wakes them up.
	csrr a0, mhartid
	c.bnez a0, wait_for_hart0

	# Set up console_strict_flush.
	la t0, console_strict_flush
	la t1, CONSOLE_STRICT_FLUSH
	sd t0, (t1)

	# Set up hart0's stack.
	la sp, hart0_initial_stack_top

	# Call hart0_boot with the address of the DeviceTree.
	c.mv a0, a1
	call hart0_boot
	# Fall through to a spin loop.
.size _start, . - _start

.type halt, STT_FUNC
halt:
	j halt
.size halt, . - halt

.section .text

.type console_strict_flush, STT_FUNC
console_strict_flush:
	li t0, 0x10000000
1:
	c.beqz a1, 2f
	lb t1, (a0)
	sb t1, (t0)
	addi a0, a0, 1
	addi a1, a1, -1
	j 1b
2:
	ret
.size console_strict_flush, . - console_strict_flush

.section .text

.type wait_for_hart0, STT_FUNC
wait_for_hart0:
	# TODO
	j halt
.size wait_for_hart0, . - wait_for_hart0