From 7dcd941df2c961028b3b5eb8c6ed31f584a7f8e4 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Wed, 5 Dec 2018 10:11:23 -0600 Subject: [PATCH] riscv32/64: Stub out some core architecture code Change-Id: I437dff816e87ec5692cca0aaacaada27b43089ee --- src/add-ons/kernel/cpu/riscv32/Jamfile | 2 ++ src/add-ons/kernel/cpu/riscv64/Jamfile | 2 ++ src/system/glue/arch/riscv32/Jamfile | 21 +++++++++++++ src/system/glue/arch/riscv32/crti.S | 30 +++++++++++++++++++ src/system/glue/arch/riscv32/crtn.S | 19 ++++++++++++ src/system/glue/arch/riscv64/Jamfile | 21 +++++++++++++ src/system/glue/arch/riscv64/crti.S | 30 +++++++++++++++++++ src/system/glue/arch/riscv64/crtn.S | 19 ++++++++++++ src/system/kernel/arch/riscv32/Jamfile | 4 +++ src/system/kernel/arch/riscv64/Jamfile | 4 +++ .../libroot/posix/string/arch/riscv32/Jamfile | 17 +++++++++++ .../libroot/posix/string/arch/riscv64/Jamfile | 17 +++++++++++ .../runtime_loader/arch/riscv32/Jamfile | 22 ++++++++++++++ .../arch/riscv32/arch_relocate.cpp | 30 +++++++++++++++++++ .../runtime_loader/arch/riscv64/Jamfile | 22 ++++++++++++++ .../arch/riscv64/arch_relocate.cpp | 30 +++++++++++++++++++ 16 files changed, 290 insertions(+) create mode 100644 src/add-ons/kernel/cpu/riscv32/Jamfile create mode 100644 src/add-ons/kernel/cpu/riscv64/Jamfile create mode 100644 src/system/glue/arch/riscv32/Jamfile create mode 100644 src/system/glue/arch/riscv32/crti.S create mode 100644 src/system/glue/arch/riscv32/crtn.S create mode 100644 src/system/glue/arch/riscv64/Jamfile create mode 100644 src/system/glue/arch/riscv64/crti.S create mode 100644 src/system/glue/arch/riscv64/crtn.S create mode 100644 src/system/kernel/arch/riscv32/Jamfile create mode 100644 src/system/kernel/arch/riscv64/Jamfile create mode 100644 src/system/libroot/posix/string/arch/riscv32/Jamfile create mode 100644 src/system/libroot/posix/string/arch/riscv64/Jamfile create mode 100644 src/system/runtime_loader/arch/riscv32/Jamfile create mode 100644 src/system/runtime_loader/arch/riscv32/arch_relocate.cpp create mode 100644 src/system/runtime_loader/arch/riscv64/Jamfile create mode 100644 src/system/runtime_loader/arch/riscv64/arch_relocate.cpp diff --git a/src/add-ons/kernel/cpu/riscv32/Jamfile b/src/add-ons/kernel/cpu/riscv32/Jamfile new file mode 100644 index 0000000000..380e405c57 --- /dev/null +++ b/src/add-ons/kernel/cpu/riscv32/Jamfile @@ -0,0 +1,2 @@ +SubDir HAIKU_TOP src add-ons kernel cpu riscv32 ; + diff --git a/src/add-ons/kernel/cpu/riscv64/Jamfile b/src/add-ons/kernel/cpu/riscv64/Jamfile new file mode 100644 index 0000000000..9dd2afc43a --- /dev/null +++ b/src/add-ons/kernel/cpu/riscv64/Jamfile @@ -0,0 +1,2 @@ +SubDir HAIKU_TOP src add-ons kernel cpu risc64 ; + diff --git a/src/system/glue/arch/riscv32/Jamfile b/src/system/glue/arch/riscv32/Jamfile new file mode 100644 index 0000000000..5ec9d7ae5d --- /dev/null +++ b/src/system/glue/arch/riscv32/Jamfile @@ -0,0 +1,21 @@ +SubDir HAIKU_TOP src system glue arch riscv32 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv32 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateSystemHeaders ; + + local sources = + crti.S + crtn.S + ; + MergeObject <$(architecture)>glue_arch_$(TARGET_ARCH).o : $(sources) ; + + if $(HAIKU_BUILD_TYPE) = bootstrap { + # build a version for stage0 of the bootstrap process + BootstrapStage0PlatformObjects [ FGristFiles $(sources) ] : true ; + } + } +} diff --git a/src/system/glue/arch/riscv32/crti.S b/src/system/glue/arch/riscv32/crti.S new file mode 100644 index 0000000000..337c772ec2 --- /dev/null +++ b/src/system/glue/arch/riscv32/crti.S @@ -0,0 +1,30 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the first part of the ".init" and ".fini" sections in + * the ELF executable. + * The functions defined here will be called during initialization/termination + * of the loaded executable/library. The ".init" and ".fini" sections are + * stacked together like this: + * + * crti.S entry point + * call to _init_before/_term_before + * crtbegin.S GCC specific: constructors/destructors are called, ... + * crtend.S + * crtn.S call to _init_after/_term_after + * exit + */ + +#define FUNCTION(x) .global x; .type x,%function; x + +.section .init +FUNCTION(_init): + bl __haiku_init_before + // crtbegin.o stuff comes here + +.section .fini +FUNCTION(_fini): + bl __haiku_term_before + // crtbegin.o stuff comes here diff --git a/src/system/glue/arch/riscv32/crtn.S b/src/system/glue/arch/riscv32/crtn.S new file mode 100644 index 0000000000..125022e37d --- /dev/null +++ b/src/system/glue/arch/riscv32/crtn.S @@ -0,0 +1,19 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the final part of the ".init" and ".fini" sections in + * the ELF executable. It is tightly connected to crti.S. + * Have a look at crti.S to find a description of what happens here. + */ + +.section .init + // the image ID and program args are still on the stack + bl __haiku_init_after + + +.section .fini + // the image ID and program args are still on the stack + bl __haiku_term_after + diff --git a/src/system/glue/arch/riscv64/Jamfile b/src/system/glue/arch/riscv64/Jamfile new file mode 100644 index 0000000000..1ec7273c45 --- /dev/null +++ b/src/system/glue/arch/riscv64/Jamfile @@ -0,0 +1,21 @@ +SubDir HAIKU_TOP src system glue arch riscv64 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv64 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateSystemHeaders ; + + local sources = + crti.S + crtn.S + ; + MergeObject <$(architecture)>glue_arch_$(TARGET_ARCH).o : $(sources) ; + + if $(HAIKU_BUILD_TYPE) = bootstrap { + # build a version for stage0 of the bootstrap process + BootstrapStage0PlatformObjects [ FGristFiles $(sources) ] : true ; + } + } +} diff --git a/src/system/glue/arch/riscv64/crti.S b/src/system/glue/arch/riscv64/crti.S new file mode 100644 index 0000000000..337c772ec2 --- /dev/null +++ b/src/system/glue/arch/riscv64/crti.S @@ -0,0 +1,30 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the first part of the ".init" and ".fini" sections in + * the ELF executable. + * The functions defined here will be called during initialization/termination + * of the loaded executable/library. The ".init" and ".fini" sections are + * stacked together like this: + * + * crti.S entry point + * call to _init_before/_term_before + * crtbegin.S GCC specific: constructors/destructors are called, ... + * crtend.S + * crtn.S call to _init_after/_term_after + * exit + */ + +#define FUNCTION(x) .global x; .type x,%function; x + +.section .init +FUNCTION(_init): + bl __haiku_init_before + // crtbegin.o stuff comes here + +.section .fini +FUNCTION(_fini): + bl __haiku_term_before + // crtbegin.o stuff comes here diff --git a/src/system/glue/arch/riscv64/crtn.S b/src/system/glue/arch/riscv64/crtn.S new file mode 100644 index 0000000000..125022e37d --- /dev/null +++ b/src/system/glue/arch/riscv64/crtn.S @@ -0,0 +1,19 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the final part of the ".init" and ".fini" sections in + * the ELF executable. It is tightly connected to crti.S. + * Have a look at crti.S to find a description of what happens here. + */ + +.section .init + // the image ID and program args are still on the stack + bl __haiku_init_after + + +.section .fini + // the image ID and program args are still on the stack + bl __haiku_term_after + diff --git a/src/system/kernel/arch/riscv32/Jamfile b/src/system/kernel/arch/riscv32/Jamfile new file mode 100644 index 0000000000..4da73e15a0 --- /dev/null +++ b/src/system/kernel/arch/riscv32/Jamfile @@ -0,0 +1,4 @@ +SubDir HAIKU_TOP src system kernel arch riscv32 ; + +SubDirHdrs $(SUBDIR) $(DOTDOT) generic ; +UsePrivateKernelHeaders ; diff --git a/src/system/kernel/arch/riscv64/Jamfile b/src/system/kernel/arch/riscv64/Jamfile new file mode 100644 index 0000000000..8fb0460454 --- /dev/null +++ b/src/system/kernel/arch/riscv64/Jamfile @@ -0,0 +1,4 @@ +SubDir HAIKU_TOP src system kernel arch riscv64 ; + +SubDirHdrs $(SUBDIR) $(DOTDOT) generic ; +UsePrivateKernelHeaders ; diff --git a/src/system/libroot/posix/string/arch/riscv32/Jamfile b/src/system/libroot/posix/string/arch/riscv32/Jamfile new file mode 100644 index 0000000000..1ea4246f0c --- /dev/null +++ b/src/system/libroot/posix/string/arch/riscv32/Jamfile @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src system libroot posix string arch riscv64 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv64 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateSystemHeaders ; + + SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + + MergeObject <$(architecture)>posix_string_arch_$(TARGET_ARCH).o : + memcpy.c + memset.c + ; + } +} diff --git a/src/system/libroot/posix/string/arch/riscv64/Jamfile b/src/system/libroot/posix/string/arch/riscv64/Jamfile new file mode 100644 index 0000000000..5f054aa971 --- /dev/null +++ b/src/system/libroot/posix/string/arch/riscv64/Jamfile @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src system libroot posix string arch ppc ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup ppc ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateSystemHeaders ; + + SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + + MergeObject <$(architecture)>posix_string_arch_$(TARGET_ARCH).o : + memcpy.c + memset.c + ; + } +} diff --git a/src/system/runtime_loader/arch/riscv32/Jamfile b/src/system/runtime_loader/arch/riscv32/Jamfile new file mode 100644 index 0000000000..609feed239 --- /dev/null +++ b/src/system/runtime_loader/arch/riscv32/Jamfile @@ -0,0 +1,22 @@ +SubDir HAIKU_TOP src system runtime_loader arch riscv32 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv32 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateHeaders runtime_loader ; + UsePrivateSystemHeaders ; + + SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; + + StaticLibrary <$(architecture)>libruntime_loader_$(TARGET_ARCH).a : + arch_relocate.cpp + : + thread.o + + arch_string.o + memset.o + ; + } +} diff --git a/src/system/runtime_loader/arch/riscv32/arch_relocate.cpp b/src/system/runtime_loader/arch/riscv32/arch_relocate.cpp new file mode 100644 index 0000000000..3a57919364 --- /dev/null +++ b/src/system/runtime_loader/arch/riscv32/arch_relocate.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2018, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include +#include +#include + +#include "runtime_loader_private.h" + +#include + +//#define TRACE_RLD +#ifdef TRACE_RLD +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +status_t +arch_relocate_image(image_t *rootImage, image_t *image, + SymbolLookupCache* cache) +{ + debugger("arch_relocate_image: Not Yet Implemented!"); + return B_OK; +} diff --git a/src/system/runtime_loader/arch/riscv64/Jamfile b/src/system/runtime_loader/arch/riscv64/Jamfile new file mode 100644 index 0000000000..16c9f534bf --- /dev/null +++ b/src/system/runtime_loader/arch/riscv64/Jamfile @@ -0,0 +1,22 @@ +SubDir HAIKU_TOP src system runtime_loader arch riscv64 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv64 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateHeaders runtime_loader ; + UsePrivateSystemHeaders ; + + SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; + + StaticLibrary <$(architecture)>libruntime_loader_$(TARGET_ARCH).a : + arch_relocate.cpp + : + thread.o + + arch_string.o + memset.o + ; + } +} diff --git a/src/system/runtime_loader/arch/riscv64/arch_relocate.cpp b/src/system/runtime_loader/arch/riscv64/arch_relocate.cpp new file mode 100644 index 0000000000..3a57919364 --- /dev/null +++ b/src/system/runtime_loader/arch/riscv64/arch_relocate.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2018, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include +#include +#include + +#include "runtime_loader_private.h" + +#include + +//#define TRACE_RLD +#ifdef TRACE_RLD +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +status_t +arch_relocate_image(image_t *rootImage, image_t *image, + SymbolLookupCache* cache) +{ + debugger("arch_relocate_image: Not Yet Implemented!"); + return B_OK; +}