[U-Boot-Users] [PATCH] fdt: add fdtcmd env var to allow post processing of device tree before boot

Kumar Gala galak at kernel.crashing.org
Mon Aug 4 20:46:57 CEST 2008


Added the 'fdtcmd' environment variable as a way to provide 'fdt' commands
that the user can supply to manipulate the device tree after ft_board_setup()
and before the tree is handled to the kernel.

The idea is that users may want to add or manipulate nodes w/changing the u-boot
binary.  The current point in the code we do this we have yet to determine the
final size and have yet to do the final fixup of the initrd information.

If its desirable for the 'fdtcmd' support to have the proper initrd information
a bit of code reorder will be in order.

Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---
 common/fdt_support.c  |   21 +++++++++++++++++++++
 include/fdt_support.h |    1 +
 lib_ppc/bootm.c       |    1 +
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 93b144e..b1aa7df 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -30,6 +30,10 @@
 #include <fdt_support.h>
 #include <exports.h>

+#ifdef CFG_HUSH_PARSER
+#include <hush.h>
+#endif
+
 /*
  * Global data (for the gd->bd)
  */
@@ -529,3 +533,20 @@ void fdt_fixup_crypto_node(void *blob, int sec_rev)
 		       fdt_strerror(err));
 }
 #endif /* defined(CONFIG_MPC83XX) || defined(CONFIG_MPC85xx) */
+
+int ft_env_setup(void *blob, bd_t *bd)
+{
+	int rcode = 0;
+
+	working_fdt = blob;
+
+#ifndef CFG_HUSH_PARSER
+	if (run_command (getenv ("fdtcmd"), 0) < 0)
+		rcode = 1;
+#else
+	if (parse_string_outer (getenv ("fdtcmd"),
+			FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
+		rcode = 1;
+#endif
+	return rcode;
+}
diff --git a/include/fdt_support.h b/include/fdt_support.h
index a7c6326..a60b5f0 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -67,6 +67,7 @@ void ft_board_setup(void *blob, bd_t *bd);
 void ft_cpu_setup(void *blob, bd_t *bd);
 void ft_pci_setup(void *blob, bd_t *bd);
 #endif
+int ft_env_setup(void *blob, bd_t *bd);

 #endif /* ifdef CONFIG_OF_LIBFDT */
 #endif /* ifndef __FDT_SUPPORT_H */
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index a872d31..d7a1236 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -194,6 +194,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		/* Call the board-specific fixup routine */
 		ft_board_setup(of_flat_tree, gd->bd);
 #endif
+		ft_env_setup(of_flat_tree, gd->bd);
 	}

 	/* Fixup the fdt memreserve now that we know how big it is */
-- 
1.5.5.1





More information about the U-Boot mailing list