From 21258e2674226d6aa732321b6f8494841895af5f Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Wed, 19 Aug 2020 10:03:24 -0500 Subject: [PATCH] riscv64: Fill in some missing CPU defines, advance build further MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id050fad59ede444f2eab7eca681c6ec44612aaf9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3160 Reviewed-by: Alex von Gluck IV Reviewed-by: François Revol --- .../kernel/boot/arch/riscv64/arch_cpu.h | 25 +++++++ src/system/boot/Jamfile | 2 + src/system/boot/arch/riscv64/Jamfile | 2 + src/system/boot/arch/riscv64/arch_cpu.cpp | 73 +++++++++++++++++++ src/system/kernel/arch/riscv64/arch_debug.cpp | 10 ++- 5 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 headers/private/kernel/boot/arch/riscv64/arch_cpu.h create mode 100644 src/system/boot/arch/riscv64/arch_cpu.cpp 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; } -