xref: /haiku/src/system/boot/arch/riscv64/arch_cpu.cpp (revision 072d3935c2497638e9c2502f574c133caeba9d3d)
1 /*
2  * Copyright 2012-2020, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ithamar R. Adema <ithamar@upgrade-android.com>
7  */
8 
9 #include <OS.h>
10 #include <boot/platform.h>
11 #include <boot/stdio.h>
12 #include <boot/kernel_args.h>
13 #include <boot/stage2.h>
14 #include <arch/cpu.h>
15 #include <arch_kernel.h>
16 #include <arch_system_info.h>
17 #include <string.h>
18 
19 
20 #define TRACE_CPU
21 #ifdef TRACE_CPU
22 #	define TRACE(x) dprintf x
23 #else
24 #	define TRACE(x) ;
25 #endif
26 
27 
28 /*! Detect RISCV core extensions.
29 */
30 static status_t
31 check_cpu_features()
32 {
33 	// only seems possible from bootloader openfirmware or FDT?
34 	return B_OK;
35 }
36 
37 
38 extern "C" status_t
39 boot_arch_cpu_init(void)
40 {
41 	status_t err = check_cpu_features();
42 	if (err != B_OK) {
43 		panic("It's RISCY business trying to boot Haiku on the wrong CPU!\n");
44 		return err;
45 	}
46 
47 	return B_OK;
48 }
49 
50 
51 extern "C" void
52 arch_ucode_load(BootVolume& volume)
53 {
54 	// NOP on riscv currently
55 }
56 
57 
58 extern "C" bigtime_t
59 system_time()
60 {
61 	#warning Implement system_time in RISCV bootloader!
62 	return 0;
63 }
64 
65 
66 extern "C" void
67 spin(bigtime_t microseconds)
68 {
69 	#warning Implment spin in RISCV bootloader!
70 	//bigtime_t time = system_time();
71 	//while ((system_time() - time) < microseconds)
72 	//	asm volatile ("nop;");
73 }
74