[haiku-commits] haiku: hrev53165 - in src/system: boot/platform/openfirmware/arch/ppc boot/platform/openfirmware boot/platform/openfirmware/arch/sparc libroot/posix/glibc/math ldscripts/sparc

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 25 May 2019 14:16:38 -0400 (EDT)

hrev53165 adds 5 changesets to branch 'master'
old head: 89b16bb4d245c3a6e55e0d8f3502324e6f31bcb4
new head: 70482896788d840019b7f92112b07fe0728f915c
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=70482896788d+%5E89b16bb4d245

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

94ba4f640695: sparc: fix bootloader executable format
  
  - The entry point has to be at the start of the text section
  - Use the correct formqt ("impure") for the a.out file
  - Strip all symbols (the bootloader isn't relocatable)
  
  Change-Id: I2b973c39eaf1416f874bf1b2668b1e3090eb5f7b
  Reviewed-on: https://review.haiku-os.org/c/1468
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

864a3f996b5a: sparc: do not leave a hole between .text and .data
  
  The a.out format does not allow to handle this properly. So we need the
  two sections to be contiguous.
  
  Change-Id: I44455d4fb728bd47d5dcebc48c52b7d90d808104
  Reviewed-on: https://review.haiku-os.org/c/1469
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

906c14da6386: sparc: use generic w_sqrtl.c implementation.
  
  I accidentally imported a newer version of the file that does the same
  thing as the existing one.
  
  Change-Id: Ifab3b24218f017cc57a459e0467cb8225accd9e5
  Reviewed-on: https://review.haiku-os.org/c/1368
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

cdbda49e8857: sparc: fix openfirmware entry point.
  
  According to the IEEE standard documentation, the OpenFirmware entry
  point should be in %o3. But that doesn't work, and both FreeBSD and
  NetBSD expect it in %o4 (5th argument of the function). I suspect this
  was changed for 64bit sparc, but neither the sparc nor 64bit
  openfirmware specs mention it.
  
  Move the sparc and powerpc specific parts out of the generic start.cpp
  for openfirmware as they each have some specificities. More
  specifically:
  - sparc already clears bss for us
  - entry point arguments are different
  - determine_machine is of course platform specific
  
  Change-Id: Icaa05087e88ea4d29198e3565223459aed75cdf9
  Reviewed-on: https://review.haiku-os.org/c/1470
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

70482896788d: openfirmware: fix jamfiles
  
  Without the MultiArchDirSetup, these would not use the boot cflags, and
  end up being compiled position-independant. Of course, the a.out format
  does not allow relocations, so this could not work.
  
  Change-Id: I6bb570e545f1533200511e6881f71feedb77025b
  Reviewed-on: https://review.haiku-os.org/c/1481
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                   [ PulkoMandy <pulkomandy@xxxxxxxxxxxxx> ]

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

11 files changed, 182 insertions(+), 129 deletions(-)
src/system/boot/Jamfile                          |  2 +-
src/system/boot/platform/openfirmware/Jamfile    |  2 +-
.../boot/platform/openfirmware/arch/ppc/Jamfile  | 25 +++---
.../platform/openfirmware/arch/ppc/start.cpp     | 81 ++++++++++++++++++++
.../platform/openfirmware/arch/sparc/Jamfile     | 23 ++++--
.../platform/openfirmware/arch/sparc/start.cpp   | 35 +++++++++
src/system/boot/platform/openfirmware/start.cpp  | 75 ++----------------
src/system/boot/platform/openfirmware/start.h    | 12 +++
.../ldscripts/sparc/boot_loader_openfirmware.ld  | 22 ++++--
.../libroot/posix/glibc/arch/sparc/Jamfile       |  3 +-
.../libroot/posix/glibc/math/w_sqrtl_compat.c    | 31 --------

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

Commit:      94ba4f6406957ab4cc68b1239910b66ca01e0188
URL:         https://git.haiku-os.org/haiku/commit/?id=94ba4f640695
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Apr 10 14:11:42 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 25 18:16:35 2019 UTC

sparc: fix bootloader executable format

- The entry point has to be at the start of the text section
- Use the correct formqt ("impure") for the a.out file
- Strip all symbols (the bootloader isn't relocatable)

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

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

diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile
index 3541e65466..b89309dc16 100644
--- a/src/system/boot/Jamfile
+++ b/src/system/boot/Jamfile
@@ -38,7 +38,7 @@ rule BuildAoutLoader {
 
 actions BuildAoutLoader {
        rm -f $(1)
-       $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(AOUT_FORMAT) $(2) $(1)
+       $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(AOUT_FORMAT) --impure 
-S $(2) $(1)
 }
 
 
diff --git a/src/system/boot/platform/openfirmware/start.cpp 
b/src/system/boot/platform/openfirmware/start.cpp
index c699823ecd..a2777e4177 100644
--- a/src/system/boot/platform/openfirmware/start.cpp
+++ b/src/system/boot/platform/openfirmware/start.cpp
@@ -27,9 +27,11 @@ extern "C" void _start(uint32 _unused1, uint32 _unused2,
        void *openFirmwareEntry);
 extern "C" void start(void *openFirmwareEntry);
 
+#ifdef __powerpc__
 // XCOFF "entry-point" is actually a pointer to the real code
 extern "C" void *_coff_start;
 void *_coff_start = (void *)&_start;
+#endif
 
 // GCC defined globals
 extern void (*__ctor_list)(void);
@@ -52,11 +54,13 @@ call_ctors(void)
 }
 
 
+#ifdef __powerpc__
 static void
 clear_bss(void)
 {
        memset(&__bss_start, 0, &_end - &__bss_start);
 }
+#endif
 
 
 static void
@@ -134,13 +138,15 @@ platform_boot_options(void)
 }
 
 
-extern "C" void
+extern "C" void __attribute__((section(".text.start")))
 _start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
 {
        // According to the PowerPC bindings, OpenFirmware should have created
        // a stack of 32kB or higher for us at this point
 
+#ifndef __sparc__
        clear_bss();
+#endif
        call_ctors();
                // call C++ constructors before doing anything else
 
diff --git a/src/system/ldscripts/sparc/boot_loader_openfirmware.ld 
b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
index 656f3689a2..3449242731 100644
--- a/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
+++ b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
@@ -5,12 +5,13 @@ ENTRY(_start)
 
 SECTIONS
 {
-       . = 0x202000 + SIZEOF_HEADERS;
+       . = 0x202000;
 
        __text_begin = .;
 
        /* text/read-only data */
-       .text : { *(.text .text.* .gnu.linkonce.t.*)
+       .text : { *(.text.start) /* Make sure entry point is at start of file */
+                         *(.text .text.* .gnu.linkonce.t.*)
                  *(.rodata .rodata.* .gnu.linkonce.r.*)
                  *(.sdata2) }
 

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

Commit:      864a3f996b5ae9820b6b32b59b91564a8f714b98
URL:         https://git.haiku-os.org/haiku/commit/?id=864a3f996b5a
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Mon May 20 21:07:00 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 25 18:16:35 2019 UTC

sparc: do not leave a hole between .text and .data

The a.out format does not allow to handle this properly. So we need the
two sections to be contiguous.

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

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

diff --git a/src/system/ldscripts/sparc/boot_loader_openfirmware.ld 
b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
index 3449242731..18b9e9b63d 100644
--- a/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
+++ b/src/system/ldscripts/sparc/boot_loader_openfirmware.ld
@@ -5,21 +5,26 @@ ENTRY(_start)
 
 SECTIONS
 {
+       /* Execution address. The file is loaded at 0x4000 with its header,
+        * then relocated here. */
        . = 0x202000;
-
        __text_begin = .;
 
+       /* keep text and data sections next to each other, as the loader in 
openboot
+        * is not able to handle a hole between them.
+        */
+
        /* text/read-only data */
-       .text : { *(.text.start) /* Make sure entry point is at start of file */
+       .text : { 
+                         /* Make sure entry point is at start of file. Not 
required, since
+                          * it is set using ENTRY above, but it looks nicer 
and makes it
+                          * clearer we jumped at the correct address. */
+              *(.text.start)
+
                          *(.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)

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

Commit:      906c14da6386116784a53e0bcc37974259b4c122
URL:         https://git.haiku-os.org/haiku/commit/?id=906c14da6386
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri May 24 18:13:18 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 25 18:16:35 2019 UTC

sparc: use generic w_sqrtl.c implementation.

I accidentally imported a newer version of the file that does the same
thing as the existing one.

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

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

diff --git a/src/system/libroot/posix/glibc/arch/sparc/Jamfile 
b/src/system/libroot/posix/glibc/arch/sparc/Jamfile
index 188fbe6d75..15d29a03e5 100644
--- a/src/system/libroot/posix/glibc/arch/sparc/Jamfile
+++ b/src/system/libroot/posix/glibc/arch/sparc/Jamfile
@@ -122,8 +122,7 @@ local genericSources =
        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_sqrtl.c
-       w_sqrtl_compat.c
+       w_sqrt.c w_sqrtf.c w_sqrtl.c
        ;
 
 
diff --git a/src/system/libroot/posix/glibc/math/w_sqrtl_compat.c 
b/src/system/libroot/posix/glibc/math/w_sqrtl_compat.c
deleted file mode 100644
index b0cc24ea21..0000000000
--- a/src/system/libroot/posix/glibc/math/w_sqrtl_compat.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@xxxxxxxxx>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-#include <math.h>
-#include <math_private.h>
-#include <libm-alias-ldouble.h>
-
-
-/* wrapper sqrtl */
-long double
-__sqrtl (long double x)
-{
-  return __ieee754_sqrtl (x);
-}
-libm_alias_ldouble (__sqrt, sqrt)

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

Commit:      cdbda49e8857ec6958c91a500cbc322304bd487f
URL:         https://git.haiku-os.org/haiku/commit/?id=cdbda49e8857
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Mon May 20 21:08:19 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 25 18:16:35 2019 UTC

sparc: fix openfirmware entry point.

According to the IEEE standard documentation, the OpenFirmware entry
point should be in %o3. But that doesn't work, and both FreeBSD and
NetBSD expect it in %o4 (5th argument of the function). I suspect this
was changed for 64bit sparc, but neither the sparc nor 64bit
openfirmware specs mention it.

Move the sparc and powerpc specific parts out of the generic start.cpp
for openfirmware as they each have some specificities. More
specifically:
- sparc already clears bss for us
- entry point arguments are different
- determine_machine is of course platform specific

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

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

diff --git a/src/system/boot/platform/openfirmware/Jamfile 
b/src/system/boot/platform/openfirmware/Jamfile
index 736258595b..fa03216547 100644
--- a/src/system/boot/platform/openfirmware/Jamfile
+++ b/src/system/boot/platform/openfirmware/Jamfile
@@ -48,7 +48,7 @@ for platform in [ MultiBootSubDirSetup openfirmware ] {
                :
                :
                        boot_platform_generic_openfirmware.a
-                       boot_platform_openfirmware_$(TARGET_ARCH).a
+                       boot_platform_openfirmware_$(TARGET_ARCH).o
                ;
 
 #              SEARCH on [ FGristFiles $(genericPlatformSources) ]
diff --git a/src/system/boot/platform/openfirmware/arch/ppc/Jamfile 
b/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
index 09471a95b8..f7c3d95efc 100644
--- a/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
+++ b/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
@@ -8,12 +8,13 @@ UsePrivateHeaders kernel [ FDirName kernel arch 
$(TARGET_KERNEL_ARCH) ]
 
 SubDirC++Flags -fno-rtti ;
 
-BootStaticLibrary boot_platform_openfirmware_ppc :
+BootStaticLibrary boot_platform_openfirmware_ppc.o :
        arch_mmu.cpp
        arch_cpu_asm.S
        arch_start_kernel.S
        cpu.cpp
        mmu.cpp
+       start.cpp
 ;
 
 SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
diff --git a/src/system/boot/platform/openfirmware/arch/ppc/start.cpp 
b/src/system/boot/platform/openfirmware/arch/ppc/start.cpp
new file mode 100644
index 0000000000..604e726c51
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/arch/ppc/start.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2011, Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "start.h"
+
+#include "machine.h"
+
+
+extern "C" void _start(uint32 _unused1, uint32 _unused2,
+       void *openFirmwareEntry);
+
+// XCOFF "entry-point" is actually a pointer to the real code
+extern "C" void *_coff_start;
+void *_coff_start = (void *)&_start;
+
+// GCC defined globals
+extern uint8 __bss_start;
+extern uint8 _end;
+
+
+static void
+clear_bss(void)
+{
+       memset(&__bss_start, 0, &_end - &__bss_start);
+}
+
+
+void
+determine_machine(void)
+{
+       gMachine = MACHINE_UNKNOWN;
+
+       intptr_t root = of_finddevice("/");
+       char buffer[64];
+       int length;
+
+       // TODO : Probe other OpenFirmware platforms and set gMachine as needed
+
+       if ((length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 
1))
+               != OF_FAILED) {
+               buffer[length] = '\0';
+               if (!strcasecmp("chrp", buffer))
+                       gMachine = MACHINE_CHRP;
+               else if (!strcasecmp("bootrom", buffer))
+                       gMachine = MACHINE_MAC;
+       } else
+               gMachine = MACHINE_MAC;
+
+       if ((length = of_getprop(root, "model", buffer, sizeof(buffer) - 1))
+               != OF_FAILED) {
+               buffer[length] = '\0';
+               if (!strcasecmp("pegasos", buffer))
+                       gMachine |= MACHINE_PEGASOS;
+       }
+
+       if ((length = of_getprop(root, "name", buffer, sizeof(buffer) - 1))
+               != OF_FAILED) {
+               buffer[length] = '\0';
+               if (!strcasecmp("openbiosteam,openbios", buffer))
+                       gMachine |= MACHINE_QEMU;
+       }
+}
+
+
+extern "C" void __attribute__((section(".text.start")))
+_start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
+{
+       // According to the PowerPC bindings, OpenFirmware should have created
+       // a stack of 32kB or higher for us at this point
+
+       clear_bss();
+       call_ctors();
+               // call C++ constructors before doing anything else
+
+       start(openFirmwareEntry);
+}
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/Jamfile 
b/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
index 4871b0cb49..1990ac2577 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 $(HAIKU_BOOT_PLATFORM) ;
+SubDirHdrs $(HAIKU_TOP) src system boot platform openfirmware ;
 UsePrivateSystemHeaders ;
 UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_KERNEL_ARCH) ] 
        [ FDirName kernel boot platform $(HAIKU_KERNEL_PLATFORM) ]
@@ -8,10 +8,11 @@ UsePrivateHeaders kernel [ FDirName kernel arch 
$(TARGET_KERNEL_ARCH) ]
 
 SubDirC++Flags -fno-rtti ;
 
-BootStaticLibrary boot_platform_openfirmware_sparc :
+BootMergeObject boot_platform_openfirmware_sparc.o :
        arch_start_kernel.S
        cpu.cpp
        mmu.cpp
+       start.cpp
 ;
 
 SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/start.cpp 
b/src/system/boot/platform/openfirmware/arch/sparc/start.cpp
new file mode 100644
index 0000000000..cd2c857b26
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/arch/sparc/start.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2011, Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "start.h"
+
+#include "machine.h"
+
+
+void
+determine_machine(void)
+{
+       gMachine = MACHINE_UNKNOWN;
+}
+
+
+extern "C" void __attribute__((section(".text.start")))
+_start(int _reserved, int _argstr, int _arglen, int _unknown,
+       void *openFirmwareEntry)
+{
+       // According to the sparc bindings, OpenFirmware should have created
+       // a stack of 8kB or higher for us at this point, and window traps are
+       // operational so it's possible to call the openFirmwareEntry safely.
+       // The bss segment is already cleared by the firmware as well.
+
+       call_ctors();
+               // call C++ constructors before doing anything else
+
+       start(openFirmwareEntry);
+}
+
diff --git a/src/system/boot/platform/openfirmware/start.cpp 
b/src/system/boot/platform/openfirmware/start.cpp
index a2777e4177..a034441dcb 100644
--- a/src/system/boot/platform/openfirmware/start.cpp
+++ b/src/system/boot/platform/openfirmware/start.cpp
@@ -1,10 +1,13 @@
 /*
  * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
  * Copyright 2011, Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
 
+#include "start.h"
+
 #include <string.h>
 
 #include <OS.h>
@@ -23,27 +26,15 @@
 #define HEAP_SIZE 65536
 
 
-extern "C" void _start(uint32 _unused1, uint32 _unused2,
-       void *openFirmwareEntry);
-extern "C" void start(void *openFirmwareEntry);
-
-#ifdef __powerpc__
-// XCOFF "entry-point" is actually a pointer to the real code
-extern "C" void *_coff_start;
-void *_coff_start = (void *)&_start;
-#endif
-
 // GCC defined globals
 extern void (*__ctor_list)(void);
 extern void (*__ctor_end)(void);
-extern uint8 __bss_start;
-extern uint8 _end;
 
 uint32 gMachine;
 static uint32 sBootOptions;
 
 
-static void
+void
 call_ctors(void)
 {
        void (**f)(void);
@@ -54,52 +45,6 @@ call_ctors(void)
 }
 
 
-#ifdef __powerpc__
-static void
-clear_bss(void)
-{
-       memset(&__bss_start, 0, &_end - &__bss_start);
-}
-#endif
-
-
-static void
-determine_machine(void)
-{
-       gMachine = MACHINE_UNKNOWN;
-
-       int root = of_finddevice("/");
-       char buffer[64];
-       int length;
-
-       // TODO : Probe other OpenFirmware platforms and set gMachine as needed
-
-       if ((length = of_getprop(root, "device_type", buffer, sizeof(buffer) - 
1))
-               != OF_FAILED) {
-               buffer[length] = '\0';
-               if (!strcasecmp("chrp", buffer))
-                       gMachine = MACHINE_CHRP;
-               else if (!strcasecmp("bootrom", buffer))
-                       gMachine = MACHINE_MAC;
-       } else
-               gMachine = MACHINE_MAC;
-
-       if ((length = of_getprop(root, "model", buffer, sizeof(buffer) - 1))
-               != OF_FAILED) {
-               buffer[length] = '\0';
-               if (!strcasecmp("pegasos", buffer))
-                       gMachine |= MACHINE_PEGASOS;
-       }
-
-       if ((length = of_getprop(root, "name", buffer, sizeof(buffer) - 1))
-               != OF_FAILED) {
-               buffer[length] = '\0';
-               if (!strcasecmp("openbiosteam,openbios", buffer))
-                       gMachine |= MACHINE_QEMU;
-       }
-}
-
-
 extern "C" void
 platform_start_kernel(void)
 {
@@ -138,22 +83,6 @@ platform_boot_options(void)
 }
 
 
-extern "C" void __attribute__((section(".text.start")))
-_start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
-{
-       // According to the PowerPC bindings, OpenFirmware should have created
-       // a stack of 32kB or higher for us at this point
-
-#ifndef __sparc__
-       clear_bss();
-#endif
-       call_ctors();
-               // call C++ constructors before doing anything else
-
-       start(openFirmwareEntry);
-}
-
-
 extern "C" void
 start(void *openFirmwareEntry)
 {
@@ -178,12 +107,14 @@ start(void *openFirmwareEntry)
        determine_machine();
        console_init();
 
+#ifdef __powerpc__
        if ((gMachine & MACHINE_QEMU) != 0)
                dprintf("OpenBIOS (QEMU?) OpenFirmware machine detected\n");
        else if ((gMachine & MACHINE_PEGASOS) != 0)
                dprintf("Pegasos PowerPC machine detected\n");
        else
                dprintf("Apple PowerPC machine assumed\n");
+#endif
 
        // Initialize and take over MMU and set the OpenFirmware callbacks - it
        // will ask us for memory after that instead of maintaining it itself
diff --git a/src/system/boot/platform/openfirmware/start.h 
b/src/system/boot/platform/openfirmware/start.h
new file mode 100644
index 0000000000..9e31d8cb95
--- /dev/null
+++ b/src/system/boot/platform/openfirmware/start.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2011, Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ * Copyright 2019, Adrien Destugues, pulkomandy@xxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
+extern "C" void start(void *openFirmwareEntry);
+
+void determine_machine(void);
+void call_ctors(void);

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

Revision:    hrev53165
Commit:      70482896788d840019b7f92112b07fe0728f915c
URL:         https://git.haiku-os.org/haiku/commit/?id=70482896788d
Author:      PulkoMandy <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri May 24 21:11:03 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 25 18:16:35 2019 UTC

openfirmware: fix jamfiles

Without the MultiArchDirSetup, these would not use the boot cflags, and
end up being compiled position-independant. Of course, the a.out format
does not allow relocations, so this could not work.

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

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

diff --git a/src/system/boot/platform/openfirmware/arch/ppc/Jamfile 
b/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
index f7c3d95efc..14a364fb08 100644
--- a/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
+++ b/src/system/boot/platform/openfirmware/arch/ppc/Jamfile
@@ -8,14 +8,20 @@ UsePrivateHeaders kernel [ FDirName kernel arch 
$(TARGET_KERNEL_ARCH) ]
 
 SubDirC++Flags -fno-rtti ;
 
-BootStaticLibrary boot_platform_openfirmware_ppc.o :
-       arch_mmu.cpp
-       arch_cpu_asm.S
-       arch_start_kernel.S
-       cpu.cpp
-       mmu.cpp
-       start.cpp
-;
+local platform ;
+for platform in [ MultiBootSubDirSetup openfirmware ] {
+       on $(platform) {
+
+               BootMergeObject boot_platform_openfirmware_ppc.o :
+                       arch_mmu.cpp
+                       arch_cpu_asm.S
+                       arch_start_kernel.S
+                       cpu.cpp
+                       mmu.cpp
+                       start.cpp
+               ;
+               SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
+               = [ FDirName $(HAIKU_TOP) src system kernel arch 
$(TARGET_KERNEL_ARCH) ] ;
+       }
+}
 
-SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
-    = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ;
diff --git a/src/system/boot/platform/openfirmware/arch/sparc/Jamfile 
b/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
index 1990ac2577..371b56060a 100644
--- a/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
+++ b/src/system/boot/platform/openfirmware/arch/sparc/Jamfile
@@ -8,12 +8,18 @@ UsePrivateHeaders kernel [ FDirName kernel arch 
$(TARGET_KERNEL_ARCH) ]
 
 SubDirC++Flags -fno-rtti ;
 
-BootMergeObject boot_platform_openfirmware_sparc.o :
-       arch_start_kernel.S
-       cpu.cpp
-       mmu.cpp
-       start.cpp
-;
+local platform ;
+for platform in [ MultiBootSubDirSetup openfirmware ] {
+       on $(platform) {
 
-SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
-    = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ;
+               BootMergeObject boot_platform_openfirmware_sparc.o :
+                       arch_start_kernel.S
+                       cpu.cpp
+                       mmu.cpp
+                       start.cpp
+               ;
+
+               SEARCH on [ FGristFiles arch_cpu_asm.S arch_mmu.cpp ]
+                   = [ FDirName $(HAIKU_TOP) src system kernel arch 
$(TARGET_KERNEL_ARCH) ] ;
+       }
+}


Other related posts:

  • » [haiku-commits] haiku: hrev53165 - in src/system: boot/platform/openfirmware/arch/ppc boot/platform/openfirmware boot/platform/openfirmware/arch/sparc libroot/posix/glibc/math ldscripts/sparc - waddlesplash