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.

Change-Id: I58b1d17a78dcf273ceee88318338b4770b500bb3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3566
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
PulkoMandy
2020-12-30 18:15:52 +00:00
committed by waddlesplash
parent 85b4ce6191
commit 2ef7fd7186
2 changed files with 12 additions and 16 deletions
+11 -15
View File
@@ -119,21 +119,14 @@ struct ELF64Class {
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 @@ struct ELF64Class {
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 @@ struct ELF64Class {
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
}
};
+1 -1
View File
@@ -8,7 +8,7 @@ UsePrivateHeaders [ FDirName graphics vesa ] ;
UsePrivateHeaders [ FDirName storage ] ;
{
local defines = _BOOT_MODE ;
local defines = _BOOT_MODE _BOOT_PLATFORM_BIOS ;
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) ;