2N/A/* xz_private.h - Private includes and definitions */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2010 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A/*
2N/A * This file is based on code from XZ embedded project
2N/A * http://tukaani.org/xz/embedded.html
2N/A */
2N/A
2N/A#ifndef XZ_PRIVATE_H
2N/A#define XZ_PRIVATE_H
2N/A
2N/A/*
2N/A * For userspace builds, use a separate header to define the required
2N/A * macros and functions. This makes it easier to adapt the code into
2N/A * different environments and avoids clutter in the Linux kernel tree.
2N/A */
2N/A#include "xz_config.h"
2N/A
2N/A/*
2N/A * If any of the BCJ filter decoders are wanted, define XZ_DEC_BCJ.
2N/A * XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
2N/A */
2N/A#ifndef XZ_DEC_BCJ
2N/A# if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \
2N/A || defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \
2N/A || defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \
2N/A || defined(XZ_DEC_SPARC)
2N/A# define XZ_DEC_BCJ
2N/A# endif
2N/A#endif
2N/A
2N/A/*
2N/A * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
2N/A * before calling xz_dec_lzma2_run().
2N/A */
2N/Astruct xz_dec_lzma2 * xz_dec_lzma2_create(
2N/A uint32_t dict_max);
2N/A
2N/A/*
2N/A * Decode the LZMA2 properties (one byte) and reset the decoder. Return
2N/A * XZ_OK on success, XZ_MEMLIMIT_ERROR if the preallocated dictionary is not
2N/A * big enough, and XZ_OPTIONS_ERROR if props indicates something that this
2N/A * decoder doesn't support.
2N/A */
2N/Aenum xz_ret xz_dec_lzma2_reset(
2N/A struct xz_dec_lzma2 *s, uint8_t props);
2N/A
2N/A/* Decode raw LZMA2 stream from b->in to b->out. */
2N/Aenum xz_ret xz_dec_lzma2_run(
2N/A struct xz_dec_lzma2 *s, struct xz_buf *b);
2N/A
2N/A/* Free the memory allocated for the LZMA2 decoder. */
2N/Avoid xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
2N/A
2N/A/*
2N/A * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before
2N/A * calling xz_dec_bcj_run().
2N/A */
2N/Astruct xz_dec_bcj * xz_dec_bcj_create(bool single_call);
2N/A
2N/A/*
2N/A * Decode the Filter ID of a BCJ filter. This implementation doesn't
2N/A * support custom start offsets, so no decoding of Filter Properties
2N/A * is needed. Returns XZ_OK if the given Filter ID is supported.
2N/A * Otherwise XZ_OPTIONS_ERROR is returned.
2N/A */
2N/Aenum xz_ret xz_dec_bcj_reset(
2N/A struct xz_dec_bcj *s, uint8_t id);
2N/A
2N/A/*
2N/A * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is
2N/A * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
2N/A * must be called directly.
2N/A */
2N/Aenum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
2N/A struct xz_dec_lzma2 *lzma2, struct xz_buf *b);
2N/A
2N/A/* Free the memory allocated for the BCJ filters. */
2N/A#define xz_dec_bcj_end(s) kfree(s)
2N/A
2N/A#endif