Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KE3zZ-0001cE-KH for mharc-grub-devel@gnu.org; Wed, 02 Jul 2008 11:11:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KE3zW-0001Zp-Ne for grub-devel@gnu.org; Wed, 02 Jul 2008 11:11:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KE3zW-0001Yj-4k for grub-devel@gnu.org; Wed, 02 Jul 2008 11:11:30 -0400 Received: from [199.232.76.173] (port=51703 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KE3zV-0001YX-Kt for grub-devel@gnu.org; Wed, 02 Jul 2008 11:11:29 -0400 Received: from rv-out-0708.google.com ([209.85.198.245]:57301) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KE3zV-0000MG-3i for grub-devel@gnu.org; Wed, 02 Jul 2008 11:11:29 -0400 Received: by rv-out-0708.google.com with SMTP id k29so477003rvb.6 for ; Wed, 02 Jul 2008 08:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=DNJghrgb7lIoR4xQ0U4CF0aLe1E9WGH1x++RGUo6iGQ=; b=qnen6xwvQlL3sjX+deBN9Z0Kq3AG/UWptUvoBonHeBZT0dSRZpAZeRxd5QhTny2FZ2 zK5QR/PTH3Co8ocJjAfhbpUS/KxK11TXenNwT5sskJ1BtDvYkkTooFnnX/JZgj1MRBYa yVt1NShYaYrAZSXmz2PmU9k1FE7lg0sE6pyN4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=jvbIprjaqzcTohvU9g5UsE6ScZtMh1sRcsePRJlD0BYOLGVmDXoRf2d72ymIFX0d76 WlvlCobkdENVAHdf5/ep7sWTA8j78mw9zl/kK1dZprQ81AAPcKr8BiwTz/67CsRjNk6+ VSIGIL2bqE21LIpAMiCo+Sjc1ShBImm0y4KTQ= Received: by 10.141.69.1 with SMTP id w1mr4445423rvk.147.1215011488308; Wed, 02 Jul 2008 08:11:28 -0700 (PDT) Received: by 10.141.66.21 with HTTP; Wed, 2 Jul 2008 08:11:28 -0700 (PDT) Message-ID: Date: Wed, 2 Jul 2008 23:11:28 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <20080702144227.GD21064@thorin> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080702144227.GD21064@thorin> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: [PATCH] LZMA support in i386-pc kernel X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jul 2008 15:11:31 -0000 On Wed, Jul 2, 2008 at 10:42 PM, Robert Millan wrote: > On Wed, Jul 02, 2008 at 09:39:52PM +0800, Bean wrote: >> 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. > > 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. > >> Result of >> ./grub-mkimage -o core.img biosdisk pc ext2 lvm raid >> >> lzma 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. > >> diff --git a/include/grub/lib/LzFind.h b/include/grub/lib/LzFind.h >> new file mode 100644 >> index 0000000..3d74d0c >> --- /dev/null >> +++ b/include/grub/lib/LzFind.h >> @@ -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. > >> +#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. > >> +#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. > >> +#ifndef ASM_FILE >> + xorl %eax, %eax >> +#endif > > Why? I thought ASM_FILE always 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. > >> diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S >> index 9542978..964643a 100644 >> --- a/kern/i386/pc/startup.S >> +++ b/kern/i386/pc/startup.S >> @@ -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 > > I suggest having this explicit, like > > #elif defined(ENABLE_LZMA) > [...] > #else > #error blah > #endif > >> +#if defined(ENABLE_LZO) >> #include "lzo1x.S" >> +#else >> +#include "lzma_decode.S" >> +#endif > > Same here (and in grub-mkimage). Sounds good to me. -- Bean