Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: kexec@lists.infradead.org
Cc: Wang Nan <wangnan0@huawei.com>, Simon Horman <horms@verge.net.au>,
	Dave Young <dyoung@redhat.com>, Geng Hui <hui.geng@huawei.com>
Subject: [PATCH 2/3] kexec: pass initrd position in dtb
Date: Wed, 22 Jan 2014 18:52:03 +0800	[thread overview]
Message-ID: <1390387924-73946-3-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1390387924-73946-1-git-send-email-wangnan0@huawei.com>

This patch append the position of initrd to dtb when loading arm kernel and
initrd without using atag.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Dave Young <dyoung@redhat.com>
Cc: Geng Hui <hui.geng@huawei.com>
---
 kexec/arch/arm/kexec-zImage-arm.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 4547765..6d6b239 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -417,6 +417,41 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		if (ramdisk) {
 			add_segment(info, ramdisk_buf, initrd_size,
 			            initrd_base, initrd_size);
+			const char *node_name = "/chosen";
+			const char *prop_start_name = "linux,initrd-start";
+			const char *prop_end_name = "linux,initrd-end";
+			int off;
+
+			dtb_length = fdt_totalsize(dtb_buf) + 1024 + 8;
+			dtb_buf = xrealloc(dtb_buf, dtb_length);
+			fdt_set_totalsize(dtb_buf, dtb_length);
+
+			/* check if a /choosen subnode already exists */
+			off = fdt_path_offset(dtb_buf, node_name);
+
+			if (off == -FDT_ERR_NOTFOUND)
+				off = fdt_add_subnode(dtb_buf, off, node_name);
+
+			if (off < 0) {
+				fprintf(stderr, "FDT: Error adding %s node.\n", node_name);
+				return -1;
+			}
+
+			unsigned long start, end;
+			start = cpu_to_be32((unsigned long)(initrd_base));
+			end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
+			if (fdt_setprop(dtb_buf, off, prop_start_name,
+						&start, sizeof(start)) != 0) {
+				fprintf(stderr, "FDT: Error setting %s/%s property.\n",
+						node_name, prop_start_name);
+				return -1;
+			}
+			if (fdt_setprop(dtb_buf, off, prop_end_name,
+						&end, sizeof(end)) != 0) {
+				fprintf(stderr, "FDT: Error setting %s/%s property.\n",
+						node_name, prop_end_name);
+				return -1;
+			}
 		}
 
 		/* Stick the dtb at the end of the initrd and page
-- 
1.8.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2014-01-22 10:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 10:52 [PATCH 0/3] kexec-tools: fix bugs and pass initrd position for arm Wang Nan
2014-01-22 10:52 ` [PATCH 1/3] kexec: align initrd when no --image-size Wang Nan
2014-02-06  3:44   ` Dave Young
2014-01-22 10:52 ` Wang Nan [this message]
2014-02-06  3:58   ` [PATCH 2/3] kexec: pass initrd position in dtb Dave Young
2014-01-22 10:52 ` [PATCH 3/3] kexec: increase zImage compression ratio from 4 to 5 Wang Nan
2014-02-06  4:01   ` Dave Young
2014-01-23  2:02 ` [PATCH 0/3] kexec-tools: fix bugs and pass initrd position for arm Dave Young
2014-01-23  2:47 ` Dave Young
2014-01-23  2:56   ` Wang Nan
2014-01-23  3:38     ` Dave Young
2014-01-23  4:17       ` Wang Nan
2014-01-23  5:00         ` Dave Young

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=1390387924-73946-3-git-send-email-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=dyoung@redhat.com \
    --cc=horms@verge.net.au \
    --cc=hui.geng@huawei.com \
    --cc=kexec@lists.infradead.org \
    /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