xref: /haiku/src/system/boot/platform/riscv/entry.S (revision 46b7da1f4f40f7157d74fc7fb26ff9ec7f2416f2)
1a182bd6eSX512/*
2a182bd6eSX512 * Copyright 2020-2021, Haiku, Inc. All rights reserved.
3a182bd6eSX512 * Distributed under the terms of the MIT License.
4a182bd6eSX512 */
5a182bd6eSX512
6a182bd6eSX512#include <asm_defs.h>
7a182bd6eSX512
8a182bd6eSX512    .text
9a182bd6eSX512
10*71530401SX512/*  status_t arch_enter_kernel(uint64 satp, struct kernel_args *kernelArgs,
11a182bd6eSX512        addr_t kernelEntry, addr_t kernelStackTop);
12a182bd6eSX512
13*71530401SX512    a0  - SATP register value
14*71530401SX512    a1  - kernelArgs
15*71530401SX512    a2  - kernelEntry
16*71530401SX512    a3  - kernelStackTop
17a182bd6eSX512*/
18a182bd6eSX512FUNCTION(arch_enter_kernel):
19*71530401SX512	csrw satp, a0
20*71530401SX512	sfence.vma
21*71530401SX512
22a182bd6eSX512	// set the kernel stack
23*71530401SX512	mv	sp, a3
24*71530401SX512#	li	fp, 0
25*71530401SX512#	li  ra, 0
26a182bd6eSX512
27a182bd6eSX512	// Setup kernel args
28*71530401SX512	mv	a0, a1	// kernelArgs
29*71530401SX512	mv	t0, a2
30a182bd6eSX512	li	a1, 0	// currentCPU=0
31a182bd6eSX512
32a182bd6eSX512	// call the kernel
33*71530401SX512	jr	t0
34a182bd6eSX512
35a182bd6eSX512	// return
36a182bd6eSX512	li	a0,-1  // B_ERROR
37a182bd6eSX512	ret
38a182bd6eSX512FUNCTION_END(arch_enter_kernel)
39