grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] Disable lzo compression, lzma is doing its job just fin


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH 2/2] Disable lzo compression, lzma is doing its job just fine
Date: Thu, 16 Jul 2009 18:24:14 +0200

On Thu, Jul 16, 2009 at 1:40 AM, Pavel Roskin<address@hidden> wrote:
> ChangeLog:
>
>        * Makefile.in: Remove LIBLZO and enable_lzo.
>        * conf/i386-pc.rmk: Remove lzo support.
>        * configure.ac: Remove checks for lzo, don't define ENABLE_LZMA.
>        * include/grub/i386/pc/kernel.h: Define ENABLE_LZMA.  Remove lzo
>        support.
>        * kern/i386/pc/lzo1x.S: Remove.
>        * kern/i386/pc/startup.S: Remove lzo support.
>        * util/i386/pc/grub-mkimage.c: Likewise.
Is there a reason to remove lzo? I know that lzma performs much better
in terms of compression but afaik lzo doesn't create any problems nor
is compiled by default and may be desirable for some users
> ---
>  Makefile.in                   |    2
>  conf/i386-pc.rmk              |    6 -
>  configure.ac                  |   26 ---
>  include/grub/i386/pc/kernel.h |    7 -
>  kern/i386/pc/lzo1x.S          |  315 
> -----------------------------------------
>  kern/i386/pc/startup.S        |   19 --
>  util/i386/pc/grub-mkimage.c   |   54 -------
>  7 files changed, 8 insertions(+), 421 deletions(-)
>  delete mode 100644 kern/i386/pc/lzo1x.S
>
> diff --git a/Makefile.in b/Makefile.in
> index 3d208e7..29e347a 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -94,7 +94,6 @@ HELP2MAN := LANG=C $(HELP2MAN) --no-info --source=FSF
>  endif
>  AWK = @AWK@
>  LIBCURSES = @LIBCURSES@
> -LIBLZO = @LIBLZO@
>  YACC = @YACC@
>  UNIFONT_BDF = @UNIFONT_BDF@
>
> @@ -103,7 +102,6 @@ enable_grub_emu = @enable_grub_emu@
>  enable_grub_emu_usb = @enable_grub_emu_usb@
>  enable_grub_fstest = @enable_grub_fstest@
>  enable_grub_pe2elf = @enable_grub_pe2elf@
> -enable_lzo = @enable_lzo@
>  enable_grub_mkfont = @enable_grub_mkfont@
>  freetype_cflags = @freetype_cflags@
>  freetype_libs = @freetype_libs@
> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
> index f1915b6..f5bded2 100644
> --- a/conf/i386-pc.rmk
> +++ b/conf/i386-pc.rmk
> @@ -89,14 +89,8 @@ 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_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_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
>  util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile
>
> diff --git a/configure.ac b/configure.ac
> index 8b12c58..66f2b59 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -171,32 +171,6 @@ if test x$grub_cv_apple_cc = xyes ; then
>   ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
>  fi
>
> -# Check LZO when compiling for the i386-pc.
> -if test "$target_cpu"-"$platform" = i386-pc; then
> -  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])
> -  [else]
> -    AC_DEFINE([ENABLE_LZMA], [1], [Use lzma compression])
> -  [fi]
> -  AC_SUBST([enable_lzo])
> -fi
> -
>  # Check for functions.
>  AC_CHECK_FUNCS(posix_memalign memalign asprintf)
>
> diff --git a/include/grub/i386/pc/kernel.h b/include/grub/i386/pc/kernel.h
> index 5b9d8dc..e830afa 100644
> --- a/include/grub/i386/pc/kernel.h
> +++ b/include/grub/i386/pc/kernel.h
> @@ -41,11 +41,10 @@
>  #define GRUB_KERNEL_MACHINE_DATA_END           0x5c
>
>  /* 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)
> -#elif defined(ENABLE_LZMA)
>  #define GRUB_KERNEL_MACHINE_RAW_SIZE           (GRUB_KERNEL_MACHINE_DATA_END 
> + 0x5F0)
> -#endif
> +
> +/* Enable LZMA compression */
> +#define ENABLE_LZMA    1
>
>  #ifndef ASM_FILE
>
> diff --git a/kern/i386/pc/lzo1x.S b/kern/i386/pc/lzo1x.S
> deleted file mode 100644
> index 49ba8cc..0000000
> --- a/kern/i386/pc/lzo1x.S
> +++ /dev/null
> @@ -1,315 +0,0 @@
> -/*
> - *  GRUB  --  GRand Unified Bootloader
> - *  Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
> - *  Copyright (C) 2003,2007  Free Software Foundation, Inc.
> - *
> - *  GRUB is free software: you can redistribute it and/or modify
> - *  it under the terms of the GNU General Public License as published by
> - *  the Free Software Foundation, either version 3 of the License, or
> - *  (at your option) any later version.
> - *
> - *  GRUB is distributed in the hope that it will be useful,
> - *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - *  GNU General Public License for more details.
> - *
> - *  You should have received a copy of the GNU General Public License
> - *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -/*
> - * This code was stolen from the files enter.sh, leave.sh, lzo1x_d.sh,
> - * lzo1x_f.s and lzo_asm.h in LZO version 1.08, and was heavily modified
> - * to adapt it to GRUB's requirement.
> - *
> - * See <http://www.oberhumer.com/opensource/lzo/>, for more information
> - * about LZO.
> - */
> -
> -#define INP    4+16(%esp)
> -#define INS    8+16(%esp)
> -#define OUTP   12+16(%esp)
> -#define NN     3
> -#define N_3    %ebp
> -#define N_255  $255
> -#define LODSB  movb (%esi), %al ;  incl %esi
> -#define NOTL_3(r)      xorl N_3, r
> -#define MOVSL(r1,r2,x) movl (r1), x ; addl $4, r1 ; movl x, (r2) ; addl $4, 
> r2
> -#define COPYL_C(r1,r2,x,rc)    9: MOVSL(r1,r2,x) ; decl rc ; jnz 9b
> -#define COPYL(r1,r2,x) COPYL_C(r1,r2,x,%ecx)
> -
> -lzo1x_decompress:
> -       pushl   %ebp
> -       pushl   %edi
> -       pushl   %esi
> -       pushl   %ebx
> -
> -       cld
> -
> -       movl    INP, %esi
> -       movl    OUTP, %edi
> -       movl    $3, %ebp
> -
> -
> -       xorl    %eax, %eax
> -       xorl    %ebx, %ebx      /* high bits 9-32 stay 0 */
> -       lodsb
> -       cmpb    $17, %al
> -       jbe     .L01
> -       subb    $17-NN, %al
> -       jmp     .LFLR
> -
> -
> -/***********************************************************************
> -// literal run
> -************************************************************************/
> -
> -0:     addl    N_255, %eax
> -1:     movb    (%esi), %bl
> -       incl    %esi
> -       orb     %bl, %bl
> -       jz      0b
> -       leal    18+NN(%eax,%ebx), %eax
> -       jmp     3f
> -
> -
> -.L00:
> -       LODSB
> -.L01:
> -       cmpb    $16, %al
> -       jae     .LMATCH
> -
> -       /* a literal run */
> -       orb     %al, %al
> -       jz      1b
> -       addl    $3+NN, %eax
> -3:
> -.LFLR:
> -       movl    %eax, %ecx
> -       NOTL_3(%eax)
> -       shrl    $2, %ecx
> -       andl    N_3, %eax
> -       COPYL(%esi,%edi,%edx)
> -       subl    %eax, %esi
> -       subl    %eax, %edi
> -
> -       LODSB
> -       cmpb    $16, %al
> -       jae     .LMATCH
> -
> -
> -/***********************************************************************
> -// R1
> -************************************************************************/
> -
> -       shrl    $2, %eax
> -       movb    (%esi), %bl
> -       leal    -0x801(%edi), %edx
> -       leal    (%eax,%ebx,4), %eax
> -       incl    %esi
> -       subl    %eax, %edx
> -       movl    (%edx), %ecx
> -       movl    %ecx, (%edi)
> -       addl    N_3, %edi
> -       jmp     .LMDONE
> -
> -
> -/***********************************************************************
> -// M2
> -************************************************************************/
> -
> -.LMATCH:
> -       cmpb    $64, %al
> -       jb      .LM3MATCH
> -
> -       /* a M2 match */
> -       movl    %eax, %ecx
> -       shrl    $2, %eax
> -       leal    -1(%edi), %edx
> -       andl    $7, %eax
> -       movb    (%esi), %bl
> -       shrl    $5, %ecx
> -       leal    (%eax,%ebx,8), %eax
> -       incl    %esi
> -       subl    %eax, %edx
> -
> -       addl    $1+3, %ecx
> -
> -       cmpl    N_3, %eax
> -       jae     .LCOPYLONG
> -       jmp     .LCOPYBYTE
> -
> -
> -/***********************************************************************
> -// M3
> -************************************************************************/
> -
> -0:     addl    N_255, %eax
> -1:     movb    (%esi), %bl
> -       incl    %esi
> -       orb     %bl, %bl
> -       jz      0b
> -       leal    33+NN(%eax,%ebx), %ecx
> -       xorl    %eax, %eax
> -       jmp     3f
> -
> -
> -.LM3MATCH:
> -       cmpb    $32, %al
> -       jb      .LM4MATCH
> -
> -       /* a M3 match */
> -       andl    $31, %eax
> -       jz      1b
> -       lea     2+NN(%eax), %ecx
> -3:
> -       movw    (%esi), %ax
> -       leal    -1(%edi), %edx
> -       shrl    $2, %eax
> -       addl    $2, %esi
> -       subl    %eax, %edx
> -
> -       cmpl    N_3, %eax
> -       jb      .LCOPYBYTE
> -
> -
> -/***********************************************************************
> -// copy match
> -************************************************************************/
> -
> -.LCOPYLONG:                     /* copy match using longwords */
> -       leal    -3(%edi,%ecx), %eax
> -       shrl    $2, %ecx
> -       COPYL(%edx,%edi,%ebx)
> -       movl    %eax, %edi
> -       xorl    %ebx, %ebx
> -
> -.LMDONE:
> -       movb    -2(%esi), %al
> -       andl    N_3, %eax
> -       jz      .L00
> -.LFLR3:
> -       movl    (%esi), %edx
> -       addl    %eax, %esi
> -       movl    %edx, (%edi)
> -       addl    %eax, %edi
> -
> -       LODSB
> -       jmp     .LMATCH
> -
> -
> -.LCOPYBYTE:                     /* copy match using bytes */
> -       xchgl   %edx,%esi
> -       subl    N_3,%ecx
> -
> -       rep
> -       movsb
> -       movl    %edx, %esi
> -       jmp     .LMDONE
> -
> -
> -/***********************************************************************
> -// M4
> -************************************************************************/
> -
> -0:     addl    N_255, %ecx
> -1:     movb    (%esi), %bl
> -       incl    %esi
> -       orb     %bl, %bl
> -       jz      0b
> -       leal    9+NN(%ebx,%ecx), %ecx
> -       jmp     3f
> -
> -
> -.LM4MATCH:
> -       cmpb    $16, %al
> -       jb      .LM1MATCH
> -
> -       /* a M4 match */
> -       movl    %eax, %ecx
> -       andl    $8, %eax
> -       shll    $13, %eax       /* save in bit 16 */
> -       andl    $7, %ecx
> -       jz      1b
> -       addl    $2+NN, %ecx
> -3:
> -       movw    (%esi), %ax
> -       addl    $2, %esi
> -       leal    -0x4000(%edi), %edx
> -       shrl    $2, %eax
> -       jz      .LEOF
> -       subl    %eax, %edx
> -       jmp     .LCOPYLONG
> -
> -
> -/***********************************************************************
> -// M1
> -************************************************************************/
> -
> -.LM1MATCH:
> -       /* a M1 match */
> -       shrl    $2, %eax
> -       movb    (%esi), %bl
> -       leal    -1(%edi), %edx
> -       leal    (%eax,%ebx,4), %eax
> -       incl    %esi
> -       subl    %eax, %edx
> -
> -       movb    (%edx), %al     /* we must use this because edx can be edi-1 
> */
> -       movb    %al, (%edi)
> -       movb    1(%edx), %bl
> -       movb    %bl, 1(%edi)
> -       addl    $2, %edi
> -       jmp     .LMDONE
> -
> -
> -/***********************************************************************
> -//
> -************************************************************************/
> -
> -.LEOF:
> -/****  xorl    %eax,%eax          eax=0 from above */
> -
> -       cmpl    $3+NN, %ecx     /* ecx must be 3/6 */
> -       setnz   %al
> -
> -       /* check compressed size */
> -       movl    INP, %edx
> -       addl    INS, %edx
> -       cmpl    %edx, %esi       /* check compressed size */
> -       ja      .L_input_overrun
> -       jb      .L_input_not_consumed
> -
> -.L_leave:
> -       negl    %eax
> -       jnz     1f
> -
> -       subl    OUTP, %edi       /* write back the uncompressed size */
> -       movl    %edi, %eax
> -
> -1:     popl    %ebx
> -       popl    %esi
> -       popl    %edi
> -       popl    %ebp
> -       ret
> -
> -.L_input_not_consumed:
> -        movl    $8, %eax         /* LZO_E_INPUT_NOT_CONSUMED */
> -        jmp     .L_leave
> -
> -.L_input_overrun:
> -        movl    $4, %eax         /* LZO_E_INPUT_OVERRUN */
> -        jmp     .L_leave
> -
> -#undef INP
> -#undef INS
> -#undef OUTP
> -#undef NN
> -#undef NN
> -#undef N_3
> -#undef N_255
> -#undef LODSB
> -#undef NOTL_3
> -#undef MOVSL
> -#undef COPYL_C
> -#undef COPYL
> diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
> index 171fbea..be258fb 100644
> --- a/kern/i386/pc/startup.S
> +++ b/kern/i386/pc/startup.S
> @@ -210,20 +210,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 + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi
> -
> -       pushl   %esi
> -       pushl   EXT_C(grub_compressed_size)
> -       pushl   %edi
> -       call    lzo1x_decompress
> -       addl    $12, %esp
> -
> -       movl    %eax, %ecx
> -       cld
> -#elif defined(ENABLE_LZMA)
> +#ifdef ENABLE_LZMA
>        movl    $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi
>        movl    $(_start + GRUB_KERNEL_MACHINE_RAW_SIZE), %esi
>        pushl   %edi
> @@ -451,9 +438,7 @@ gate_a20_check_state:
>        popl    %ebx
>        ret
>
> -#if defined(ENABLE_LZO)
> -#include "lzo1x.S"
> -#elif defined(ENABLE_LZMA)
> +#ifdef ENABLE_LZMA
>  #include "lzma_decode.S"
>  #endif
>
> diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c
> index ee1af82..b81392c 100644
> --- a/util/i386/pc/grub-mkimage.c
> +++ b/util/i386/pc/grub-mkimage.c
> @@ -36,57 +36,9 @@
>  #define _GNU_SOURCE    1
>  #include <getopt.h>
>
> -#if defined(ENABLE_LZO)
> -
> -#if defined(HAVE_LZO_LZO1X_H)
> -# include <lzo/lzo1x.h>
> -#elif defined(HAVE_LZO1X_H)
> -# include <lzo1x.h>
> -#endif
> -
> -#elif defined(ENABLE_LZMA)
> -
> +#ifdef ENABLE_LZMA
>  #include <grub/lib/LzmaEnc.h>
>
> -#endif
> -
> -#if defined(ENABLE_LZO)
> -
> -static void
> -compress_kernel (char *kernel_img, size_t kernel_size,
> -                char **core_img, size_t *core_size)
> -{
> -  lzo_uint size;
> -  char *wrkmem;
> -
> -  if (kernel_size < GRUB_KERNEL_MACHINE_RAW_SIZE)
> -    grub_util_error ("the core image is too small");
> -
> -  if (lzo_init () != LZO_E_OK)
> -    grub_util_error ("cannot initialize LZO");
> -
> -  *core_img = xmalloc (kernel_size + kernel_size / 64 + 16 + 3);
> -  wrkmem = xmalloc (LZO1X_999_MEM_COMPRESS);
> -
> -  memcpy (*core_img, kernel_img, GRUB_KERNEL_MACHINE_RAW_SIZE);
> -
> -  grub_util_info ("compressing the core image");
> -  if (lzo1x_999_compress ((const lzo_byte *) (kernel_img
> -                                             + GRUB_KERNEL_MACHINE_RAW_SIZE),
> -                         kernel_size - GRUB_KERNEL_MACHINE_RAW_SIZE,
> -                         (lzo_byte *) (*core_img
> -                                       + GRUB_KERNEL_MACHINE_RAW_SIZE),
> -                         &size, wrkmem)
> -      != LZO_E_OK)
> -    grub_util_error ("cannot compress the kernel image");
> -
> -  free (wrkmem);
> -
> -  *core_size = (size_t) size + GRUB_KERNEL_MACHINE_RAW_SIZE;
> -}
> -
> -#elif defined(ENABLE_LZMA)
> -
>  static void *SzAlloc(void *p, size_t size) { p = p; return xmalloc(size); }
>  static void SzFree(void *p, void *address) { p = p; free(address); }
>  static ISzAlloc g_Alloc = { SzAlloc, SzFree };
> @@ -124,7 +76,7 @@ compress_kernel (char *kernel_img, size_t kernel_size,
>   *core_size += GRUB_KERNEL_MACHINE_RAW_SIZE;
>  }
>
> -#else
> +#else  /* No lzma compression */
>
>  static void
>  compress_kernel (char *kernel_img, size_t kernel_size,
> @@ -135,7 +87,7 @@ compress_kernel (char *kernel_img, size_t kernel_size,
>   *core_size = kernel_size;
>  }
>
> -#endif
> +#endif /* No lzma compression */
>
>  static void
>  generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git




reply via email to

[Prev in Thread] Current Thread [Next in Thread]