From 5d1f3d53e2e05d27b8ed9af6daf5de888b7b25f0 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 10 Mar 2010 18:38:57 +0000 Subject: [PATCH] get_next_physical_address(): Directly update the gKernelArgs.physical_allocated_range array. This way it is always up to date and we don't need to fix it in mmu_init_for_kernel(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35802 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/bios_ia32/mmu.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index 21eb631045..1d6384a5f3 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -111,10 +111,19 @@ get_next_virtual_address(size_t size) static addr_t get_next_physical_address(size_t size) { - addr_t address = sNextPhysicalAddress; - sNextPhysicalAddress += size; + addr_t base; + if (!get_free_address_range(gKernelArgs.physical_allocated_range, + gKernelArgs.num_physical_allocated_ranges, sNextPhysicalAddress, + size, &base)) { + panic("Out of physical memory!"); + return 0; + } - return address; + insert_physical_allocated_range(base, size); + sNextPhysicalAddress = base + size; + // TODO: Can overflow theoretically. + + return base; } @@ -559,10 +568,6 @@ mmu_init_for_kernel(void) (void*)gKernelArgs.arch_args.vir_gdt); } - // save the memory we've physically allocated - gKernelArgs.physical_allocated_range[0].size - = sNextPhysicalAddress - gKernelArgs.physical_allocated_range[0].start; - // Save the memory we've virtually allocated (for the kernel and other // stuff) gKernelArgs.virtual_allocated_range[0].start = KERNEL_BASE;