[haiku-commits] haiku: hrev53762 - in src: system/libroot/posix/glibc/arch/arm64 system/libroot/posix/arch/arm64 system/kernel/arch/arm64 add-ons/kernel/bus_managers/isa/arch/arm64 add-ons/kernel/bus_managers/pci/arch/arm64

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 25 Jan 2020 03:50:56 -0500 (EST)

hrev53762 adds 1 changeset to branch 'master'
old head: 80f7396496d7e0907ef805c820401aea5c93e20f
new head: cbdb30f4676680970c8d85860e7b8195b9f9b67b
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=cbdb30f46766+%5E80f7396496d7

----------------------------------------------------------------------------

cbdb30f46766: arm64: Add more random scripts to get stuff to compile
  
  Signed-off-by: Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
  Change-Id: Ie043af5b7471f626a1ffe100848151c832dcc439
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1853
  Reviewed-by: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>

                                   [ Jaroslaw Pelczar <jarek@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53762
Commit:      cbdb30f4676680970c8d85860e7b8195b9f9b67b
URL:         https://git.haiku-os.org/haiku/commit/?id=cbdb30f46766
Author:      Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
Date:        Mon Sep  2 19:57:16 2019 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sat Jan 25 08:50:51 2020 UTC

----------------------------------------------------------------------------

26 files changed, 875 insertions(+), 2 deletions(-)
build/jam/ArchitectureRules                      |   7 +
.../kernel/bus_managers/isa/arch/arm64/Jamfile   |  11 ++
.../bus_managers/isa/arch/arm64/isa_controller.c |  85 ++++++++++
.../kernel/bus_managers/isa/arch/arm64/isa_dma.c |  25 +++
.../kernel/bus_managers/pci/arch/arm64/Jamfile   |  10 ++
.../pci/arch/arm64/pci_controller.cpp            |  27 ++++
.../kernel/bus_managers/pci/arch/arm64/pci_io.c  |  61 ++++++++
.../kernel/bus_managers/pci/arch/arm64/pci_io.h  |  12 ++
src/add-ons/kernel/cpu/arm64/Jamfile             |   2 +
src/kits/debug/arch/arm64/arch_debug_support.cpp |  23 +++
src/system/boot/arch/arm64/Jamfile               |  41 +++++
src/system/kernel/arch/arm64/Jamfile             |   8 +
src/system/kernel/arch/arm64/arch_elf.cpp        | 107 +++++++++++++
src/system/kernel/lib/arch/arm64/Jamfile         |  27 ++++
src/system/libroot/os/arch/arm64/Jamfile         |   5 +-
src/system/libroot/os/arch/arm64/thread.c        |  15 ++
src/system/libroot/os/arch/arm64/tls.c           |  57 +++++++
src/system/libroot/posix/arch/arm64/Jamfile      |  26 ++++
src/system/libroot/posix/arch/arm64/fenv.c       |  56 +++++++
src/system/libroot/posix/arch/arm64/siglongjmp.S |  21 +++
src/system/libroot/posix/arch/arm64/sigsetjmp.S  |  22 +++
.../libroot/posix/glibc/arch/arm64/Jamfile       | 154 +++++++++++++++++++
.../libroot/posix/string/arch/arm64/Jamfile      |  18 +++
.../posix/string/arch/arm64/arch_string.S        |   6 +
src/system/runtime_loader/arch/arm64/Jamfile     |  22 +++
.../runtime_loader/arch/arm64/arch_relocate.cpp  |  29 ++++

----------------------------------------------------------------------------

diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules
index 64493d93e8..552fe2c7ea 100644
--- a/build/jam/ArchitectureRules
+++ b/build/jam/ArchitectureRules
@@ -422,6 +422,13 @@ rule KernelArchitectureSetup architecture
                                -Wl,-z -Wl,max-page-size=0x1000
                                -Wl,-z -Wl,common-page-size=0x1000 ;
 
+               case arm64 :
+                       # Workaround for ld using 32k for alignment despite 
forcing it in the config...
+                       # should definitely not be needed!
+                       HAIKU_KERNEL_LINKFLAGS +=
+                               -Wl,-z -Wl,max-page-size=0x1000
+                               -Wl,-z -Wl,common-page-size=0x1000 ;
+
                case ppc :
                        # Build a position independent PPC kernel. We need to 
be able to
                        # relocate the kernel, since the virtual address space 
layout at
diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm64/Jamfile 
b/src/add-ons/kernel/bus_managers/isa/arch/arm64/Jamfile
new file mode 100644
index 0000000000..1ae74046ce
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/isa/arch/arm64/Jamfile
@@ -0,0 +1,11 @@
+SubDir HAIKU_TOP src add-ons kernel bus_managers isa arch arm64 ;
+
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
+
+UsePrivateHeaders kernel [ FDirName kernel arch arm64 ] ;
+
+KernelStaticLibrary isa_arch_bus_manager : 
+       isa_dma.c
+       isa_controller.c
+       ;
+
diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_controller.c 
b/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_controller.c
new file mode 100644
index 0000000000..d64ae262e4
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_controller.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007 Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * arch-specific config manager
+ *
+ * Authors (in chronological order):
+ *              François Revol (revol@xxxxxxx)
+ */
+
+
+#include <KernelExport.h>
+#include "ISA.h"
+#include "arch_cpu.h"
+#include "isa_arch.h"
+
+//#define TRACE_ISA
+#ifdef TRACE_ISA
+#       define TRACE(x) dprintf x
+#else
+#       define TRACE(x) ;
+#endif
+
+
+uint8
+arch_isa_read_io_8(int mapped_io_addr)
+{
+       uint8 value = in8(mapped_io_addr);
+
+       TRACE(("isa_read8(%x->%x)\n", mapped_io_addr, value));
+
+       return value;
+}
+
+
+void
+arch_isa_write_io_8(int mapped_io_addr, uint8 value)
+{
+       TRACE(("isa_write8(%x->%x)\n", value, mapped_io_addr));
+
+       out8(value, mapped_io_addr);
+}
+
+
+uint16
+arch_isa_read_io_16(int mapped_io_addr)
+{
+       return in16(mapped_io_addr);
+}
+
+
+void
+arch_isa_write_io_16(int mapped_io_addr, uint16 value)
+{
+       out16(value, mapped_io_addr);
+}
+
+
+uint32
+arch_isa_read_io_32(int mapped_io_addr)
+{
+       return in32(mapped_io_addr);
+}
+
+
+void
+arch_isa_write_io_32(int mapped_io_addr, uint32 value)
+{
+       out32(value, mapped_io_addr);
+}
+
+
+phys_addr_t
+arch_isa_ram_address(phys_addr_t physical_address_in_system_memory)
+{
+       // this is what the BeOS kernel does
+       return physical_address_in_system_memory;
+}
+
+
+status_t
+arch_isa_init(void)
+{
+       return B_OK;
+}
diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_dma.c 
b/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_dma.c
new file mode 100644
index 0000000000..50bc63af6c
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/isa/arch/arm64/isa_dma.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2007 Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * arch-specific config manager
+ *
+ * Authors (in chronological order):
+ *              François Revol (revol@xxxxxxx)
+ */
+
+#include <KernelExport.h>
+#include "ISA.h"
+#include "arch_cpu.h"
+#include "isa_arch.h"
+
+
+status_t
+arch_start_isa_dma(long channel, void *buf, long transfer_count,
+       uchar mode, uchar e_mode)
+{
+       // ToDo: implement this?!
+       return B_NOT_ALLOWED;
+}
+
+
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm64/Jamfile 
b/src/add-ons/kernel/bus_managers/pci/arch/arm64/Jamfile
new file mode 100644
index 0000000000..a09b7cbb37
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/arm64/Jamfile
@@ -0,0 +1,10 @@
+SubDir HAIKU_TOP src add-ons kernel bus_managers pci arch $(TARGET_ARCH) ;
+
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
+UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ]
+       [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ;
+
+KernelStaticLibrary pci_arch_bus_manager :
+       pci_controller.cpp
+       pci_io.c
+;
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_controller.cpp 
b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_controller.cpp
new file mode 100644
index 0000000000..c4e9917718
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_controller.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2009, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "pci_controller.h"
+
+//#include <arch_platform.h>
+
+#include "pci_private.h"
+
+
+status_t
+pci_controller_init(void)
+{
+       /* no support yet */
+#warning ARM:WRITEME
+       return B_OK;
+}
+
+
+phys_addr_t
+pci_ram_address(phys_addr_t physical_address_in_system_memory)
+{
+       return physical_address_in_system_memory;
+}
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.c 
b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.c
new file mode 100644
index 0000000000..f0b9a700d5
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2009, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "pci_io.h"
+#include "pci_private.h"
+#warning ARM:WRITEME
+
+
+status_t
+pci_io_init()
+{
+       return B_OK;
+}
+
+
+uint8
+pci_read_io_8(int mapped_io_addr)
+{
+       /* NOT IMPLEMENTED */
+       return 0;
+}
+
+
+void
+pci_write_io_8(int mapped_io_addr, uint8 value)
+{
+       /* NOT IMPLEMENTED */
+}
+
+
+uint16
+pci_read_io_16(int mapped_io_addr)
+{
+       /* NOT IMPLEMENTED */
+       return 0;
+}
+
+
+void
+pci_write_io_16(int mapped_io_addr, uint16 value)
+{
+       /* NOT IMPLEMENTED */
+}
+
+
+uint32
+pci_read_io_32(int mapped_io_addr)
+{
+       /* NOT IMPLEMENTED */
+       return 0;
+}
+
+
+void
+pci_write_io_32(int mapped_io_addr, uint32 value)
+{
+       /* NOT IMPLEMENTED */
+}
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.h 
b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.h
new file mode 100644
index 0000000000..a900b6c82c
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/arm64/pci_io.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2009, Haiku Inc.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef PCI_BUS_MANAGER_ARM_IO_H
+#define PCI_BUS_MANAGER_ARM_IO_H
+
+
+#include <SupportDefs.h>
+
+
+#endif // PCI_BUS_MANAGER_ARM_IO_H
diff --git a/src/add-ons/kernel/cpu/arm64/Jamfile 
b/src/add-ons/kernel/cpu/arm64/Jamfile
new file mode 100644
index 0000000000..d862fe6713
--- /dev/null
+++ b/src/add-ons/kernel/cpu/arm64/Jamfile
@@ -0,0 +1,2 @@
+SubDir HAIKU_TOP src add-ons kernel cpu arm64 ;
+
diff --git a/src/kits/debug/arch/arm64/arch_debug_support.cpp 
b/src/kits/debug/arch/arm64/arch_debug_support.cpp
new file mode 100644
index 0000000000..f7dc726046
--- /dev/null
+++ b/src/kits/debug/arch/arm64/arch_debug_support.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <debug_support.h>
+
+#include "arch_debug_support.h"
+
+status_t
+arch_debug_get_instruction_pointer(debug_context *context, thread_id thread,
+       void **ip, void **stackFrameAddress)
+{
+       return B_ERROR;
+}
+
+
+status_t
+arch_debug_get_stack_frame(debug_context *context, void *stackFrameAddress,
+       debug_stack_frame_info *stackFrameInfo)
+{
+       return B_ERROR;
+}
diff --git a/src/system/boot/arch/arm64/Jamfile 
b/src/system/boot/arch/arm64/Jamfile
new file mode 100644
index 0000000000..c89edfd49a
--- /dev/null
+++ b/src/system/boot/arch/arm64/Jamfile
@@ -0,0 +1,41 @@
+SubDir HAIKU_TOP src system boot arch arm64 ;
+
+UseLibraryHeaders [ FDirName libfdt ] ;
+UsePrivateHeaders [ FDirName kernel platform $(TARGET_BOOT_PLATFORM) ] ;
+SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers fdt ;
+
+# TODO: Is there any reason to recompile arch_string.S here?
+local librootArchObjects =
+#      <src!system!libroot!posix!string!arch!$(TARGET_ARCH)>arch_string.o
+       arch_string.S
+;
+
+local kernelLibArchObjects =
+       <src!system!kernel!lib!arch!$(TARGET_ARCH)>byteorder.o
+       <src!system!kernel!lib!arch!$(TARGET_ARCH)>memset.o
+;
+
+local platform ;
+for platform in [ MultiBootSubDirSetup u-boot efi ] {
+    on $(platform) {
+               DEFINES += _BOOT_MODE ;
+               BootMergeObject [ FGristFiles boot_arch_$(TARGET_KERNEL_ARCH).o 
] :
+                       # Reuse a subset of kernel debugging.
+                       $(librootArchObjects)
+                       :
+                       :
+                       $(kernelLibArchObjects)
+               ;
+               SEARCH on [ FGristFiles arch_elf.cpp $(kernelArchDriverSources) 
]
+                       = [ FDirName $(HAIKU_TOP) src system kernel arch 
$(TARGET_KERNEL_ARCH) ] ;
+
+               SEARCH on [ FGristFiles $(kernelGenericDriverSources) ]
+                       = [ FDirName $(HAIKU_TOP) src system kernel arch 
generic ] ;
+
+               SEARCH on [ FGristFiles $(librootArchObjects) ]
+                       = [ FDirName $(HAIKU_TOP) src system libroot posix 
string arch $(TARGET_ARCH) ] ;
+
+               SEARCH on [ FGristFiles $(kernelDebugSources) ]
+                       = [ FDirName $(HAIKU_TOP) src system kernel debug ] ;
+       }
+}
diff --git a/src/system/kernel/arch/arm64/Jamfile 
b/src/system/kernel/arch/arm64/Jamfile
index 9557fadcbc..88f33b1c14 100644
--- a/src/system/kernel/arch/arm64/Jamfile
+++ b/src/system/kernel/arch/arm64/Jamfile
@@ -2,3 +2,11 @@ SubDir HAIKU_TOP src system kernel arch arm64 ;
 
 SubDirHdrs $(SUBDIR) $(DOTDOT) generic ;
 UsePrivateKernelHeaders ;
+
+KernelMergeObject kernel_arch_arm64.o :
+       arch_elf.cpp
+       
+       :
+       $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused
+       :
+;
diff --git a/src/system/kernel/arch/arm64/arch_elf.cpp 
b/src/system/kernel/arch/arm64/arch_elf.cpp
new file mode 100644
index 0000000000..a2f2e8951a
--- /dev/null
+++ b/src/system/kernel/arch/arm64/arch_elf.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2004-2018, Haiku Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT license.
+ *
+ * Copyright 2002, Travis Geiselbrecht. All rights reserved.
+ * Distributed under the terms of the NewOS License.
+ */
+
+
+#ifdef _BOOT_MODE
+#      include <boot/arch.h>
+#endif
+
+#include <KernelExport.h>
+
+#include <elf_priv.h>
+#include <arch/elf.h>
+
+
+//#define TRACE_ARCH_ELF
+#ifdef TRACE_ARCH_ELF
+#      define TRACE(x) dprintf x
+#else
+#      define TRACE(x) ;
+#endif
+
+
+#ifndef _BOOT_MODE
+static bool
+is_in_image(struct elf_image_info *image, addr_t address)
+{
+       return (address >= image->text_region.start
+                       && address < image->text_region.start + 
image->text_region.size)
+               || (address >= image->data_region.start
+                       && address < image->data_region.start + 
image->data_region.size);
+}
+#endif // !_BOOT_MODE
+
+
+#ifdef _BOOT_MODE
+status_t
+boot_arch_elf_relocate_rel(preloaded_elf64_image* image, Elf64_Rel* rel,
+       int relLength)
+#else
+int
+arch_elf_relocate_rel(struct elf_image_info *image,
+       struct elf_image_info *resolveImage, Elf64_Rel *rel, int relLength)
+#endif
+{
+       dprintf("arch_elf_relocate_rel: not supported on arm64\n");
+       return B_ERROR;
+}
+
+
+#ifdef _BOOT_MODE
+status_t
+boot_arch_elf_relocate_rela(preloaded_elf64_image* image, Elf64_Rela* rel,
+       int relLength)
+#else
+int
+arch_elf_relocate_rela(struct elf_image_info *image,
+       struct elf_image_info *resolveImage, Elf64_Rela *rel, int relLength)
+#endif
+{
+       for (int i = 0; i < relLength / (int)sizeof(Elf64_Rela); i++) {
+               int type = ELF64_R_TYPE(rel[i].r_info);
+               int symIndex = ELF64_R_SYM(rel[i].r_info);
+               Elf64_Addr symAddr = 0;
+
+               // Resolve the symbol, if any.
+               if (symIndex != 0) {
+                       Elf64_Sym* symbol = SYMBOL(image, symIndex);
+
+                       status_t status;
+#ifdef _BOOT_MODE
+                       status = boot_elf_resolve_symbol(image, symbol, 
&symAddr);
+#else
+                       status = elf_resolve_symbol(image, symbol, 
resolveImage, &symAddr);
+#endif
+                       if (status < B_OK)
+                               return status;
+               }
+
+               // Address of the relocation.
+               Elf64_Addr relocAddr = image->text_region.delta + 
rel[i].r_offset;
+
+               // Calculate the relocation value.
+               Elf64_Addr relocValue;
+               switch (type) {
+                       default:
+                               dprintf("arch_elf_relocate_rela: unhandled 
relocation type %d\n",
+                                       type);
+                               return B_BAD_DATA;
+               }
+#ifdef _BOOT_MODE
+               boot_elf64_set_relocation(relocAddr, relocValue);
+#else
+               if (!is_in_image(image, relocAddr)) {
+                       dprintf("arch_elf_relocate_rela: invalid offset %#lx\n",
+                               rel[i].r_offset);
+                       return B_BAD_ADDRESS;
+               }
+#endif
+       }
+
+       return B_OK;
+}
diff --git a/src/system/kernel/lib/arch/arm64/Jamfile 
b/src/system/kernel/lib/arch/arm64/Jamfile
new file mode 100644
index 0000000000..a2dc1cd0ad
--- /dev/null
+++ b/src/system/kernel/lib/arch/arm64/Jamfile
@@ -0,0 +1,27 @@
+SubDir HAIKU_TOP src system kernel lib arch arm64 ;
+
+SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
+
+local librootSources = [ FDirName $(HAIKU_TOP) src system libroot ] ;
+local posixSources = [ FDirName $(librootSources) posix ] ;
+
+SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ;
+SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ;
+
+KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :
+       generic_atomic.cpp
+       generic_system_time_nsecs.cpp
+
+       : $(TARGET_KERNEL_PIC_CCFLAGS)
+;
+
+SEARCH_SOURCE += [ FDirName $(posixSources) arch $(TARGET_ARCH) ] ;
+SEARCH_SOURCE += [ FDirName $(posixSources) string arch generic ] ;
+SEARCH_SOURCE += [ FDirName $(posixSources) string arch $(TARGET_ARCH) ] ;
+
+KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o :
+       arch_string.S
+       memset.c
+
+       : $(TARGET_KERNEL_PIC_CCFLAGS)
+;
diff --git a/src/system/libroot/os/arch/arm64/Jamfile 
b/src/system/libroot/os/arch/arm64/Jamfile
index d8d33832fd..2bfb410ca9 100644
--- a/src/system/libroot/os/arch/arm64/Jamfile
+++ b/src/system/libroot/os/arch/arm64/Jamfile
@@ -1,4 +1,4 @@
-SubDir HAIKU_TOP src system libroot os arch arm ;
+SubDir HAIKU_TOP src system libroot os arch arm64 ;
 
 SubDirC++Flags -std=gnu++11 ;
 
@@ -13,7 +13,8 @@ for architectureObject in [ MultiArchSubDirSetup arm64 ] {
                SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
 
                MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o :
-
+                       tls.c
+                       thread.c
 
                        generic_atomic.cpp
                        generic_stack_trace.cpp
diff --git a/src/system/libroot/os/arch/arm64/thread.c 
b/src/system/libroot/os/arch/arm64/thread.c
new file mode 100644
index 0000000000..be6bd7259c
--- /dev/null
+++ b/src/system/libroot/os/arch/arm64/thread.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2019 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include <OS.h>
+#include "syscalls.h"
+
+
+thread_id
+find_thread(const char *name)
+{
+       return _kern_find_thread(name);
+}
diff --git a/src/system/libroot/os/arch/arm64/tls.c 
b/src/system/libroot/os/arch/arm64/tls.c
new file mode 100644
index 0000000000..20550ef938
--- /dev/null
+++ b/src/system/libroot/os/arch/arm64/tls.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <runtime_loader/runtime_loader.h>
+
+#include "support/TLS.h"
+#include "tls.h"
+
+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;
+
+
+int32
+tls_allocate(void)
+{
+       int32 next = atomic_add(&gNextSlot, 1);
+       if (next >= TLS_MAX_KEYS)
+               return B_NO_MEMORY;
+
+       return next;
+}
+
+
+void *
+tls_get(int32 index)
+{
+       return NULL;
+}
+
+
+void **
+tls_address(int32 index)
+{
+       return NULL;
+}
+
+
+void
+tls_set(int32 index, void *value)
+{
+
+}
+
+
+void*
+__tls_get_addr(struct tls_index* ti)
+{
+       return __gRuntimeLoader->get_tls_address(ti->ti_module, ti->ti_offset);
+}
diff --git a/src/system/libroot/posix/arch/arm64/Jamfile 
b/src/system/libroot/posix/arch/arm64/Jamfile
new file mode 100644
index 0000000000..295780be59
--- /dev/null
+++ b/src/system/libroot/posix/arch/arm64/Jamfile
@@ -0,0 +1,26 @@
+SubDir HAIKU_TOP src system libroot posix arch arm64 ;
+
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup arm64 ] {
+       on $(architectureObject) {
+               local architecture = $(TARGET_PACKAGING_ARCH) ;
+
+               UsePrivateHeaders [ FDirName system arch $(TARGET_ARCH) ] ;
+
+               local genericSources =
+                       setjmp_save_sigs.c
+                       longjmp_return.c
+                       ;
+
+               MergeObject <$(architecture)>posix_arch_$(TARGET_ARCH).o :
+                       fenv.c
+                       sigsetjmp.S
+                       siglongjmp.S
+
+                       $(genericSources)
+                       ;
+
+               SEARCH on [ FGristFiles $(genericSources) ]
+                       = [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
+       }
+}
diff --git a/src/system/libroot/posix/arch/arm64/fenv.c 
b/src/system/libroot/posix/arch/arm64/fenv.c
new file mode 100644
index 0000000000..4ec362f105
--- /dev/null
+++ b/src/system/libroot/posix/arch/arm64/fenv.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@xxxxxxxxxxx>
+ * Copyright (c) 2013 Andrew Turner <andrew@xxxxxxxxxxx>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#define        __fenv_static
+#include "fenv.h"
+
+/*
+ * Hopefully the system ID byte is immutable, so it's valid to use
+ * this as a default environment.
+ */
+const fenv_t __fe_dfl_env = 0;
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);
+extern inline int feenableexcept(int __mask);
+extern inline int fedisableexcept(int __mask);
+extern inline int fegetexcept(void);
diff --git a/src/system/libroot/posix/arch/arm64/siglongjmp.S 
b/src/system/libroot/posix/arch/arm64/siglongjmp.S
new file mode 100644
index 0000000000..59e28fc333
--- /dev/null
+++ b/src/system/libroot/posix/arch/arm64/siglongjmp.S
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include <asm_defs.h>
+
+
+/* int __siglongjmp(jmp_buf buffer, int value) */
+FUNCTION(siglongjmp):
+FUNCTION(longjmp):
+FUNCTION(_longjmp):
+       /* Loop infinitely here, for now.
+        TODO implement this for real */
+       b               .
+FUNCTION_END(siglongjmp)
+FUNCTION_END(longjmp)
+FUNCTION_END(_longjmp)
+
+#pragma weak longjmp=siglongjmp
diff --git a/src/system/libroot/posix/arch/arm64/sigsetjmp.S 
b/src/system/libroot/posix/arch/arm64/sigsetjmp.S
new file mode 100644
index 0000000000..edde2aa135
--- /dev/null
+++ b/src/system/libroot/posix/arch/arm64/sigsetjmp.S
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <asm_defs.h>
+
+/* int sigsetjmp(jmp_buf buffer, int saveMask) */
+FUNCTION(__sigsetjmp):
+FUNCTION(sigsetjmp):
+       b       .
+FUNCTION_END(sigsetjmp)
+FUNCTION_END(__sigsetjmp)
+
+
+/* int setjmp(jmp_buf buffer) */
+FUNCTION(setjmp):
+FUNCTION(_setjmp):
+       b       .
+FUNCTION_END(setjmp)
+
+#pragma weak _setjmp=setjmp
diff --git a/src/system/libroot/posix/glibc/arch/arm64/Jamfile 
b/src/system/libroot/posix/glibc/arch/arm64/Jamfile
new file mode 100644
index 0000000000..e700d161fb
--- /dev/null
+++ b/src/system/libroot/posix/glibc/arch/arm64/Jamfile
@@ -0,0 +1,154 @@
+SubDir HAIKU_TOP src system libroot posix glibc arch arm64 ;
+
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch 
$(TARGET_ARCH) ;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch generic 
;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc stdlib ;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc math ;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc libio ;
+SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
+
+SubDirHdrs $(HAIKU_TOP) src system libroot posix glibc arch generic ;
+
+UsePrivateHeaders libroot ;
+
+if $(OPTIM) = -O0 {
+       OPTIM = -O ;
+}
+
+# don't compile with debugging
+DEBUG = 0 ;
+
+SubDirCcFlags -D_GNU_SOURCE -D_IEEE_LIBM ;
+
+# Note: There is no *l() support yet. Our compiler says sizeof(long double) = 
8,
+# while there are only 96 and 128 bit implementation in glibc.
+local genericSources =
+       lshift.c rshift.c submul_1.c
+       add_n.c sub_n.c
+       addmul_1.c mul_1.c
+
+       branred.c
+       cmp.c dbl2mpn.c divrem.c
+       doasin.c dosincos.c
+       halfulp.c
+       memrchr.c
+       mpa.c mpatan.c mpatan2.c mpexp.c mplog.c mpn2dbl.c
+       mpn2flt.c mpn2ldbl.c mpsqrt.c mptan.c
+       mul.c mul_n.c
+       sincos32.c
+       slowexp.c
+       slowpow.c
+
+       e_acos.c e_acosf.c # e_acosl.c
+       e_acosh.c e_acoshf.c # e_acoshl.c
+       e_asin.c e_asinf.c # e_asinl.c
+       e_atan2.c e_atan2f.c # e_atan2l.c
+       e_atanh.c e_atanhf.c # e_atanhl.c
+       e_cosh.c e_coshf.c # e_coshl.c
+       e_exp.c e_expf.c
+       e_fmod.c e_fmodf.c # e_fmodl.c
+       e_gamma_r.c e_gammaf_r.c
+       e_hypot.c e_hypotf.c # e_hypotl.c
+       e_j0.c e_j0f.c
+       e_j1.c e_j1f.c
+       e_jn.c e_jnf.c
+       e_lgamma_r.c e_lgammaf_r.c
+       e_log.c e_logf.c
+       e_log10.c e_log10f.c
+       e_pow.c e_powf.c # e_powl.c
+       e_rem_pio2f.c
+       e_remainder.c e_remainderf.c # e_remainderl.c
+       e_scalb.c e_scalbf.c # e_scalbl.c
+       e_sinh.c e_sinhf.c # e_sinhl.c
+       k_cos.c k_cosf.c
+       k_sin.c k_sinf.c
+       k_rem_pio2.c k_rem_pio2f.c # k_rem_pio2l.c
+       k_tan.c k_tanf.c
+       s_asinh.c s_asinhf.c # s_asinhl.c
+       s_atan.c s_atanf.c # s_atanl.c
+       s_cbrt.c s_cbrtf.c # s_cbrtl.c
+       s_ceil.c s_ceilf.c # s_ceill.c
+       s_cos.c s_cosf.c
+       s_copysign.c s_copysignf.c
+       s_erf.c s_erff.c # s_erfl.c
+       s_expm1f.c s_expm1.c
+       s_finite.c s_finitef.c # s_finitel.c
+       s_clog.c s_clogf.c # s_clogl.c
+       s_csqrt.c s_csqrtf.c # s_csqrtl.c
+       s_floor.c s_floorf.c # s_floorl.c
+       s_fabs.c s_fabsf.c
+       s_fdim.c s_fdimf.c
+       s_fma.c s_fmaf.c # s_fmal.c
+       s_fmax.c s_fmaxf.c
+       s_fmin.c s_fminf.c
+       s_fpclassify.c s_fpclassifyf.c # s_fpclassifyl.c
+       s_frexp.c s_frexpf.c # s_frexpl.c
+       s_ilogb.c s_ilogbf.c
+       s_isinf.c s_isinff.c # s_isinfl.c
+       s_isnan.c s_isnanf.c
+       s_ldexp.c s_ldexpf.c # s_ldexpl.c
+       s_llrint.c s_llrintf.c # s_llrintl.c
+       s_log1p.c s_log1pf.c
+       s_logb.c s_logbf.c # s_logbl.c
+       s_lrint.c s_lrintf.c # s_lrintl.c
+       s_lround.c s_lroundf.c
+       s_modf.c s_modff.c # s_modfl.c
+       s_nan.c s_nanf.c # s_nanl.c
+       # s_nexttoward.c s_nexttowardf.c s_nexttowardl.c
+       s_round.c s_roundf.c # s_roundl.c
+       s_rint.c s_rintf.c
+       s_scalbn.c s_scalbnf.c # s_scalbnl.c
+       s_signbit.c s_signbitf.c # s_signbitl.c
+       s_significand.c s_significandf.c
+       s_signgam.c
+       s_sin.c s_sinf.c # s_sinl.c
+       s_sincos.c s_sincosf.c
+       s_tan.c s_tanf.c
+       s_tanh.c s_tanhf.c
+       s_trunc.c s_truncf.c
+       t_exp.c
+       w_acos.c w_acosf.c # w_acosl.c
+       w_acosh.c w_acoshf.c # w_acoshl.c
+       w_atan2.c w_atan2f.c # w_atan2l.c
+       w_asin.c w_asinf.c # w_asinl.c
+       w_atanh.c w_atanhf.c # w_atanhl.c
+       w_cosh.c w_coshf.c # w_coshl.c
+       w_drem.c w_dremf.c # w_dreml.c
+       w_exp.c w_expf.c # w_expl.c
+       w_fmod.c w_fmodf.c # w_fmodl.c
+       w_hypot.c w_hypotf.c # w_hypotl.c
+       w_j0.c w_j0f.c
+       w_j1.c w_j1f.c
+       w_jn.c w_jnf.c
+       w_lgamma.c w_lgammaf.c
+       w_lgamma_r.c w_lgammaf_r.c
+       w_log.c w_logf.c # w_logl.c
+       w_log10.c w_log10f.c # w_log10l.c
+       w_pow.c w_powf.c # w_powl.c
+       w_remainder.c w_remainderf.c # w_remainderl.c
+       w_scalb.c w_scalbf.c # w_scalbl.c
+       w_sinh.c w_sinhf.c # w_sinhl.c
+       w_sqrt.c w_sqrtf.c
+       w_tgamma.c w_tgammaf.c # w_tgammal.c
+       ;
+
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup arm64 ] {
+       on $(architectureObject) {
+               local architecture = $(TARGET_PACKAGING_ARCH) ;
+
+               MergeObject 
<$(architecture)>posix_gnu_arch_$(TARGET_ARCH)_generic.o :
+                       $(genericSources)
+                       ;
+
+               MergeObjectFromObjects 
<$(architecture)>posix_gnu_arch_$(TARGET_ARCH).o
+                       : :
+                       <$(architecture)>posix_gnu_arch_$(TARGET_ARCH)_generic.o
+                       ;
+
+               SEARCH on [ FGristFiles $(genericSources) ]
+                       = [ FDirName $(HAIKU_TOP) src system libroot posix 
glibc arch
+                               generic ] ;
+       }
+}
diff --git a/src/system/libroot/posix/string/arch/arm64/Jamfile 
b/src/system/libroot/posix/string/arch/arm64/Jamfile
new file mode 100644
index 0000000000..98958391f0
--- /dev/null
+++ b/src/system/libroot/posix/string/arch/arm64/Jamfile
@@ -0,0 +1,18 @@
+SubDir HAIKU_TOP src system libroot posix string arch arm64 ;
+
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup arm64 ] {
+       on $(architectureObject) {
+               local architecture = $(TARGET_PACKAGING_ARCH) ;
+
+               UsePrivateSystemHeaders ;
+
+               SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
+
+               MergeObject <$(architecture)>posix_string_arch_$(TARGET_ARCH).o 
:
+                       arch_string.S
+                       memcpy.c
+                       memset.c
+                       ;
+       }
+}
diff --git a/src/system/libroot/posix/string/arch/arm64/arch_string.S 
b/src/system/libroot/posix/string/arch/arm64/arch_string.S
new file mode 100644
index 0000000000..4c57a0adc0
--- /dev/null
+++ b/src/system/libroot/posix/string/arch/arm64/arch_string.S
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <asm_defs.h>
diff --git a/src/system/runtime_loader/arch/arm64/Jamfile 
b/src/system/runtime_loader/arch/arm64/Jamfile
new file mode 100644
index 0000000000..a1e1867657
--- /dev/null
+++ b/src/system/runtime_loader/arch/arm64/Jamfile
@@ -0,0 +1,22 @@
+SubDir HAIKU_TOP src system runtime_loader arch arm64 ;
+
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup arm64 ] {
+       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
+                       :
+                       
<src!system!libroot!os!arch!$(TARGET_ARCH)!$(architecture)>thread.o
+
+                       
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)!$(architecture)>arch_string.o
+                       
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)!$(architecture)>memset.o
+                       ;
+       }
+}
diff --git a/src/system/runtime_loader/arch/arm64/arch_relocate.cpp 
b/src/system/runtime_loader/arch/arm64/arch_relocate.cpp
new file mode 100644
index 0000000000..13968f0db2
--- /dev/null
+++ b/src/system/runtime_loader/arch/arm64/arch_relocate.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "runtime_loader_private.h"
+
+#include <runtime_loader.h>
+
+
+//#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;
+}


Other related posts:

  • » [haiku-commits] haiku: hrev53762 - in src: system/libroot/posix/glibc/arch/arm64 system/libroot/posix/arch/arm64 system/kernel/arch/arm64 add-ons/kernel/bus_managers/isa/arch/arm64 add-ons/kernel/bus_managers/pci/arch/arm64 - Adrien Destugues