aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-02-27 22:12:29 -0500
committerPaul Mackerras <paulus@samba.org>2007-03-07 23:43:35 -0500
commit30437b3e743f33e9b68f813ca24e547aa9fcf7d7 (patch)
tree6ff8799e8fbfd717f288e7365a5329a01505e9be /arch/powerpc/kernel
parenteb6de2863750e696201780283e4c9ada19b4728e (diff)
[POWERPC] Automatically lmb_reserve() initrd
At present, when an initrd is passed to the kernel used flat device tree properties, the memory the initrd occupies must also be reserved in the flat tree's reserve map, or the kernel may overwrite it. That makes life more complicated than it could be for the bootwrapper. This patch makes the kernel automatically reserve the initrd's space. That in turn requires parsing the initrd parameters earlier than they are currently, in early_init_dt_scan_chosen() instead of check_for_initrd(). Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/prom.c23
-rw-r--r--arch/powerpc/kernel/setup-common.c22
2 files changed, 25 insertions, 20 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 15ece3abfb37..ef6bfb70b24a 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -719,6 +719,7 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
719 const char *uname, int depth, void *data) 719 const char *uname, int depth, void *data)
720{ 720{
721 unsigned long *lprop; 721 unsigned long *lprop;
722 u32 *prop;
722 unsigned long l; 723 unsigned long l;
723 char *p; 724 char *p;
724 725
@@ -760,6 +761,22 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
760 crashk_res.end = crashk_res.start + *lprop - 1; 761 crashk_res.end = crashk_res.start + *lprop - 1;
761#endif 762#endif
762 763
764#ifdef CONFIG_BLK_DEV_INITRD
765 DBG("Looking for initrd properties... ");
766 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
767 if (prop) {
768 initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));
769 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
770 if (prop) {
771 initrd_end = (unsigned long)__va(of_read_ulong(prop, l/4));
772 initrd_below_start_ok = 1;
773 } else {
774 initrd_start = 0;
775 }
776 }
777 DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end);
778#endif /* CONFIG_BLK_DEV_INITRD */
779
763 /* Retreive command line */ 780 /* Retreive command line */
764 p = of_get_flat_dt_prop(node, "bootargs", &l); 781 p = of_get_flat_dt_prop(node, "bootargs", &l);
765 if (p != NULL && l > 0) 782 if (p != NULL && l > 0)
@@ -926,6 +943,12 @@ static void __init early_reserve_mem(void)
926 self_size = initial_boot_params->totalsize; 943 self_size = initial_boot_params->totalsize;
927 lmb_reserve(self_base, self_size); 944 lmb_reserve(self_base, self_size);
928 945
946#ifdef CONFIG_BLK_DEV_INITRD
947 /* then reserve the initrd, if any */
948 if (initrd_start && (initrd_end > initrd_start))
949 lmb_reserve(__pa(initrd_start), initrd_end - initrd_start);
950#endif /* CONFIG_BLK_DEV_INITRD */
951
929#ifdef CONFIG_PPC32 952#ifdef CONFIG_PPC32
930 /* 953 /*
931 * Handle the case where we might be booting from an old kexec 954 * Handle the case where we might be booting from an old kexec
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 89cfaf49d3de..d050d9a61bd4 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -304,26 +304,8 @@ struct seq_operations cpuinfo_op = {
304void __init check_for_initrd(void) 304void __init check_for_initrd(void)
305{ 305{
306#ifdef CONFIG_BLK_DEV_INITRD 306#ifdef CONFIG_BLK_DEV_INITRD
307 const unsigned int *prop; 307 DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
308 int len; 308 initrd_start, initrd_end);
309
310 DBG(" -> check_for_initrd()\n");
311
312 if (of_chosen) {
313 prop = get_property(of_chosen, "linux,initrd-start", &len);
314 if (prop != NULL) {
315 initrd_start = (unsigned long)
316 __va(of_read_ulong(prop, len / 4));
317 prop = get_property(of_chosen,
318 "linux,initrd-end", &len);
319 if (prop != NULL) {
320 initrd_end = (unsigned long)
321 __va(of_read_ulong(prop, len / 4));
322 initrd_below_start_ok = 1;
323 } else
324 initrd_start = 0;
325 }
326 }
327 309
328 /* If we were passed an initrd, set the ROOT_DEV properly if the values 310 /* If we were passed an initrd, set the ROOT_DEV properly if the values
329 * look sensible. If not, clear initrd reference. 311 * look sensible. If not, clear initrd reference.