linux/lib/decompress_unlzma.c

/* Lzma decompressor for Linux kernel. Shamelessly snarfed
 *from busybox 1.1.1
 *
 *Linux kernel adaptation
 *Copyright (C) 2006  Alain < [email protected] >
 *
 *Based on small lzma deflate implementation/Small range coder
 *implementation for lzma.
 *Copyright (C) 2006  Aurelien Jacobs < [email protected] >
 *
 *Based on LzmaDecode.c from the LZMA SDK 4.22 (https://www.7-zip.org/)
 *Copyright (C) 1999-2005  Igor Pavlov
 *
 *Copyrights of the parts, see headers below.
 *
 *
 *This program is free software; you can redistribute it and/or
 *modify it under the terms of the GNU Lesser General Public
 *License as published by the Free Software Foundation; either
 *version 2.1 of the License, or (at your option) any later version.
 *
 *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
 *Lesser General Public License for more details.
 *
 *You should have received a copy of the GNU Lesser General Public
 *License along with this library; if not, write to the Free Software
 *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifdef STATIC
#define PREBOOT
#else
#include <linux/decompress/unlzma.h>
#endif /* STATIC */

#include <linux/decompress/mm.h>

#ifndef MIN
#define MIN
#endif

static long long INIT read_int(unsigned char *ptr, int size)
{}

#define ENDIAN_CONVERT(x)


/* Small range coder implementation for lzma.
 *Copyright (C) 2006  Aurelien Jacobs < [email protected] >
 *
 *Based on LzmaDecode.c from the LZMA SDK 4.22 (https://www.7-zip.org/)
 *Copyright (c) 1999-2005  Igor Pavlov
 */

#include <linux/compiler.h>

#define LZMA_IOBUF_SIZE

struct rc {};


#define RC_TOP_BITS
#define RC_MOVE_BITS
#define RC_MODEL_TOTAL_BITS


static long INIT nofill(void *buffer, unsigned long len)
{}

/* Called twice: once at startup and once in rc_normalize() */
static void INIT rc_read(struct rc *rc)
{}

/* Called once */
static inline void INIT rc_init(struct rc *rc,
				       long (*fill)(void*, unsigned long),
				       char *buffer, long buffer_size)
{}

static inline void INIT rc_init_code(struct rc *rc)
{}


/* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
static void INIT rc_do_normalize(struct rc *rc)
{}
static inline void INIT rc_normalize(struct rc *rc)
{}

/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
 *Because we want to always expose (rc->code < rc->bound) to optimizer
 */
static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
{}
static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
{}

/* Called ~10 times, but very small, thus inlined */
static inline void INIT rc_update_bit_0(struct rc *rc, uint16_t *p)
{}
static inline void INIT rc_update_bit_1(struct rc *rc, uint16_t *p)
{}

/* Called 4 times in unlzma loop */
static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
{}

/* Called once */
static inline int INIT rc_direct_bit(struct rc *rc)
{}

/* Called twice */
static inline void INIT
rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
{}


/*
 * Small lzma deflate implementation.
 * Copyright (C) 2006  Aurelien Jacobs < [email protected] >
 *
 * Based on LzmaDecode.c from the LZMA SDK 4.22 (https://www.7-zip.org/)
 * Copyright (C) 1999-2005  Igor Pavlov
 */


struct lzma_header {} __attribute__ ((packed)) ;


#define LZMA_BASE_SIZE
#define LZMA_LIT_SIZE

#define LZMA_NUM_POS_BITS_MAX

#define LZMA_LEN_NUM_LOW_BITS
#define LZMA_LEN_NUM_MID_BITS
#define LZMA_LEN_NUM_HIGH_BITS

#define LZMA_LEN_CHOICE
#define LZMA_LEN_CHOICE_2
#define LZMA_LEN_LOW
#define LZMA_LEN_MID
#define LZMA_LEN_HIGH
#define LZMA_NUM_LEN_PROBS

#define LZMA_NUM_STATES
#define LZMA_NUM_LIT_STATES

#define LZMA_START_POS_MODEL_INDEX
#define LZMA_END_POS_MODEL_INDEX
#define LZMA_NUM_FULL_DISTANCES

#define LZMA_NUM_POS_SLOT_BITS
#define LZMA_NUM_LEN_TO_POS_STATES

#define LZMA_NUM_ALIGN_BITS

#define LZMA_MATCH_MIN_LEN

#define LZMA_IS_MATCH
#define LZMA_IS_REP
#define LZMA_IS_REP_G0
#define LZMA_IS_REP_G1
#define LZMA_IS_REP_G2
#define LZMA_IS_REP_0_LONG
#define LZMA_POS_SLOT
#define LZMA_SPEC_POS
#define LZMA_ALIGN
#define LZMA_LEN_CODER
#define LZMA_REP_LEN_CODER
#define LZMA_LITERAL


struct writer {};

struct cstate {};

static inline size_t INIT get_pos(struct writer *wr)
{}

static inline uint8_t INIT peek_old_byte(struct writer *wr,
						uint32_t offs)
{}

static inline int INIT write_byte(struct writer *wr, uint8_t byte)
{}


static inline int INIT copy_byte(struct writer *wr, uint32_t offs)
{}

static inline int INIT copy_bytes(struct writer *wr,
					 uint32_t rep0, int len)
{}

static inline int INIT process_bit0(struct writer *wr, struct rc *rc,
				     struct cstate *cst, uint16_t *p,
				     int pos_state, uint16_t *prob,
				     int lc, uint32_t literal_pos_mask) {}

static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
					    struct cstate *cst, uint16_t *p,
					    int pos_state, uint16_t *prob) {}



STATIC inline int INIT unlzma(unsigned char *buf, long in_len,
			      long (*fill)(void*, unsigned long),
			      long (*flush)(void*, unsigned long),
			      unsigned char *output,
			      long *posp,
			      void(*error)(char *x)
	)
{}

#ifdef PREBOOT
STATIC int INIT __decompress(unsigned char *buf, long in_len,
			      long (*fill)(void*, unsigned long),
			      long (*flush)(void*, unsigned long),
			      unsigned char *output, long out_len,
			      long *posp,
			      void (*error)(char *x))
{
	return unlzma(buf, in_len - 4, fill, flush, output, posp, error);
}
#endif