[haiku-commits] haiku: hrev53034 - in src: system/boot/platform/openfirmware/arch/sparc add-ons/kernel/bus_managers/pci/arch/sparc add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware system/ldscripts/sparc system/boot/platform/openfirmware

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 4 Apr 2019 16:31:29 -0400 (EDT)

hrev53034 adds 7 changesets to branch 'master'
old head: 834a613e53f13fef910cb12bacbc1403d35b6c2d
new head: b1ec65fcfecdd145707ad1fcdbf4b66be02ff606
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b1ec65fcfecd+%5E834a613e53f1

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

e8f58ba4beb7: sparc: fix bootloader build
  
  - Add various missing jamfiles
  - Add required implementation stubs
  - Update openfirmware jamfiles for multiboot support
  - Update linker rules for sparc loader
  
  Change-Id: I2d06c7a4d33827f58d82946687003f9a0dcb1b7d
  Reviewed-on: https://review.haiku-os.org/c/1329
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

2f2d56e2e334: Move stack_trace.cpp to generic directory.
  
  4 architectures are using it, so it is generic enough.
  Make it error out for platforms where the stack grows in the other
  direction. Another implementation can be added for them.
  
  Change-Id: Ia52b5dd34da7b5ebcca0782af079c43d72ba3a8e
  Reviewed-on: https://review.haiku-os.org/c/1340
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

d0ff1a1f2fad: openfirmware: fix mismatched prototype
  
  Change-Id: I294608aa739bedef47c6c1f34fba0241444a8901
  Reviewed-on: https://review.haiku-os.org/c/1363
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

fea91fdc77c1: sparc: pci bus manager
  
  Copied from PPC with the hooks for Apple hardware removed.
  To be completed with the actual PCI bus implementation for Sun machines.
  This is where we start doing machine specific stuff, apparently.
  
  Change-Id: I06af4de9621e9d40593d153642478d928083e49a
  Reviewed-on: https://review.haiku-os.org/c/1364
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

815a1596a6d3: openfirmware: support a.out bootloader
  
  Apparently each architecture and manufacturer uses a different binary
  format (I heard current POWER hardware uses elf).
  
  Change-Id: I4f1b9977d0a9d5a700c2d50b36844d6e4640b68b
  Reviewed-on: https://review.haiku-os.org/c/1365
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

1cba023e0a69: sparc: fix support for elf in boot mode
  
  Change-Id: I901a4e494dd5273a0aa433f08b94363b486c58e1
  Reviewed-on: https://review.haiku-os.org/c/1366
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

b1ec65fcfecd: sparc: link the runtime_loader
  
  Change-Id: Id30476480f4e4141935d6735209ecc0872dd6696
  Reviewed-on: https://review.haiku-os.org/c/1367
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                   [ PulkoMandy <pulkomandy@xxxxxxxxxxxxx> ]

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

32 files changed, 1363 insertions(+), 59 deletions(-)
headers/private/kernel/arch/sparc/arch_mmu.h     |  15 +
.../private/kernel/arch/sparc/arch_platform.h    |  50 ++
.../kernel}/boot/platform/openfirmware/support.h |   0
.../config_manager/arch/sparc/Jamfile            |  11 +
.../arch/sparc/config_manager_arch.c             |  18 +
.../kernel/bus_managers/pci/arch/sparc/Jamfile   |  16 +
.../arch/sparc/openfirmware/pci_openfirmware.cpp | 105 +++++
.../arch/sparc/openfirmware/pci_openfirmware.h   |  13 +
.../sparc/openfirmware/pci_openfirmware_priv.h   |  49 ++
.../pci/arch/sparc/pci_controller.cpp            |  27 ++
.../kernel/bus_managers/pci/arch/sparc/pci_io.c  |  61 +++
.../kernel/bus_managers/pci/arch/sparc/pci_io.h  |  97 ++++
src/system/boot/Jamfile                          |  50 +-
src/system/boot/arch/sparc/Jamfile               |  48 +-
src/system/boot/platform/openfirmware/Jamfile    |  45 +-
.../platform/openfirmware/arch/sparc/Jamfile     |   5 +-
.../openfirmware/arch/sparc/arch_start_kernel.S  |  16 +
.../platform/openfirmware/arch/sparc/cpu.cpp     | 125 +++++
.../platform/openfirmware/arch/sparc/mmu.cpp     | 457 +++++++++++++++++++
src/system/kernel/arch/sparc/arch_elf.cpp        |  12 +
.../platform/openfirmware/openfirmware.cpp       |   2 +-
.../ldscripts/sparc/boot_loader_openfirmware.ld  |  45 ++
src/system/ldscripts/sparc/runtime_loader.ld     |  63 +++
.../arch/{x86_common => generic}/stack_trace.cpp |   8 +
src/system/libroot/os/arch/ppc/Jamfile           |   2 +-
src/system/libroot/os/arch/sparc/Jamfile         |   1 +
src/system/libroot/os/arch/x86/Jamfile           |   3 -
src/system/libroot/os/arch/x86_64/Jamfile        |   5 +-
.../libroot/posix/string/arch/sparc/Jamfile      |  19 +-
src/system/runtime_loader/Jamfile                |   2 +-
src/system/runtime_loader/arch/sparc/Jamfile     |  22 +
.../runtime_loader/arch/sparc/arch_relocate.cpp  |  30 ++

############################################################################

Commit:      e8f58ba4beb77a0a6c42e17bcf89cce7a999f8d8
URL:         https://git.haiku-os.org/haiku/commit/?id=e8f58ba4beb7
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Thu Mar 28 07:07:33 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

sparc: fix bootloader build

- Add various missing jamfiles
- Add required implementation stubs
- Update openfirmware jamfiles for multiboot support
- Update linker rules for sparc loader

Change-Id: I2d06c7a4d33827f58d82946687003f9a0dcb1b7d
Reviewed-on: https://review.haiku-os.org/c/1329
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/headers/private/kernel/arch/sparc/arch_mmu.h 
b/headers/private/kernel/arch/sparc/arch_mmu.h
new file mode 100644
index 0000000000..e271186bcd
--- /dev/null
+++ b/headers/private/kernel/arch/sparc/arch_mmu.h
@@ -0,0 +1,15 @@
+/*
+** Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
+** Distributed under the terms of the MIT License.
+*/
+#ifndef _KERNEL_ARCH_SPARC_MMU_H
+#define _KERNEL_ARCH_SPARC_MMU_H
+
+
+#include <SupportDefs.h>
+#include <string.h>
+
+#include <arch_cpu.h>
+
+
+#endif /* _KERNEL_ARCH_SPARC_MMU_H */
diff --git a/src/system/boot/platform/openfirmware/support.h 
b/headers/private/kernel/boot/platform/openfirmware/support.h
similarity index 100%
rename from src/system/boot/platform/openfirmware/support.h
rename to headers/private/kernel/boot/platform/openfirmware/support.h
diff --git a/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/Jamfile 
b/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/Jamfile
new file mode 100644
index 0000000000..f1ee9bbc15
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/Jamfile
@@ -0,0 +1,11 @@
+SubDir HAIKU_TOP src add-ons kernel bus_managers config_manager arch 
$(TARGET_ARCH) ;
+
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
+
+UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] ;
+
+KernelStaticLibrary config_manager_arch :
+       config_manager_arch.c
+       ;
+
+
diff --git 
a/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/config_manager_arch.c
 
b/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/config_manager_arch.c
new file mode 100644
index 0000000000..1996ba4daf
--- /dev/null
+++ 
b/src/add-ons/kernel/bus_managers/config_manager/arch/sparc/config_manager_arch.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2009 Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * arch-specific config manager
+ *
+ * Authors (in chronological order):
+ *              François Revol (revol@xxxxxxx)
+ */
+
+#include <OS.h>
+#include <config_manager.h>
+
+int config_manager_scan_hardcoded(struct device_info **info, int32 *count)
+{
+       return B_OK;
+}
+
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile
new file mode 100644
index 0000000000..3a4790e24e
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile
@@ -0,0 +1,16 @@
+SubDir HAIKU_TOP src add-ons kernel bus_managers pci arch sparc ;
+
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
+UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ]
+       [ FDirName kernel boot platform $(HAIKU_BOOT_PLATFORM) ] ;
+
+SEARCH_SOURCE += [ FDirName $(SUBDIR) openfirmware ] ;
+
+KernelStaticLibrary pci_arch_bus_manager :
+       pci_controller.cpp
+       pci_io.c
+
+       # openfirmware
+       # TODO
+;
+
diff --git a/src/system/boot/arch/sparc/Jamfile 
b/src/system/boot/arch/sparc/Jamfile
index 0ff3a31120..5ce2dbe955 100644
--- a/src/system/boot/arch/sparc/Jamfile
+++ b/src/system/boot/arch/sparc/Jamfile
@@ -1,33 +1,29 @@
 SubDir HAIKU_TOP src system boot arch sparc ;
 
