[haiku-commits] Change in haiku[master]: bootloader elf: fix elf64 loading for non-x86 platforms

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 30 Dec 2020 18:07:01 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3566 ;)


Change subject: bootloader elf: fix elf64 loading for non-x86 platforms
......................................................................

bootloader elf: fix elf64 loading for non-x86 platforms

Some code was enabled only for EFI, but is in fact correct for all
platforms except BIOS. Switch the defines around to have the correct
code enabled by default.
---
M src/system/boot/loader/elf.cpp
M src/system/boot/platform/bios_ia32/Jamfile
2 files changed, 12 insertions(+), 16 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/66/3566/1

diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp
index 1a39c96..b0e3e58 100644
--- a/src/system/boot/loader/elf.cpp
+++ b/src/system/boot/loader/elf.cpp
@@ -119,21 +119,14 @@
        AllocateRegion(AddrType* _address, AddrType size, uint8 protection,
                void **_mappedAddress)
        {
-#ifdef _BOOT_PLATFORM_EFI
-               void* address = (void*)*_address;
-
-               status_t status = platform_allocate_region(&address, size, 
protection,
-                       false);
-               if (status != B_OK)
-                       return status;
-
-               *_mappedAddress = address;
-               platform_bootloader_address_to_kernel_address(address, 
_address);
-#else
+#if defined(_BOOT_PLATFORM_BIOS)
                // Assume the real 64-bit base address is 
KERNEL_LOAD_BASE_64_BIT and
                // the mappings in the loader address space are at 
KERNEL_LOAD_BASE.

                void* address = (void*)(addr_t)(*_address & 0xffffffff);
+#else
+               void* address = (void*)*_address;
+#endif

                status_t status = platform_allocate_region(&address, size, 
protection,
                        false);
@@ -141,8 +134,11 @@
                        return status;

                *_mappedAddress = address;
+#if defined(_BOOT_PLATFORM_BIOS)
                *_address = (AddrType)(addr_t)address + KERNEL_LOAD_BASE_64_BIT
                        - KERNEL_LOAD_BASE;
+#else
+               platform_bootloader_address_to_kernel_address(address, 
_address);
 #endif
                return B_OK;
        }
@@ -150,15 +146,15 @@
        static inline void*
        Map(AddrType address)
        {
-#ifdef _BOOT_PLATFORM_EFI
+#ifdef _BOOT_PLATFORM_BIOS
+               return (void*)(addr_t)(address - KERNEL_LOAD_BASE_64_BIT
+                       + KERNEL_LOAD_BASE);
+#else
                void *result;
                if (platform_kernel_address_to_bootloader_address(address, 
&result) != B_OK) {
                        panic("Couldn't convert address %#lx", address);
                }
                return result;
-#else
-               return (void*)(addr_t)(address - KERNEL_LOAD_BASE_64_BIT
-                       + KERNEL_LOAD_BASE);
 #endif
        }
 };
diff --git a/src/system/boot/platform/bios_ia32/Jamfile 
b/src/system/boot/platform/bios_ia32/Jamfile
index 872ced4..6c44677 100644
--- a/src/system/boot/platform/bios_ia32/Jamfile
+++ b/src/system/boot/platform/bios_ia32/Jamfile
@@ -8,7 +8,7 @@
 UsePrivateHeaders [ FDirName storage ] ;

 {
-       local defines = _BOOT_MODE ;
+       local defines = _BOOT_MODE _BOOT_PLATFORM_BIOS ;

        defines = [ FDefines $(defines) ] ;
        SubDirCcFlags $(defines) ;

--
To view, visit https://review.haiku-os.org/c/haiku/+/3566
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I58b1d17a78dcf273ceee88318338b4770b500bb3
Gerrit-Change-Number: 3566
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: bootloader elf: fix elf64 loading for non-x86 platforms - Gerrit