aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/init/start.S
blob: b6394f7e84a9db159c91659d1e3f556d7a357be2 (plain) (blame)
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
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */

/* generic u-boot passes argc and argv as if we were a regular
 * program, so our load address must be placed third.
 * If we have a 'custom' u-boot with kmi support, the fdt
 * will be passed to us directly, so the load address can go second.
 */
#if GENERIC_UBOOT
# define LOAD_REG a2
# define INIT init_go
#else
# define LOAD_REG a1
# define INIT init
#endif

.section .init
.global _start
/* Entry point to the kernel loader. */
_start:
/* get load address */
auipc LOAD_REG, 0
/* keep using bootloader stack for now */
//li sp, PM_STACK_TOP
/* make sure there's no garbage in tp, important for id assignment */
li tp, 0
call INIT
// INIT shouldn't return, but if we do we might as well just jump back to u-boot
// or wherever
ret

.section .text
.global jump_to_kernel
jump_to_kernel:
li sp, VM_STACK_TOP // load virtual stack address
li fp, 0
li gp, 0
jr a2 // jump to kernel