public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 3/9] [new uImage] ppc: Re-order ramdisk/fdt handling sequence
Date: Wed, 27 Feb 2008 21:51:45 -0600	[thread overview]
Message-ID: <1204170711-2057-4-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1204170711-2057-3-git-send-email-galak@kernel.crashing.org>

Doing the fdt before the ramdisk allows us to grow the fdt w/o concern
however it does mean we have to go in and fixup the initrd info since
we don't know where it will be.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 lib_ppc/bootm.c |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 3e89da1..de6995e 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -71,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	bd_t	*kbd;
 	ulong	ep = 0;
 	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);
+	int	ret;
 	ulong	of_size = 0;
 
 #if defined(CONFIG_OF_LIBFDT)
@@ -126,9 +127,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	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)
 	alloc_current = fdt_relocate (alloc_current,
 			cmdtp, flag, argc, argv, &of_flat_tree, &of_size);
@@ -138,7 +136,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	 * if the user wants it (the logic is in the subroutines).
 	 */
 	if (of_size) {
-		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);
 		}
@@ -161,6 +160,38 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	}
 #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;
+
+		/* Look for the dummy entry and delete it */
+		for (j = 0; j < total; j++) {
+			fdt_get_mem_rsv(of_flat_tree, j, &addr, &size);
+			if (addr == rd_data_start) {
+				fdt_del_mem_rsv(of_flat_tree, j);
+				break;
+			}
+		}
+
+		ret = fdt_add_mem_rsv(of_flat_tree, initrd_start,
+					initrd_end - initrd_start + 1);
+		if (ret < 0) {
+			printf("fdt_chosen: %s\n", fdt_strerror(ret));
+			do_reset (cmdtp, flag, argc, argv);
+		}
+
+		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.4.1

  reply	other threads:[~2008-02-28  3:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-28  3:51 [U-Boot-Users] [PATCH 0/9] [new uImage] Add support for booting images at non-zero addresses Kumar Gala
2008-02-28  3:51 ` [U-Boot-Users] [PATCH 1/9] [new uImage] Don't pass kdb to ramdisk_high since we may not have one Kumar Gala
2008-02-28  3:51   ` [U-Boot-Users] [PATCH 2/9] [new uImage] ppc: Determine if we are booting an OF style Kumar Gala
2008-02-28  3:51     ` Kumar Gala [this message]
2008-02-28  3:51       ` [U-Boot-Users] [PATCH 4/9] [new uImage] rework error handling so common functions don't reset Kumar Gala
2008-02-28  3:51         ` [U-Boot-Users] [PATCH 5/9] [new uImage] Introduce lmb from linux kernel for memory mgmt of boot images Kumar Gala
2008-02-28  3:51           ` [U-Boot-Users] [PATCH 6/9] [new uImage] Add autostart flag to bootm_headers structure Kumar Gala
2008-02-28  3:51             ` [U-Boot-Users] [PATCH 7/9] [new uImage] Use lmb for bootm allocations Kumar Gala
2008-02-28  3:51               ` [U-Boot-Users] [PATCH 8/9] [new uImage] Provide ability to restrict region used for boot images Kumar Gala
2008-02-28  3:51                 ` [U-Boot-Users] [PATCH 9/9] [new uImage] Respect autostart setting in linux bootm Kumar Gala
2008-02-29 14:35                   ` Marian Balakowicz
2008-02-29 14:34                 ` [U-Boot-Users] [PATCH 8/9] [new uImage] Provide ability to restrict region used for boot images Marian Balakowicz
2008-02-29 14:26             ` [U-Boot-Users] [PATCH 6/9] [new uImage] Add autostart flag to bootm_headers structure Marian Balakowicz
2008-02-29 14:24         ` [U-Boot-Users] [PATCH 4/9] [new uImage] rework error handling so common functions don't reset Marian Balakowicz
2008-02-29 14:22     ` [U-Boot-Users] [PATCH 2/9] [new uImage] ppc: Determine if we are booting an OF style Marian Balakowicz
2008-02-29 14:21   ` [U-Boot-Users] [PATCH 1/9] [new uImage] Don't pass kdb to ramdisk_high since we may not have one Marian Balakowicz
2008-02-29 14:47 ` [U-Boot-Users] [PATCH 0/9] [new uImage] Add support for booting images at non-zero addresses Marian Balakowicz
  -- strict thread matches above, loose matches on Subject: below --
2008-02-20  4:03 Kumar Gala
2008-02-20  4:03 ` [U-Boot-Users] [PATCH 1/9] [new uImage] Don't pass kdb to ramdisk_high since we may not have one Kumar Gala
2008-02-20  4:03   ` [U-Boot-Users] [PATCH 2/9] [new uImage] ppc: Determine if we are booting an OF style Kumar Gala
2008-02-20  4:03     ` [U-Boot-Users] [PATCH 3/9] [new uImage] ppc: Re-order ramdisk/fdt handling sequence Kumar Gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1204170711-2057-4-git-send-email-galak@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox