diff options
author | Yinghai Lu <yinghailu@gmail.com> | 2006-05-04 00:47:15 +0000 |
---|---|---|
committer | Yinghai Lu <yinghailu@gmail.com> | 2006-05-04 00:47:15 +0000 |
commit | 608d4b2c444515784a0ee54e018bb8a68456eb4a (patch) | |
tree | 47ca84cad4dbc1f6a5d266e9eaf4ecff3da5b58f | |
parent | 4c475321341e16250cdc7b6eb1183e1a3cf62c74 (diff) | |
download | coreboot-608d4b2c444515784a0ee54e018bb8a68456eb4a.tar.xz |
merge zrom to rom_stream and print olen ilen
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2292 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r-- | src/cpu/amd/car/cache_as_ram_post.c | 0 | ||||
-rw-r--r-- | src/cpu/amd/car/copy_and_run.c | 25 | ||||
-rw-r--r-- | src/lib/nrv2b.c | 34 | ||||
-rw-r--r-- | src/stream/Config.lb | 5 | ||||
-rw-r--r-- | src/stream/rom_stream.c | 55 | ||||
-rw-r--r-- | src/stream/zrom_stream.c | 84 |
6 files changed, 89 insertions, 114 deletions
diff --git a/src/cpu/amd/car/cache_as_ram_post.c b/src/cpu/amd/car/cache_as_ram_post.c deleted file mode 100644 index e69de29bb2..0000000000 --- a/src/cpu/amd/car/cache_as_ram_post.c +++ /dev/null diff --git a/src/cpu/amd/car/copy_and_run.c b/src/cpu/amd/car/copy_and_run.c index 341c66e910..b81297c149 100644 --- a/src/cpu/amd/car/copy_and_run.c +++ b/src/cpu/amd/car/copy_and_run.c @@ -3,10 +3,6 @@ 2006/05/02 - stepan: move nrv2b to an extra file. */ -#if CONFIG_COMPRESS -#include "lib/nrv2b.c" -#endif - static inline void print_debug_cp_run(const char *strval, uint32_t val) { #if CONFIG_USE_INIT @@ -16,12 +12,17 @@ static inline void print_debug_cp_run(const char *strval, uint32_t val) #endif } +#if CONFIG_COMPRESS +#define ENDIAN 0 +#define BITSIZE 32 +#include "lib/nrv2b.c" +#endif + + static void copy_and_run(void) { uint8_t *src, *dst; - unsigned long ilen = 0, olen = 0, last_m_off = 1; - uint32_t bb = 0; - unsigned bc = 0; + unsigned long ilen, olen; print_debug("Copying LinuxBIOS to ram.\r\n"); @@ -37,18 +38,20 @@ static void copy_and_run(void) #else __asm__ volatile ( - "leal _liseg, %0\n\t" - "leal _iseg, %1\n\t" + "leal _liseg, %0\n\t" + "leal _iseg, %1\n\t" : "=a" (src) , "=b" (dst) ); print_debug_cp_run("src=",(uint32_t)src); print_debug_cp_run("dst=",(uint32_t)dst); - unrv2b(src, dst); + olen = unrv2b(src, dst, &ilen); + print_debug_cp_run("linxbios_ram.nrv2b length = ", ilen); + #endif - print_debug_cp_run("linxbios_ram.bin length = ", olen); + print_debug_cp_run("linxbios_ram.bin length = ", olen); print_debug("Jumping to LinuxBIOS.\r\n"); diff --git a/src/lib/nrv2b.c b/src/lib/nrv2b.c index f912347e3a..e9d6ebf8b0 100644 --- a/src/lib/nrv2b.c +++ b/src/lib/nrv2b.c @@ -1,16 +1,35 @@ -#include <stdlib.h> -#include <stddef.h> - // This GETBIT is supposed to work on little endian // 32bit systems. The algorithm will definitely need // some fixing on other systems, but it might not be // a problem since the nrv2b binary behaves the same.. -#define GETBIT(bb, src, ilen) \ +#ifndef ENDIAN +#define ENDIAN 0 +#endif +#ifndef BITSIZE +#define BITSIZE 32 +#endif + +#define GETBIT_8(bb, src, ilen) \ + (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) + +#define GETBIT_LE16(bb, src, ilen) \ + (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1)) +#define GETBIT_LE32(bb, src, ilen) \ (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\ bb=*(const uint32_t *)((src)+ilen),ilen+=4,(bb>>31)&1)) -static void unrv2b(uint8_t * src, uint8_t * dst) +#if ENDIAN == 0 && BITSIZE == 8 +#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 16 +#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 32 +#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen) +#endif + +static unsigned long unrv2b(uint8_t * src, uint8_t * dst, unsigned long *ilen_p) { unsigned long ilen = 0, olen = 0, last_m_off = 1; uint32_t bb = 0; @@ -20,6 +39,7 @@ static void unrv2b(uint8_t * src, uint8_t * dst) // skip length src += 4; + /* FIXME: check olen with len on first 4 bytes */ for (;;) { unsigned int m_off, m_len; while (GETBIT(bb, src, ilen)) { @@ -57,5 +77,9 @@ static void unrv2b(uint8_t * src, uint8_t * dst) } while (--m_len > 0); } + *ilen_p = ilen; + + return olen; + } diff --git a/src/stream/Config.lb b/src/stream/Config.lb index 46c2dc7f08..b146c0451e 100644 --- a/src/stream/Config.lb +++ b/src/stream/Config.lb @@ -1,4 +1,3 @@ -uses CONFIG_COMPRESSED_ROM_STREAM uses CONFIG_ROM_STREAM uses CONFIG_IDE_STREAM uses CONFIG_FS_STREAM @@ -8,10 +7,6 @@ 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 1127be0b8a..f62f13d2f1 100644 --- a/src/stream/rom_stream.c +++ b/src/stream/rom_stream.c @@ -4,33 +4,70 @@ #include <stream/read_bytes.h> #include <string.h> +#if CONFIG_COMPRESSED_ROM_STREAM +// include generic nrv2b +#include "../lib/nrv2b.c" +extern unsigned char _heap, _eheap; +#endif #ifndef CONFIG_ROM_STREAM_START #define CONFIG_ROM_STREAM_START 0xffff0000UL #endif -/* well, this is a mess, and it will get fixed, but not right away. - * until we stop using 'ld' for building the rom image, that is. - * problem is, that on the sc520, ROM_STREAM_START has to be at 0x2000000. - * but if you set CONFIG_ROM_STREAM_START to that, then ld will try to - * build a giant image: 0x0-0x2000000, i.e. almost 4 GB. - * so make this non-static, non-const for now. +/* well, this is a mess, and it will get fixed, but not right away. + * until we stop using 'ld' for building the rom image, that is. + * problem is, that on the sc520, ROM_STREAM_START has to be at 0x2000000. + * but if you set CONFIG_ROM_STREAM_START to that, then ld will try to + * build a giant image: 0x0-0x2000000, i.e. almost 4 GB. + * so make this non-static, non-const for now. */ /*XXXXXXXXXXXXXX */ /*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 */ + +unsigned char *rom_start = (void *)CONFIG_ROM_STREAM_START; +unsigned char *rom_end = (void *)(CONFIG_ROM_STREAM_START + PAYLOAD_SIZE - 1); static const unsigned char *rom; int stream_init(void) { - rom = rom_start; +#if CONFIG_COMPRESSED_ROM_STREAM + unsigned long dest; + unsigned long ilen; + unsigned long olen; +#endif - printk_debug("%6d:%s() - rom_stream: 0x%08lx - 0x%08lx\n", - __LINE__, __FUNCTION__, + printk_debug("rom_stream: 0x%08lx - 0x%08lx\n", (unsigned long)rom_start, (unsigned long)rom_end); + +#if CONFIG_COMPRESSED_ROM_STREAM + + dest = &_eheap; /* need a good address on RAM */ + +#if _RAMBASE<0x00100000 + olen = *(unsigned int *)dest; +#if (CONFIG_CONSOLE_VGA==1) || (CONFIG_PCI_ROM_RUN == 1) + if((dest < 0xa0000) && ((dest+olen)>0xa0000)) { + dest = (CONFIG_LB_MEM_TOPK<<10); + } +#endif + if((dest < 0xf0000) && ((dest+olen)>0xf0000)) { //linuxbios tables etc + dest = (CONFIG_LB_MEM_TOPK<<10); + } +#endif + + printk_debug("Uncompressing to RAM 0x%08lx ", dest); + olen = unrv2b((uint8_t *) rom_start, (uint8_t *)dest, &ilen ); + printk_debug(" ilen = 0x%08lx olen = 0x%08lx done.\n", ilen, olen); + rom_end = dest + olen - 1; + rom = dest; +#else + rom = rom_start; +#endif + return 0; } diff --git a/src/stream/zrom_stream.c b/src/stream/zrom_stream.c deleted file mode 100644 index 39da619a04..0000000000 --- a/src/stream/zrom_stream.c +++ /dev/null @@ -1,84 +0,0 @@ -#include <console/console.h> -#include <stdlib.h> -#include <stddef.h> -#include <stream/read_bytes.h> -#include <string.h> - -// 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; -} |