LZMA support in i386-pc kernel
Subsystems (2)
PATCH 1/1 LZMA support in i386-pc kernel
Hi,
This patch add support for lzma decompression. The assembly code lzma_decode.S is manually optimized to reduce size. The result decoder is tiny, only 416 bytes longer than the lzo version.
I also include lzma encode from the LZMA SDK. grub needs to use the ANSI-C version of encoder, which is only present in the latest 4.58 beta. I can't find ready to use shared library in most distro. Including the encoder/decoder has advantages as well. We don't need to worry about the host os, and lzma encoder/decoder can be used in other place, like font compression.
I use lzma as default, it's still possible to use the old lzo compression, you just need to add --enable-lzo option when running configure.
PS, here are some information about the lzma decoder:
properties: lc = 3 lp = 0 pb = 2
memory requirement for the decoder: 15980 bytes
Result of
./grub-mkimage -o core.img biosdisk pc ext2 lvm raid
lzma version: 27,776 bytes
lzo version: 32,768 bytes
Signature · 1 line
Bean
Makefile.in +1 -0
@@ -87,6 +87,7 @@ UNIFONT_HEX = @UNIFONT_HEX@ # Options. enable_grub_emu = @enable_grub_emu@ enable_grub_fstest = @enable_grub_fstest@ +enable_lzo = @enable_lzo@ ### General variables.
conf/i386-pc.rmk +6 -1
@@ -72,10 +72,15 @@ sbin_UTILITIES += grub-emu endif # For grub-mkimage. +ifeq ($(enable_lzo), yes) grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ util/resolve.c -grub_mkimage_CFLAGS = -DGRUB_MEMORY_MACHINE_LINK_ADDR=$(GRUB_MEMORY_MACHINE_LINK_ADDR) grub_mkimage_LDFLAGS = $(LIBLZO) +else +grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ + util/resolve.c lib/LzmaEnc.c lib/LzFind.c +endif +grub_mkimage_CFLAGS = -DGRUB_MEMORY_MACHINE_LINK_ADDR=$(GRUB_MEMORY_MACHINE_LINK_ADDR) util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile # For grub-setup.
config.h.in +3 -0
@@ -13,6 +13,9 @@ /* Define it to \"data32\" or \"data32;\" to make GAS happy */ #undef DATA32 +/* Use lzo compression */ +#undef ENABLE_LZO + /* Define it to either end or _end */ #undef END_SYMBOL
configure.ac +18 -11
@@ -143,19 +143,26 @@ fi # Check LZO when compiling for the i386-pc. if test "$target_cpu"-"$platform" = i386-pc; then - # There are three possibilities. LZO version 2 installed with the name - # liblzo2, with the name liblzo, and LZO version 1. - AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"], - AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"], - AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"], - AC_MSG_ERROR([LZO library version 1.02 or later is required])))) - AC_SUBST(LIBLZO) - LIBS="$LIBS $LIBLZO" - AC_CHECK_FUNC(lzo1x_999_compress, , + AC_ARG_ENABLE([lzo], + [AS_HELP_STRING([--enable-lzo], + [use lzo to compress kernel (default is lzma)])]) + [if [ x"$enable_lzo" = xyes ]; then + # There are three possibilities. LZO version 2 installed with the name + # liblzo2, with the name liblzo, and LZO version 1.] + AC_DEFINE([ENABLE_LZO], [1], [Use lzo compression]) + AC_CHECK_LIB([lzo2], [__lzo_init_v2], [LIBLZO="-llzo2"], + [AC_CHECK_LIB([lzo], [__lzo_init_v2], [LIBLZO="-llzo"], + [AC_CHECK_LIB([lzo], [__lzo_init2], [LIBLZO="-llzo"], + [AC_MSG_ERROR([LZO library version 1.02 or later is required])])])]) + AC_SUBST([LIBLZO]) + [LIBS="$LIBS $LIBLZO"] + AC_CHECK_FUNC([lzo1x_999_compress], , [AC_MSG_ERROR([LZO1X-999 must be enabled])]) - # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h. - AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h) + [# LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.] + AC_CHECK_HEADERS([lzo/lzo1x.h lzo1x.h]) + [fi] + AC_SUBST([enable_lzo]) fi # Check for functions.
include/grub/i386/pc/kernel.h +4 -0
@@ -44,7 +44,11 @@#define GRUB_KERNEL_MACHINE_DATA_END 0x50/* The size of the first region which won't be compressed. */ +#if defined(ENABLE_LZO )#define GRUB_KERNEL_MACHINE_RAW_SIZE (GRUB_KERNEL_MACHINE_DATA_END + 0x450) +#else +#define GRUB_KERNEL_MACHINE_RAW_SIZE (GRUB_KERNEL_MACHINE_DATA_END + 0x5F0) +#endif #ifndef ASM_FILE
include/grub/lib/LzFind.h new file +116 -0
116 lines not on this page · raw message
include/grub/lib/LzHash.h new file +56 -0
56 lines not on this page · raw message
include/grub/lib/LzmaDec.h new file +232 -0
232 lines not on this page · raw message
include/grub/lib/LzmaEnc.h new file +74 -0
74 lines not on this page · raw message
include/grub/lib/LzmaTypes.h new file +130 -0
130 lines not on this page · raw message
kern/i386/pc/lzma_decode.S new file +677 -0
677 lines not on this page · raw message
kern/i386/pc/startup.S +22 -0
@@ -200,6 +200,7 @@ codestart: incl %eax call EXT_C(grub_gate_a20) +#if defined(ENABLE_LZO) /* decompress the compressed part and put the result at 1MB */ movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %esi movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi
@@ -213,6 +214,23 @@ codestart: /* copy back the decompressed part */ movl %eax, %ecx cld +#else + movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi + movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %esi + pushl %edi + pushl %esi + movl EXT_C(grub_kernel_image_size), %ecx + addl EXT_C(grub_total_module_size), %ecx + addl EXT_C(grub_memdisk_image_size), %ecx + subl $GRUB_KERNEL_MACHINE_RAW_SIZE, %ecx + pushl %ecx + leal (%edi, %ecx), %ebx + call _LzmaDecodeA + popl %ecx + popl %edi + popl %esi +#endif + rep movsb
@@ -476,7 +494,11 @@ gate_a20_check_state: popl %ebx ret +#if defined(ENABLE_LZO) #include "lzo1x.S" +#else +#include "lzma_decode.S" +#endif /* * The code beyond this point is compressed. Assert that the uncompressed
lib/LzFind.c new file +753 -0
753 lines not on this page · raw message
lib/LzmaDec.c new file +1014 -0
841 lines not on this page · raw message
lib/LzmaEnc.c new file +2332 -0
2,332 lines not on this page · raw message
util/i386/pc/grub-mkimage.c +52 -0
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 6 lines · Bean
Hi,
This patch add support for lzma decompression. The assembly code
lzma_decode.Sis manually optimized to reduce size. The result decoder is tiny, only 416 bytes longer than the lzo version.
Quoted 6 lines
I also include lzma encode from the LZMA SDK. grub needs to use the ANSI-C version of encoder, which is only present in the latest 4.58 beta. I can't find ready to use shared library in most distro. Including the encoder/decoder has advantages as well. We don't need to worry about the host os, and lzma encoder/decoder can be used in other place, like font compression.
Lenny's most likely going to ship with lzma 4.43. Is that good?
Quoted 5 lines
Result of
./grub-mkimage -o core.img biosdisk pc ext2 lvm raidlzma version: 27,776 bytes
lzo version: 32,768 bytes
Amazing. I'd really like this to make it in time for lenny; although we're really pressed for time now.
include/grub/lib/LzFind.h line 3
Quoted 9 lines
include/grub/lib/LzFind.h new file +3
-0@@ -0,0 +1,116 @@ +/* LzFind.h -- Match finder for LZ algorithms +2008-04-04 +Copyright (c) 1999-2008 Igor Pavlov
Have you modified the files from LZMA SDK? Please add our license boilerplate to them if you did (e.g. like in kern/i386/pc/lzo1x.S).
include/grub/lib/LzFind.h
Quoted 3 lines
include/grub/lib/LzFind.h new file +2
-0+#define FIXED_PROPS +#ifdef FIXED_PROPS
What's this option for? Some comment would be nice.
include/grub/lib/LzFind.h
Quoted 3 lines
include/grub/lib/LzFind.h new file +3
-0+#if 0 + +DbgOut:
This is just for debugging, right? Maybe "#ifdef DEBUG" or so would be better, to make it clear.
include/grub/lib/LzFind.h
Quoted 3 lines
include/grub/lib/LzFind.h new file +3
-0+#ifndef ASM_FILE + xorl %eax, %eax +#endif
Why? I thought ASM_FILE always ought to be defined for asm files in GRUB.
Quoted 22 lines
kern/i386/pc/startup.S +7
-0@@ -200,6 +200,7 @@ codestart: incl %eax call EXT_C(grub_gate_a20) +#if defined(ENABLE_LZO) /* decompress the compressed part and put the result at 1MB */ movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %esi movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi@@ -213,6 +214,23 @@ codestart: /* copy back the decompressed part */ movl %eax, %ecx cld +#else + movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi + movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %esi + pushl %edi + pushl %esi + movl EXT_C(grub_kernel_image_size), %ecx
kern/i386/pc/startup.S codestart: · line 232
Quoted 10 lines
kern/i386/pc/startup.S +10
-0+ addl EXT_C(grub_total_module_size), %ecx + addl EXT_C(grub_memdisk_image_size), %ecx + subl $GRUB_KERNEL_MACHINE_RAW_SIZE, %ecx + pushl %ecx + leal (%edi, %ecx), %ebx + call _LzmaDecodeA + popl %ecx + popl %edi + popl %esi +#endif
I suggest having this explicit, like
#elif defined(ENABLE_LZMA)
[...]
#else
#error blah
#endif
kern/i386/pc/startup.S gate_a20_check_state: · line 501
Quoted 5 lines
kern/i386/pc/startup.S +4
-0+#if defined(ENABLE_LZO) #include "lzo1x.S" +#else +#include "lzma_decode.S" +#endif
Same here (and in grub-mkimage).
Nice work!
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 7 lines · Robert Millan
Quoted 6 lines · Bean
Hi,
This patch add support for lzma decompression. The assembly code
lzma_decode.Sis manually optimized to reduce size. The result decoder is tiny, only 416 bytes longer than the lzo version.
Quoted 8 lines
Quoted 6 lines
I also include lzma encode from the LZMA SDK. grub needs to use the ANSI-C version of encoder, which is only present in the latest 4.58 beta. I can't find ready to use shared library in most distro. Including the encoder/decoder has advantages as well. We don't need to worry about the host os, and lzma encoder/decoder can be used in other place, like font compression.
Lenny's most likely going to ship with lzma 4.43. Is that good?
The c encoder first appears in 4.58 beta. Previous version of lzma only have cpp version.
Quoted 10 lines
Quoted 6 lines
Result of
./grub-mkimage -o core.img biosdisk pc ext2 lvm raidlzma version: 27,776 bytes
lzo version: 32,768 bytesAmazing. I'd really like this to make it in time for lenny; although we're really pressed for time now.
Quoted 12 lines
include/grub/lib/LzFind.h line 3
Quoted 9 lines
include/grub/lib/LzFind.h new file +3
-0@@ -0,0 +1,116 @@ +/* LzFind.h -- Match finder for LZ algorithms +2008-04-04 +Copyright (c) 1999-2008 Igor Pavlov Have you modified the files from LZMA SDK? Please add our license boilerplate to them if you did (e.g. like in
kern/i386/pc/lzo1x.S).
I change the location of some include files.
Quoted 6 lines
include/grub/lib/LzFind.h
Quoted 4 lines
include/grub/lib/LzFind.h new file +2
-0+#define FIXED_PROPS +#ifdef FIXED_PROPS What's this option for? Some comment would be nice.
lzma have three properties that control its behavior, lc, lp and pb. We can use these values as variable or constant. The default value, 3, 0, 2 is nice in most case, we hardly need to change them. So I use it as constant to save some extra space.
Quoted 7 lines
include/grub/lib/LzFind.h
Quoted 4 lines
include/grub/lib/LzFind.h new file +3
-0+#if 0 + +DbgOut:This is just for debugging, right? Maybe "#ifdef DEBUG" or so would be better, to make it clear.
Yes, this is used in debugging. Now it's working, it's not needed anymore. I think it's better to keep it disable like this. The kernel raw space is critical, if we happen to define DEBUG, the decoder code would expand and kernel.img would fail to compile any more.
Quoted 6 lines
include/grub/lib/LzFind.h
Quoted 4 lines
include/grub/lib/LzFind.h new file +3
-0+#ifndef ASM_FILE + xorl %eax, %eax +#endif Why? I thought
ASM_FILEalways ought to be defined for asm files in GRUB.
This is also used in debugging. Previously, I link it with c program to check the decoder, which require to keep register like %esi, %edi, %ebx. But inside grub, there is no need to keep them. I use ASM_FILE to distinguish between these two conditions.
Quoted 42 lines
Quoted 23 lines
kern/i386/pc/startup.S +7
-0@@ -200,6 +200,7 @@ codestart: incl %eax call EXT_C(grub_gate_a20) +#if defined(ENABLE_LZO) /* decompress the compressed part and put the result at 1MB */ movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %esi movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi@@ -213,6 +214,23 @@ codestart: /* copy back the decompressed part */ movl %eax, %ecx cld +#else + movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi + movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %esi + pushl %edi + pushl %esi + movl EXT_C(grub_kernel_image_size), %ecxkern/i386/pc/startup.S codestart: · line 232
Quoted 10 lines
kern/i386/pc/startup.S +10
-0+ addl EXT_C(grub_total_module_size), %ecx + addl EXT_C(grub_memdisk_image_size), %ecx + subl $GRUB_KERNEL_MACHINE_RAW_SIZE, %ecx + pushl %ecx + leal (%edi, %ecx), %ebx + call _LzmaDecodeA + popl %ecx + popl %edi + popl %esi +#endifI suggest having this explicit, like
#elif
defined(ENABLE_LZMA)
[...]
#else
#error blah
#endif
Quoted 7 lines
kern/i386/pc/startup.S gate_a20_check_state: · line 501
Quoted 5 lines
kern/i386/pc/startup.S +4
-0+#if defined(ENABLE_LZO) #include "lzo1x.S" +#else +#include "lzma_decode.S" +#endifSame here (and in grub-mkimage).
Sounds good to me.
Signature · 1 line
Bean
Hi,
This is the new patch.
Signature · 1 line
Bean
Makefile.in +1 -0
@@ -87,6 +87,7 @@ UNIFONT_HEX = @UNIFONT_HEX@ # Options. enable_grub_emu = @enable_grub_emu@ enable_grub_fstest = @enable_grub_fstest@ +enable_lzo = @enable_lzo@ ### General variables.
conf/i386-pc.rmk +6 -1
@@ -72,10 +72,15 @@ sbin_UTILITIES += grub-emu endif # For grub-mkimage. +ifeq ($(enable_lzo), yes) grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ util/resolve.c -grub_mkimage_CFLAGS = -DGRUB_MEMORY_MACHINE_LINK_ADDR=$(GRUB_MEMORY_MACHINE_LINK_ADDR) grub_mkimage_LDFLAGS = $(LIBLZO) +else +grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ + util/resolve.c lib/LzmaEnc.c lib/LzFind.c +endif +grub_mkimage_CFLAGS = -DGRUB_MEMORY_MACHINE_LINK_ADDR=$(GRUB_MEMORY_MACHINE_LINK_ADDR) util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile # For grub-setup.
config.h.in +6 -0
@@ -13,6 +13,12 @@ /* Define it to \"data32\" or \"data32;\" to make GAS happy */ #undef DATA32 +/* Use lzma compression */ +#undef ENABLE_LZMA + +/* Use lzo compression */ +#undef ENABLE_LZO + /* Define it to either end or _end */ #undef END_SYMBOL
configure.ac +20 -11
@@ -143,19 +143,28 @@ fi # Check LZO when compiling for the i386-pc. if test "$target_cpu"-"$platform" = i386-pc; then - # There are three possibilities. LZO version 2 installed with the name - # liblzo2, with the name liblzo, and LZO version 1. - AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"], - AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"], - AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"], - AC_MSG_ERROR([LZO library version 1.02 or later is required])))) - AC_SUBST(LIBLZO) - LIBS="$LIBS $LIBLZO" - AC_CHECK_FUNC(lzo1x_999_compress, , + AC_ARG_ENABLE([lzo], + [AS_HELP_STRING([--enable-lzo], + [use lzo to compress kernel (default is lzma)])]) + [if [ x"$enable_lzo" = xyes ]; then + # There are three possibilities. LZO version 2 installed with the name + # liblzo2, with the name liblzo, and LZO version 1.] + AC_DEFINE([ENABLE_LZO], [1], [Use lzo compression]) + AC_CHECK_LIB([lzo2], [__lzo_init_v2], [LIBLZO="-llzo2"], + [AC_CHECK_LIB([lzo], [__lzo_init_v2], [LIBLZO="-llzo"], + [AC_CHECK_LIB([lzo], [__lzo_init2], [LIBLZO="-llzo"], + [AC_MSG_ERROR([LZO library version 1.02 or later is required])])])]) + AC_SUBST([LIBLZO]) + [LIBS="$LIBS $LIBLZO"] + AC_CHECK_FUNC([lzo1x_999_compress], , [AC_MSG_ERROR([LZO1X-999 must be enabled])]) - # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h. - AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h) + [# LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.] + AC_CHECK_HEADERS([lzo/lzo1x.h lzo1x.h]) + [else] + AC_DEFINE([ENABLE_LZMA], [1], [Use lzma compression]) + [fi] + AC_SUBST([enable_lzo]) fi # Check for functions.
include/grub/i386/pc/kernel.h +4 -0
@@ -44,7 +44,11 @@#define GRUB_KERNEL_MACHINE_DATA_END 0x50/* The size of the first region which won't be compressed. */ +#if defined(ENABLE_LZO )#define GRUB_KERNEL_MACHINE_RAW_SIZE (GRUB_KERNEL_MACHINE_DATA_END + 0x450) +#else +#define GRUB_KERNEL_MACHINE_RAW_SIZE (GRUB_KERNEL_MACHINE_DATA_END + 0x5F0) +#endif #ifndef ASM_FILE
include/grub/lib/LzFind.h new file +130 -0
130 lines not on this page · raw message
include/grub/lib/LzHash.h new file +77 -0
77 lines not on this page · raw message
include/grub/lib/LzmaDec.h new file +246 -0
246 lines not on this page · raw message
include/grub/lib/LzmaEnc.h new file +95 -0
95 lines not on this page · raw message
include/grub/lib/LzmaTypes.h new file +151 -0
151 lines not on this page · raw message
kern/i386/pc/lzma_decode.S new file +677 -0
677 lines not on this page · raw message
kern/i386/pc/startup.S +22 -0
@@ -200,6 +200,7 @@ codestart: incl %eax call EXT_C(grub_gate_a20) +#if defined(ENABLE_LZO) /* decompress the compressed part and put the result at 1MB */ movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %esi movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi
@@ -213,6 +214,23 @@ codestart: /* copy back the decompressed part */ movl %eax, %ecx cld +#elif defined(ENABLE_LZMA) + movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi + movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %esi + pushl %edi + pushl %esi + movl EXT_C(grub_kernel_image_size), %ecx + addl EXT_C(grub_total_module_size), %ecx + addl EXT_C(grub_memdisk_image_size), %ecx + subl $GRUB_KERNEL_MACHINE_RAW_SIZE, %ecx + pushl %ecx + leal (%edi, %ecx), %ebx + call _LzmaDecodeA + popl %ecx + popl %edi + popl %esi +#endif + rep movsb
@@ -476,7 +494,11 @@ gate_a20_check_state: popl %ebx ret +#if defined(ENABLE_LZO) #include "lzo1x.S" +#elif defined(ENABLE_LZMA) +#include "lzma_decode.S" +#endif /* * The code beyond this point is compressed. Assert that the uncompressed
lib/LzFind.c new file +774 -0
774 lines not on this page · raw message
lib/LzmaDec.c new file +1035 -0
724 lines not on this page · raw message
lib/LzmaEnc.c new file +2353 -0
2,353 lines not on this page · raw message
util/i386/pc/grub-mkimage.c +52 -0
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Hi,
Quoted 1 line · Bean
This is the new patch.
Can you please include a changelog entry?
--
Marco
Quoted 7 lines · Marco Gerards
Hi,
Quoted 1 line · Bean
This is the new patch.
Can you please include a changelog entry?
Hi,
Oh, this is the changelog
2008-07-04 Bean <[email protected]>
* Makefile.in (enable_lzo): New rule.
* i386-pc.rmk (grub_mkimage_SOURCES): New test with enable_lzo.
* configure.ac (ENABLE_LZO): New option --enable-lzo.
* include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_RAW_SIZE): Change its value accordding to the compression algorithm used, lzo or lzma.
* util/i386/pc/grub-mkimage.c (compress_kernel): Use different compression according to macro ENABLE_LZO.
* kern/i386/pc/startup.S (codestart): Likewise.
* kern/i386/pc/lzma_decode.S: New file.
* include/grub/lib/LzFind.h: Likewise.
* include/grub/lib/LzHash.h: Likewise.
* include/grub/lib/LzmaDec.h: Likewise.
* lib/LzFind.c: Likewise.
* lib/LzmaDec.c: Likewise.
* lib/LzmaEnc.c: Likewise.
Signature · 1 line
Bean
Quoted 5 lines · Bean
Quoted 2 lines
Lenny's most likely going to ship with lzma 4.43. Is that good?
The c encoder first appears in 4.58 beta. Previous version of lzma only have cpp version.
That's too bad, I guess it'll have to be for lenny+1.
Quoted 10 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+#define FIXED_PROPS +#ifdef FIXED_PROPSWhat's this option for? Some comment would be nice.
lzma have three properties that control its behavior, lc, lp and pb. We can use these values as variable or constant. The default value, 3, 0, 2 is nice in most case, we hardly need to change them. So I use it as constant to save some extra space.
Could you make a comment out of this? :-)
Quoted 11 lines
Quoted 6 lines
kern/i386/pc/lzma_decode.S line 83
Quoted 3 lines
kern/i386/pc/lzma_decode.S new file +3
-0+#if 0 + +DbgOut:This is just for debugging, right? Maybe "#ifdef DEBUG" or so would be better, to make it clear.
Yes, this is used in debugging. Now it's working, it's not needed anymore. I think it's better to keep it disable like this. The kernel raw space is critical, if we happen to define DEBUG, the decoder code would expand and kernel.img would fail to compile any more.
Ok.
Quoted 10 lines
Quoted 5 lines
kern/i386/pc/lzma_decode.S line 140
Quoted 3 lines
kern/i386/pc/lzma_decode.S new file +3
-0+#ifndef ASM_FILE + xorl %eax, %eax +#endifWhy? I thought
ASM_FILEalways ought to be defined for asm files in GRUB.This is also used in debugging. Previously, I link it with c program to check the decoder, which require to keep register like %esi, %edi, %ebx. But inside grub, there is no need to keep them. I use
ASM_FILEto distinguish between these two conditions.
Ok. If you intend to keep it, please add a note explaining why; it looks a bit puzzling without it.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 5 lines · Bean
Hi,
This patch add support for lzma decompression. The assembly code
lzma_decode.Sis manually optimized to reduce size. The result decoder is tiny, only 416 bytes longer than the lzo version.
Not bad.
Quoted 6 lines
I also include lzma encode from the LZMA SDK. grub needs to use the ANSI-C version of encoder, which is only present in the latest 4.58 beta. I can't find ready to use shared library in most distro. Including the encoder/decoder has advantages as well. We don't need to worry about the host os, and lzma encoder/decoder can be used in other place, like font compression.
We can load more complete decoder module after we can load modules and leave more optimized version in boot code.
Quoted 8 lines
I use lzma as default, it's still possible to use the old lzo compression, you just need to add --enable-lzo option when running configure.
PS, here are some information about the lzma decoder:
properties: lc = 3 lp = 0 pb = 2
memory requirement for the decoder: 15980 bytes
Can we probe for best values and then use always the best? Perhaps embed them as constants to boot code?
Quoted 5 lines
Result of
./grub-mkimage -o core.img biosdisk pc ext2 lvm raidlzma version: 27,776 bytes
lzo version: 32,768 bytes
Not bad. Not bad at all.
Quoted 5 lines · Vesa Jääskeläinen
Quoted 2 lines
properties: lc = 3 lp = 0 pb = 2
memory requirement for the decoder: 15980 bytesCan we probe for best values and then use always the best? Perhaps embed them as constants to boot code?
Hi,
These are the default value of lzma, they are tricky to set, and not much can be gained by adjusting them anyway. Inside the boot code, I already use constant for these value, although it can also uses variable if macro FIXED_PROPS is not defined.
Signature · 1 line
Bean
Quoted 6 lines · Bean
Quoted 4 lines · Vesa Jääskeläinen
Quoted 2 lines
properties: lc = 3 lp = 0 pb = 2
memory requirement for the decoder: 15980 bytesCan we probe for best values and then use always the best? Perhaps embed them as constants to boot code?
Quoted 7 lines
Hi,
These are the default value of lzma, they are tricky to set, and not much can be gained by adjusting them anyway. Inside the boot code, I already use constant for these value, although it can also uses variable if macro
FIXED_PROPSis not defined.
Well... If they are default and you did not pick them by hand. Go with defaults then :)
by the way, is LZMA decoding slow enough to be noticable on old machines, every boot time? (say, more than 1 second to decode core.img?)
-Isaac
Quoted 2 lines · Isaac Dupree
by the way, is LZMA decoding slow enough to be noticable on old machines, every boot time? (say, more than 1 second to decode core.img?)
The code is highly optimized for size, speed may hurt a little bit. But anyway, today's machine should have no problem with it. Besides, the time spent to load font file or a true color splash image may well exceed it
Signature · 1 line
Bean
Quoted 9 lines · Bean
Quoted 2 lines · Isaac Dupree
by the way, is LZMA decoding slow enough to be noticable on old machines, every boot time? (say, more than 1 second to decode core.img?)
The code is highly optimized for size, speed may hurt a little bit. But anyway, today's machine should have no problem with it. Besides, the time spent to load font file or a true color splash image may well exceed it
Besides, on old machines there is also the possibility of using LZO - I doubt someone would try to put a setup which required embedding [biosdisk pc raid lvm ext2], which is what pushed core.img over the limit, on a 80386.
Committed.
Signature · 1 line
Bean