diff mbox

[10/14] Add prom_claim_chunk_top

Message ID 20100709050342.259074546@samba.org
State Changes Requested
Headers show

Commit Message

Anton Blanchard July 9, 2010, 5:03 a.m. UTC
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>
---
diff mbox

Patch

Index: yaboot/second/prom.c
===================================================================
--- yaboot.orig/second/prom.c	2010-07-09 14:36:47.000000000 +1000
+++ yaboot/second/prom.c	2010-07-09 14:39:19.000000000 +1000
@@ -599,6 +599,23 @@  prom_claim_chunk(void *virt, unsigned in
      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)
 {
Index: yaboot/include/prom.h
===================================================================
--- yaboot.orig/include/prom.h	2010-07-09 14:36:47.000000000 +1000
+++ yaboot/include/prom.h	2010-07-09 14:39:09.000000000 +1000
@@ -91,6 +91,7 @@  int prom_set_color(prom_handle device, i
 /* 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);