aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexlartsev19 <alexlartsev19@gmail.com>2017-04-14 19:15:18 +0300
committerMister Oyster <oysterized@gmail.com>2017-09-26 19:35:46 +0200
commit381a36ec93103b31b8dff83fe62fb9eb942bde57 (patch)
tree5ef6aeed599adce771dd822bd42fbb5eab50c818
parent9fbef1df22dcf1628c576a2b9ad5ac2a37ce823d (diff)
lz4k: Remove lz4k module
-rw-r--r--arch/arm64/configs/m2note_defconfig1
-rw-r--r--crypto/Kconfig6
-rw-r--r--crypto/lz4kc.c151
-rw-r--r--include/linux/lz4k.h27
-rw-r--r--lib/Makefile2
-rwxr-xr-xlib/lz4k/Makefile2
-rw-r--r--lib/lz4k/lz4k_compress.c305
-rw-r--r--lib/lz4k/lz4k_decompress.c519
-rw-r--r--lib/lz4k/lz4k_init.c27
9 files changed, 0 insertions, 1040 deletions
diff --git a/arch/arm64/configs/m2note_defconfig b/arch/arm64/configs/m2note_defconfig
index 9ac39ef0d..65796a7b9 100644
--- a/arch/arm64/configs/m2note_defconfig
+++ b/arch/arm64/configs/m2note_defconfig
@@ -3311,7 +3311,6 @@ CONFIG_CRYPTO_TWOFISH_COMMON=y
CONFIG_CRYPTO_DEFLATE=y
# CONFIG_CRYPTO_ZLIB is not set
CONFIG_CRYPTO_LZO=y
-# CONFIG_CRYPTO_LZ4K is not set
CONFIG_CRYPTO_LZ4=y
# CONFIG_CRYPTO_LZ4HC is not set
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 237a17096..0bb21501e 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1413,12 +1413,6 @@ config CRYPTO_LZO
help
This is the LZO algorithm.
-config CRYPTO_LZ4K
- tristate "LZ4K compression algorithm"
- select CRYPTO_ALGAPI
- help
- This is the LZ4K algorithm.
-
config CRYPTO_842
tristate "842 compression algorithm"
depends on CRYPTO_DEV_NX_COMPRESS
diff --git a/crypto/lz4kc.c b/crypto/lz4kc.c
deleted file mode 100644
index 219ea2c2e..000000000
--- a/crypto/lz4kc.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Cryptographic API.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program 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
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/crypto.h>
-#include <linux/vmalloc.h>
-#include <linux/lzo.h>
-#include <linux/lz4k.h>
-
-#define malloc(a) kmalloc(a, GFP_KERNEL)
-#define free(a) kfree(a)
-
-#if 0
-
-extern int lz4k_compress_ubifs(const unsigned char *in, size_t in_len, unsigned char *out,
- size_t *out_len, void *wrkmem);
-
-extern int lz4k_decompress_ubifs(const unsigned char *in, size_t in_len,
- unsigned char *out, size_t *out_len);
-
-extern int lz4k_compress(const unsigned char *in, size_t in_len, unsigned char *out,
- size_t *out_len, void *wrkmem);
-#endif
-struct lz4k_ctx {
- void *lz4k_comp_mem;
-};
-
-static int lz4kc_init(struct crypto_tfm *tfm)
-{
- struct lz4k_ctx *ctx = crypto_tfm_ctx(tfm);
-
- ctx->lz4k_comp_mem = vmalloc(LZO1X_MEM_COMPRESS);
- if (!ctx->lz4k_comp_mem)
- return -ENOMEM;
-
- return 0;
-}
-
-static void lz4kc_exit(struct crypto_tfm *tfm)
-{
- struct lz4k_ctx *ctx = crypto_tfm_ctx(tfm);
-
- vfree(ctx->lz4k_comp_mem);
-}
-
-static int lz4kc_compress(struct crypto_tfm *tfm, const u8 *src,
- unsigned int slen, u8 *dst, unsigned int *dlen)
-{
-
- struct lz4k_ctx *ctx = crypto_tfm_ctx(tfm);
- //static size_t in_size = 0, out_size = 0;
- size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
- int err;
-
- static int count = 0;
-
- //printk("lz4k_compress 2 count = %d\r\n", count);
-
- count++;
-
-
- err = lz4k_compress(src, slen, dst, &tmp_len, ctx->lz4k_comp_mem);
- //err = lzo1x_1_compress(src, slen, dst, &tmp_len, ctx->lz4k_comp_mem);
-
-
- if (err != LZO_E_OK)
- return -EINVAL;
-#if 0
- if (count%10 == 0)
- {
- in_size += slen;
- out_size += tmp_len;
- printk("lz4k_compress_ubifs result in_size = %d, out_size = %d \n", in_size,out_size);
- }
-#endif
- //printk("lz4k_compress result in_size = %d, out_size = %d \n", in_size,out_size);
- //printk("lz4k_compress result slen = %d, tmp_len = %d \n", slen,tmp_len);
-
- *dlen = tmp_len;
- return 0;
-
-}
-
-static int lz4kc_decompress(struct crypto_tfm *tfm, const u8 *src,
- unsigned int slen, u8 *dst, unsigned int *dlen)
-{
- static int count = 0;
- int err;
- size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
-
-
- //printk("lz4k_decompress 2count = %d, *dlen = %d", count,*dlen);
-
- err = lz4k_decompress_ubifs(src, slen, dst, &tmp_len);
- //err = lzo1x_decompress_safe(src, slen, dst, &tmp_len);
-
-
- count++;
-
- if (err != LZO_E_OK)
- return -EINVAL;
-
- *dlen = tmp_len;
- return 0;
-
-}
-
-static struct crypto_alg alg = {
- .cra_name = "lz4k",
- .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
- .cra_ctxsize = sizeof(struct lz4k_ctx),
- .cra_module = THIS_MODULE,
- .cra_list = LIST_HEAD_INIT(alg.cra_list),
- .cra_init = lz4kc_init,
- .cra_exit = lz4kc_exit,
- .cra_u = { .compress = {
- .coa_compress = lz4kc_compress,
- .coa_decompress = lz4kc_decompress } }
-};
-
-static int __init lz4k_mod_init(void)
-{
- return crypto_register_alg(&alg);
-}
-
-static void __exit lz4k_mod_fini(void)
-{
- crypto_unregister_alg(&alg);
-}
-
-module_init(lz4k_mod_init);
-module_exit(lz4k_mod_fini);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("LZ77 with 4K Compression Algorithm");
diff --git a/include/linux/lz4k.h b/include/linux/lz4k.h
deleted file mode 100644
index e31c5042f..000000000
--- a/include/linux/lz4k.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#ifndef __LZ4K_H__
-#define __LZ4K_H__
-
-#include <linux/types.h>
-#include <linux/lzo.h>
-
-#define LZ4K_TAG 1261722188 /* "LZ4K" */
-
-#ifndef CONFIG_64BIT
-#define LZ4K_MEM_COMPRESS LZO1X_MEM_COMPRESS
-#else
-#define LZ4K_MEM_COMPRESS (LZO1X_MEM_COMPRESS << 1)
-#endif
-
-int lz4k_compress(const unsigned char *src, size_t src_len,
- unsigned char *dst, size_t *dst_len, void *wrkmem);
-
-int lz4k_decompress_safe(const unsigned char *src, size_t src_len,
- unsigned char *dst, size_t *dst_len);
-
-#ifdef CONFIG_UBIFS_FS
-int lz4k_decompress_ubifs(const unsigned char *src, size_t src_len,
- unsigned char *dst, size_t *dst_len);
-#endif /* CONFIG_UBIFS_FS */
-
-#endif /* __LZ4K_H__ */
diff --git a/lib/Makefile b/lib/Makefile
index 3993e5474..8db4b868a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -185,5 +185,3 @@ clean-files += oid_registry_data.c
obj-$(CONFIG_UCS2_STRING) += ucs2_string.o
-obj-$(CONFIG_LZ4K) += lz4k/
-
diff --git a/lib/lz4k/Makefile b/lib/lz4k/Makefile
deleted file mode 100755
index 02e12270d..000000000
--- a/lib/lz4k/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-lz4k-objs := lz4k_compress.o lz4k_decompress.o lz4k_init.o
-obj-y += lz4k.o
diff --git a/lib/lz4k/lz4k_compress.c b/lib/lz4k/lz4k_compress.c
deleted file mode 100644
index 060279901..000000000
--- a/lib/lz4k/lz4k_compress.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * LZ4K Compressor by Vovo
- */
-#include <linux/lz4k.h>
-#include <linux/types.h>
-#include <linux/string.h>
-
-unsigned short lz4k_matchlen_encode[32] =
- { 0, 0, 0, 1024, 1026, 2049, 2053, 2057, 2061, 3091, 3123, 3083, 2563, 3643, 3707, 3115, 3099,
-4119, 3591, 4247, 3655, 4791, 4183, 4311, 3623, 5047, 4727, 4983, 3687, 4855, 5111, 4151, };
-
-unsigned short lz4k_matchoff_encode[32] =
- { 1024, 1032, 1292, 1028, 1554, 1308, 1586, 1546, 1578, 1562, 1830, 1594, 1894, 1282, 1814,
-1542, 2158, 1878, 2286, 1846, 2078, 1910, 2206, 1806, 2142, 2270, 2110, 1870, 2238, 1838, 2174, 2302, };
-
-unsigned short lz4k_literallen_encode[18] =
- { 0, 128, 385, 517, 525, 515, 651, 775, 807, 667, 919, 983, 951, 1015, 911, 975, 943, 1007, };
-
-unsigned short lz4k_literalch_encode[256] =
- { 2048, 3092, 3596, 3660, 3628, 4154, 4282, 4218, 3692, 3612, 3676, 4346, 4102, 4230, 4166,
-4294, 3644, 4134, 4262, 4198, 4326, 4861, 5117, 4611, 4118, 4867, 4246, 4182, 4310, 4150, 4278, 4214, 3124, 4342, 4110, 4238,
-4174, 4302, 4739, 4995, 3708, 4142, 4675, 4931, 4270, 4803, 4206, 4334, 3586, 4126, 4254, 4190, 4318, 5059, 4643, 4899, 4158,
-4771, 5027, 4707, 4963, 4835, 5091, 4627, 2564, 3650, 4286, 4222, 4350, 4883, 4755, 5011, 4097, 4691, 4947, 4225, 4161, 4289,
-4129, 4257, 3618, 3682, 4193, 4321, 4113, 4819, 5075, 4659, 4241, 4915, 4787, 5043, 4723, 4979, 4851, 4177, 4305, 3602, 4145,
-4273, 4209, 3666, 4337, 4105, 4233, 3634, 5107, 4619, 4169, 4297, 3698, 3594, 3658, 4137, 3626, 4265, 3690, 4201, 4329, 4875,
-4121, 4249, 4747, 5003, 4683, 4939, 4811, 5067, 3610, 4651, 4907, 4779, 4185, 5035, 4715, 4971, 4313, 4843, 5099, 4635, 4891,
-4763, 5019, 4699, 4153, 4955, 4827, 5083, 4667, 4923, 4795, 5051, 4281, 4731, 4987, 4859, 5115, 4615, 4871, 4743, 4217, 4999,
-4679, 4935, 4807, 5063, 4647, 4903, 4345, 4775, 5031, 4711, 4967, 4839, 5095, 4631, 4101, 4887, 4759, 5015, 4229, 4695, 4951,
-4823, 4165, 5079, 4663, 4919, 4293, 4791, 5047, 4727, 4133, 4983, 4855, 5111, 4623, 4879, 4751, 5007, 4261, 4687, 4943, 4815,
-5071, 4655, 4911, 4783, 4197, 4325, 4117, 4245, 4181, 4309, 5039, 4719, 4149, 4975, 4847, 5103, 4639, 4895, 4767, 5023, 3674,
-4277, 4703, 4213, 4959, 4341, 4831, 5087, 4109, 4671, 4927, 4799, 4237, 4173, 4301, 5055, 4141, 4269, 4205, 4333, 4125, 4253,
-4735, 4189, 4317, 4157, 4285, 4991, 4221, 4863, 5119, 2056, };
-
-#define RESERVE_16_BITS() \
-if (bitstobeoutput >= 16) { \
- *((unsigned short *)op) = (unsigned short) (bits_buffer32 & 0xffff); \
- op += 2; \
- bits_buffer32 = bits_buffer32 >> 16; \
- bitstobeoutput -= 16; \
-}
-
-#define STORE_BITS(bits, code) \
- bits_buffer32 |= (code) << bitstobeoutput; \
- bitstobeoutput += (bits);
-
-static size_t
-_lz4k_do_compress(const unsigned char *in, size_t in_len,
- unsigned char *out, size_t *out_len, void *wrkmem)
-{
- const unsigned char *ip = in;
- unsigned char *op = out;
- const unsigned char *const in_end = in + in_len;
- const unsigned char *const ip_end = in + in_len - 3;
- const unsigned char *ii = ip;
- const unsigned char **const dict = wrkmem;
- unsigned int bitstobeoutput = 0;
- unsigned int bits_buffer32 = 0;
-
- bitstobeoutput = 1;
-
- for (;;) {
- const unsigned char *m_pos;
- {
- size_t dindex;
- unsigned int ip_content = *(unsigned int *)ip;
- unsigned int hash_temp = ip_content ^ (ip_content >> 12);
- dindex = hash_temp & 0xfff;
- m_pos = dict[dindex];
- dict[dindex] = ip;
-
- if (m_pos < in || m_pos >= ip
- || ((*(unsigned int *)m_pos << 8) != (ip_content << 8))) {
- ++ip;
- dindex = (hash_temp >> 8) & 0xfff;
- m_pos = dict[dindex];
- dict[dindex] = ip;
- if (m_pos < in || m_pos >= ip
- || ((*(unsigned int *)m_pos << 8) !=
- (ip_content & 0xffffff00))) {
- ++ip;
- if (__builtin_expect(!!(ip >= ip_end), 0))
- break;
- continue;
- }
- }
- }
-
- {
- size_t lit = ip - ii;
-
- if (lit > 0) {
- if (lit == 1) {
- int value, bits, code;
- RESERVE_16_BITS();
- value = lz4k_literalch_encode[*ii++];
- bits = value >> 9;
- code = (value & 0x1ff) << 2;
- STORE_BITS(bits + 2, code);
- } else if (lit == 2) {
- int value, bits, code;
- int value2, bits2, code2;
- RESERVE_16_BITS();
- if (bitstobeoutput > (32 - 22)) {
- *op++ = (unsigned char)(bits_buffer32 & 0xff);
- bits_buffer32 = bits_buffer32 >> 8;
- bitstobeoutput -= 8;
- }
- value = lz4k_literalch_encode[*ii++];
- bits = value >> 9;
- code = value & 0x1ff;
- value2 = lz4k_literalch_encode[*ii++];
- bits2 = value2 >> 9;
- code2 = value2 & 0x1ff;
- bits_buffer32 |=
- ((((code2 << bits) | code) << 4) | 2) << bitstobeoutput;
- bitstobeoutput += bits2 + bits + 4;
- } else {
- if (lit <= 17) {
- int value, bits, code;
- RESERVE_16_BITS();
- value = lz4k_literallen_encode[lit];
- bits = value >> 7;
- code = (value & 0x7f) << 1;
- STORE_BITS(bits + 1, code);
- } else {
- int code = ((lit - 1) << 6) | 0x3e;
-
- RESERVE_16_BITS();
- if (bitstobeoutput > (32 - 18)) {
- *op++ =
- (unsigned char)(bits_buffer32 & 0xff);
- bits_buffer32 = bits_buffer32 >> 8;
- bitstobeoutput -= 8;
- }
- STORE_BITS(17 + 1, code);
- }
-
- while (1) {
- while (bitstobeoutput < 24) {
- int value, bits, code;
- value = lz4k_literalch_encode[*ii++];
- bits = value >> 9;
- code = value & 0x1ff;
- STORE_BITS(bits, code);
- if (__builtin_expect(!!(ii == ip), 0)) {
- goto break_literal_1;
- }
- }
- *((unsigned int *)op) = bits_buffer32;
- op += 3;
- bits_buffer32 = bits_buffer32 >> 24;
- bitstobeoutput -= 24;
- }
- }
- } else {
- if (bitstobeoutput == 32) {
- *((unsigned int *)op) = bits_buffer32;
- op += 4;
- bits_buffer32 = 1;
- bitstobeoutput = 1;
- } else {
- bits_buffer32 |= 1 << bitstobeoutput;
- bitstobeoutput += 1;
- }
- }
- }
-
- break_literal_1:
-
- m_pos += 3;
- ip += 3;
-
- if (__builtin_expect(!!(ip < in_end), 1) && *m_pos == *ip) {
- m_pos++, ip++;
- while (__builtin_expect(!!(ip < (in_end - 1)), 1)
- && *(unsigned short *)m_pos == *(unsigned short *)ip)
- m_pos += 2, ip += 2;
- if (__builtin_expect(!!(ip < in_end), 1) && *m_pos == *ip)
- m_pos += 1, ip += 1;
- }
-
- RESERVE_16_BITS();
-
- {
- size_t m_off = ip - m_pos;
- if ((m_off & 3) == 0 && m_off <= 128) {
- int value = lz4k_matchoff_encode[(m_off / 4) - 1];
- int bits = value >> 8;
- int code = value & 0xff;
- STORE_BITS(bits, code);
- } else {
- int code = (m_off << 1) | 0x1;
- STORE_BITS(13, code);
- }
- }
- RESERVE_16_BITS();
-
- {
- size_t m_len = ip - ii;
- if (m_len < 32) {
- int value = lz4k_matchlen_encode[m_len];
- int bits = value >> 9;
- int code = value & 0x1ff;
- STORE_BITS(bits, code);
- } else {
- int code = (m_len << 4) | 0xf;
- STORE_BITS(16, code);
- }
- }
-
- ii = ip;
- if (__builtin_expect(!!(ip >= ip_end), 0))
- break;
- }
-
- if ((in_end - ii) > 0) {
- size_t t = in_end - ii;
- if (t == 1) {
- int value, bits, code;
- RESERVE_16_BITS();
- value = lz4k_literalch_encode[*ii++];
- bits = value >> 9;
- code = (value & 0x1ff) << 2;
- bits_buffer32 |= code << bitstobeoutput;
- bitstobeoutput += bits + 2;
- } else {
- while (bitstobeoutput >= 8) {
- *op++ = (unsigned char)(bits_buffer32 & 0xff);
- bits_buffer32 = bits_buffer32 >> 8;
- bitstobeoutput -= 8;
- }
- bitstobeoutput += 1;
-
- if (t <= 17) {
- int value = lz4k_literallen_encode[t];
- int bits = value >> 7;
- int code = value & 0x7f;
- bits_buffer32 |= code << bitstobeoutput;
- bitstobeoutput += bits;
- } else {
- int code = ((t - 1) << 5) | 0x1f;
- bits_buffer32 |= code << bitstobeoutput;
- bitstobeoutput += 17;
- }
-
- while (1) {
- while (bitstobeoutput < 24) {
- int value, bits, code;
- value = lz4k_literalch_encode[*ii++];
- bits = value >> 9;
- code = value & 0x1ff;
- bits_buffer32 |= code << bitstobeoutput;
- bitstobeoutput += bits;
- if (__builtin_expect(!!(--t == 0), 0))
- goto break_literal_2;
- }
- *((unsigned int *)op) = bits_buffer32;
- op += 3;
- bits_buffer32 = bits_buffer32 >> 24;
- bitstobeoutput -= 24;
- }
- }
- }
-
- break_literal_2:
- while (bitstobeoutput >= 8) {
- *op++ = (unsigned char)(bits_buffer32 & 0xff);
- bits_buffer32 = bits_buffer32 >> 8;
- bitstobeoutput -= 8;
- }
- if (bitstobeoutput != 0) {
- *op++ = (unsigned char)(bits_buffer32 & 0xff);
- }
-
- *((unsigned int *)op) = LZ4K_TAG;
- op += 4;
-
- *out_len = op - out;
-
- return 0;
-}
-
-int lz4k_compress(const unsigned char *in, size_t in_len, unsigned char *out,
- size_t *out_len, void *wrkmem)
-{
- unsigned char *op = out;
-
- if (in_len > 4096) {
- return -1;
- }
-
- if (__builtin_expect(!!(in_len == 0), 0)) {
- *out_len = 0;
- return -1;
- } else {
- memset(wrkmem, 0, LZ4K_MEM_COMPRESS);
- _lz4k_do_compress(in, in_len, op, out_len, wrkmem);
- }
-
- if (*out_len <= 0) {
- return -1;
- }
-
- return 0;
-}
diff --git a/lib/lz4k/lz4k_decompress.c b/lib/lz4k/lz4k_decompress.c
deleted file mode 100644
index fad686ee0..000000000
--- a/lib/lz4k/lz4k_decompress.c
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * LZ4K Decompressor by Vovo
- */
-#include <linux/lz4k.h>
-#include <linux/types.h>
-
-//#define CONFIG_UBIFS_FS
-static unsigned short lz4k_matchlen_decode[128] =
- { 780, 1298, 1035, 0, 1033, 1553, 1040, 0, 780, 1304, 1039, 0, 1034, 1567, 1293, 0, 780, 1300,
-1035, 0, 1033, 1558, 1040, 0, 780, 1308, 1039, 0, 1034, 1818, 1294, 0, 780, 1298, 1035, 0, 1033, 1555, 1040, 0, 780, 1304, 1039, 0,
-1034, 1813, 1293, 0, 780, 1300, 1035, 0, 1033, 1559, 1040, 0, 780, 1308, 1039, 0, 1034, 1821, 1294, 0,
- 780, 1298, 1035, 0, 1033, 1553, 1040, 0, 780, 1304, 1039, 0, 1034, 1567, 1293, 0, 780, 1300,
- 1035, 0, 1033, 1558, 1040, 0, 780, 1308, 1039, 0, 1034, 1819, 1294, 0, 780, 1298, 1035,
- 0, 1033, 1555, 1040, 0, 780, 1304, 1039, 0, 1034, 1817, 1293, 0, 780, 1300, 1035, 0,
- 1033, 1559, 1040, 0, 780, 1308, 1039, 0, 1034, 1822, 1294, 0,
-};
-
-#ifdef CONFIG_UBIFS_FS
-static unsigned short lz4k_matchlen_decode_hc[256] =
- { 514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2061, 514,
-772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772, 515, 1031, 514, 1029, 515, 1548, 514, 772, 515,
-1288, 514, 1030, 515, 2067, 514, 772, 515, 1031, 514, 1029, 515, 1802, 514, 772, 515, 1291, 514, 1030, 515, 0,
- 514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2065, 514,
- 772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
- 515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2072, 514, 772,
- 515, 1031, 514, 1029, 515, 1808, 514, 772, 515, 1291, 514, 1030, 515, 0,
- 514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2062, 514,
- 772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
- 515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2068, 514, 772,
- 515, 1031, 514, 1029, 515, 1802, 514, 772, 515, 1291, 514, 1030, 515, 0,
- 514, 772, 515, 1031, 514, 1029, 515, 1545, 514, 772, 515, 1288, 514, 1030, 515, 2066, 514,
- 772, 515, 1031, 514, 1029, 515, 1551, 514, 772, 515, 1291, 514, 1030, 515, 0, 514, 772,
- 515, 1031, 514, 1029, 515, 1548, 514, 772, 515, 1288, 514, 1030, 515, 2076, 514, 772,
- 515, 1031, 514, 1029, 515, 1808, 514, 772, 515, 1291, 514, 1030, 515, 0,
-};
-#endif /* CONFIG_UBIFS_FS */
-
-static unsigned short lz4k_matchoff_decode[128] =
- { 1028, 1336, 1040, 1600, 1032, 1568, 1292, 1888, 1028, 1556, 1040, 1852, 1032, 1576, 1304,
-2132, 1028, 1336, 1040, 1836, 1032, 1572, 1292, 1912, 1028, 1564, 1040, 1872, 1032, 1584, 1304, 2156, 1028, 1336, 1040, 1600, 1032,
-1568, 1292, 1904, 1028, 1556, 1040, 1864, 1032, 1576, 1304, 2148, 1028, 1336, 1040, 1844, 1032, 1572, 1292, 2116, 1028, 1564, 1040,
-1880, 1032, 1584, 1304, 2172,
- 1028, 1336, 1040, 1600, 1032, 1568, 1292, 1888, 1028, 1556, 1040, 1852, 1032, 1576, 1304,
- 2140, 1028, 1336, 1040, 1836, 1032, 1572, 1292, 1912, 1028, 1564, 1040, 1872, 1032,
- 1584, 1304, 2164, 1028, 1336, 1040, 1600, 1032, 1568, 1292, 1904, 1028, 1556, 1040,
- 1864, 1032, 1576, 1304, 2152, 1028, 1336, 1040, 1844, 1032, 1572, 1292, 2124, 1028,
- 1564, 1040, 1880, 1032, 1584, 1304, 2176,
-};
-
-#ifdef CONFIG_UBIFS_FS
-static unsigned short lz4k_matchoff_decode_hc[128] =
- { 768, 1560, 1284, 1814, 768, 1836, 1296, 1876, 768, 1820, 1288, 1860, 768, 1856, 1548, 2160,
-768, 1793, 1284, 1822, 768, 1848, 1296, 2144, 768, 1828, 1288, 1868, 768, 1806, 1556, 2176, 768, 1560, 1284, 1818, 768, 1840, 1296, 2136,
-768, 1824, 1288, 1864, 768, 1802, 1548, 2168, 768, 1798, 1284, 1844, 768, 1852, 1296, 2152, 768, 1832, 1288, 1872, 768, 1810, 1556, 2082,
- 768, 1560, 1284, 1814, 768, 1836, 1296, 1876, 768, 1820, 1288, 1860, 768, 1856, 1548, 2164,
- 768, 1793, 1284, 1822, 768, 1848, 1296, 2148, 768, 1828, 1288, 1868, 768, 1806, 1556,
- 2050, 768, 1560, 1284, 1818, 768, 1840, 1296, 2140, 768, 1824, 1288, 1864, 768, 1802,
- 1548, 2172, 768, 1798, 1284, 1844, 768, 1852, 1296, 2156, 768, 1832, 1288, 1872, 768,
- 1810, 1556, 2180,
-};
-#endif /* CONFIG_UBIFS_FS */
-
-static unsigned short lz4k_literallen_decode[128] =
- { 257, 770, 257, 1029, 257, 1027, 257, 1543, 257, 770, 257, 1286, 257, 1028, 257, 1806, 257,
-770, 257, 1029, 257, 1027, 257, 1802, 257, 770, 257, 1289, 257, 1028, 257, 0, 257, 770, 257, 1029, 257, 1027, 257, 1544, 257, 770, 257,
-1286, 257, 1028, 257, 1808, 257, 770, 257, 1029, 257, 1027, 257, 1804, 257, 770, 257, 1289, 257, 1028, 257, 0,
- 257, 770, 257, 1029, 257, 1027, 257, 1543, 257, 770, 257, 1286, 257, 1028, 257, 1807, 257,
- 770, 257, 1029, 257, 1027, 257, 1803, 257, 770, 257, 1289, 257, 1028, 257, 0, 257, 770,
- 257, 1029, 257, 1027, 257, 1544, 257, 770, 257, 1286, 257, 1028, 257, 1809, 257, 770,
- 257, 1029, 257, 1027, 257, 1805, 257, 770, 257, 1289, 257, 1028, 257, 0,
-};
-
-static unsigned short lz4k_literalch_decode[512] =
- { 1024, 2120, 1840, 2327, 1344, 2224, 2060, 2461, 1279, 2151, 1903, 2411, 1794, 2280, 2082,
-2500, 1024, 2132, 1889, 2367, 1537, 2258, 2072, 2479, 1279, 2168, 1920, 2443, 1801, 2292, 2097, 2524, 1024, 2126, 1872, 2358, 1344,
-2240, 2065, 2470, 1279, 2161, 1906, 2433, 1796, 2288, 2089, 2509, 1024, 2146, 1897, 2391, 1568, 2264, 2077, 2490, 1279, 2192, 2053,
-2452, 1808, 2297, 2104, 2537,
- 1024, 2124, 1857, 2346, 1344, 2232, 2062, 2466, 1279, 2156, 1904, 2428, 1795, 2285, 2084,
- 2505, 1024, 2143, 1893, 2377, 1537, 2260, 2075, 2485, 1279, 2180, 2016, 2447, 1802,
- 2295, 2099, 2530, 1024, 2130, 1873, 2363, 1344, 2256, 2067, 2475, 1279, 2165, 1908,
- 2438, 1800, 2290, 2094, 2519, 1024, 2148, 1902, 2396, 1568, 2275, 2079, 2495, 1279,
- 2208, 2055, 2457, 1832, 2300, 2115, 2550,
- 1024, 2123, 1840, 2342, 1344, 2228, 2061, 2463, 1279, 2152, 1903, 2426, 1794, 2284, 2083,
- 2502, 1024, 2136, 1889, 2374, 1537, 2259, 2074, 2482, 1279, 2169, 1920, 2445, 1801,
- 2293, 2098, 2526, 1024, 2127, 1872, 2361, 1344, 2248, 2066, 2473, 1279, 2163, 1906,
- 2435, 1796, 2289, 2092, 2511, 1024, 2147, 1897, 2394, 1568, 2273, 2078, 2493, 1279,
- 2200, 2054, 2454, 1808, 2298, 2114, 2539,
- 1024, 2125, 1857, 2349, 1344, 2236, 2063, 2468, 1279, 2157, 1904, 2430, 1795, 2286, 2085,
- 2507, 1024, 2144, 1893, 2389, 1537, 2261, 2076, 2487, 1279, 2184, 2016, 2450, 1802,
- 2296, 2100, 2534, 1024, 2131, 1873, 2365, 1344, 2257, 2068, 2477, 1279, 2166, 1908,
- 2441, 1800, 2291, 2095, 2522, 1024, 2150, 1902, 2398, 1568, 2277, 2081, 2498, 1279,
- 2216, 2059, 2459, 1832, 2325, 2116, 2557,
- 1024, 2120, 1840, 2329, 1344, 2224, 2060, 2462, 1279, 2151, 1903, 2423, 1794, 2280, 2082,
- 2501, 1024, 2132, 1889, 2373, 1537, 2258, 2072, 2481, 1279, 2168, 1920, 2444, 1801,
- 2292, 2097, 2525, 1024, 2126, 1872, 2359, 1344, 2240, 2065, 2471, 1279, 2161, 1906,
- 2434, 1796, 2288, 2089, 2510, 1024, 2146, 1897, 2393, 1568, 2264, 2077, 2491, 1279,
- 2192, 2053, 2453, 1808, 2297, 2104, 2538,
- 1024, 2124, 1857, 2347, 1344, 2232, 2062, 2467, 1279, 2156, 1904, 2429, 1795, 2285, 2084,
- 2506, 1024, 2143, 1893, 2378, 1537, 2260, 2075, 2486, 1279, 2180, 2016, 2449, 1802,
- 2295, 2099, 2532, 1024, 2130, 1873, 2364, 1344, 2256, 2067, 2476, 1279, 2165, 1908,
- 2439, 1800, 2290, 2094, 2521, 1024, 2148, 1902, 2397, 1568, 2275, 2079, 2497, 1279,
- 2208, 2055, 2458, 1832, 2300, 2115, 2555,
- 1024, 2123, 1840, 2343, 1344, 2228, 2061, 2465, 1279, 2152, 1903, 2427, 1794, 2284, 2083,
- 2503, 1024, 2136, 1889, 2375, 1537, 2259, 2074, 2483, 1279, 2169, 1920, 2446, 1801,
- 2293, 2098, 2527, 1024, 2127, 1872, 2362, 1344, 2248, 2066, 2474, 1279, 2163, 1906,
- 2437, 1796, 2289, 2092, 2518, 1024, 2147, 1897, 2395, 1568, 2273, 2078, 2494, 1279,
- 2200, 2054, 2455, 1808, 2298, 2114, 2543,
- 1024, 2125, 1857, 2357, 1344, 2236, 2063, 2469, 1279, 2157, 1904, 2431, 1795, 2286, 2085,
- 2508, 1024, 2144, 1893, 2390, 1537, 2261, 2076, 2489, 1279, 2184, 2016, 2451, 1802,
- 2296, 2100, 2535, 1024, 2131, 1873, 2366, 1344, 2257, 2068, 2478, 1279, 2166, 1908,
- 2442, 1800, 2291, 2095, 2523, 1024, 2150, 1902, 2410, 1568, 2277, 2081, 2499, 1279,
- 2216, 2059, 2460, 1832, 2326, 2116, 2558,
-};
-
-#define RESERVE_16_BITS() \
-if (remaining_bits <= 16) { \
- bits_buffer32 = bits_buffer32 | (*((unsigned short *)ip)) << remaining_bits; \
- ip += 2; \
- remaining_bits += 16; \
-}
-
-static int lz4k_decompress_simple(const unsigned char *in, size_t in_len, unsigned char *out,
- unsigned char *const op_end)
-{
- unsigned char *op = out;
- const unsigned char *ip = in;
- unsigned int bits_buffer32 = 0;
- unsigned int remaining_bits = 32;
-
- bits_buffer32 = *((unsigned int *)ip);
- ip += 4;
- bits_buffer32 = bits_buffer32 >> 1;
- remaining_bits -= 1;
-
- /* check lz4k tag */
- if (*((unsigned int *)(in + in_len - 4)) != LZ4K_TAG) {
- return -1;
- }
-
- while (1) {
- RESERVE_16_BITS();
- if ((bits_buffer32 & 1) == 0) {
- if ((bits_buffer32 & 2) == 0) {
- unsigned short value;
- int bits;
- value = lz4k_literalch_decode[(bits_buffer32 >> 2) & 0x1ff];
- bits = value >> 8;
- *op++ = value & 0xff;
- bits_buffer32 = bits_buffer32 >> (bits + 2);
- remaining_bits -= bits + 2;
- } else {
- int litlen;
- unsigned short value;
- value = lz4k_literallen_decode[(bits_buffer32 >> 1) & 0x7f];
- if (value != 0) {
- int bits = value >> 8;
- litlen = value & 0xff;
- bits_buffer32 = bits_buffer32 >> (bits + 1);
- remaining_bits -= bits + 1;
- } else {
- if (remaining_bits < 18) {
- bits_buffer32 =
- bits_buffer32 | ((*ip) << remaining_bits);
- ip += 1;
- remaining_bits += 8;
- }
- litlen = ((bits_buffer32 >> 6) & 0xfff) + 1;
- bits_buffer32 = bits_buffer32 >> 18;
- remaining_bits -= 18;
- }
-
- while (1) {
- while (remaining_bits > 8) {
- unsigned short value;
- int bits;
- value =
- lz4k_literalch_decode[bits_buffer32 & 0x1ff];
- bits = value >> 8;
- *op++ = value & 0xff;
- bits_buffer32 = bits_buffer32 >> bits;
- remaining_bits -= bits;
- if (--litlen == 0) {
- goto break_literal;
- }
- }
- bits_buffer32 =
- bits_buffer32 | (*((unsigned int *)ip)) <<
- remaining_bits;
- ip += 3;
- remaining_bits += 24;
- }
- }
-
- break_literal:
- if (__builtin_expect(!!(op == op_end), 0))
- break;
- } else {
- bits_buffer32 = bits_buffer32 >> 1;
- remaining_bits -= 1;
- }
-
- {
- int offset;
- int len;
- RESERVE_16_BITS();
- if ((bits_buffer32 & 1) == 0) {
- unsigned short value =
- lz4k_matchoff_decode[(bits_buffer32 & 0xff) >> 1];
- int bits = value >> 8;
- offset = value & 0xff;
- bits_buffer32 = bits_buffer32 >> bits;
- remaining_bits -= bits;
- } else {
- offset = (bits_buffer32 >> 1) & 0xfff;
- bits_buffer32 = bits_buffer32 >> 13;
- remaining_bits -= 13;
- }
- RESERVE_16_BITS();
-
- if ((bits_buffer32 & 1) == 0) {
- len = 3 + ((bits_buffer32 >> 1) & 1);
- bits_buffer32 = bits_buffer32 >> 2;
- remaining_bits -= 2;
- } else if ((bits_buffer32 & 2) == 0) {
- len = 5 + ((bits_buffer32 >> 2) & 3);
- bits_buffer32 = bits_buffer32 >> 4;
- remaining_bits -= 4;
- } else {
- unsigned short value =
- lz4k_matchlen_decode[(bits_buffer32 >> 2) & 0x7f];
- if (value != 0) {
- int bits = value >> 8;
- len = value & 0xff;
- bits_buffer32 = bits_buffer32 >> (bits + 2);
- remaining_bits -= (bits + 2);
- } else {
- len = (bits_buffer32 >> 4) & 0xfff;
- bits_buffer32 = bits_buffer32 >> 16;
- remaining_bits -= 16;
- }
- }
-
- if (__builtin_expect(!!((offset >> 2) != 0), 1)) {
- const unsigned char *m_pos = op - offset;
- if ((len & 1) != 0) {
- *op++ = *m_pos++;
- --len;
- }
- if ((len & 2) != 0) {
- *(unsigned short *)op = *(unsigned short *)m_pos;
- op += 2;
- m_pos += 2;
- len -= 2;
- }
- while (len > 0) {
- *(unsigned int *)op = *(unsigned int *)m_pos;
- op += 4;
- m_pos += 4;
- len -= 4;
- }
- } else if (__builtin_expect(!!(offset == 1), 1)) {
- unsigned int value = *(op - 1);
- value = value | (value << 8);
- value = value | (value << 16);
- if ((len & 1) != 0) {
- *op++ = (unsigned char)value;
- --len;
- }
- if ((len & 2) != 0) {
- *(unsigned short *)op = (unsigned short)value;
- op += 2;
- len -= 2;
- }
- while (len > 0) {
- *(unsigned int *)op = (unsigned int)value;
- op += 4;
- len -= 4;
- }
- } else {
- const unsigned char *m_pos = op - offset;
- if ((len & 1) != 0) {
- *op++ = *m_pos++;
- --len;
- }
- do {
- *((unsigned short *)op) = *((unsigned short *)m_pos);
- op += 2;
- m_pos += 2;
- len -= 2;
- } while (len != 0);
- }
- }
- if (__builtin_expect(!!(op == op_end), 0))
- break;
- }
- if (op != op_end) {
- return -1;
- }
-
- return 0;
-}
-
-#ifdef CONFIG_UBIFS_FS
-static int lz4k_decompress_hc(const unsigned char *in, size_t in_len, unsigned char *out,
- unsigned char *const op_end)
-{
- unsigned char *op = out;
- const unsigned char *ip = in;
- unsigned int bits_buffer32 = 0;
- unsigned int remaining_bits = 32;
- int previous_off = 0;
-
- bits_buffer32 = *((unsigned int *)ip);
- ip += 4;
- bits_buffer32 = bits_buffer32 >> 1;
- remaining_bits -= 1;
-
- while (1) {
- RESERVE_16_BITS();
- if ((bits_buffer32 & 1) == 0) {
- if ((bits_buffer32 & 2) == 0) {
- *op++ = (bits_buffer32 >> 2) & 0xff;
- bits_buffer32 = bits_buffer32 >> (8 + 2);
- remaining_bits -= 8 + 2;
- } else {
- int litlen;
- unsigned short value;
- value = lz4k_literallen_decode[(bits_buffer32 >> 1) & 0x7f];
- if (value != 0) {
- int bits = value >> 8;
- litlen = value & 0xff;
- bits_buffer32 = bits_buffer32 >> (bits + 1);
- remaining_bits -= bits + 1;
- } else {
- if (remaining_bits < 18) {
- bits_buffer32 =
- bits_buffer32 | ((*ip) << remaining_bits);
- ip += 1;
- remaining_bits += 8;
- }
- litlen = ((bits_buffer32 >> 6) & 0xfff) + 1;
- bits_buffer32 = bits_buffer32 >> 18;
- remaining_bits -= 18;
- }
-
- RESERVE_16_BITS();
- if ((litlen & 1) != 0) {
- *op++ = bits_buffer32 & 0xff;
- bits_buffer32 = bits_buffer32 >> 8;
- remaining_bits -= 8;
- --litlen;
- RESERVE_16_BITS();
- }
- do {
- *(unsigned short *)op = bits_buffer32 & 0xffff;
- bits_buffer32 =
- (bits_buffer32 >> 16) | (*(unsigned short *)ip) <<
- (remaining_bits - 16);
- ip += 2;
- op += 2;
- litlen -= 2;
- } while (litlen > 0);
- }
-
- /*break_literal:*/
- if (__builtin_expect(!!(op == op_end), 0))
- break;
- } else {
- bits_buffer32 = bits_buffer32 >> 1;
- remaining_bits -= 1;
- }
-
- {
- int offset;
- int len;
- RESERVE_16_BITS();
- if ((bits_buffer32 & 1) == 0) {
- unsigned short value =
- lz4k_matchoff_decode_hc[(bits_buffer32 & 0xff) >> 1];
- int bits = value >> 8;
- int code = value & 0xff;
- if (code == 0) { /* previous */
- offset = previous_off;
- } else {
- offset = code;
- }
- bits_buffer32 = bits_buffer32 >> bits;
- remaining_bits -= bits;
- } else {
- int index = op - out;
- int bits = 32 - __builtin_clz(index);
- offset = (bits_buffer32 >> 1) & ((1 << bits) - 1);
- bits_buffer32 = bits_buffer32 >> (bits + 1);
- remaining_bits -= bits + 1;
- }
- previous_off = offset;
- RESERVE_16_BITS();
-
- {
- if ((bits_buffer32 & 0x1f) != 0x1f) {
- unsigned short value =
- lz4k_matchlen_decode_hc[(bits_buffer32) & 0xff];
- int bits = value >> 8;
- len = value & 0xff;
- bits_buffer32 = bits_buffer32 >> bits;
- remaining_bits -= bits;
- } else {
- len = (bits_buffer32 >> 5) & 0xfff;
- bits_buffer32 = bits_buffer32 >> 17;
- remaining_bits -= 17;
- }
- }
-
- if (__builtin_expect(!!((offset >> 2) != 0), 1)) {
- const unsigned char *m_pos = op - offset;
- if ((len & 1) != 0) {
- *op++ = *m_pos++;
- --len;
- }
- if ((len & 2) != 0) {
- *(unsigned short *)op = *(unsigned short *)m_pos;
- op += 2;
- m_pos += 2;
- len -= 2;
- }
- while (len > 0) {
- *(unsigned int *)op = *(unsigned int *)m_pos;
- op += 4;
- m_pos += 4;
- len -= 4;
- }
- } else if (__builtin_expect(!!(offset == 1), 1)) {
- unsigned int value = *(op - 1);
- value = value | (value << 8);
- value = value | (value << 16);
- if ((len & 1) != 0) {
- *op++ = (unsigned char)value;
- --len;
- }
- if ((len & 2) != 0) {
- *(unsigned short *)op = (unsigned short)value;
- op += 2;
- len -= 2;
- }
- while (len > 0) {
- *(unsigned int *)op = (unsigned int)value;
- op += 4;
- len -= 4;
- }
- } else {
- const unsigned char *m_pos = op - offset;
- if ((len & 1) != 0) {
- *op++ = *m_pos++;
- --len;
- }
- do {
- *((unsigned short *)op) = *((unsigned short *)m_pos);
- op += 2;
- m_pos += 2;
- len -= 2;
- } while (len != 0);
- }
- }
- if (__builtin_expect(!!(op == op_end), 0))
- break;
- }
- if (op != op_end) {
- return -1;
- }
-
- return 0;
-}
-#endif /* CONFIG_UBIFS_FS */
-
-int lz4k_decompress_safe(const unsigned char *in, size_t in_len, unsigned char *out,
- size_t *pout_len)
-{
- int result = 0;
- unsigned char *const op_end = out + *pout_len;
-
-
- if (*pout_len > 4096) {
- return -1;
- }
- if (in_len == 0) {
- return -1;
- }
-
- result = lz4k_decompress_simple(in, in_len, out, op_end);
-
-
- return result;
-}
-
-#ifdef CONFIG_UBIFS_FS
-
-int lz4k_decompress_ubifs(const unsigned char *in, size_t in_len, unsigned char *out,
- size_t *pout_len)
-{
- int result = 0;
- unsigned char *const op_end = out + *pout_len;
-
-
- if (*pout_len > 4096) {
- return -1;
- }
- if (in_len == 0) {
- return -1;
- }
- if ((*in & 1) == 0) {
- result = lz4k_decompress_simple(in, in_len, out, op_end);
- } else {
- result = lz4k_decompress_hc(in, in_len, out, op_end);
- }
-
-
- return result;
-}
-#endif /* CONFIG_UBIFS_FS */
diff --git a/lib/lz4k/lz4k_init.c b/lib/lz4k/lz4k_init.c
deleted file mode 100644
index a18f8d751..000000000
--- a/lib/lz4k/lz4k_init.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-
-int lz4k_compress(const unsigned char *src, size_t src_len,
- unsigned char *dst, size_t *dst_len, void *wrkmem);
-int lz4k_decompress_safe(const unsigned char *src, size_t src_len,
- unsigned char *dst, size_t *dst_len);
-
-#ifdef CONFIG_ZRAM
-/* Set ZRAM hooks */
-extern void zram_set_hooks(void *compress_func, void *decompress_func, const char *name);
-#endif
-static int __init lz4k_init(void)
-{
-#ifdef CONFIG_ZRAM
- zram_set_hooks(&lz4k_compress, &lz4k_decompress_safe, "LZ4K");
-#endif
- return 0;
-}
-
-static void __exit lz4k_exit(void)
-{
- printk(KERN_INFO "Bye LZ4K!\n");
-}
-module_init(lz4k_init);
-module_exit(lz4k_exit);