aa24b516a2
* Makefile.in (enable_lzo): New rule. * conf/i386-pc.rmk (grub_mkimage_SOURCES): New test with enable_lzo. * configure.ac (ENABLE_LZO): New option --enable-lzo. * boot/i386/pc/lnxboot.S: #include <config.h>. * 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 algorithm according to configure macro. * 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. * include/grub/lib/LzmaEnc.h: Likewise. * include/grub/lib/LzmaTypes.h: Likewise. * lib/LzFind.c: Likewise. * lib/LzmaDec.c: Likewise. * lib/LzmaEnc.c: Likewise.
77 lines
2.8 KiB
C
77 lines
2.8 KiB
C
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (c) 1999-2008 Igor Pavlov
|
|
* Copyright (C) 2008 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 taken from LZMA SDK 4.58 beta, and was slightly modified
|
|
* to adapt it to GRUB's requirement.
|
|
*
|
|
* See <http://www.7-zip.org>, for more information about LZMA.
|
|
*/
|
|
|
|
#ifndef __LZHASH_H
|
|
#define __LZHASH_H
|
|
|
|
#define kHash2Size (1 << 10)
|
|
#define kHash3Size (1 << 16)
|
|
#define kHash4Size (1 << 20)
|
|
|
|
#define kFix3HashSize (kHash2Size)
|
|
#define kFix4HashSize (kHash2Size + kHash3Size)
|
|
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
|
|
|
|
#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
|
|
|
|
#define HASH3_CALC { \
|
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
|
hash2Value = temp & (kHash2Size - 1); \
|
|
hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
|
|
|
|
#define HASH4_CALC { \
|
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
|
hash2Value = temp & (kHash2Size - 1); \
|
|
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
|
|
|
|
#define HASH5_CALC { \
|
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
|
hash2Value = temp & (kHash2Size - 1); \
|
|
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
|
|
hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
|
|
hash4Value &= (kHash4Size - 1); }
|
|
|
|
/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
|
|
#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
|
|
|
|
|
|
#define MT_HASH2_CALC \
|
|
hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
|
|
|
|
#define MT_HASH3_CALC { \
|
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
|
hash2Value = temp & (kHash2Size - 1); \
|
|
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
|
|
|
|
#define MT_HASH4_CALC { \
|
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
|
hash2Value = temp & (kHash2Size - 1); \
|
|
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
|
|
|
|
#endif
|