diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index 91569204d6..a8ecf832ba 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -41,6 +41,7 @@ rule ArchitectureSetup architecture case ppc : archFlags += -mcpu=440fp ; case arm : archFlags += -march=armv7-a -mfloat-abi=hard ; case x86 : archFlags += -march=pentium ; + case riscv64 : archFlags += -march=rv64gc ; } if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { # TODO: These should be included in Clang's compiler specs. diff --git a/build/scripts/build_cross_tools_gcc4 b/build/scripts/build_cross_tools_gcc4 index b5eefe340e..f56f2c0932 100755 --- a/build/scripts/build_cross_tools_gcc4 +++ b/build/scripts/build_cross_tools_gcc4 @@ -62,13 +62,13 @@ arm-*) gdbTarget="arm-unknown-elf" ;; riscv*-*) - binutilsConfigureArgs="--disable-multilib" - gccConfigureArgs="--disable-multilib" - gdbConfigureArgs="--disable-multilib" + binutilsConfigureArgs=" --with-arch=rv64gc" + gccConfigureArgs=" --with-arch=rv64gc" + gdbConfigureArgs="" - # TODO: Disable building with TLS support for riscv until implemented. - binutilsConfigureArgs="$binutilsConfigureArgs --disable-tls" - gccConfigureArgs="$gccConfigureArgs --disable-tls" + binutilsConfigureArgs="$binutilsConfigureArgs --disable-multilib" + gccConfigureArgs="$gccConfigureArgs --disable-multilib" + gdbConfigureArgs="$gdbConfigureArgs --disable-multilib" ;; powerpc-*) binutilsConfigureArgs="--disable-multilib" diff --git a/src/system/libroot/os/arch/riscv64/tls.c b/src/system/libroot/os/arch/riscv64/tls.c index f030edb966..d840a8b692 100644 --- a/src/system/libroot/os/arch/riscv64/tls.c +++ b/src/system/libroot/os/arch/riscv64/tls.c @@ -1,24 +1,25 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the MIT License. -*/ + * Copyright 2019 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ -// ToDo: this is a dummy implementation - I've not yet gained enough knowledge -// to decide how this should be done, so it's just broken now (okay for single -// threaded apps, though). - -// we don't want to have the inline assembly included here -#ifndef _NO_INLINE_ASM -# define _NO_INLINE_ASM 1 -#endif +#include #include "support/TLS.h" #include "tls.h" -static int32 gNextSlot = TLS_FIRST_FREE_SLOT; -static void *gSlots[TLS_MAX_KEYS]; +struct tls_index { + unsigned long ti_module; + unsigned long ti_offset; +}; +void* __tls_get_addr(struct tls_index* ti); + +static int32 gNextSlot = TLS_FIRST_FREE_SLOT; + + +// TODO: RISCV64 has a dedicated (TP) register for TLS int32 tls_allocate(void) @@ -34,20 +35,28 @@ tls_allocate(void) void * tls_get(int32 index) { - return gSlots[index]; + debugger("Implement TLS support before SMP"); + return NULL; } void ** tls_address(int32 index) { - return &gSlots[index]; + debugger("Implement TLS support before SMP"); + return NULL; } void tls_set(int32 index, void *value) { - gSlots[index] = value; + debugger("Implement TLS support before SMP"); } + +void* +__tls_get_addr(struct tls_index* ti) +{ + return __gRuntimeLoader->get_tls_address(ti->ti_module, ti->ti_offset); +}