9
0
Fork 0

add default environment

This commit is contained in:
Sascha Hauer 2007-09-13 15:22:23 +02:00
parent 46f6648adb
commit 6634cfe849
3 changed files with 56 additions and 3 deletions

View File

@ -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 "

View File

@ -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

View File

@ -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 */
}