From: David S. Miller Date: Thu, 14 Feb 2008 02:00:03 +0000 (-0800) Subject: [SPARC64]: Move ramdisk discovery code out to seperate function. X-Git-Tag: v2.6.26-rc1~1089^2~21 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e82c9a606da2b1c1c7ea7dfd8052626a4c6d5d6;p=linux-2.6 [SPARC64]: Move ramdisk discovery code out to seperate function. And add some comments explaining all of the quirks involved in the way the bootloader provides this information. Signed-off-by: David S. Miller --- diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index f37078d964..21e9267608 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c @@ -883,6 +883,37 @@ static void __init trim_pavail(unsigned long *cur_size_p, } } +static void __init find_ramdisk(unsigned long phys_base) +{ +#ifdef CONFIG_BLK_DEV_INITRD + if (sparc_ramdisk_image || sparc_ramdisk_image64) { + unsigned long ramdisk_image; + + /* Older versions of the bootloader only supported a + * 32-bit physical address for the ramdisk image + * location, stored at sparc_ramdisk_image. Newer + * SILO versions set sparc_ramdisk_image to zero and + * provide a full 64-bit physical address at + * sparc_ramdisk_image64. + */ + ramdisk_image = sparc_ramdisk_image; + if (!ramdisk_image) + ramdisk_image = sparc_ramdisk_image64; + + /* Another bootloader quirk. The bootloader normalizes + * the physical address to KERNBASE, so we have to + * factor that back out and add in the lowest valid + * physical page address to get the true physical address. + */ + ramdisk_image -= KERNBASE; + ramdisk_image += phys_base; + + initrd_start = ramdisk_image; + initrd_end = ramdisk_image + sparc_ramdisk_size; + } +#endif +} + /* About pages_avail, this is the value we will use to calculate * the zholes_size[] argument given to free_area_init_node(). The * page allocator uses this to calculate nr_kernel_pages, @@ -912,30 +943,6 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail, bytes_avail += pavail[i].reg_size; } - /* Determine the location of the initial ramdisk before trying - * to honor the "mem=xxx" command line argument. We must know - * where the kernel image and the ramdisk image are so that we - * do not trim those two areas from the physical memory map. - */ - -#ifdef CONFIG_BLK_DEV_INITRD - /* Now have to check initial ramdisk, so that bootmap does not overwrite it */ - if (sparc_ramdisk_image || sparc_ramdisk_image64) { - unsigned long ramdisk_image = sparc_ramdisk_image ? - sparc_ramdisk_image : sparc_ramdisk_image64; - ramdisk_image -= KERNBASE; - initrd_start = ramdisk_image + phys_base; - initrd_end = initrd_start + sparc_ramdisk_size; - if (initrd_end > end_of_phys_memory) { - printk(KERN_CRIT "initrd extends beyond end of memory " - "(0x%016lx > 0x%016lx)\ndisabling initrd\n", - initrd_end, end_of_phys_memory); - initrd_start = 0; - initrd_end = 0; - } - } -#endif - if (cmdline_memory_size && bytes_avail > cmdline_memory_size) trim_pavail(&bytes_avail, @@ -1337,6 +1344,8 @@ void __init paging_init(void) for (i = 0; i < pavail_ents; i++) phys_base = min(phys_base, pavail[i].phys_addr); + find_ramdisk(phys_base); + set_bit(0, mmu_context_bmap); shift = kern_base + PAGE_OFFSET - ((unsigned long)KERNBASE);