* [PATCH] kexec-zImage-arm: add code to support --command-line along with --dtb
@ 2012-12-13 13:35 Daniel Mack
2012-12-14 9:20 ` Sven Neumann
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Mack @ 2012-12-13 13:35 UTC (permalink / raw)
To: kexec; +Cc: matthew.leach, horms, s.neumann, Daniel Mack
If --dtb is called together with --command-line, we need to modify the
binary dtb buffer. Luckily, we have libfdt functions available, so this
is straight forward.
Signed-off-by: Daniel Mack <zonque@gmail.com>
---
kexec/arch/arm/kexec-zImage-arm.c | 48 +++++++++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 46cedbf..0950897 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -359,6 +359,49 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
*/
if (dtb_file) {
dtb_buf = slurp_file(dtb_file, &dtb_length);
+
+ if (fdt_check_header(dtb_buf) != 0) {
+ fprintf(stderr, "Invalid FDT buffer.\n");
+ return -1;
+ }
+
+ if (command_line) {
+ const char *node_name = "/chosen";
+ const char *prop_name = "bootargs";
+ int off;
+
+ /* check if a /choosen subnode already exists */
+ off = fdt_path_offset(dtb_buf, node_name);
+
+ if (off == -FDT_ERR_NOTFOUND) {
+ dtb_length = fdt_totalsize(dtb_buf)
+ + strlen(node_name) + 1
+ + sizeof(struct fdt_node_header)
+ + FDT_TAGSIZE;
+ dtb_buf = xrealloc(dtb_buf, dtb_length);
+ fdt_set_totalsize(dtb_buf, dtb_length);
+ off = fdt_add_subnode(dtb_buf, off, node_name);
+ }
+
+ if (off < 0) {
+ fprintf(stderr, "FDT: Error adding %s node.\n", node_name);
+ return -1;
+ }
+
+ dtb_length = fdt_totalsize(dtb_buf)
+ + strlen(prop_name)
+ + strlen(command_line) + 1
+ + sizeof(struct fdt_property);
+ dtb_buf = xrealloc(dtb_buf, dtb_length);
+ fdt_set_totalsize(dtb_buf, dtb_length);
+
+ if (fdt_setprop(dtb_buf, off, prop_name,
+ command_line, strlen(command_line) + 1) != 0) {
+ fprintf(stderr, "FDT: Error setting %s/%s property.\n",
+ node_name, prop_name);
+ return -1;
+ }
+ }
} else {
/*
* Extract the DTB from /proc/device-tree.
@@ -366,11 +409,6 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
create_flatten_tree(&dtb_buf, &dtb_length, command_line);
}
- if (fdt_check_header(dtb_buf) != 0) {
- fprintf(stderr, "Invalid FDT buffer.\n");
- return -1;
- }
-
if (base + atag_offset + dtb_length > base + offset) {
fprintf(stderr, "DTB too large!\n");
return -1;
--
1.7.11.7
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kexec-zImage-arm: add code to support --command-line along with --dtb
2012-12-13 13:35 [PATCH] kexec-zImage-arm: add code to support --command-line along with --dtb Daniel Mack
@ 2012-12-14 9:20 ` Sven Neumann
2012-12-14 13:33 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Sven Neumann @ 2012-12-14 9:20 UTC (permalink / raw)
To: kexec; +Cc: matthew.leach, horms, Daniel Mack
Hi,
On Thu, 2012-12-13 at 14:35 +0100, Daniel Mack wrote:
> If --dtb is called together with --command-line, we need to modify the
> binary dtb buffer. Luckily, we have libfdt functions available, so this
> is straight forward.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>
Tested-by: Sven Neumann <s.neumann@raumfeld.com>
Works fine for us. Please include this upstream as we rely on this
functionality to be present.
Regards,
Sven
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kexec-zImage-arm: add code to support --command-line along with --dtb
2012-12-14 9:20 ` Sven Neumann
@ 2012-12-14 13:33 ` Simon Horman
0 siblings, 0 replies; 3+ messages in thread
From: Simon Horman @ 2012-12-14 13:33 UTC (permalink / raw)
To: Sven Neumann; +Cc: matthew.leach, kexec, Daniel Mack
On Fri, Dec 14, 2012 at 10:20:21AM +0100, Sven Neumann wrote:
> Hi,
>
> On Thu, 2012-12-13 at 14:35 +0100, Daniel Mack wrote:
> > If --dtb is called together with --command-line, we need to modify the
> > binary dtb buffer. Luckily, we have libfdt functions available, so this
> > is straight forward.
> >
> > Signed-off-by: Daniel Mack <zonque@gmail.com>
>
> Tested-by: Sven Neumann <s.neumann@raumfeld.com>
>
> Works fine for us. Please include this upstream as we rely on this
> functionality to be present.
Thanks, applied.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-14 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 13:35 [PATCH] kexec-zImage-arm: add code to support --command-line along with --dtb Daniel Mack
2012-12-14 9:20 ` Sven Neumann
2012-12-14 13:33 ` Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.