xref: /haiku/headers/private/kernel/arch/riscv64/arch_cpu.h (revision fc7456e9b1ec38c941134ed6d01c438cf289381e)
1 /*
2  * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de.
3  * Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef _KERNEL_ARCH_RISCV64_CPU_H
7 #define _KERNEL_ARCH_RISCV64_CPU_H
8 
9 
10 #include <arch/riscv64/arch_thread_types.h>
11 #include <arch_cpu_defs.h>
12 #include <kernel.h>
13 
14 
15 #define CPU_MAX_CACHE_LEVEL	8
16 #define CACHE_LINE_SIZE		64
17 
18 
19 static inline void
20 arch_cpu_enable_user_access()
21 {
22 	SetBitsSstatus(SstatusReg{.sum = 1}.val);
23 }
24 
25 
26 static inline void
27 arch_cpu_disable_user_access()
28 {
29 	ClearBitsSstatus(SstatusReg{.sum = 1}.val);
30 }
31 
32 
33 typedef struct arch_cpu_info {
34 	uint64 hartId;
35 } arch_cpu_info;
36 
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 void __riscv64_setup_system_time(uint64 conversionFactor);
44 
45 
46 static inline void
47 arch_cpu_pause(void)
48 {
49 	// TODO: CPU pause
50 }
51 
52 
53 static inline void
54 arch_cpu_idle(void)
55 {
56 	Wfi();
57 }
58 
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 
65 #endif	/* _KERNEL_ARCH_RISCV64_CPU_H */
66