]> git.ozlabs.org Git - yaboot.git/commitdiff
Add prom_claim_chunk_top
authorAnton Blanchard <anton@samba.org>
Thu, 8 Jul 2010 19:03:40 +0000 (19:03 +0000)
committerTony Breeds <tony@bakeyournoodle.com>
Fri, 16 Jul 2010 05:51:57 +0000 (15:51 +1000)
We want temporary allocations to be taken from the top of our address
space so the kernel and initrd can be loaded as low as possible. The
very early kernel code uses the top of the initrd as the low watermark
for memory allocations so the lower this is the better.

We currently see a number of fails where a large initrd causes us
to run out of space in a 128MB RMO region. Allocating the temporary
areas up high and therefore the initrd lower fixes it.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
include/prom.h
second/prom.c

index 5ccfb274ed4d565bc37c7a376c91c72b439e8042..62e65480810e79f3654823ce5af04226adff99d9 100644 (file)
@@ -92,6 +92,7 @@ int prom_set_color(prom_handle device, int color, int r, int g, int b);
 /* memory */
 
 void *prom_claim_chunk(void *virt, unsigned int size, unsigned int align);
 /* memory */
 
 void *prom_claim_chunk(void *virt, unsigned int size, unsigned int align);
+void *prom_claim_chunk_top(unsigned int size, unsigned int align);
 void *prom_claim (void *virt, unsigned int size, unsigned int align);
 void prom_release(void *virt, unsigned int size);
 void prom_map (void *phys, void *virt, int size);
 void *prom_claim (void *virt, unsigned int size, unsigned int align);
 void prom_release(void *virt, unsigned int size);
 void prom_map (void *phys, void *virt, int size);
index 119d0f363cabbc971f259b6e6f4c61b27cbbaf4c..fbadb2ac664632a9243fbaf4d44c9a6a273c466e 100644 (file)
@@ -599,6 +599,23 @@ prom_claim_chunk(void *virt, unsigned int size, unsigned int align)
      return((void*)-1);
 }
 
      return((void*)-1);
 }
 
+/* Start from top of memory and work down to get the needed space */
+void *
+prom_claim_chunk_top(unsigned int size, unsigned int align)
+{
+     void *found, *addr;
+     for(addr=(void*)PROM_CLAIM_MAX_ADDR; addr >= (void *)size;
+         addr-=(0x100000/sizeof(addr))) {
+          found = call_prom("claim", 3, 1, addr, size, 0);
+          if (found != (void *)-1) {
+               prom_debug("claim of 0x%x at 0x%x returned 0x%x\n", size, (int)addr, (int)found);
+               return(found);
+          }
+     }
+     prom_printf("ERROR: claim of 0x%x in range 0x0-0x%x failed\n", size, PROM_CLAIM_MAX_ADDR);
+     return((void*)-1);
+}
+
 void *
 prom_claim (void *virt, unsigned int size, unsigned int align)
 {
 void *
 prom_claim (void *virt, unsigned int size, unsigned int align)
 {