diff --git a/headers/private/kernel/boot/arch/riscv64/arch_cpu.h b/headers/private/kernel/boot/arch/riscv64/arch_cpu.h new file mode 100644 index 0000000000..0bb2f6ec5c --- /dev/null +++ b/headers/private/kernel/boot/arch/riscv64/arch_cpu.h @@ -0,0 +1,25 @@ +/* + * Copyright 2013-2020 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef BOOT_ARCH_CPU_H +#define BOOT_ARCH_CPU_H + + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +status_t boot_arch_cpu_init(void); +void arch_ucode_load(BootVolume& volume); + +#ifdef __cplusplus +} +#endif + + +#endif /* BOOT_ARCH_CPU_H */ diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index 6a1f525502..f0bd545b83 100644 --- a/src/system/boot/Jamfile +++ b/src/system/boot/Jamfile @@ -113,6 +113,8 @@ rule BuildEFILoader { OUTPUT_TARGET on $(efiLoader) = binary ; case arm64 : OUTPUT_TARGET on $(efiLoader) = binary ; + case riscv64 : + OUTPUT_TARGET on $(efiLoader) = binary ; case * : Exit "Currently unsupported arch:" $(TARGET_ARCH) ; } diff --git a/src/system/boot/arch/riscv64/Jamfile b/src/system/boot/arch/riscv64/Jamfile index 1d074a78d8..c8dd186300 100644 --- a/src/system/boot/arch/riscv64/Jamfile +++ b/src/system/boot/arch/riscv64/Jamfile @@ -22,6 +22,8 @@ local kernelDebugSources = local kernelArchDriverSources = arch_elf.cpp + arch_cpu.cpp + # Serial UART Drivers #arch_uart_8250.cpp #arch_uart_8250_omap.cpp diff --git a/src/system/boot/arch/riscv64/arch_cpu.cpp b/src/system/boot/arch/riscv64/arch_cpu.cpp new file mode 100644 index 0000000000..0b1ace2b85 --- /dev/null +++ b/src/system/boot/arch/riscv64/arch_cpu.cpp @@ -0,0 +1,73 @@ +/* + * Copyright 2012-2020, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define TRACE_CPU +#ifdef TRACE_CPU +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +/*! Detect RISCV core extensions. +*/ +static status_t +check_cpu_features() +{ + // only seems possible from bootloader openfirmware or FDT? + return B_OK; +} + + +extern "C" status_t +boot_arch_cpu_init(void) +{ + status_t err = check_cpu_features(); + if (err != B_OK) { + panic("It's RISCY business trying to boot Haiku on the wrong CPU!\n"); + return err; + } + + return B_OK; +} + + +extern "C" void +arch_ucode_load(BootVolume& volume) +{ + // NOP on riscv currently +} + + +extern "C" bigtime_t +system_time() +{ + #warning Implement system_time in RISCV bootloader! + return 0; +} + + +extern "C" void +spin(bigtime_t microseconds) +{ + #warning Implment spin in RISCV bootloader! + //bigtime_t time = system_time(); + //while ((system_time() - time) < microseconds) + // asm volatile ("nop;"); +} diff --git a/src/system/kernel/arch/riscv64/arch_debug.cpp b/src/system/kernel/arch/riscv64/arch_debug.cpp index 495c9abf0e..07a48ef0da 100644 --- a/src/system/kernel/arch/riscv64/arch_debug.cpp +++ b/src/system/kernel/arch/riscv64/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019, Haiku, Inc. All rights reserved. + * Copyright 2019-2020, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -92,6 +92,13 @@ arch_debug_get_interrupt_pc(bool* _isSyscall) } +void +arch_debug_unset_current_thread(void) +{ + // TODO: Implement! +} + + status_t arch_debug_init(kernel_args *args) { @@ -103,4 +110,3 @@ arch_debug_init(kernel_args *args) return B_NO_ERROR; } -