aboutsummaryrefslogtreecommitdiff
path: root/src/stream/rom_stream.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <Carl-Daniel Hailfinger>2006-09-14 15:12:36 +0000
committerRonald G. Minnich <rminnich@gmail.com>2006-09-14 15:12:36 +0000
commitcba07dd682f0142474f0aa235e97b6fcbc34d760 (patch)
treef825a9550774d81ebf92ca5ed7fd1d29c30eba2d /src/stream/rom_stream.c
parent7d9441276f144f0ffc5fe1523daaa63f916b9a25 (diff)
additions and mods for lzma.
Signed-off-by: Carl-Daniel Hailfinger Signed-off-by: Ronald G. Minnich git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2413 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/stream/rom_stream.c')
-rw-r--r--src/stream/rom_stream.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/stream/rom_stream.c b/src/stream/rom_stream.c
index ef8df9f394..711aa1f58d 100644
--- a/src/stream/rom_stream.c
+++ b/src/stream/rom_stream.c
@@ -4,10 +4,30 @@
#include <stream/read_bytes.h>
#include <string.h>
-#if CONFIG_COMPRESSED_ROM_STREAM || CONFIG_PRECOMPRESSED_ROM_STREAM
+/* if they set the precompressed rom stream, they better have set a type */
+#if CONFIG_PRECOMPRESSED_ROM_STREAM && ((!CONFIG_COMPRESSED_ROM_STREAM) && (!CONFIG_COMPRESSED_ROM_STREAM_NRV2B) && (!CONFIG_COMPRESSED_ROM_STREAM_LZMA))
+#error "You set CONFIG_PRECOMPRESSED_ROM_STREAM but need to set CONFIG_COMPRESSED_ROM_STREAM (implies NRV2B, deprecated) or CONFIG_COMPRESSED_ROM_STREAM_NRV2B or CONFIG_COMPRESSED_ROM_STREAM_LZMA
+#endif
+
+/* If they set ANY of these, then we're compressed */
+#if ((CONFIG_COMPRESSED_ROM_STREAM) || (CONFIG_COMPRESSED_ROM_STREAM_NRV2B) || (CONFIG_COMPRESSED_ROM_STREAM_LZMA))
+#define UNCOMPRESSER 1
+extern unsigned char _heap, _eheap;
+#endif
+
+#if (CONFIG_COMPRESSED_ROM_STREAM) || (CONFIG_COMPRESSED_ROM_STREAM_NRV2B)
+#define HAVE_UNCOMPRESSER 1
// include generic nrv2b
#include "../lib/nrv2b.c"
-extern unsigned char _heap, _eheap;
+#endif
+
+#if (CONFIG_COMPRESSED_ROM_STREAM_LZMA)
+#if HAVE_UNCOMPRESSER
+#error "You're defining more than one compression type, which is not allowed (of course)"
+#endif
+#define HAVE_UNCOMPRESSER 1
+// include generic nrv2b
+#include "../lib/lzma.c"
#endif
#ifndef CONFIG_ROM_STREAM_START
@@ -29,9 +49,21 @@ extern unsigned char _heap, _eheap;
static const unsigned char *rom;
+#if UNCOMPRESSER
+unsigned long
+uncompress(uint8_t * rom_start, uint8_t *dest )
+{
+#if (CONFIG_COMPRESSED_ROM_STREAM) || (CONFIG_COMPRESSED_ROM_STREAM_NRV2B)
+ return unrv2b(rom_start, dest);
+#endif
+#if (CONFIG_COMPRESSED_ROM_STREAM_LZMA)
+ return ulzma(rom_start, dest);
+#endif
+}
+#endif
int stream_init(void)
{
-#if CONFIG_COMPRESSED_ROM_STREAM || CONFIG_PRECOMPRESSED_ROM_STREAM
+#if (UNCOMPRESSER)
unsigned char *dest;
unsigned long olen;
#endif
@@ -40,7 +72,7 @@ int stream_init(void)
(unsigned long)rom_start,
(unsigned long)rom_end);
-#if CONFIG_COMPRESSED_ROM_STREAM || CONFIG_PRECOMPRESSED_ROM_STREAM
+#if (UNCOMPRESSER)
dest = &_eheap; /* need a good address on RAM */
@@ -56,8 +88,13 @@ int stream_init(void)
}
#endif
+ /* ALL of those settings are too smart and also unsafe. Set the dest to 16 MB:
+ * known to be safe for LB for now, and mostly safe for all elf images we have tried.
+ * long term, this has got to be fixed.
+ */
+ dest = (unsigned char *) (16 * 1024 * 1024);
printk_debug("Uncompressing to RAM 0x%08lx ", dest);
- olen = unrv2b((uint8_t *) rom_start, (uint8_t *)dest );
+ olen = uncompress((uint8_t *) rom_start, (uint8_t *)dest );
printk_debug(" olen = 0x%08lx done.\n", olen);
rom_end = dest + olen - 1;
rom = dest;