summaryrefslogtreecommitdiffstats
path: root/common/startup.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-12-31 16:11:12 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-01-02 11:47:49 +0100
commit26927bafde8b1757a42ed3425cc8804207f85318 (patch)
treef033c1ff7ea3f4ddc66e1780fc096fded1598507 /common/startup.c
parentb74f8dd81df40abc67200c33073a404c496b4626 (diff)
downloadbarebox-26927bafde8b1757a42ed3425cc8804207f85318.tar.gz
barebox-26927bafde8b1757a42ed3425cc8804207f85318.tar.xz
defaultenv: use a compressed version when embedded in barebox
enable it only if a compression is enabled support gzip, bzip2 and lzo you will be able to choose which compression to use -rw-r--r-- 1 root root 8436 Dec 15 01:35 barebox_default_env -rw-r--r-- 1 root root 2782 Dec 15 01:35 barebox_default_env.bz2 -rw-r--r-- 1 root root 2691 Dec 15 01:38 barebox_default_env.gz -rw-r--r-- 1 root root 3262 Dec 15 01:38 barebox_default_env.lzo with using gzip and the default env we can save 5.6KiB (5,745 bytes) with using bzip2 and the default env we can save 5.5KiB (5,654 bytes) with using lzo and the default env we can save 5.1KiB (5,174 bytes) Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/startup.c')
-rw-r--r--common/startup.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/common/startup.c b/common/startup.c
index 13783fb27a..180fdc3599 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -64,10 +64,35 @@ static void display_meminfo(void)
#ifdef CONFIG_DEFAULT_ENVIRONMENT
#include <generated/barebox_default_env.h>
+#ifdef CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED
+#include <uncompress.h>
+void *defaultenv;
+#else
+#define defaultenv default_environment
+#endif
+
static int register_default_env(void)
{
- add_mem_device("defaultenv", (unsigned long)default_environment,
- sizeof(default_environment),
+#ifdef CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED
+ int ret;
+ void *tmp;
+
+ tmp = xzalloc(default_environment_size);
+ memcpy(tmp, default_environment, default_environment_size);
+
+ defaultenv = xzalloc(default_environment_uncompress_size);
+
+ ret = uncompress(tmp, default_environment_size, NULL, NULL,
+ defaultenv, NULL, uncompress_err_stdout);
+
+ free(tmp);
+
+ if (ret)
+ return ret;
+#endif
+
+ add_mem_device("defaultenv", (unsigned long)defaultenv,
+ default_environment_uncompress_size,
IORESOURCE_MEM_WRITEABLE);
return 0;
}