From 7fa10256c3f4b38f9ca899c5367584380c017bea Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 18 Feb 2014 10:25:13 +0100 Subject: 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 --- include/envfs.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include/envfs.h') diff --git a/include/envfs.h b/include/envfs.h index b63683c043..ae98808ede 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -3,6 +3,7 @@ #ifdef __BAREBOX__ #include +#include #endif #define ENVFS_MAJOR 1 @@ -111,4 +112,34 @@ static inline char *default_environment_path_get(void) int envfs_register_partition(const char *devname, unsigned int partnr); +#ifdef CONFIG_DEFAULT_ENVIRONMENT +void defaultenv_append(void *buf, unsigned int size, const char *name); +int defaultenv_load(const char *dir, unsigned flags); +#else +static inline void defaultenv_append(void *buf, unsigned int size, const char *name) +{ +} + +static inline int defaultenv_load(const char *dir, unsigned flags) +{ + return -ENOSYS; +} +#endif + +/* + * Append environment directory compiled into barebox with bbenv-y + * to the default environment. The symbol is generated from the filename + * during the build process. Replace '-' with '_' to get the name + * from the filename. + */ +#define defaultenv_append_directory(name) \ + { \ + extern char __bbenv_##name##_start[]; \ + extern char __bbenv_##name##_end[]; \ + defaultenv_append(__bbenv_##name##_start, \ + __bbenv_##name##_end - \ + __bbenv_##name##_start, \ + __stringify(name)); \ + } + #endif /* _ENVFS_H */ -- cgit v1.2.3