summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-02-18 10:25:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-02-28 08:14:14 +0100
commit7fa10256c3f4b38f9ca899c5367584380c017bea (patch)
treed1c5654947c4d8305d66646aa35656c8611bd16d /common
parentb850dbad6557c4cd0e03c9b83be88579412cdd3f (diff)
downloadbarebox-7fa10256c3f4b38f9ca899c5367584380c017bea.tar.gz
barebox-7fa10256c3f4b38f9ca899c5367584380c017bea.tar.xz
defaultenv: Allow multiple defaultenvironment overlays
We can compile barebox for multiple boards at once, but currently they all share a single default environment. This patch adds a defaultenv_append() which boards can call to customize the default environment during runtime. Each board now generate default environment snippets using bbenv-y and add them during runtime with defaultenv_append() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig6
-rw-r--r--common/Makefile39
-rw-r--r--common/environment.c2
-rw-r--r--common/startup.c35
4 files changed, 8 insertions, 74 deletions
diff --git a/common/Kconfig b/common/Kconfig
index d6cda8c0c9..d862c05831 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -587,6 +587,12 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
select CMD_BOOT
prompt "Generic environment template"
+config DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU
+ bool
+ depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
+ depends on CONFIG_CMD_MENU_MANAGEMENT
+ default y
+
config DEFAULT_ENVIRONMENT_GENERIC
bool
depends on !HAVE_DEFAULT_ENVIRONMENT_NEW
diff --git a/common/Makefile b/common/Makefile
index 9c68f7b466..667c7b36ba 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,7 +7,6 @@ obj-y += misc.o
obj-y += memsize.o
obj-y += resource.o
obj-y += bootsource.o
-extra-y += barebox_default_env barebox_default_env.h
obj-$(CONFIG_AUTO_COMPLETE) += complete.o
obj-$(CONFIG_BANNER) += version.o
obj-$(CONFIG_BAREBOX_UPDATE) += bbu.o
@@ -45,44 +44,6 @@ obj-$(CONFIG_SHELL_HUSH) += hush.o
obj-$(CONFIG_SHELL_SIMPLE) += parser.o
obj-$(CONFIG_UIMAGE) += image.o uimage.o
-
-ifdef CONFIG_DEFAULT_ENVIRONMENT
-$(obj)/startup.o: $(obj)/barebox_default_env.h
-$(obj)/env.o: $(obj)/barebox_default_env.h
-
-ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW),y)
-DEFAULT_ENVIRONMENT_PATH = "defaultenv/defaultenv-2-base"
-ifeq ($(CONFIG_CMD_MENU_MANAGEMENT),y)
-DEFAULT_ENVIRONMENT_PATH += "defaultenv/defaultenv-2-menu"
-endif
-endif
-
-ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_GENERIC),y)
-DEFAULT_ENVIRONMENT_PATH = "defaultenv/defaultenv-1"
-endif
-
-ifneq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
-DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
-endif
-
-endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
-
-#
-# Generate a barebox envfs image.
-#
-quiet_cmd_envs = ENV $@
-cmd_envs = ($(srctree)/scripts/genenv $(srctree) $(objtree) $@ $(DEFAULT_ENVIRONMENT_PATH))
-
-$(obj)/barebox_default_env: FORCE
- $(call cmd,envs)
-
-quiet_cmd_env_h = ENVH $@
-cmd_env_h = cat $< | (cd $(obj) && $(objtree)/scripts/bin2c "__aligned(4) default_environment") > $@; \
- echo "static const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
-
-$(obj)/barebox_default_env.h: $(obj)/barebox_default_env$(DEFAULT_COMPRESSION_SUFFIX) FORCE
- $(call if_changed,env_h)
-
quiet_cmd_pwd_h = PWDH $@
ifdef CONFIG_PASSWORD
ifneq ($(CONFIG_PASSWORD_DEFAULT),"")
diff --git a/common/environment.c b/common/environment.c
index 19fb0273b3..776fa3ad38 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -240,7 +240,7 @@ static int envfs_check_super(struct envfs_super *super, size_t *size)
return 0;
}
-static int envfs_check_data(struct envfs_super *super, void *buf, size_t size)
+static int envfs_check_data(struct envfs_super *super, const void *buf, size_t size)
{
uint32_t crc;
diff --git a/common/startup.c b/common/startup.c
index 6847b61b46..9c4e995a5e 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -44,39 +44,6 @@
extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
__barebox_initcalls_end[];
-#ifdef CONFIG_DEFAULT_ENVIRONMENT
-#include "barebox_default_env.h"
-
-static int register_default_env(void)
-{
- int ret;
- void *defaultenv;
-
- if (!IS_ENABLED(CONFIG_DEFAULT_COMPRESSION_NONE)) {
-
- defaultenv = xzalloc(default_environment_uncompress_size);
-
- ret = uncompress(default_environment, default_environment_size,
- NULL, NULL,
- defaultenv, NULL, uncompress_err_stdout);
- if (ret) {
- free(defaultenv);
- return ret;
- }
- } else {
- defaultenv = (void *)default_environment;
- }
-
-
- add_mem_device("defaultenv", (unsigned long)defaultenv,
- default_environment_uncompress_size,
- IORESOURCE_MEM_WRITEABLE);
- return 0;
-}
-
-device_initcall(register_default_env);
-#endif
-
#if defined CONFIG_FS_RAMFS && defined CONFIG_FS_DEVFS
static int mount_root(void)
{
@@ -120,7 +87,7 @@ void __noreturn start_barebox(void)
pr_err("no valid environment found on %s. "
"Using default environment\n",
default_environment_path);
- envfs_load("/dev/defaultenv", "/env", 0);
+ defaultenv_load("/env", 0);
}
}