-{
-       local defines = _BOOT_MODE ;
-
-       defines = [ FDefines $(defines) ] ;
-       SubDirCcFlags $(defines) ;
-       SubDirC++Flags $(defines) -fno-rtti ;
-}
-
-
 local kernelLibArchObjects =
-       <src!system!kernel!lib!arch!$(TARGET_ARCH)>byteorder.o
        <src!system!kernel!lib!arch!$(TARGET_ARCH)>memcpy.o
        <src!system!kernel!lib!arch!$(TARGET_ARCH)>memset.o
 ;
 
-BootMergeObject boot_arch_$(TARGET_KERNEL_ARCH).o :
-       debug_uart_8250.cpp
-       #arch_uart_8250.cpp
-       arch_elf.cpp
-       : # additional flags
-       :
-       $(kernelArchObjects)
-       $(kernelLibArchObjects)
-;
-
-SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ]
-    = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ;
-
-SEARCH on [ FGristFiles debug_uart_8250.cpp ]
-       = [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ;
-
+local platform ;
+for platform in [ MultiBootSubDirSetup openfirmware ] {
+    on $(platform) {
+               DEFINES += _BOOT_MODE ;
+
+               BootMergeObject [ FGristFiles boot_arch_$(TARGET_KERNEL_ARCH).o 
] :
+                       debug_uart_8250.cpp
+                       #arch_uart_8250.cpp
+                       arch_elf.cpp
+                       : # additional flags
+                       :
+                       $(kernelArchObjects)
+                       $(kernelLibArchObjects)
+               ;
+
+               SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ]
+                   = [ FDirName $(HAIKU_TOP) src system kernel arch 
$(TARGET_KERNEL_ARCH) ] ;
+
+               SEARCH on [ FGristFiles debug_uart_8250.cpp ]
+                       = [ FDirName $(HAIKU_TOP) src system kernel arch 
generic ] ;
+       }
+}
diff --git a/src/system/boot/platform/openfirmware/Jamfile 
b/src/system/boot/platform/openfirmware/Jamfile
index 43f2f2c765..736258595b 100644
--- a/src/system/boot/platform/openfirmware/Jamfile
+++ b/src/system/boot/platform/openfirmware/Jamfile
@@ -4,9 +4,14 @@ SubDirC++Flags -D_BOOT_MODE -fno-rtti ;
 
 UsePrivateHeaders [ FDirName graphics common ] ;
 
-SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
+{
+       local defines = _BOOT_MODE _BOOT_PLATFORM_OPENFIRMWARE ;
+       defines = [ FDefines $(defines) ] ;
+       SubDirCcFlags $(defines) ;
+       SubDirC++Flags $(defines) -fno-rtti ;
+}
 
-BootMergeObject boot_platform_openfirmware.o :
+local platform_src =
        console.cpp
        debug.cpp
        devices.cpp
@@ -19,23 +24,41 @@ BootMergeObject boot_platform_openfirmware.o :
        start.cpp
        support.cpp
        video.cpp
+;
 
+local kernel_src =
        openfirmware.cpp
        openfirmware_devices.cpp
+;
 
+local vesa_src =
        # VESA/DDC EDID
        decode_edid.c
        dump_edid.c
-
-       :
-       :
-       boot_platform_generic.a
-       boot_platform_openfirmware_$(TARGET_ARCH).a
 ;
 
-SEARCH on [ FGristFiles $(genericPlatformSources) ]
-       = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;
-SEARCH on [ FGristFiles openfirmware.cpp openfirmware_devices.cpp ]
-       = [ FDirName $(HAIKU_TOP) src system kernel platform openfirmware ] ;
+local platform ;
+for platform in [ MultiBootSubDirSetup openfirmware ] {
+       on $(platform) {
+               BootMergeObject boot_platform_openfirmware.o :
+
+                       $(platform_src)
+                       $(kernel_src)
+                       $(vesa_src)
+               :
+               :
+                       boot_platform_generic_openfirmware.a
+                       boot_platform_openfirmware_$(TARGET_ARCH).a
+               ;
+
+#              SEARCH on [ FGristFiles $(genericPlatformSources) ]
+#                      = [ FDirName $(HAIKU_TOP) src system boot platform 
generic ] ;
+               SEARCH on [ FGristFiles $(kernel_src) ]
+                       = [ FDirName $(HAIKU_TOP) src system kernel platform 
openfirmware ] ;
+               SEARCH on [ FGristFiles $(vesa_src) ]
+                       = [ FDirName $(HAIKU_TOP) src add-ons accelerants 
common ] ;
+
+       }
+}
 
 SubInclude HAIKU_TOP src system boot platform openfirmware arch ;
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/Jamfile 
b/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
index b081899dd7..4871b0cb49 100644
--- a/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
+++ b/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
@@ -1,6 +1,6 @@
 SubDir HAIKU_TOP src system boot platform openfirmware arch sparc ;
 
-SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ;
+SubDirHdrs $(HAIKU_TOP) src system boot platform $(HAIKU_BOOT_PLATFORM) ;
 UsePrivateSystemHeaders ;
 UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_KERNEL_ARCH) ] 
        [ FDirName kernel boot platform $(HAIKU_KERNEL_PLATFORM) ]
@@ -9,6 +9,9 @@ UsePrivateHeaders kernel [ FDirName kernel arch 
$(TARGET_KERNEL_ARCH) ]
 SubDirC++Flags -fno-rtti ;
 
 BootStaticLibrary boot_platform_openfirmware_sparc :
+       arch_start_kernel.S
+       cpu.cpp
+       mmu.cpp
 ;
 
 SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
