diff options
author | Hemant Kumar <hemant@linux.vnet.ibm.com> | 2017-06-22 17:45:20 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-06-27 15:31:52 +1000 |
commit | c3aad53b91d2295dc7950c1d064d63a314f7b98a (patch) | |
tree | 3b815fb88d11b2ec58f6f8c91d4a2521b783af13 /libxz/xz_stream.h | |
parent | 4dcc361183b58b2e68f4ebbd6a84d758c90776e0 (diff) | |
download | skiboot-c3aad53b91d2295dc7950c1d064d63a314f7b98a.zip skiboot-c3aad53b91d2295dc7950c1d064d63a314f7b98a.tar.gz skiboot-c3aad53b91d2295dc7950c1d064d63a314f7b98a.tar.bz2 |
skiboot: Add a library for xz
This patch adds a library for compression/decompression using xz.
The code comes from http://tukaani.org/xz/embedded.html.
The codebase has been kept as-is with a new Makefile.inc.
For libxz/Makefile.inc and Makefile.main :
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Acked-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libxz/xz_stream.h')
-rw-r--r-- | libxz/xz_stream.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libxz/xz_stream.h b/libxz/xz_stream.h new file mode 100644 index 0000000..c0fcd58 --- /dev/null +++ b/libxz/xz_stream.h @@ -0,0 +1,62 @@ +/* + * Definitions for handling the .xz file format + * + * Author: Lasse Collin <lasse.collin@tukaani.org> + * + * This file has been put into the public domain. + * You can do whatever you want with this file. + */ + +#ifndef XZ_STREAM_H +#define XZ_STREAM_H + +#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32 + #include <linux/crc32.h> + #undef crc32 + #define xz_crc32(buf, size, crc) \ + (~crc32_le(~(uint32_t)(crc), buf, size)) +#endif + +/* + * See the .xz file format specification at + * http://tukaani.org/xz/xz-file-format.txt + * to understand the container format. + */ + +#define STREAM_HEADER_SIZE 12 + +#define HEADER_MAGIC "\3757zXZ" +#define HEADER_MAGIC_SIZE 6 + +#define FOOTER_MAGIC "YZ" +#define FOOTER_MAGIC_SIZE 2 + +/* + * Variable-length integer can hold a 63-bit unsigned integer or a special + * value indicating that the value is unknown. + * + * Experimental: vli_type can be defined to uint32_t to save a few bytes + * in code size (no effect on speed). Doing so limits the uncompressed and + * compressed size of the file to less than 256 MiB and may also weaken + * error detection slightly. + */ +typedef uint64_t vli_type; + +#define VLI_MAX ((vli_type)-1 / 2) +#define VLI_UNKNOWN ((vli_type)-1) + +/* Maximum encoded size of a VLI */ +#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7) + +/* Integrity Check types */ +enum xz_check { + XZ_CHECK_NONE = 0, + XZ_CHECK_CRC32 = 1, + XZ_CHECK_CRC64 = 4, + XZ_CHECK_SHA256 = 10 +}; + +/* Maximum possible Check ID */ +#define XZ_CHECK_MAX 15 + +#endif |