diff options
author | Stefan Reinauer <stepan@openbios.org> | 2006-05-02 12:05:13 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2006-05-02 12:05:13 +0000 |
commit | ead73689db79fecc3e17215d100ab52ce4377657 (patch) | |
tree | f3decd3d843e222394b848805f0f88f74d153700 /src/cpu/x86 | |
parent | d3ba4aaa245b1af50f70443ba01ec0baf883995f (diff) |
add automatic payload compression method to LinuxBIOS
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2288 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/cpu/x86')
-rw-r--r-- | src/cpu/x86/car/copy_and_run.c | 69 |
1 files changed, 5 insertions, 64 deletions
diff --git a/src/cpu/x86/car/copy_and_run.c b/src/cpu/x86/car/copy_and_run.c index ae77e50956..4954e43841 100644 --- a/src/cpu/x86/car/copy_and_run.c +++ b/src/cpu/x86/car/copy_and_run.c @@ -1,31 +1,10 @@ /* by yhlu 6.2005 moved from nrv2v.c and some lines from crt0.S + 2006/05/02 - stepan: move nrv2b to an extra file. */ -#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)) - -#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) +#if CONFIG_COMPRESS +#include "lib/nrv2b.c" #endif static void copy_and_run(unsigned cpu_reset) @@ -65,46 +44,8 @@ static void copy_and_run(unsigned cpu_reset) // dump_mem(src, src+0x100); - for(;;) { - unsigned int m_off, m_len; - while(GETBIT(bb, src, ilen)) { - dst[olen++] = src[ilen++]; - } - m_off = 1; - do { - m_off = m_off*2 + GETBIT(bb, src, ilen); - } while (!GETBIT(bb, src, ilen)); - if (m_off == 2) - { - m_off = last_m_off; - } - else - { - m_off = (m_off - 3)*256 + src[ilen++]; - if(m_off == 0xffffffffU) - break; - last_m_off = ++m_off; - } - m_len = GETBIT(bb, src, ilen); - m_len = m_len*2 + GETBIT(bb, src, ilen); - if (m_len == 0) - { - m_len++; - do { - m_len = m_len*2 + GETBIT(bb, src, ilen); - } while(!GETBIT(bb, src, ilen)); - m_len += 2; - } - m_len += (m_off > 0xd00); - { - const uint8_t *m_pos; - m_pos = dst + olen - m_off; - dst[olen++] = *m_pos++; - do { - dst[olen++] = *m_pos++; - } while(--m_len > 0); - } - } + unrv2b(src, dst); + #endif // dump_mem(dst, dst+0x100); #if CONFIG_USE_INIT |