diff options
| author | David S. Miller <davem@davemloft.net> | 2010-01-23 03:31:06 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-01-23 03:31:06 -0500 |
| commit | 51c24aaacaea90c8e87f1dec75a2ac7622b593f8 (patch) | |
| tree | 9f54936c87764bef75e97395cb56b7d1e0df24c6 /lib | |
| parent | 4276e47e2d1c85a2477caf0d22b91c4f2377fba8 (diff) | |
| parent | 6be325719b3e54624397e413efd4b33a997e55a3 (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig | 4 | ||||
| -rw-r--r-- | lib/Makefile | 3 | ||||
| -rw-r--r-- | lib/decompress.c | 5 | ||||
| -rw-r--r-- | lib/decompress_unlzo.c | 209 | ||||
| -rw-r--r-- | lib/dma-debug.c | 15 | ||||
| -rw-r--r-- | lib/list_sort.c | 102 | ||||
| -rw-r--r-- | lib/lzo/lzo1x_decompress.c | 9 | ||||
| -rw-r--r-- | lib/rational.c | 1 | ||||
| -rw-r--r-- | lib/string.c | 27 | ||||
| -rw-r--r-- | lib/vsprintf.c | 4 | ||||
| -rw-r--r-- | lib/zlib_inflate/inffast.c | 75 |
11 files changed, 434 insertions, 20 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 1cfe51628e1b..97b136ff117e 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -117,6 +117,10 @@ config DECOMPRESS_BZIP2 | |||
| 117 | config DECOMPRESS_LZMA | 117 | config DECOMPRESS_LZMA |
| 118 | tristate | 118 | tristate |
| 119 | 119 | ||
| 120 | config DECOMPRESS_LZO | ||
| 121 | select LZO_DECOMPRESS | ||
| 122 | tristate | ||
| 123 | |||
| 120 | # | 124 | # |
| 121 | # Generic allocator support is selected if needed | 125 | # Generic allocator support is selected if needed |
| 122 | # | 126 | # |
diff --git a/lib/Makefile b/lib/Makefile index 347ad8db29d3..3b0b4a696db9 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -21,7 +21,7 @@ lib-y += kobject.o kref.o klist.o | |||
| 21 | 21 | ||
| 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
| 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
| 24 | string_helpers.o gcd.o | 24 | string_helpers.o gcd.o list_sort.o |
| 25 | 25 | ||
| 26 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) | 26 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) |
| 27 | CFLAGS_kobject.o += -DDEBUG | 27 | CFLAGS_kobject.o += -DDEBUG |
| @@ -69,6 +69,7 @@ obj-$(CONFIG_LZO_DECOMPRESS) += lzo/ | |||
| 69 | lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o | 69 | lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o |
| 70 | lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o | 70 | lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o |
| 71 | lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o | 71 | lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o |
| 72 | lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o | ||
| 72 | 73 | ||
| 73 | obj-$(CONFIG_TEXTSEARCH) += textsearch.o | 74 | obj-$(CONFIG_TEXTSEARCH) += textsearch.o |
| 74 | obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o | 75 | obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o |
diff --git a/lib/decompress.c b/lib/decompress.c index d2842f571674..a7606815541f 100644 --- a/lib/decompress.c +++ b/lib/decompress.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <linux/decompress/bunzip2.h> | 9 | #include <linux/decompress/bunzip2.h> |
| 10 | #include <linux/decompress/unlzma.h> | 10 | #include <linux/decompress/unlzma.h> |
| 11 | #include <linux/decompress/inflate.h> | 11 | #include <linux/decompress/inflate.h> |
| 12 | #include <linux/decompress/unlzo.h> | ||
| 12 | 13 | ||
| 13 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 14 | #include <linux/string.h> | 15 | #include <linux/string.h> |
| @@ -22,6 +23,9 @@ | |||
| 22 | #ifndef CONFIG_DECOMPRESS_LZMA | 23 | #ifndef CONFIG_DECOMPRESS_LZMA |
| 23 | # define unlzma NULL | 24 | # define unlzma NULL |
| 24 | #endif | 25 | #endif |
| 26 | #ifndef CONFIG_DECOMPRESS_LZO | ||
| 27 | # define unlzo NULL | ||
| 28 | #endif | ||
| 25 | 29 | ||
| 26 | static const struct compress_format { | 30 | static const struct compress_format { |
| 27 | unsigned char magic[2]; | 31 | unsigned char magic[2]; |
| @@ -32,6 +36,7 @@ static const struct compress_format { | |||
| 32 | { {037, 0236}, "gzip", gunzip }, | 36 | { {037, 0236}, "gzip", gunzip }, |
| 33 | { {0x42, 0x5a}, "bzip2", bunzip2 }, | 37 | { {0x42, 0x5a}, "bzip2", bunzip2 }, |
| 34 | { {0x5d, 0x00}, "lzma", unlzma }, | 38 | { {0x5d, 0x00}, "lzma", unlzma }, |
| 39 | { {0x89, 0x4c}, "lzo", unlzo }, | ||
| 35 | { {0, 0}, NULL, NULL } | 40 | { {0, 0}, NULL, NULL } |
| 36 | }; | 41 | }; |
| 37 | 42 | ||
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c new file mode 100644 index 000000000000..db521f45626e --- /dev/null +++ b/lib/decompress_unlzo.c | |||
| @@ -0,0 +1,209 @@ | |||
| 1 | /* | ||
| 2 | * LZO decompressor for the Linux kernel. Code borrowed from the lzo | ||
| 3 | * implementation by Markus Franz Xaver Johannes Oberhumer. | ||
| 4 | * | ||
| 5 | * Linux kernel adaptation: | ||
| 6 | * Copyright (C) 2009 | ||
| 7 | * Albin Tonnerre, Free Electrons <albin.tonnerre@free-electrons.com> | ||
| 8 | * | ||
| 9 | * Original code: | ||
| 10 | * Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer | ||
| 11 | * All Rights Reserved. | ||
| 12 | * | ||
| 13 | * lzop and the LZO library are free software; you can redistribute them | ||
| 14 | * and/or modify them under the terms of the GNU General Public License as | ||
| 15 | * published by the Free Software Foundation; either version 2 of | ||
| 16 | * the License, or (at your option) any later version. | ||
| 17 | * | ||
| 18 | * This program is distributed in the hope that it will be useful, | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | * GNU General Public License for more details. | ||
| 22 | * | ||
| 23 | * You should have received a copy of the GNU General Public License | ||
| 24 | * along with this program; see the file COPYING. | ||
| 25 | * If not, write to the Free Software Foundation, Inc., | ||
| 26 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 27 | * | ||
| 28 | * Markus F.X.J. Oberhumer | ||
| 29 | * <markus@oberhumer.com> | ||
| 30 | * http://www.oberhumer.com/opensource/lzop/ | ||
| 31 | */ | ||
| 32 | |||
| 33 | #ifdef STATIC | ||
| 34 | #include "lzo/lzo1x_decompress.c" | ||
| 35 | #else | ||
| 36 | #include <linux/slab.h> | ||
| 37 | #include <linux/decompress/unlzo.h> | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #include <linux/types.h> | ||
| 41 | #include <linux/lzo.h> | ||
| 42 | #include <linux/decompress/mm.h> | ||
| 43 | |||
| 44 | #include <linux/compiler.h> | ||
| 45 | #include <asm/unaligned.h> | ||
| 46 | |||
| 47 | static const unsigned char lzop_magic[] = { | ||
| 48 | 0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a }; | ||
| 49 | |||
| 50 | #define LZO_BLOCK_SIZE (256*1024l) | ||
| 51 | #define HEADER_HAS_FILTER 0x00000800L | ||
| 52 | |||
| 53 | STATIC inline int INIT parse_header(u8 *input, u8 *skip) | ||
| 54 | { | ||
| 55 | int l; | ||
| 56 | u8 *parse = input; | ||
| 57 | u8 level = 0; | ||
| 58 | u16 version; | ||
| 59 | |||
| 60 | /* read magic: 9 first bits */ | ||
| 61 | for (l = 0; l < 9; l++) { | ||
| 62 | if (*parse++ != lzop_magic[l]) | ||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | /* get version (2bytes), skip library version (2), | ||
| 66 | * 'need to be extracted' version (2) and | ||
| 67 | * method (1) */ | ||
| 68 | version = get_unaligned_be16(parse); | ||
| 69 | parse += 7; | ||
| 70 | if (version >= 0x0940) | ||
| 71 | level = *parse++; | ||
| 72 | if (get_unaligned_be32(parse) & HEADER_HAS_FILTER) | ||
| 73 | parse += 8; /* flags + filter info */ | ||
| 74 | else | ||
| 75 | parse += 4; /* flags */ | ||
| 76 | |||
| 77 | /* skip mode and mtime_low */ | ||
| 78 | parse += 8; | ||
| 79 | if (version >= 0x0940) | ||
| 80 | parse += 4; /* skip mtime_high */ | ||
| 81 | |||
| 82 | l = *parse++; | ||
| 83 | /* don't care about the file name, and skip checksum */ | ||
| 84 | parse += l + 4; | ||
| 85 | |||
| 86 | *skip = parse - input; | ||
| 87 | return 1; | ||
| 88 | } | ||
| 89 | |||
| 90 | STATIC inline int INIT unlzo(u8 *input, int in_len, | ||
| 91 | int (*fill) (void *, unsigned int), | ||
| 92 | int (*flush) (void *, unsigned int), | ||
| 93 | u8 *output, int *posp, | ||
| 94 | void (*error_fn) (char *x)) | ||
| 95 | { | ||
| 96 | u8 skip = 0, r = 0; | ||
| 97 | u32 src_len, dst_len; | ||
| 98 | size_t tmp; | ||
| 99 | u8 *in_buf, *in_buf_save, *out_buf; | ||
| 100 | int obytes_processed = 0; | ||
| 101 | |||
| 102 | set_error_fn(error_fn); | ||
| 103 | |||
| 104 | if (output) { | ||
| 105 | out_buf = output; | ||
| 106 | } else if (!flush) { | ||
| 107 | error("NULL output pointer and no flush function provided"); | ||
| 108 | goto exit; | ||
| 109 | } else { | ||
| 110 | out_buf = malloc(LZO_BLOCK_SIZE); | ||
| 111 | |||
