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 bool 20 get_ac() 21 { 22 return SstatusReg{.val = Sstatus()}.sum; 23 } 24 25 26 static inline void 27 set_ac() 28 { 29 SetBitsSstatus(SstatusReg{.sum = 1}.val); 30 } 31 32 33 static inline void 34 clear_ac() 35 { 36 ClearBitsSstatus(SstatusReg{.sum = 1}.val); 37 } 38 39 40 typedef struct arch_cpu_info { 41 uint64 hartId; 42 } arch_cpu_info; 43 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 50 void __riscv64_setup_system_time(uint64 conversionFactor); 51 52 53 static inline void 54 arch_cpu_pause(void) 55 { 56 // TODO: CPU pause 57 } 58 59 60 static inline void 61 arch_cpu_idle(void) 62 { 63 Wfi(); 64 } 65 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 72 #endif /* _KERNEL_ARCH_RISCV64_CPU_H */ 73