summaryrefslogtreecommitdiff
path: root/kernel/entry.S
blob: 8d3bd303b56e57c6ceb66f4b6f0ee95cce6c7eb2 (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
	# qemu -kernel loads the kernel at 0x80000000
        # and causes each CPU to jump there.
        # kernel.ld causes the following code to
        # be placed at 0x80000000.
.section .text
_entry:
	# set up a stack for C.
        # stack0 is declared in start.c,
        # with a 4096-byte stack per CPU.
        # sp = stack0 + (hartid * 4096)
        la sp, stack0
        li a0, 1024*4
	csrr a1, mhartid
        addi a1, a1, 1
	
	addi t0, a1, 0
	addi t1, a0, 0
mul:
	add a0, a0, t1
	addi t0, t0, -1
	bne t0, zero, mul
	
        add sp, sp, a0
	# jump to start() in start.c
        call start
spin:
        j spin