diff --git 
a/src/system/boot/platform/openfirmware/arch/sparc/arch_start_kernel.S 
b/src/system/boot/platform/openfirmware/arch/sparc/arch_start_kernel.S
new file mode 100644
index 0000000000..54bc658dbc
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/arch/sparc/arch_start_kernel.S
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2005, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#define FUNCTION(x) .global x; .type x,@function; x
+
+/*     status_t arch_start_kernel(struct kernel_args *kernelArgs,
+               addr_t kernelEntry, addr_t kernelStackTop);
+
+       r3      - kernelArgs
+       r4      - kernelEntry
+       r5      - kernelStackTop
+*/
+FUNCTION(arch_start_kernel):
+       return
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/cpu.cpp 
b/src/system/boot/platform/openfirmware/arch/sparc/cpu.cpp
new file mode 100644
index 0000000000..517c228add
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/arch/sparc/cpu.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2005, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#include <boot/platform/openfirmware/platform_arch.h>
+
+#include <stdio.h>
+
+#include <KernelExport.h>
+
+#include <boot/kernel_args.h>
+#include <boot/stage2.h>
+#include <kernel.h>
+#include <platform/openfirmware/devices.h>
+#include <platform/openfirmware/openfirmware.h>
+
+#define TRACE_CPU
+#ifdef TRACE_CPU
+#      define TRACE(x) dprintf x
+#else
+#      define TRACE(x) ;
+#endif
+
+
+status_t
+boot_arch_cpu_init(void)
+{
+       int32 busFrequency = 0;
+
+       int root = of_finddevice("/");
+       if (root == OF_FAILED) {
+               printf("boot_arch_cpu_init(): Failed to open \"/\"!\n");
+               return B_ERROR;
+       }
+
+       of_getprop(root, "clock-frequency", &busFrequency, 4);
+               // we might find it in /cpus instead
+
+       // iterate through the "/cpus" node to find all CPUs
+       int cpus = of_finddevice("/cpus");
+       if (cpus == OF_FAILED) {
+               printf("boot_arch_cpu_init(): Failed to open \"/cpus\"!\n");
+               return B_ERROR;
+       }
+
+       char cpuPath[256];
+       int cookie = 0;
+       int cpuCount = 0;
+       while (of_get_next_device(&cookie, cpus, "cpu", cpuPath,
+                       sizeof(cpuPath)) == B_OK) {
+               TRACE(("found CPU: %s\n", cpuPath));
+
+               // For the first CPU get the frequencies of CPU, bus, and time 
base.
+               // We assume they are the same for all CPUs.
+               if (cpuCount == 0) {
+                       int cpu = of_finddevice(cpuPath);
+                       if (cpu == OF_FAILED) {
+                               printf("boot_arch_cpu_init: Failed get CPU 
device node!\n");
+                               return B_ERROR;
+                       }
+
+                       // TODO: Does encode-int really encode quadlet (32 bit 
numbers)
+                       // only?
+                       int32 clockFrequency;
+                       if (of_getprop(cpu, "clock-frequency", &clockFrequency, 
4)
+                                       == OF_FAILED) {
+                               printf("boot_arch_cpu_init: Failed to get CPU 
clock "
+                                       "frequency!\n");
+                               return B_ERROR;
+                       }
+                       if (busFrequency == 0
+                               && of_getprop(cpu, "bus-frequency", 
&busFrequency, 4)
+                                       == OF_FAILED) {
+                               printf("boot_arch_cpu_init: Failed to get bus 
clock "
+                                       "frequency!\n");
+                               return B_ERROR;
+                       }
+                       int32 timeBaseFrequency;
+                       if (of_getprop(cpu, "timebase-frequency", 
&timeBaseFrequency, 4)
+                                       == OF_FAILED) {
+                               printf("boot_arch_cpu_init: Failed to get time 
base "
+                                       "frequency!\n");
+                               return B_ERROR;
+                       }
+
+                       gKernelArgs.arch_args.cpu_frequency = clockFrequency;
+                       gKernelArgs.arch_args.bus_frequency = busFrequency;
+                       gKernelArgs.arch_args.time_base_frequency = 
timeBaseFrequency;
+
+                       TRACE(("  CPU clock frequency: %d\n", clockFrequency));
+                       TRACE(("  bus clock frequency: %d\n", busFrequency));
+                       TRACE(("  time base frequency: %d\n", 
timeBaseFrequency));
+               }
+
+               cpuCount++;
+       }
+
+       if (cpuCount == 0) {
+               printf("boot_arch_cpu_init(): Found no CPUs!\n");
+               return B_ERROR;
+       }
+
+       gKernelArgs.num_cpus = cpuCount;
+
+       // allocate the kernel stacks (the memory stuff is already initialized
+       // at this point)
+       addr_t stack = (addr_t)arch_mmu_allocate((void*)0x80000000,
+               cpuCount * (KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * 
B_PAGE_SIZE),
+               B_READ_AREA | B_WRITE_AREA, false);
+       if (!stack) {
+               printf("boot_arch_cpu_init(): Failed to allocate kernel 
stack(s)!\n");
+               return B_NO_MEMORY;
+       }
+
+       for (int i = 0; i < cpuCount; i++) {
+               gKernelArgs.cpu_kstack[i].start = stack;
+               gKernelArgs.cpu_kstack[i].size = KERNEL_STACK_SIZE
+                       + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE;
+               stack += KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * 
B_PAGE_SIZE;
+       }
+
+       return B_OK;
+}
+
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/mmu.cpp 
b/src/system/boot/platform/openfirmware/arch/sparc/mmu.cpp
new file mode 100644
index 0000000000..7d5f4bde6b
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/arch/sparc/mmu.cpp
@@ -0,0 +1,457 @@
+/*
+ * Copyright 2003-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2010-2011, Haiku, Inc. All Rights Reserved.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ *             Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ */
+
+
+#include <OS.h>
+
+#include <platform_arch.h>
+#include <boot/addr_range.h>
+#include <boot/kernel_args.h>
+#include <boot/platform.h>
+#include <boot/stage2.h>
+#include <boot/stdio.h>
+#include <platform/openfirmware/openfirmware.h>
+#include <arch_cpu.h>
+#include <arch_mmu.h>
+#include <kernel.h>
+
+#include "support.h"
+
+
+// set protection to WIMGNPP: -----PP
+// PP: 00 - no access
+//             01 - read only
+//             10 - read/write
+//             11 - read only
+#define PAGE_READ_ONLY 0x01
+#define PAGE_READ_WRITE        0x02
+
+// NULL is actually a possible physical address...
+//#define PHYSINVAL ((void *)-1)
+#define PHYSINVAL NULL
+
+//#define TRACE_MMU
+#ifdef TRACE_MMU
+#   define TRACE(x...) dprintf(x)
+#else
+#   define TRACE(x...) ;
+#endif
+
+
+uint32 sPageTableHashMask;
+
+
+// begin and end of the boot loader
+extern "C" uint8 __text_begin;
+extern "C" uint8 _end;
+
+
+static status_t
+find_physical_memory_ranges(size_t &total)
+{
+       int memory;
+       dprintf("checking for memory...\n");
+       if (of_getprop(gChosen, "memory", &memory, sizeof(int)) == OF_FAILED)
+               return B_ERROR;
+       int package = of_instance_to_package(memory);
+
+       total = 0;
+
+       // Memory base addresses are provided in 32 or 64 bit flavors
+       // #address-cells and #size-cells matches the number of 32-bit 'cells'
+       // representing the length of the base address and size fields
+       int root = of_finddevice("/");
+       int32 regAddressCells = of_address_cells(root);
+       int32 regSizeCells = of_size_cells(root);
+       if (regAddressCells == OF_FAILED || regSizeCells == OF_FAILED) {
+               dprintf("finding base/size length counts failed, assume 
32-bit.\n");
+               regAddressCells = 1;
+               regSizeCells = 1;
+       }
+
+       // NOTE : Size Cells of 2 is possible in theory... but I haven't seen 
it yet.
+       if (regAddressCells > 2 || regSizeCells > 1) {
+               panic("%s: Unsupported OpenFirmware cell count detected.\n"
+               "Address Cells: %" B_PRId32 "; Size Cells: %" B_PRId32
+               " (CPU > 64bit?).\n", __func__, regAddressCells, regSizeCells);
+               return B_ERROR;
+       }
+
+       // On 64-bit PowerPC systems (G5), our mem base range address is larger
+       if (regAddressCells == 2) {
+               struct of_region<uint64> regions[64];
+               int count = of_getprop(package, "reg", regions, 
sizeof(regions));
+               if (count == OF_FAILED)
+                       count = of_getprop(memory, "reg", regions, 
sizeof(regions));
+               if (count == OF_FAILED)
+                       return B_ERROR;
+               count /= sizeof(regions[0]);
+
+               for (int32 i = 0; i < count; i++) {
+                       if (regions[i].size <= 0) {
+                               dprintf("%d: empty region\n", i);
+                               continue;
+                       }
+                       dprintf("%" B_PRIu32 ": base = %" B_PRIu64 ","
+                               "size = %" B_PRIu32 "\n", i, regions[i].base, 
regions[i].size);
+
+                       total += regions[i].size;
+
+                       if 
(insert_physical_memory_range((addr_t)regions[i].base,
+                                       regions[i].size) != B_OK) {
+                               dprintf("cannot map physical memory range "
+                                       "(num ranges = %" B_PRIu32 ")!\n",
+                                       gKernelArgs.num_physical_memory_ranges);
+                               return B_ERROR;
+                       }
+               }
+               return B_OK;
+       }
+
+       // Otherwise, normal 32-bit PowerPC G3 or G4 have a smaller 32-bit one
+       struct of_region<uint32> regions[64];
+       int count = of_getprop(package, "reg", regions, sizeof(regions));
+       if (count == OF_FAILED)
+               count = of_getprop(memory, "reg", regions, sizeof(regions));
+       if (count == OF_FAILED)
+               return B_ERROR;
+       count /= sizeof(regions[0]);
+
+       for (int32 i = 0; i < count; i++) {
+               if (regions[i].size <= 0) {
+                       dprintf("%d: empty region\n", i);
+                       continue;
+               }
+               dprintf("%" B_PRIu32 ": base = %" B_PRIu32 ","
+                       "size = %" B_PRIu32 "\n", i, regions[i].base, 
regions[i].size);
+
+               total += regions[i].size;
+
+               if (insert_physical_memory_range((addr_t)regions[i].base,
+                               regions[i].size) != B_OK) {
+                       dprintf("cannot map physical memory range "
+                               "(num ranges = %" B_PRIu32 ")!\n",
+                               gKernelArgs.num_physical_memory_ranges);
+                       return B_ERROR;
+               }
+       }
+
+       return B_OK;
+}
+
+
+static bool
+is_virtual_allocated(void *address, size_t size)
+{
+       uint64 foundBase;
+       return !get_free_address_range(gKernelArgs.virtual_allocated_range,
+               gKernelArgs.num_virtual_allocated_ranges, (addr_t)address, size,
+               &foundBase) || foundBase != (addr_t)address;
+}
+
+
+static bool
+is_physical_allocated(void *address, size_t size)
+{
+       uint64 foundBase;
+       return !get_free_address_range(gKernelArgs.physical_allocated_range,
+               gKernelArgs.num_physical_allocated_ranges, (addr_t)address, 
size,
+               &foundBase) || foundBase != (addr_t)address;
+}
+
+
+static bool
+is_physical_memory(void *address, size_t size)
+{
+       return is_address_range_covered(gKernelArgs.physical_memory_range,
+               gKernelArgs.num_physical_memory_ranges, (addr_t)address, size);
+}
+
+
+static bool
+is_physical_memory(void *address)
+{
+       return is_physical_memory(address, 1);
+}
+
+
+static void
+map_page(void *virtualAddress, void *physicalAddress, uint8 mode)
+{
+       panic("%s: out of page table entries!\n", __func__);
+}
+
+
+static void
+map_range(void *virtualAddress, void *physicalAddress, size_t size, uint8 mode)
+{
+       for (uint32 offset = 0; offset < size; offset += B_PAGE_SIZE) {
+               map_page((void *)(intptr_t(virtualAddress) + offset),
+                       (void *)(intptr_t(physicalAddress) + offset), mode);
+       }
+}
+
+
+static void *
+find_physical_memory_range(size_t size)
+{
+       for (uint32 i = 0; i < gKernelArgs.num_physical_memory_ranges; i++) {
+               if (gKernelArgs.physical_memory_range[i].size > size)
+                       return (void 
*)(addr_t)gKernelArgs.physical_memory_range[i].start;
+       }
+       return PHYSINVAL;
+}
+
+
+static void *
+find_free_physical_range(size_t size)
+{
+       // just do a simple linear search at the end of the allocated
+       // ranges (dumb memory allocation)
+       if (gKernelArgs.num_physical_allocated_ranges == 0) {
+               if (gKernelArgs.num_physical_memory_ranges == 0)
+                       return PHYSINVAL;
+
+               return find_physical_memory_range(size);
+       }
+
+       for (uint32 i = 0; i < gKernelArgs.num_physical_allocated_ranges; i++) {
+               void *address
+                       = (void 
*)(addr_t)(gKernelArgs.physical_allocated_range[i].start
+                               + gKernelArgs.physical_allocated_range[i].size);
+               if (!is_physical_allocated(address, size)
+                       && is_physical_memory(address, size))
+                       return address;
+       }
+       return PHYSINVAL;
+}
+
+
+static void *
+find_free_virtual_range(void *base, size_t size)
+{
+       if (base && !is_virtual_allocated(base, size))
+               return base;
+
+       void *firstFound = NULL;
+       void *firstBaseFound = NULL;
+       for (uint32 i = 0; i < gKernelArgs.num_virtual_allocated_ranges; i++) {
+               void *address
+                       = (void 
*)(addr_t)(gKernelArgs.virtual_allocated_range[i].start
+                               + gKernelArgs.virtual_allocated_range[i].size);
+               if (!is_virtual_allocated(address, size)) {
+                       if (!base)
+                               return address;
+
+                       if (firstFound == NULL)
+                               firstFound = address;
+                       if (address >= base
+                               && (firstBaseFound == NULL || address < 
firstBaseFound)) {
+                               firstBaseFound = address;
+                       }
+               }
+       }
+       return (firstBaseFound ? firstBaseFound : firstFound);
+}
+
+
+extern "C" void *
+arch_mmu_allocate(void *_virtualAddress, size_t size, uint8 _protection,
+       bool exactAddress)
+{
+       // we only know page sizes
+       size = ROUNDUP(size, B_PAGE_SIZE);
+
+       uint8 protection = 0;
+       if (_protection & B_WRITE_AREA)
+               protection = PAGE_READ_WRITE;
+       else
+               protection = PAGE_READ_ONLY;
+
+       // If no address is given, use the KERNEL_BASE as base address, since
+       // that avoids trouble in the kernel, when we decide to keep the region.
+       void *virtualAddress = _virtualAddress;
+       if (!virtualAddress)
+               virtualAddress = (void*)KERNEL_BASE;
+
+       // find free address large enough to hold "size"
+       virtualAddress = find_free_virtual_range(virtualAddress, size);
+       if (virtualAddress == NULL)
+               return NULL;
+
+       // fail if the exact address was requested, but is not free
+       if (exactAddress && _virtualAddress && virtualAddress != 
_virtualAddress) {
+               dprintf("arch_mmu_allocate(): exact address requested, but 
virtual "
+                       "range (base: %p, size: %" B_PRIuSIZE ") is not 
free.\n",
+                       _virtualAddress, size);
+               return NULL;
+       }
+
+       // we have a free virtual range for the allocation, now
+       // have a look for free physical memory as well (we assume
+       // that a) there is enough memory, and b) failing is fatal
+       // so that we don't have to optimize for these cases :)
+
+       void *physicalAddress = find_free_physical_range(size);
+       if (physicalAddress == PHYSINVAL) {
+               dprintf("arch_mmu_allocate(base: %p, size: %" B_PRIuSIZE ") "
+                       "no free physical address\n", virtualAddress, size);
+               return NULL;
+       }
+
+       // everything went fine, so lets mark the space as used.
+
+       dprintf("mmu_alloc: va %p, pa %p, size %" B_PRIuSIZE "\n", 
virtualAddress,
+               physicalAddress, size);
+       insert_virtual_allocated_range((addr_t)virtualAddress, size);
+       insert_physical_allocated_range((addr_t)physicalAddress, size);
+
+       map_range(virtualAddress, physicalAddress, size, protection);
+
+       return virtualAddress;
+}
+
+
+extern "C" status_t
+arch_mmu_free(void *address, size_t size)
+{
+       // TODO: implement freeing a region!
+       return B_OK;
+}
+
+
+//     #pragma mark - OpenFirmware callbacks and public API
+
+
+static int
+map_callback(struct of_arguments *args)
+{
+       void *physicalAddress = (void *)args->Argument(0);
+       void *virtualAddress = (void *)args->Argument(1);
+       int length = args->Argument(2);
+       int mode = args->Argument(3);
+       intptr_t &error = args->ReturnValue(0);
+
+       // insert range in physical allocated if needed
+
+       if (is_physical_memory(physicalAddress)
+               && insert_physical_allocated_range((addr_t)physicalAddress, 
length)
+                       != B_OK) {
+               error = -1;
+               return OF_FAILED;
+       }
+
+       // insert range in virtual allocated
+
+       if (insert_virtual_allocated_range((addr_t)virtualAddress, length)
+                       != B_OK) {
+               error = -2;
+               return OF_FAILED;
+       }
+
+       // map range into the page table
+
+       map_range(virtualAddress, physicalAddress, length, mode);
+
+       return B_OK;
+}
+
+
+static int
+unmap_callback(struct of_arguments *args)
+{
+/*     void *address = (void *)args->Argument(0);
+       int length = args->Argument(1);
+       int &error = args->ReturnValue(0);
+*/
+       // TODO: to be implemented
+
+       return OF_FAILED;
+}
+
+
+static int
+translate_callback(struct of_arguments *args)
+{
+       // could not find the translation
+       return OF_FAILED;
+}
+
+
+static int
+alloc_real_mem_callback(struct of_arguments *args)
+{
+/*     addr_t minAddress = (addr_t)args->Argument(0);
+       addr_t maxAddress = (addr_t)args->Argument(1);
+       int length = args->Argument(2);
+       int mode = args->Argument(3);
+       int &error = args->ReturnValue(0);
+       int &physicalAddress = args->ReturnValue(1);
+*/
+       // ToDo: to be implemented
+
+       return OF_FAILED;
+}
+
+
+/** Dispatches the callback to the responsible function */
+
+static int
+callback(struct of_arguments *args)
+{
+       const char *name = args->name;
+       TRACE("OF CALLBACK: %s\n", name);
+
+       if (!strcmp(name, "map"))
+               return map_callback(args);
+       else if (!strcmp(name, "unmap"))
+               return unmap_callback(args);
+       else if (!strcmp(name, "translate"))
+               return translate_callback(args);
+       else if (!strcmp(name, "alloc-real-mem"))
+               return alloc_real_mem_callback(args);
+
+       return OF_FAILED;
+}
+
+
+extern "C" status_t
+arch_set_callback(void)
+{
+       // set OpenFirmware callbacks - it will ask us for memory after that
+       // instead of maintaining it itself
+
+       void *oldCallback = NULL;
+       if (of_call_client_function("set-callback", 1, 1, &callback, 
&oldCallback)
+                       == OF_FAILED) {
+               dprintf("Error: OpenFirmware set-callback failed\n");
+               return B_ERROR;
+       }
+       TRACE("old callback = %p; new callback = %p\n", oldCallback, callback);
+
+       return B_OK;
+}
+
+
+extern "C" status_t
+arch_mmu_init(void)
+{
+       // get map of physical memory (fill in kernel_args structure)
+
+       size_t total;
+       if (find_physical_memory_ranges(total) != B_OK) {
+               dprintf("Error: could not find physical memory ranges!\n");
+               return B_ERROR;
+       }
+       dprintf("total physical memory = %luMB\n", total / (1024 * 1024));
+
+       return B_OK;
+}
+
diff --git a/src/system/ldscripts/sparc/boot_loader_openfirmware.ld 
b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
new file mode 100644
index 0000000000..656f3689a2
--- /dev/null
+++ b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
@@ -0,0 +1,45 @@
+OUTPUT_FORMAT("elf64-sparc")
+OUTPUT_ARCH(sparc:v9)
+
+ENTRY(_start)
+
+SECTIONS
+{
+       . = 0x202000 + SIZEOF_HEADERS;
+
+       __text_begin = .;
+
+       /* text/read-only data */
+       .text : { *(.text .text.* .gnu.linkonce.t.*)
+                 *(.rodata .rodata.* .gnu.linkonce.r.*)
+                 *(.sdata2) }
+
+       /* writable data  */
+       /* align to the same offset in the next page (for performance reasons
+          (not that it really matters in the boot loader)) */
+       . = ALIGN(0x1000) + 0x1000 + (. & (0x1000 - 1));
+
+       .data : {
+               __ctor_list = .;
+               *(.ctors)
+               __ctor_end = .;
+
+               __data_start = .;
+               *(.data .gnu.linkonce.d.*)
+               *(.data.rel.ro.local .data.rel.ro*)
+               *(.got .got2)
+               *(.sdata .sdata.* .gnu.linkonce.s.* .fixup) }
+
+       /* uninitialized data (in same segment as writable data) */
+       __bss_start = .;
+       .bss : { *(.sbss .sbss.* .gnu.linkonce.sb.*)
+
+               *(.bss .bss.* .gnu.linkonce.b.*)
+               . = ALIGN(0x1000);
+       }
+
+       _end = . ;
+
+       /* Strip unnecessary stuff */
+       /DISCARD/ : { *(.comment .note .eh_frame .dtors .debug_* 
.gnu.attributes) }
+}
diff --git a/src/system/libroot/posix/string/arch/sparc/Jamfile 
b/src/system/libroot/posix/string/arch/sparc/Jamfile
index e19b60f834..466ca203f0 100644
--- a/src/system/libroot/posix/string/arch/sparc/Jamfile
+++ b/src/system/libroot/posix/string/arch/sparc/Jamfile
@@ -1,10 +1,17 @@
 SubDir HAIKU_TOP src system libroot posix string arch sparc ;
 
-UsePrivateSystemHeaders ;
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup sparc ] {
+       on $(architectureObject) {
+               local architecture = $(TARGET_PACKAGING_ARCH) ;
 
-SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
+               UsePrivateSystemHeaders ;
 
-MergeObject <$(TARGET_ARCH)>posix_string_arch_$(TARGET_ARCH).o :
-       memcpy.c
-       memset.c
-;
+               SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ;
+
+               MergeObject <$(TARGET_ARCH)>posix_string_arch_$(TARGET_ARCH).o :
+                       memcpy.c
+                       memset.c
+               ;
+       }
+}
diff --git a/src/system/runtime_loader/Jamfile 
b/src/system/runtime_loader/Jamfile
index 46239d120e..eda9a47d25 100644
--- a/src/system/runtime_loader/Jamfile
+++ b/src/system/runtime_loader/Jamfile
@@ -7,7 +7,7 @@ if $(TARGET_ARCH) = x86_64
 }
 
 local architectureObject ;
