This cleans up a lot of subtle or hidden inconsistencies:
* Drop the "exactAddress" parameter. It was added in hrev15708 (2005),
but all callers in all bootloaders passed "false" to it until 2022,
when one codepath in the ARM32 EFI loader started using it.
* Adjust EFI's platform_allocate_lomem to platform_allocate_region_below,
and add a platform_assign_kernel_address_for_region(). This allows the
aforementioned ARM EFI codepath to continue to do what it wants,
which is to get an identity-mapped trampoline page, without having
functions with confusingly different semantics ("allocate_lomem"
assigned the virtual addresses as identity-mapped unconditionally,
but it didn't insert these into the virtual allocated ranges.)
This also paves the way for other EFI loaders to use this method
to allocate memory below whatever default the boot services
would give us.
* Drop fixed virtual address allocation for all arches on EFI, with the
exception of fixed addresses inside KERNEL_LOAD_BASE, same as on
other boot platforms. Anything which wants fixed virtual addresses
outside that region can use the new "assign kernel address" method.
* Validate kernel base and size against kMaxKernelSize, instead of
assuming it fits. This matches behavior of other boot platforms.
Ideally we would have some more generic routine for mapping the
kernel, but this suffices for now.
Tested with x86_64 and ARM; both still boot (well, ARM boots as
far as it did before this commit, anyway.)
Change-Id: Ieb4fba752994101191a2335cb5395eb2b726fcbb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9024
Reviewed-by: waddlesplash <[email protected]>
45 lines
808 B
C++
45 lines
808 B
C++
/*
|
|
* Copyright 2003, Axel Dörfler, [email protected].
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <boot/platform.h>
|
|
#include <boot/heap.h>
|
|
#include <boot/stdio.h>
|
|
#include <platform/openfirmware/openfirmware.h>
|
|
|
|
|
|
//#define TRACE_HEAP 1
|
|
#if TRACE_HEAP
|
|
# define TRACE(x) printf x
|
|
#else
|
|
# define TRACE(x) ;
|
|
#endif
|
|
|
|
|
|
ssize_t
|
|
platform_allocate_heap_region(size_t size, void **_base)
|
|
{
|
|
TRACE(("platform_allocate_heap_region()\n"));
|
|
|
|
*_base = NULL;
|
|
status_t error = platform_allocate_region(_base, size,
|
|
B_READ_AREA | B_WRITE_AREA);
|
|
if (error != B_OK)
|
|
return error;
|
|
|
|
printf("heap base = %p\n", *_base);
|
|
return size;
|
|
}
|
|
|
|
|
|
void
|
|
platform_free_heap_region(void *_base, size_t size)
|
|
{
|
|
if (_base != NULL)
|
|
platform_free_region(_base, size);
|
|
}
|