From: Anton Blanchard Date: Thu, 8 Jul 2010 19:03:40 +0000 (+0000) Subject: Add prom_claim_chunk_top X-Git-Tag: yaboot-1.3.17-rc1~7 X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=commitdiff_plain;h=86a488e2f3078a2a4e9942f1ec9d0fb1a3a632ad;hp=5429399eef8152cb3b2a29bc6ee426a214afc701 Add prom_claim_chunk_top 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 Signed-off-by: Tony Breeds --- diff --git a/include/prom.h b/include/prom.h index 5ccfb27..62e6548 100644 --- a/include/prom.h +++ b/include/prom.h @@ -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); +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); diff --git a/second/prom.c b/second/prom.c index 119d0f3..fbadb2a 100644 --- a/second/prom.c +++ b/second/prom.c @@ -599,6 +599,23 @@ prom_claim_chunk(void *virt, unsigned int size, unsigned int align) 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) {