diff options
author | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-09-13 15:22:23 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-09-13 15:22:23 +0200 |
commit | 6634cfe849b547b35e50e73b0a142a294cd39a80 (patch) | |
tree | 291c1fca6a32b35654c8358689e53d1458da7bdc | |
parent | 46f6648adbbad796e459acf9f3cb8a53b7408584 (diff) | |
download | barebox-6634cfe849b547b35e50e73b0a142a294cd39a80.tar.gz barebox-6634cfe849b547b35e50e73b0a142a294cd39a80.tar.xz |
add default environment
-rw-r--r-- | common/Kconfig | 16 | ||||
-rw-r--r-- | common/Makefile | 9 | ||||
-rw-r--r-- | common/startup.c | 34 |
3 files changed, 56 insertions, 3 deletions
diff --git a/common/Kconfig b/common/Kconfig index 05b8d47fe6..7672ebffff 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -126,6 +126,22 @@ config OF_FLAT_TREE bool prompt "Open Firmware flat device tree support" +config DEFAULT_ENVIRONMENT + bool + default y + prompt "Compile in default environment" + help + Enabling this option will give you a default environment when + the environment found in the environment sector is invalid + +config DEFAULT_ENVIRONMENT_PATH + string + depends on DEFAULT_ENVIRONMENT + prompt "Default environment path" + help + The path the default environment will be taken from. Relative + pathes will be relative to the U-Boot Toplevel dir, but absolute + pathes are fine aswell. endmenu menu "Debugging " diff --git a/common/Makefile b/common/Makefile index df1ccdd0f1..b83c437f03 100644 --- a/common/Makefile +++ b/common/Makefile @@ -13,3 +13,12 @@ obj-y += env.o obj-y += startup.o obj-y += misc.o obj-y += memsize.o + +ifdef CONFIG_DEFAULT_ENVIRONMENT_PATH +include/uboot_default_env.h: $(shell ls $(CONFIG_DEFAULT_ENVIRONMENT_PATH)/*) + $(Q)scripts/ubootenv -s $(CONFIG_DEFAULT_ENVIRONMENT_PATH) uboot_default_env + $(Q)cat uboot_default_env | scripts/bin2c default_environment > $@ + +$(obj)/env.o: include/uboot_default_env.h +endif + diff --git a/common/startup.c b/common/startup.c index 68753bdc1b..643077343e 100644 --- a/common/startup.c +++ b/common/startup.c @@ -34,6 +34,7 @@ #include <debug_ll.h> #include <fs.h> #include <linux/stat.h> +#include <environment.h> #include <reloc.h> #ifndef CONFIG_IDENT_STRING @@ -74,6 +75,26 @@ void early_init (void) #endif /* CONFIG_HAS_EARLY_INIT */ +#ifdef CONFIG_DEFAULT_ENVIRONMENT +#include <uboot_default_env.h> + +static struct device_d default_env_dev = { + .name = "rom", + .id = "defaultenv", +}; + +static void register_default_env(void) +{ + default_env_dev.map_base = (unsigned long)default_environment; + default_env_dev.size = sizeof(default_environment); + register_device(&default_env_dev); +} +#else +static void register_default_env(void) +{ +} +#endif + void start_uboot (void) { initcall_t *initcall; @@ -102,11 +123,19 @@ void start_uboot (void) display_banner(); #endif + register_default_env(); + mount("none", "ramfs", "/"); mkdir("/dev"); mkdir("/env"); mount("none", "devfs", "/dev"); - run_command("loadenv", 0); + + if (envfs_load("/dev/env0", "/env")) { +#ifdef CONFIG_DEFAULT_ENVIRONMENT + printf("using default environment\n"); + envfs_load("/dev/defaultenv", "/env"); +#endif + } if (!stat("/env/init", &s)) { printf("running /env/init\n"); @@ -114,9 +143,8 @@ void start_uboot (void) } /* main_loop() can return to retry autoboot, if so just run it again. */ - for (;;) { + for (;;) main_loop (); - } /* NOTREACHED - no way out of command loop except booting */ } |