[U-Boot-Users] [PATCH 3/3] [new uImage] ppc: Re-order ramdisk/fdt handling sequence

Kumar Gala galak at kernel.crashing.org
Fri Feb 15 16:29:36 CET 2008


Do the fdt before the ramdisk allows us to grow the fdt w/o concern
however it does me we have to go in and fixup the initrd info since
we dont know where it will be.

Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---

Patch against u-boot-testing new-image branch.

 lib_ppc/bootm.c |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 5158ccc..927842c 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -121,9 +121,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,

 	rd_len = rd_data_end - rd_data_start;

-	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
-			sp_limit, get_sp (), &initrd_start, &initrd_end);
-
 #if defined(CONFIG_OF_LIBFDT)
 	/* find flattened device tree */
 	alloc_current = get_fdt (alloc_current,
@@ -134,7 +131,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	 * if the user wants it (the logic is in the subroutines).
 	 */
 	if (of_flat_tree) {
-		if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) {
+		/* pass in dummy initrd info, we'll fix up later */
+		if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) {
 			fdt_error ("/chosen node create failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
@@ -157,6 +155,38 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	}
 #endif	/* CONFIG_OF_LIBFDT */

+	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
+			sp_limit, get_sp (), &initrd_start, &initrd_end);
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* fixup the initrd now that we know where it should be */
+	if ((of_flat_tree) && (initrd_start && initrd_end)) {
+		uint64_t addr, size;
+		int  total = fdt_num_mem_rsv(of_flat_tree);
+		int  j, err;
+
+		/* Look for the dummy entry and delete it */
+		for (j = 0; j < total; j++) {
+			err = fdt_get_mem_rsv(of_flat_tree, j, &addr, &size);
+			if (addr == rd_data_start) {
+				fdt_del_mem_rsv(of_flat_tree, j);
+				break;
+			}
+		}
+
+		err = fdt_add_mem_rsv(of_flat_tree, initrd_start,
+					initrd_end - initrd_start + 1);
+		if (err < 0) {
+			printf("fdt_chosen: %s\n", fdt_strerror(err));
+			return err;
+		}
+
+		do_fixup_by_path_u32(of_flat_tree, "/chosen",
+					"linux,initrd-start", initrd_start, 0);
+		do_fixup_by_path_u32(of_flat_tree, "/chosen",
+					"linux,initrd-end", initrd_end, 0);
+	}
+#endif
 	debug ("## Transferring control to Linux (at address %08lx) ...\n",
 		(ulong)kernel);

-- 
1.5.3.8





More information about the U-Boot mailing list