From 90bf6bef34e10276c20265c387a2a5f5507a157a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 11 Mar 2010 17:42:00 +0000 Subject: [PATCH] Added mmu_allocate_physical(), which allocates a specified physical memory range. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35815 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/bios_ia32/mmu.cpp | 17 +++++++++++++++++ src/system/boot/platform/bios_ia32/mmu.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index 1d6384a5f3..83d5334f06 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -444,6 +444,23 @@ mmu_allocate(void *virtualAddress, size_t size) } +/*! Allocates the given physical range. + \return \c true, if the range could be allocated, \c false otherwise. +*/ +bool +mmu_allocate_physical(addr_t base, size_t size) +{ + addr_t foundBase; + if (!get_free_address_range(gKernelArgs.physical_allocated_range, + gKernelArgs.num_physical_allocated_ranges, sNextPhysicalAddress, + size, &foundBase)) { + return B_BAD_VALUE; + } + + return insert_physical_allocated_range(base, size) == B_OK; +} + + /*! This will unmap the allocated chunk of memory from the virtual address space. It might not actually free memory (as its implementation is very simple), but it might. diff --git a/src/system/boot/platform/bios_ia32/mmu.h b/src/system/boot/platform/bios_ia32/mmu.h index 7cd38633f9..fc197e98c8 100644 --- a/src/system/boot/platform/bios_ia32/mmu.h +++ b/src/system/boot/platform/bios_ia32/mmu.h @@ -20,6 +20,7 @@ extern void mmu_init(void); extern void mmu_init_for_kernel(void); extern addr_t mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 flags); extern void *mmu_allocate(void *virtualAddress, size_t size); +extern bool mmu_allocate_physical(addr_t base, size_t size); extern void mmu_free(void *virtualAddress, size_t size); #ifdef __cplusplus