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