diff options
author | Eric Biederman <ebiederm@xmission.com> | 2003-04-22 19:02:15 +0000 |
---|---|---|
committer | Eric Biederman <ebiederm@xmission.com> | 2003-04-22 19:02:15 +0000 |
commit | 8ca8d7665d671e10d72b8fcb4d69121d75f7906e (patch) | |
tree | daad2699b4e6b6014bce5a76e82dd9c974801777 /src/stream | |
parent | b138ac83b53da9abf3dc9a87a1cd4b3d3a8150bd (diff) | |
download | coreboot-8ca8d7665d671e10d72b8fcb4d69121d75f7906e.tar.xz |
- Initial checkin of the freebios2 tree
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@784 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/stream')
-rw-r--r-- | src/stream/rom_stream.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/stream/rom_stream.c b/src/stream/rom_stream.c new file mode 100644 index 0000000000..20b7686c84 --- /dev/null +++ b/src/stream/rom_stream.c @@ -0,0 +1,58 @@ +#include <console/console.h> +#include <stdlib.h> +#include <stddef.h> +#include <stream/read_bytes.h> +#include <string.h> + + +#ifndef CONFIG_ROM_STREAM_START +#define CONFIG_ROM_STREAM_START 0xffff0000UL +#endif + +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; + +int stream_init(void) +{ + rom = rom_start; + + printk_spew("%6d:%s() - rom_stream: 0x%08lx - 0x%08lx\n" + __LINE__, __FUNCTION__, + (unsigned long)rom_start, + (unsigned long)rom_end); + 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("%6d:%s() - overflowed source buffer\n", + __LINE__, __FUNCTION__); + 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; +} |