mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
small nrv2b regression fix from Patrick
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@419 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
25ebd9110b
commit
405edb8e80
2 changed files with 40 additions and 36 deletions
|
@ -25,7 +25,7 @@ $(obj)/util/nrv2b/nrv2b: nrv2bdir $(src)/util/nrv2b/nrv2b.c
|
|||
|
||||
$(obj)/util/nrv2b/nrv2b-compress.o: nrv2bdir $(src)/util/nrv2b/nrv2b.c
|
||||
$(Q)printf " HOSTCC $(subst $(shell pwd)/,,$(@))\n"
|
||||
$(Q)$(HOSTCC) $(HOSTCFLAGS) -DENCODE -DVERBOSE -DCOMPACT -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -c -o $@ $(src)/util/nrv2b/nrv2b.c
|
||||
$(Q)$(HOSTCC) $(HOSTCFLAGS) -DENCODE -DDECODE -DVERBOSE -DCOMPACT -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -c -o $@ $(src)/util/nrv2b/nrv2b.c
|
||||
|
||||
nrv2bdir:
|
||||
$(Q)printf " BUILD NRV2B\n"
|
||||
|
|
|
@ -1309,9 +1309,47 @@ void do_nrv2b_compress(char* in, unsigned long in_len, char* out, unsigned long*
|
|||
out = malloc(*out_len);
|
||||
ucl_nrv2b_99_compress(in, in_len, out, out_len, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE
|
||||
|
||||
#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)
|
||||
#endif
|
||||
|
||||
#ifndef GETBIT
|
||||
#error "Bad Combination of ENDIAN and BITSIZE values specified"
|
||||
#endif
|
||||
|
||||
#undef SAFE
|
||||
|
||||
#ifdef SAFE
|
||||
#define FAIL(x,r) if (x) { Error(r); }
|
||||
#else
|
||||
#define FAIL(x,r)
|
||||
#endif
|
||||
|
||||
#ifdef COMPACT
|
||||
void do_nrv2b_uncompress(char* dst, char* src, unsigned long len) {
|
||||
unsigned long ilen = 0, olen = 0, last_m_off = 1;
|
||||
uint32_t bb = 0;
|
||||
unsigned bc = 0;
|
||||
for (;;) {
|
||||
unsigned int m_off, m_len;
|
||||
while (GETBIT(bb, src, ilen)) {
|
||||
|
@ -1359,42 +1397,7 @@ void do_nrv2b_uncompress(char* dst, char* src, unsigned long len) {
|
|||
}
|
||||
FAIL(ilen < src_len, "input not consumed");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE
|
||||
|
||||
#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)
|
||||
#endif
|
||||
|
||||
#ifndef GETBIT
|
||||
#error "Bad Combination of ENDIAN and BITSIZE values specified"
|
||||
#endif
|
||||
|
||||
#undef SAFE
|
||||
|
||||
#ifdef SAFE
|
||||
#define FAIL(x,r) if (x) { Error(r); }
|
||||
#else
|
||||
#define FAIL(x,r)
|
||||
#endif
|
||||
|
||||
void Decode(void) /* recover */
|
||||
{
|
||||
uint32_t tw;
|
||||
|
@ -1494,6 +1497,7 @@ void Decode(void) /* recover */
|
|||
free(dst);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MAIN
|
||||
int main(int argc, char *argv[])
|
||||
|
|
Loading…
Add table
Reference in a new issue