ARM: Add arm_memblock_steal() to allocate memory away from the kernel
[deliverable/linux.git] / arch / arm / mm / init.c
index e34ea8adc1f928fe8ebeadc677aba06fbd8b4f47..6ec1226fc62d2fc58caa6c795614455c0f7e8ed7 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/memblock.h>
 
 #include <asm/mach-types.h>
+#include <asm/memblock.h>
 #include <asm/prom.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -307,6 +308,21 @@ static void arm_memory_present(void)
 }
 #endif
 
+static bool arm_memblock_steal_permitted = true;
+
+phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align)
+{
+       phys_addr_t phys;
+
+       BUG_ON(!arm_memblock_steal_permitted);
+
+       phys = memblock_alloc(size, align);
+       memblock_free(phys, size);
+       memblock_remove(phys, size);
+
+       return phys;
+}
+
 void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 {
        int i;
@@ -349,6 +365,7 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
        if (mdesc->reserve)
                mdesc->reserve();
 
+       arm_memblock_steal_permitted = false;
        memblock_allow_resize();
        memblock_dump_all();
 }
This page took 0.024231 seconds and 5 git commands to generate.