kernel/arch/arm: introduce virtual_ranges_to_keep

Change-Id: I36b8b871a103f2be87c600fc0b0a12f7ceff0ae4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4743
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
David Karoly
2021-12-02 08:16:31 +00:00
committed by Adrien Destugues
parent 19960ba6f9
commit 1f46427d16
2 changed files with 40 additions and 0 deletions
@@ -16,6 +16,8 @@
#define _PACKED __attribute__((packed)) #define _PACKED __attribute__((packed))
#define MAX_VIRTUAL_RANGES_TO_KEEP 32
// kernel args // kernel args
typedef struct { typedef struct {
@@ -30,6 +32,10 @@ typedef struct {
uint32 vir_pgdir; uint32 vir_pgdir;
uint32 next_pagetable; uint32 next_pagetable;
// The virtual ranges we want to keep in the kernel.
uint32 num_virtual_ranges_to_keep;
addr_range virtual_ranges_to_keep[MAX_VIRTUAL_RANGES_TO_KEEP];
// needed for UEFI, otherwise kernel acpi support can't find ACPI root // needed for UEFI, otherwise kernel acpi support can't find ACPI root
FixedWidthPointer<void> acpi_root; FixedWidthPointer<void> acpi_root;
FixedWidthPointer<void> fdt; FixedWidthPointer<void> fdt;
+34
View File
@@ -16,6 +16,7 @@
#include <boot/kernel_args.h> #include <boot/kernel_args.h>
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/VMAddressSpace.h>
#include <vm/vm_types.h> #include <vm/vm_types.h>
#include <arch/vm.h> #include <arch/vm.h>
//#include <arch_mmu.h> //#include <arch_mmu.h>
@@ -55,6 +56,39 @@ arch_vm_init_post_area(kernel_args *args)
status_t status_t
arch_vm_init_end(kernel_args *args) arch_vm_init_end(kernel_args *args)
{ {
TRACE(("arch_vm_init_end(): %" B_PRIu32 " virtual ranges to keep:\n",
args->arch_args.num_virtual_ranges_to_keep));
for (int i = 0; i < (int)args->arch_args.num_virtual_ranges_to_keep; i++) {
addr_range &range = args->arch_args.virtual_ranges_to_keep[i];
TRACE((" start: %p, size: %#" B_PRIxSIZE "\n", (void*)range.start, range.size));
// skip ranges outside the kernel address space
if (!IS_KERNEL_ADDRESS(range.start)) {
TRACE((" no kernel address, skipping...\n"));
continue;
}
phys_addr_t physicalAddress;
void *address = (void*)range.start;
if (vm_get_page_mapping(VMAddressSpace::KernelID(), range.start,
&physicalAddress) != B_OK)
panic("arch_vm_init_end(): No page mapping for %p\n", address);
area_id area = vm_map_physical_memory(VMAddressSpace::KernelID(),
"boot loader reserved area", &address,
B_EXACT_ADDRESS, range.size,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
physicalAddress, true);
if (area < 0) {
panic("arch_vm_init_end(): Failed to create area for boot loader "
"reserved area: %p - %p\n", (void*)range.start,
(void*)(range.start + range.size));
}
}
// Throw away all mappings that are unused by the kernel // Throw away all mappings that are unused by the kernel
vm_free_unused_boot_loader_range(KERNEL_LOAD_BASE, KERNEL_SIZE); vm_free_unused_boot_loader_range(KERNEL_LOAD_BASE, KERNEL_SIZE);