1/* 2 * Decompression convenience functions 3 * 4 * Copyright 2007 David Gibson, IBM Corporation. 5 * 6 * This file is licensed under the terms of the GNU General Public 7 * License version 2. This program is licensed "as is" without any 8 * warranty of any kind, whether express or implied. 9 */ 10#ifndef _PPC_BOOT_GUNZIP_UTIL_H_ 11#define _PPC_BOOT_GUNZIP_UTIL_H_ 12 13#include "zlib.h" 14 15/* 16 * These functions are designed to make life easy for decompressing 17 * kernel images, initrd images or any other gzip compressed image, 18 * particularly if its useful to decompress part of the image (e.g. to 19 * examine headers) before decompressing the remainder. 20 * 21 * To use: 22 * - declare a gunzip_state structure 23 * - use gunzip_start() to initialize the state, associating it 24 * with a stream of compressed data 25 * - use gunzip_partial(), gunzip_exactly() and gunzip_discard() 26 * in any combination to extract pieces of data from the stream 27 * - Finally use gunzip_finish() to extract the tail of the 28 * compressed stream and wind up zlib 29 */ 30 31/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */ 32#define GUNZIP_SCRATCH_SIZE 46912 33 34struct gunzip_state { 35 z_stream s; 36 char scratch[46912]; 37}; 38 39void gunzip_start(struct gunzip_state *state, void *src, int srclen); 40int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen); 41void gunzip_exactly(struct gunzip_state *state, void *dst, int len); 42void gunzip_discard(struct gunzip_state *state, int len); 43int gunzip_finish(struct gunzip_state *state, void *dst, int len); 44 45#endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */ 46