-for architectureObject in [ MultiArchSubDirSetup ] {
+for architectureObject in [ MultiArchSubDirSetup sparc ] {
        on $(architectureObject) {
                local architecture = $(TARGET_PACKAGING_ARCH) ;
 
diff --git a/src/system/runtime_loader/arch/sparc/Jamfile 
b/src/system/runtime_loader/arch/sparc/Jamfile
new file mode 100644
index 0000000000..319053761a
--- /dev/null
+++ b/src/system/runtime_loader/arch/sparc/Jamfile
@@ -0,0 +1,21 @@
+SubDir HAIKU_TOP src system runtime_loader arch sparc ;
+
+local architectureObject ;
+for architectureObject in [ MultiArchSubDirSetup sparc ] {
+       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)>memset.o
+               ;
+       }
+}
diff --git a/src/system/runtime_loader/arch/sparc/arch_relocate.cpp 
b/src/system/runtime_loader/arch/sparc/arch_relocate.cpp
new file mode 100644
index 0000000000..3a57919364
--- /dev/null
+++ b/src/system/runtime_loader/arch/sparc/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 <ithamar@xxxxxxxxxxxxxxxxxxx>
+ */
+
+#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;
+}

############################################################################

Commit:      2f2d56e2e33455ac0b093262b6ee89b988c67ec4
URL:         https://git.haiku-os.org/haiku/commit/?id=2f2d56e2e334
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Mon Apr  1 20:48:51 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

