From ead73689db79fecc3e17215d100ab52ce4377657 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Tue, 2 May 2006 12:05:13 +0000 Subject: add automatic payload compression method to LinuxBIOS git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2288 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/stream/Config.lb | 5 +++ src/stream/rom_stream.c | 4 +-- src/stream/zrom_stream.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/stream/zrom_stream.c (limited to 'src/stream') diff --git a/src/stream/Config.lb b/src/stream/Config.lb index b146c0451e..46c2dc7f08 100644 --- a/src/stream/Config.lb +++ b/src/stream/Config.lb @@ -1,3 +1,4 @@ +uses CONFIG_COMPRESSED_ROM_STREAM uses CONFIG_ROM_STREAM uses CONFIG_IDE_STREAM uses CONFIG_FS_STREAM @@ -7,6 +8,10 @@ if CONFIG_ROM_STREAM object rom_stream.o end +if CONFIG_COMPRESSED_ROM_STREAM + object zrom_stream.o +end + if CONFIG_IDE_STREAM default CONFIG_IDE=1 object ide_stream.o diff --git a/src/stream/rom_stream.c b/src/stream/rom_stream.c index 7a662d019e..1127be0b8a 100644 --- a/src/stream/rom_stream.c +++ b/src/stream/rom_stream.c @@ -18,8 +18,8 @@ */ /*XXXXXXXXXXXXXX */ -/*static const */unsigned char *rom_start = (void *)CONFIG_ROM_STREAM_START; -/*static const */unsigned char *rom_end = (void *)(CONFIG_ROM_STREAM_START + PAYLOAD_SIZE - 1); +/*static const */unsigned char *rom_start = (unsigned char *)CONFIG_ROM_STREAM_START; +/*static const */unsigned char *rom_end = (unsigned char *)(CONFIG_ROM_STREAM_START + PAYLOAD_SIZE - 1); /*XXXXXXXXXXXXXX */ static const unsigned char *rom; diff --git a/src/stream/zrom_stream.c b/src/stream/zrom_stream.c new file mode 100644 index 0000000000..39da619a04 --- /dev/null +++ b/src/stream/zrom_stream.c @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include + +// include generic nrv2b +#include "../lib/nrv2b.c" + +#ifndef CONFIG_ROM_STREAM_START +#define CONFIG_ROM_STREAM_START 0xffff0000UL +#endif + +unsigned char *rom_start = (unsigned char *)CONFIG_ROM_STREAM_START; +unsigned char *rom_end = (unsigned char *)(CONFIG_ROM_STREAM_START + PAYLOAD_SIZE - 1);; + +extern unsigned char _heap, _eheap; + +static const unsigned char *rom; + +int stream_init(void) +{ + unsigned long compressed_rom_start=rom_start; + unsigned long compressed_rom_end=rom_end; + unsigned int len; + + len=*(unsigned int *)compressed_rom_start; // LE only for now + + printk_debug (" compressed rom stream: 0x%08lx - 0x%08lx\n", + compressed_rom_start, compressed_rom_end); + + rom_start = &_eheap; + rom_end = rom_start + len; // LE only for now +#if 0 + { + int i; + for (i=0; i<512; i++) { + if( i%16==0) printk_spew("\n%04x :", i); + printk_spew(" %02x", *(unsigned char *)(compressed_rom_start+i)); + } + } +#endif + printk_debug(" rom stream: 0x%08lx - 0x%08lx\n", (unsigned long) + rom_start, (unsigned long) rom_end); + + printk_debug("Uncompressing..."); + unrv2b((uint8_t *) compressed_rom_start, (uint8_t *)rom_start); + printk_debug(" done.\n"); + + rom = rom_start; + + return 0; +} + +void stream_fini(void) +{ + return; +} + +byte_offset_t stream_skip(byte_offset_t count) +{ + byte_offset_t bytes; + bytes = count; + if ((rom + bytes) > rom_end) { + printk_warning(" overflowed source buffer\n"); + bytes = 0; + if (rom <= rom_end) { + bytes = (rom_end - rom) + 1; + } + } + rom += bytes; + return bytes; +} + +byte_offset_t stream_read(void *vdest, byte_offset_t count) +{ + unsigned char *dest = vdest; + const unsigned char *src = rom; + byte_offset_t bytes; + + bytes = stream_skip(count); + memcpy(dest, src, bytes); + return bytes; +} -- cgit v1.2.3