hrev51998 adds 2 changesets to branch 'master'
old head: 8845ad353d239fac8233c571d2eb6f0f0e6a5f7b
new head: 86b12d85c703e75ef9bfa064d0fcdba5d5e1c9a7
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=86b12d85c703+%5E8845ad353d23
----------------------------------------------------------------------------
b2d0b3699e5f: efi: redo mmu_map_physical_address to not require allocations.
* mmu_map_physical_address will get called prior to calling main()
which leaves us without a heap, malloc, and new. Instead, use
the kernel args physical allocated range array, and then
convert to our allocated memory region type on-demand.
Change-Id: I265fd165ef7143681e8e40c3686fda1a583c20dc
86b12d85c703: efi: move various init before call to main().
* With the previous commit, we can now move functions that require
calling mmu_map_physical_memory to where they should have been
originally. This also allows the SMP safe mode menu entries to
be properly generated, now that smp_init is called prior to
main().
Change-Id: I05ddca5273b11cb4846021664c1ea2cf8ba723b7
[ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]
----------------------------------------------------------------------------
2 files changed, 42 insertions(+), 21 deletions(-)
src/system/boot/platform/efi/mmu.cpp | 54 ++++++++++++++++++++----------
src/system/boot/platform/efi/start.cpp | 9 ++---
############################################################################
Commit: b2d0b3699e5f3ec43396c8faf937247b1912e5fd
URL: https://git.haiku-os.org/haiku/commit/?id=b2d0b3699e5f
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Mon Jun 11 03:09:28 2018 UTC
efi: redo mmu_map_physical_address to not require allocations.
* mmu_map_physical_address will get called prior to calling main()
which leaves us without a heap, malloc, and new. Instead, use
the kernel args physical allocated range array, and then
convert to our allocated memory region type on-demand.
Change-Id: I265fd165ef7143681e8e40c3686fda1a583c20dc
----------------------------------------------------------------------------
diff --git a/src/system/boot/platform/efi/mmu.cpp
b/src/system/boot/platform/efi/mmu.cpp
old mode 100644
new mode 100755
index d3057c3dee..9cb7b64cae
--- a/src/system/boot/platform/efi/mmu.cpp
+++ b/src/system/boot/platform/efi/mmu.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
+#include <boot/addr_range.h>
#include <boot/platform.h>
#include <boot/stage2.h>
#include <kernel/arch/x86/arch_kernel.h>
@@ -276,25 +277,9 @@ mmu_map_physical_memory(addr_t physicalAddress, size_t
size, uint32 flags)
physicalAddress -= pageOffset;
size += pageOffset;
- size_t aligned_size = ROUNDUP(size, B_PAGE_SIZE);
- allocated_memory_region *region = new(std::nothrow)
allocated_memory_region;
-
- if (!region)
+ if (insert_physical_allocated_range(physicalAddress, ROUNDUP(size,
B_PAGE_SIZE)) != B_OK)
return B_NO_MEMORY;
- // Addresses above 512GB not supported.
- // Memory map regions above 512GB can be ignored, but if EFI returns
pages above
- // that there's nothing that can be done to fix it.
- if (physicalAddress + size > (512ull * 1024 * 1024 * 1024))
- panic("Can't currently support more than 512GB of RAM!");
-
- region->next = allocated_memory_regions;
- allocated_memory_regions = region;
- region->vaddr = 0;
- region->paddr = physicalAddress;
- region->size = aligned_size;
- region->released = false;
-
return physicalAddress + pageOffset;
}
@@ -331,9 +316,44 @@ get_region(void *address, size_t size)
}
+static void
+convert_physical_ranges() {
+ addr_range *range = gKernelArgs.physical_allocated_range;
+ uint32 num_ranges = gKernelArgs.num_physical_allocated_ranges;
+
+ for (uint32 i = 0; i < num_ranges; ++i) {
+ allocated_memory_region *region = new(std::nothrow)
allocated_memory_region;
+
+ if (!region)
+ panic("Couldn't add allocated region");
+
+ // Addresses above 512GB not supported.
+ // Memory map regions above 512GB can be ignored, but if EFI
returns pages above
+ // that there's nothing that can be done to fix it.
+ if (range[i].start + range[i].size > (512ull * 1024 * 1024 *
1024))
+ panic("Can't currently support more than 512GB of
RAM!");
+
+ region->next = allocated_memory_regions;
+ allocated_memory_regions = region;
+ region->vaddr = 0;
+ region->paddr = range[i].start;
+ region->size = range[i].size;
+ region->released = false;
+
+ // Clear out the allocated range
+ range[i].start = 0;
+ range[i].size = 0;
+ gKernelArgs.num_physical_allocated_ranges--;
+ }
+}
+
+
extern "C" status_t
platform_bootloader_address_to_kernel_address(void *address, uint64_t *_result)
{
+ // Convert any physical ranges prior to looking up address
+ convert_physical_ranges();
+
uint64_t addr = (uint64_t)address;
for (allocated_memory_region *region = allocated_memory_regions;
region; region = region->next) {
############################################################################
Revision: hrev51998
Commit: 86b12d85c703e75ef9bfa064d0fcdba5d5e1c9a7
URL: https://git.haiku-os.org/haiku/commit/?id=86b12d85c703
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Mon Jun 11 03:12:52 2018 UTC
efi: move various init before call to main().
* With the previous commit, we can now move functions that require
calling mmu_map_physical_memory to where they should have been
originally. This also allows the SMP safe mode menu entries to
be properly generated, now that smp_init is called prior to
main().
Change-Id: I05ddca5273b11cb4846021664c1ea2cf8ba723b7
----------------------------------------------------------------------------
diff --git a/src/system/boot/platform/efi/start.cpp
b/src/system/boot/platform/efi/start.cpp
old mode 100644
new mode 100755
index a8cc4bc718..dcac306874
--- a/src/system/boot/platform/efi/start.cpp
+++ b/src/system/boot/platform/efi/start.cpp
@@ -147,10 +147,6 @@ platform_start_kernel(void)
if (gKernelArgs.kernel_image->elf_class != ELFCLASS64)
panic("32-bit kernels not supported with EFI");
- cpu_init();
- acpi_init();
- hpet_init();
- smp_init();
smp_init_other_cpus();
preloaded_elf64_image *image = static_cast<preloaded_elf64_image *>(
@@ -292,6 +288,11 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
gKernelArgs.arch_args.hpet_phys = 0;
gKernelArgs.arch_args.hpet = NULL;
+ cpu_init();
+ acpi_init();
+ hpet_init();
+ smp_init();
+
main(&args);
return EFI_SUCCESS;