[LinuxBIOS] selection of compression algorithm

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Tue May 23 04:43:30 CEST 2006


Ronald G Minnich wrote:
> Carl-Daniel Hailfinger wrote:
>> yhlu wrote:
>>
>>> then how about the lines for 7z uncompress code?
>>>
>>> YH
>>
>> Working on it. 7z decompressor is really small (8 kb compiled on
>> i386) and written in ISO C (1884 lines of code), but compressor is
>> big and written in C++.
>>
>> Does it still make sense to try to use 7z?
> 
> yes, this is the perfect tradeoff. Highly complex, compute-intensive 
> compressor and simple, small decompressor. Exactly what we want.

I managed to trim this down further.
4 kb compiled code on i386, 497 lines of C code.

>> How much RAM is the decompressor allowed to use?
> 
> for the romcc section, you have about 6 32-bit words (or so). for the 
> gcc section, you have all of memory more or less.

OK, then we can call lzma decompressor only from the gcc section.
It needs to allocate some scratch space (between 5228 and 6295148 bytes,
default value is 15980 bytes) besides src and dst. The size of the
scratch space can be determined at compile time, so we can create
compressed images which only need 5228 bytes scratch space.
What is the best way to handle this? Dynamic allocation or fixed buffer?

Size comparison for OLPC target and small kernel:
843910 vmlinux.bin
437684 vmlinux.bin.nrv2b
377334 vmlinux.bin.lzma.smallscratchspace
373445 vmlinux.bin.lzma.default
 46832 linuxbios_ram.bin
 23923 linuxbios_ram.bin.nrv2b
 21829 linuxbios_ram.bin.lzma.smallscratchspace
 21738 linuxbios_ram.bin.lzma.default

The .lzma.smallscratchspace needs 5228 bytes scratch space,
the .lzma.default needs 15980 bytes scratch space.

lzma decompression can be called the same way as nrv2b decompression:
static unsigned long unlzma(unsigned char * src, unsigned char * dst);

Patch is attached. Please note that this patch doesn't change anything,
it only adds infrastructure. If you want a patch that builds most
targets (especially OLPC) with lzma, just ask. I have it sitting on
my hard drive.

To use lzma compression, download the LZMA SDK.

curl -O http://switch.dl.sourceforge.net/sourceforge/sevenzip/lzma442.tar.bz2
mkdir lzma442
cd lzma442
tar xfj ../lzma442.tar.bz2
cd C/7zip/Compress/LZMA_Alone/
make -f makefile.gcc
cp -a lzma /usr/local/bin/

Regards,
Carl-Daniel
-- 
http://www.hailfinger.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: linuxbios_lzma.diff
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20060523/0445b197/attachment.ksh>


More information about the coreboot mailing list