xref: /OK3568_Linux_fs/kernel/arch/arm/boot/compressed/decompress.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun #define _LINUX_STRING_H_
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #include <linux/compiler.h>	/* for inline */
5*4882a593Smuzhiyun #include <linux/types.h>	/* for size_t */
6*4882a593Smuzhiyun #include <linux/stddef.h>	/* for NULL */
7*4882a593Smuzhiyun #include <linux/linkage.h>
8*4882a593Smuzhiyun #include <asm/string.h>
9*4882a593Smuzhiyun #include "misc.h"
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #define STATIC static
12*4882a593Smuzhiyun #define STATIC_RW_DATA	/* non-static please */
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun /* Diagnostic functions */
15*4882a593Smuzhiyun #ifdef DEBUG
16*4882a593Smuzhiyun #  define Assert(cond,msg) {if(!(cond)) error(msg);}
17*4882a593Smuzhiyun #  define Trace(x) fprintf x
18*4882a593Smuzhiyun #  define Tracev(x) {if (verbose) fprintf x ;}
19*4882a593Smuzhiyun #  define Tracevv(x) {if (verbose>1) fprintf x ;}
20*4882a593Smuzhiyun #  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
21*4882a593Smuzhiyun #  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
22*4882a593Smuzhiyun #else
23*4882a593Smuzhiyun #  define Assert(cond,msg)
24*4882a593Smuzhiyun #  define Trace(x)
25*4882a593Smuzhiyun #  define Tracev(x)
26*4882a593Smuzhiyun #  define Tracevv(x)
27*4882a593Smuzhiyun #  define Tracec(c,x)
28*4882a593Smuzhiyun #  define Tracecv(c,x)
29*4882a593Smuzhiyun #endif
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun /* Not needed, but used in some headers pulled in by decompressors */
32*4882a593Smuzhiyun extern char * strstr(const char * s1, const char *s2);
33*4882a593Smuzhiyun extern size_t strlen(const char *s);
34*4882a593Smuzhiyun extern int memcmp(const void *cs, const void *ct, size_t count);
35*4882a593Smuzhiyun extern char * strchrnul(const char *, int);
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #ifdef CONFIG_KERNEL_GZIP
38*4882a593Smuzhiyun #include "../../../../lib/decompress_inflate.c"
39*4882a593Smuzhiyun #endif
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #ifdef CONFIG_KERNEL_LZO
42*4882a593Smuzhiyun #include "../../../../lib/decompress_unlzo.c"
43*4882a593Smuzhiyun #endif
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #ifdef CONFIG_KERNEL_LZMA
46*4882a593Smuzhiyun #include "../../../../lib/decompress_unlzma.c"
47*4882a593Smuzhiyun #endif
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #ifdef CONFIG_KERNEL_XZ
50*4882a593Smuzhiyun /* Prevent KASAN override of string helpers in decompressor */
51*4882a593Smuzhiyun #undef memmove
52*4882a593Smuzhiyun #define memmove memmove
53*4882a593Smuzhiyun #undef memcpy
54*4882a593Smuzhiyun #define memcpy memcpy
55*4882a593Smuzhiyun #include "../../../../lib/decompress_unxz.c"
56*4882a593Smuzhiyun #endif
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #ifdef CONFIG_KERNEL_LZ4
59*4882a593Smuzhiyun #include "../../../../lib/decompress_unlz4.c"
60*4882a593Smuzhiyun #endif
61*4882a593Smuzhiyun 
do_decompress(u8 * input,int len,u8 * output,void (* error)(char * x))62*4882a593Smuzhiyun int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
63*4882a593Smuzhiyun {
64*4882a593Smuzhiyun 	return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
65*4882a593Smuzhiyun }
66