Move stack_trace.cpp to generic directory.

4 architectures are using it, so it is generic enough.
Make it error out for platforms where the stack grows in the other
direction. Another implementation can be added for them.

Change-Id: Ia52b5dd34da7b5ebcca0782af079c43d72ba3a8e
Reviewed-on: https://review.haiku-os.org/c/1340
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/system/libroot/os/arch/x86_common/stack_trace.cpp 
b/src/system/libroot/os/arch/generic/stack_trace.cpp
similarity index 90%
rename from src/system/libroot/os/arch/x86_common/stack_trace.cpp
rename to src/system/libroot/os/arch/generic/stack_trace.cpp
index 48b82ae0df..41ac99693c 100644
--- a/src/system/libroot/os/arch/x86_common/stack_trace.cpp
+++ b/src/system/libroot/os/arch/generic/stack_trace.cpp
@@ -6,8 +6,10 @@
  *             Michael Lotz, mmlr@xxxxxxxx
  */
 
+#include <arch_config.h>
 #include <libroot_private.h>
 
+#ifdef STACK_GROWS_DOWNWARDS
 
 /*!    Captures a stack trace (the return addresses) of the current thread.
        \param returnAddresses The array the return address shall be written to.
@@ -45,3 +47,9 @@ __arch_get_stack_trace(addr_t* returnAddresses, int32 
maxCount,
 
        return count;
 }
+
+#else
+
+#error Implementation needed for upwards growing stacks
+
+#endif
diff --git a/src/system/libroot/os/arch/ppc/Jamfile 
b/src/system/libroot/os/arch/ppc/Jamfile
index cdbf5725e0..88711765a2 100644
--- a/src/system/libroot/os/arch/ppc/Jamfile
+++ b/src/system/libroot/os/arch/ppc/Jamfile
@@ -17,7 +17,6 @@ for architectureObject in [ MultiArchSubDirSetup ppc ] {
                        byteorder.S
                        compatibility.c # only here until the places where 
those functions
                                                        # are used are fixed
-                       stack_trace.cpp
                        stack_frame.c
 #                      systeminfo.c
                        system_time.c
@@ -27,6 +26,7 @@ for architectureObject in [ MultiArchSubDirSetup ppc ] {
                        tls.c
 
                        generic_system_time_nsecs.cpp
+                       stack_trace.cpp
                        ;
        }
 }
diff --git a/src/system/libroot/os/arch/sparc/Jamfile 
b/src/system/libroot/os/arch/sparc/Jamfile
index 43d9ed6aff..65fadaea06 100644
--- a/src/system/libroot/os/arch/sparc/Jamfile
+++ b/src/system/libroot/os/arch/sparc/Jamfile
@@ -27,6 +27,7 @@ for architectureObject in [ MultiArchSubDirSetup sparc ] {
 
                        generic_atomic.cpp
                        generic_system_time_nsecs.cpp
+                       stack_trace.cpp
                        ;
        }
 }
diff --git a/src/system/libroot/os/arch/x86/Jamfile 
b/src/system/libroot/os/arch/x86/Jamfile
index 98821562b8..8fda6b8ff5 100644
--- a/src/system/libroot/os/arch/x86/Jamfile
+++ b/src/system/libroot/os/arch/x86/Jamfile
@@ -17,8 +17,6 @@ for architectureObject in [ MultiArchSubDirSetup x86 x86_gcc2 
] {
                        ;
                }
 
-               SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) x86_common ] ;
-
                MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o :
                        atomic.S
                        byteorder.S
@@ -31,7 +29,6 @@ for architectureObject in [ MultiArchSubDirSetup x86 x86_gcc2 
] {
 
                        $(compatibilitySources)
 
-                       # sources from x86_common
                        stack_trace.cpp
                        ;
        }
diff --git a/src/system/libroot/os/arch/x86_64/Jamfile 
b/src/system/libroot/os/arch/x86_64/Jamfile
index 86e96d19f4..e4670b3638 100644
--- a/src/system/libroot/os/arch/x86_64/Jamfile
+++ b/src/system/libroot/os/arch/x86_64/Jamfile
@@ -12,7 +12,6 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] {
 
                SEARCH_SOURCE +=
                        [ FDirName $(SUBDIR) $(DOTDOT) generic ]
-                       [ FDirName $(SUBDIR) $(DOTDOT) x86_common ]
                        ;
 
                MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o :
@@ -24,11 +23,9 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] {
                        time.cpp
                        tls.cpp
 
-                       # sources from x86_common
-                       stack_trace.cpp
-
                        # sources from generic
                        generic_atomic.cpp
+                       stack_trace.cpp
                        ;
        }
 }

############################################################################

Commit:      d0ff1a1f2fad6270a35d568b27afada83d4e2d4b
URL:         https://git.haiku-os.org/haiku/commit/?id=d0ff1a1f2fad
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Apr  3 20:48:11 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

openfirmware: fix mismatched prototype

Change-Id: I294608aa739bedef47c6c1f34fba0241444a8901
Reviewed-on: https://review.haiku-os.org/c/1363
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/system/kernel/platform/openfirmware/openfirmware.cpp 
b/src/system/kernel/platform/openfirmware/openfirmware.cpp
index 1f1d997496..5594c98f09 100644
--- a/src/system/kernel/platform/openfirmware/openfirmware.cpp
+++ b/src/system/kernel/platform/openfirmware/openfirmware.cpp
@@ -466,7 +466,7 @@ of_write(int handle, const void *buffer, int bufferSize)
 
 
 int
-of_seek(int handle, long long pos)
+of_seek(int handle, off_t pos)
 {
        struct {
                const char      *name;

############################################################################

Commit:      fea91fdc77c1d8a9964f8cb5370b07e872bad90b
URL:         https://git.haiku-os.org/haiku/commit/?id=fea91fdc77c1
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Tue Apr  2 20:56:29 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

sparc: pci bus manager

Copied from PPC with the hooks for Apple hardware removed.
To be completed with the actual PCI bus implementation for Sun machines.
This is where we start doing machine specific stuff, apparently.

Change-Id: I06af4de9621e9d40593d153642478d928083e49a
Reviewed-on: https://review.haiku-os.org/c/1364
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/headers/private/kernel/arch/sparc/arch_platform.h 
b/headers/private/kernel/arch/sparc/arch_platform.h
new file mode 100644
index 0000000000..24e774eb2f
--- /dev/null
+++ b/headers/private/kernel/arch/sparc/arch_platform.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_SPARC_ARCH_PLATFORM_H
+#define _KERNEL_SPARC_ARCH_PLATFORM_H
+
+#include <arch/platform.h>
+
+struct real_time_data;
+
+enum sparc_platform_type {
+       PPC_PLATFORM_OPEN_FIRMWARE = 0,
+};
+
+namespace BPrivate {
+
+class SparcPlatform {
+public:
+       SparcPlatform(sparc_platform_type platformType);
+       virtual ~SparcPlatform();
+
+       static SparcPlatform *Default();
+
+       inline sparc_platform_type PlatformType() const { return fPlatformType; 
}
+
+       virtual status_t Init(struct kernel_args *kernelArgs) = 0;
+       virtual status_t InitSerialDebug(struct kernel_args *kernelArgs) = 0;
+       virtual status_t InitPostVM(struct kernel_args *kernelArgs) = 0;
+       virtual status_t InitRTC(struct kernel_args *kernelArgs,
+               struct real_time_data *data) = 0;
+
+       virtual char SerialDebugGetChar() = 0;
+       virtual void SerialDebugPutChar(char c) = 0;
+
+       virtual void SetHardwareRTC(uint32 seconds) = 0;
+       virtual uint32 GetHardwareRTC() = 0;
+
+       virtual void ShutDown(bool reboot) = 0;
+
+private:
+       sparc_platform_type     fPlatformType;
+};
+
+}      // namespace BPrivate
+
+using BPrivate::SparcPlatform;
+
+
+#endif // _KERNEL_SPARC_ARCH_PLATFORM_H
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile
index 3a4790e24e..8d0941693a 100644
--- a/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile
+++ b/src/add-ons/kernel/bus_managers/pci/arch/sparc/Jamfile
@@ -11,6 +11,6 @@ KernelStaticLibrary pci_arch_bus_manager :
        pci_io.c
 
        # openfirmware
-       # TODO
+       pci_openfirmware.cpp
 ;
 
diff --git 
a/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
new file mode 100644
index 0000000000..7df3153a98
--- /dev/null
+++ 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#include "pci_openfirmware.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <KernelExport.h>
+
+#include <platform/openfirmware/devices.h>
+#include <platform/openfirmware/openfirmware.h>
+#include <platform/openfirmware/pci.h>
+
+#include "pci_openfirmware_priv.h"
+
+
+typedef status_t (*probeFunction)(int, const StringArrayPropertyValue&);
+
+static const probeFunction sProbeFunctions[] = {
+       NULL,
+};
+
+
+status_t
+sparc_openfirmware_pci_controller_init(void)
+{
+       char path[256];
+       int cookie = 0;
+       while (of_get_next_device(&cookie, 0, "pci", path, sizeof(path))
+                       == B_OK) {
+dprintf("sparc_openfirmware_pci_controller_init(): pci device node: %s\n", 
path);
+               // get the device node and the "compatible" property
+               int deviceNode = of_finddevice(path);
+               StringArrayPropertyValue compatible;
+               status_t error = openfirmware_get_property(deviceNode, 
"compatible",
+                       compatible);
+               if (error != B_OK) {
+                       dprintf("sparc_openfirmware_pci_controller_init: Failed 
to get "
+                               "\"compatible\" property for pci device: %s\n", 
path);
+                       continue;
+               }
+
+               // probe
+               for (int i = 0; sProbeFunctions[i]; i++) {
+                       error = sProbeFunctions[i](deviceNode, compatible);
+                       if (error == B_OK)
+                               break;
+               }
+       }
+
+       return B_OK;
+}
+
+
+// #pragma mark - support functions
+
+
+char *
+StringArrayPropertyValue::NextElement(int &cookie) const
+{
+       if (cookie >= length)
+               return NULL;
+
+       char *result = value + cookie;
+       cookie += strnlen(result, length - cookie) + 1;
+       return result;
+}
+
+
+bool
+StringArrayPropertyValue::ContainsElement(const char *value) const
+{
+       int cookie = 0;
+       while (char *checkValue = NextElement(cookie)) {
+               if (strcmp(checkValue, value) == 0)
+                       return true;
+       }
+
+       return false;
+}
+
+
+status_t
+openfirmware_get_property(int package, const char *propertyName,
+       PropertyValue &value)
+{
+       value.length = of_getproplen(package, propertyName);
+       if (value.length < 0)
+               return B_ENTRY_NOT_FOUND;
+
+       value.value = (char*)malloc(value.length);
+       if (!value.value)
+               return B_NO_MEMORY;
+
+       if (of_getprop(package, propertyName, value.value, value.length)
+               == OF_FAILED) {
+               return B_ERROR;
+       }
+
+       return B_OK;
+}
+
diff --git 
a/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.h
 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.h
new file mode 100644
index 0000000000..5b8c2573b0
--- /dev/null
+++ 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#ifndef PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_H
+#define PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_H
+
+#include <SupportDefs.h>
+
+status_t       sparc_openfirmware_pci_controller_init(void);
+
+#endif // PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_H
diff --git 
a/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware_priv.h
 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware_priv.h
new file mode 100644
index 0000000000..6c9c917696
--- /dev/null
+++ 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware/pci_openfirmware_priv.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#ifndef PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_PRIV_H
+#define PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_PRIV_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <SupportDefs.h>
+
+
+struct StringArrayPropertyValue;
+
+
+// implementations
+
+// TODO
+
+
+// property support
+
+struct PropertyValue {
+       PropertyValue()
+               : value(NULL)
+       {
+       }
+
+       ~PropertyValue()
+       {
+               free(value);
+       }
+
+       char    *value;
+       int             length;
+};
+
+struct StringArrayPropertyValue : PropertyValue {
+
+       char *NextElement(int &cookie) const;
+       bool ContainsElement(const char *value) const;
+};
+
+status_t       openfirmware_get_property(int package, const char *propertyName,
+                               PropertyValue &value);
+
+#endif // PCI_BUS_MANAGER_SPARC_OPEN_FIRMWARE_PRIV_H
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_controller.cpp 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_controller.cpp
new file mode 100644
index 0000000000..ff8eea2ac0
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_controller.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006, Ingo Weinhold. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "pci_controller.h"
+
+#include <arch_platform.h>
+
+#include "pci_private.h"
+
+#include "openfirmware/pci_openfirmware.h"
+
+
+status_t
+pci_controller_init(void)
+{
+       return sparc_openfirmware_pci_controller_init();
+}
+
+
+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/sparc/pci_io.c 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_io.c
new file mode 100644
index 0000000000..94877e26d9
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_io.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006, Ingo Weinhold. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "pci_io.h"
+#include "pci_private.h"
+
+
+static const uint8_t* gPCIBase;
+
+
+status_t
+pci_io_init()
+{
+       // TODO set gPCIBase
+       return B_OK;
+}
+
+
+uint8
+pci_read_io_8(int mapped_io_addr)
+{
+       return sparc_in8((vuint8*)(gPCIBase + mapped_io_addr));
+}
+
+
+void
+pci_write_io_8(int mapped_io_addr, uint8 value)
+{
+       sparc_out8((vuint8*)(gPCIBase + mapped_io_addr), value);
+}
+
+
+uint16
+pci_read_io_16(int mapped_io_addr)
+{
+       return sparc_in16((vuint16*)(gPCIBase + mapped_io_addr));
+}
+
+
+void
+pci_write_io_16(int mapped_io_addr, uint16 value)
+{
+       sparc_out16((vuint16*)(gPCIBase + mapped_io_addr), value);
+}
+
+
+uint32
+pci_read_io_32(int mapped_io_addr)
+{
+       return sparc_in32((vuint32*)(gPCIBase + mapped_io_addr));
+}
+
+
+void
+pci_write_io_32(int mapped_io_addr, uint32 value)
+{
+       sparc_out32((vuint32*)(gPCIBase + mapped_io_addr), value);
+}
diff --git a/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_io.h 
b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_io.h
new file mode 100644
index 0000000000..6cf0cbc70d
--- /dev/null
+++ b/src/add-ons/kernel/bus_managers/pci/arch/sparc/pci_io.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#ifndef PCI_BUS_MANAGER_SPARC_IO_H
+#define PCI_BUS_MANAGER_SPARC_IO_H
+
+#include <SupportDefs.h>
+
+static inline void
+sparc_out8(vuint8 *address, uint8 value)
+{
+       *address = value;
+       asm volatile("MEMBAR #MemIssue");
+}
+
+
+static inline void
+sparc_out16(vuint16 *address, uint16 value)
+{
+       *address = value;
+       asm volatile("MEMBAR #MemIssue");
+}
+
+
+static inline void
+sparc_out16_reverse(vuint16 *address, uint16 value)
+{
+       asm volatile("stha %1, [%0] 0x88" : : "r"(address), "r"(value));
+       asm volatile("MEMBAR #MemIssue");
+}
+
+
+static inline void
+sparc_out32(vuint32 *address, uint32 value)
+{
+       *address = value;
+       asm volatile("MEMBAR #MemIssue");
+}
+
+
+static inline void
+sparc_out32_reverse(vuint32 *address, uint32 value)
+{
+       asm volatile("stwa %1, [%0] 0x88" : : "r"(address), "r"(value));
+       asm volatile("MEMBAR #MemIssue");
+}
+
+
+static inline uint8
+sparc_in8(const vuint8 *address)
+{
+       uint8 value = *address;
+       asm volatile("MEMBAR #MemIssue");
+       return value;
+}
+
+
+static inline uint16
+sparc_in16(const vuint16 *address)
+{
+       uint16 value = *address;
+       asm volatile("MEMBAR #MemIssue");
+       return value;
+}
+
+
+static inline uint16
+sparc_in16_reverse(const vuint16 *address)
+{
+       uint16 value;
+       asm volatile("lha [%1] 0x88,  %0" : "=r"(value) : "r"(address));
+       asm volatile("MEMBAR #MemIssue");
+       return value;
+}
+
+
+static inline uint32
+sparc_in32(const vuint32 *address)
+{
+       uint32 value = *address;
+       asm volatile("MEMBAR #MemIssue");
+       return value;
+}
+
+
+static inline uint32
+sparc_in32_reverse(const vuint32 *address)
+{
+       uint32 value;
+       asm volatile("ldwa [%1] 0x88, %0" : "=r"(value) : "r"(address));
+       asm volatile("MEMBAR #MemIssue");
+       return value;
+}
+
+#endif // PCI_BUS_MANAGER_SPARC_IO_H

############################################################################

Commit:      815a1596a6d3ba8b6ee51d1afec5b0b880213419
URL:         https://git.haiku-os.org/haiku/commit/?id=815a1596a6d3
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Apr  3 20:42:45 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

openfirmware: support a.out bootloader

Apparently each architecture and manufacturer uses a different binary
format (I heard current POWER hardware uses elf).

Change-Id: I4f1b9977d0a9d5a700c2d50b36844d6e4640b68b
Reviewed-on: https://review.haiku-os.org/c/1365
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile
index a02a02533b..3541e65466 100644
--- a/src/system/boot/Jamfile
+++ b/src/system/boot/Jamfile
@@ -4,19 +4,59 @@ DEFINES += _BOOT_MODE ;
 
 UsePrivateHeaders [ FDirName libroot locale ] ;
 
+rule BuildOpenFirmwareLoader {
+       local haikuLoader = $(1) ;
+       local bootLoader = $(2) ;
+
+       Depends $(haikuLoader) : $(bootLoader) ;
+       MakeLocateDebug $(haikuLoader) ;
+
+       switch $(TARGET_ARCH) {
+               case ppc :
+                       BuildCoffLoader $(haikuLoader) : $(bootLoader) ;
+               case sparc :
+                       BuildAoutLoader $(haikuLoader) : $(bootLoader) ;
+               case * :
+                       Exit "Currently unsupported arch:" $(TARGET_ARCH) ;
+       }
+}
+
+
+#
+# A.out haiku_loader creation
+#
+rule BuildAoutLoader {
+       local haikuLoader = $(1) ;
+       local bootLoader = $(2) ;
+       switch $(TARGET_ARCH) {
+               case sparc :
+                       AOUT_FORMAT on $(haikuLoader) = a.out-sunos-big ;
+               case * :
+                       Exit "Currently unsupported coff arch:" $(TARGET_ARCH) ;
+       }
+}
+
+actions BuildAoutLoader {
+       rm -f $(1)
+       $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(AOUT_FORMAT) $(2) $(1)
+}
+
+
 #
 # Coff haiku_loader creation
 #
 rule BuildCoffLoader {
        local coffLoader = $(1) ;
        local bootLoader = $(2) ;
-       # XXX: eventually switch on arch
-       COFF_FORMAT on $(coffLoader) = xcoff-powermac ;
+       switch $(TARGET_ARCH) {
+               case ppc :
+                       COFF_FORMAT on $(coffLoader) = xcoff-powermac ;
+               case * :
+                       Exit "Currently unsupported coff arch:" $(TARGET_ARCH) ;
+       }
        HACK_COFF on $(coffLoader) = <build>hack-coff ;
 
        Depends $(coffLoader) : <build>hack-coff ;
-       Depends $(coffLoader) : $(bootLoader) ;
-       MakeLocateDebug $(coffLoader) ;
 }
 
 actions BuildCoffLoader bind HACK_COFF {
@@ -214,7 +254,7 @@ for platform in [ MultiBootSubDirSetup ] {
                                BuildBiosLoader 
haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
 
                        case openfirmware :
-                               BuildCoffLoader 
haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
+                               BuildOpenFirmwareLoader 
haiku_loader.$(TARGET_BOOT_PLATFORM) : boot_loader_$(TARGET_BOOT_PLATFORM) ;
 
                        case u-boot :
                                local loader_entry = `printf 
\"obase=16;ibase=16;10 + %x\\n\" $(HAIKU_BOOT_LOADER_BASE)|bc` ;

############################################################################

Commit:      1cba023e0a69064b7f9370bccac1ac052d298254
URL:         https://git.haiku-os.org/haiku/commit/?id=1cba023e0a69
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Apr  3 20:47:52 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

sparc: fix support for elf in boot mode

Change-Id: I901a4e494dd5273a0aa433f08b94363b486c58e1
Reviewed-on: https://review.haiku-os.org/c/1366
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/system/kernel/arch/sparc/arch_elf.cpp 
b/src/system/kernel/arch/sparc/arch_elf.cpp
index 452f9d80fe..cde850bb4f 100644
--- a/src/system/kernel/arch/sparc/arch_elf.cpp
+++ b/src/system/kernel/arch/sparc/arch_elf.cpp
@@ -36,9 +36,15 @@ is_in_image(struct elf_image_info *image, addr_t address)
 #endif // !_BOOT_MODE
 
 
+#ifdef _BOOT_MODE
+status_t
+boot_arch_elf_relocate_rel(struct preloaded_elf64_image *image, Elf64_Rel *rel,
+       int rel_len)
+#else
 int
 arch_elf_relocate_rel(struct elf_image_info *image,
        struct elf_image_info *resolve_image, Elf64_Rel *rel, int rel_len)
+#endif
 {
        // there are no rel entries in M68K elf
        return B_NO_ERROR;
@@ -91,9 +97,15 @@ write_8_check(addr_t P, Elf32_Word value)
 }
 
 
+#ifdef _BOOT_MODE
+status_t
+boot_arch_elf_relocate_rela(struct preloaded_elf64_image *image,
+       Elf64_Rela *rel, int rel_len)
+#else
 int
 arch_elf_relocate_rela(struct elf_image_info *image,
        struct elf_image_info *resolve_image, Elf64_Rela *rel, int rel_len)
+#endif
 {
        return B_OK;
 }

############################################################################

Revision:    hrev53034
Commit:      b1ec65fcfecdd145707ad1fcdbf4b66be02ff606
URL:         https://git.haiku-os.org/haiku/commit/?id=b1ec65fcfecd
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Thu Apr  4 18:47:16 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Apr  4 20:31:25 2019 UTC

sparc: link the runtime_loader

Change-Id: Id30476480f4e4141935d6735209ecc0872dd6696
Reviewed-on: https://review.haiku-os.org/c/1367
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

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

diff --git a/src/system/ldscripts/sparc/runtime_loader.ld 
b/src/system/ldscripts/sparc/runtime_loader.ld
new file mode 100644
index 0000000000..5f934062c1
--- /dev/null
+++ b/src/system/ldscripts/sparc/runtime_loader.ld
@@ -0,0 +1,63 @@
+OUTPUT_FORMAT("elf64-sparc")
+OUTPUT_ARCH(sparc:v9)
+
+ENTRY(runtime_loader)
+SEARCH_DIR("libgcc");
+SECTIONS
+{
+       . = 0x00100000 + SIZEOF_HEADERS;
+
+       .interp : { *(.interp) }
+       .hash : { *(.hash) }
+       .dynsym : { *(.dynsym) }
+       .dynstr : { *(.dynstr) }
+       .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
+       .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+       .rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
+       .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+       .rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
+       .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+       .rel.got : { *(.rel.got) }
+       .rela.got : { *(.rela.got) }
+       .rel.ctors : { *(.rel.ctors) }
+       .rela.ctors : { *(.rela.ctors) }
+       .rel.dtors : { *(.rel.dtors) }
+       .rela.dtors : { *(.rela.dtors) }
+       .rel.init : { *(.rel.init) }
+       .rela.init : { *(.rela.init) }
+       .rel.fini : { *(.rel.fini) }
+       .rela.fini : { *(.rela.fini) }
+       .rel.bss : { *(.rel.bss) }
+       .rela.bss : { *(.rela.bss) }
+       .rel.plt : { *(.rel.plt) }
+       .rela.plt : { *(.rela.plt) }
+       .init : { *(.init) } =0x9090
+       .plt : { *(.plt) }
+
+       /* text/read-only data */
+       .text : { *(.text .gnu.linkonce.t.*) }
+
+       .rodata : { *(.rodata) }
+
+       /* writable data  */
+       . = ALIGN(0x1000) + (. & (0x1000 - 1));
+       __data_start = .;
+       PROVIDE(_data_start = .);
+       .data : { *(.data .gnu.linkonce.d.*) }
+
+       __ctor_list = .;
+       PROVIDE (_ctor_list = .);
+       .ctors : { *(.ctors) }
+       PROVIDE (__ctor_end = .);
+
+
+       /* uninitialized data (in same segment as writable data) */
+       PROVIDE (__bss_start = .);
+       .bss : { *(.bss) }
+
+       . = ALIGN(0x1000);
+       PROVIDE (_end = .);
+
+       /* Strip unnecessary stuff */
+       /DISCARD/ : { *(.comment .note .dtors) }
+}
diff --git a/src/system/runtime_loader/arch/sparc/Jamfile 
b/src/system/runtime_loader/arch/sparc/Jamfile
index 319053761a..59472320ee 100644
--- a/src/system/runtime_loader/arch/sparc/Jamfile
+++ b/src/system/runtime_loader/arch/sparc/Jamfile
@@ -15,6 +15,7 @@ for architectureObject in [ MultiArchSubDirSetup sparc ] {
                        :
                        
<src!system!libroot!os!arch!$(TARGET_ARCH)!$(architecture)>thread.o
 
+                       
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)!$(architecture)>memcpy.o
                        
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)!$(architecture)>memset.o
                ;
        }


Other related posts:

  • » [haiku-commits] haiku: hrev53034 - in src: system/boot/platform/openfirmware/arch/sparc add-ons/kernel/bus_managers/pci/arch/sparc add-ons/kernel/bus_managers/pci/arch/sparc/openfirmware system/ldscripts/sparc system/boot/platform/openfirmware - waddlesplash