2019-08-01 23:46:36 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2009
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GZIP_H
|
|
|
|
#define __GZIP_H
|
|
|
|
|
2020-05-11 01:39:58 +08:00
|
|
|
struct blk_desc;
|
|
|
|
|
2019-08-01 23:46:36 +08:00
|
|
|
/**
|
|
|
|
* gzip_parse_header() - Parse a header from a gzip file
|
|
|
|
*
|
|
|
|
* This returns the length of the header.
|
|
|
|
*
|
|
|
|
* @src: Pointer to gzip file
|
|
|
|
* @len: Length of data
|
2022-01-20 01:05:50 +08:00
|
|
|
* Return: length of header in bytes, or -1 if not enough data
|
2019-08-01 23:46:36 +08:00
|
|
|
*/
|
|
|
|
int gzip_parse_header(const unsigned char *src, unsigned long len);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gunzip() - Decompress gzipped data
|
|
|
|
*
|
|
|
|
* @dst: Destination for uncompressed data
|
|
|
|
* @dstlen: Size of destination buffer
|
|
|
|
* @src: Source data to decompress
|
|
|
|
* @lenp: Returns length of uncompressed data
|
2022-01-20 01:05:50 +08:00
|
|
|
* Return: 0 if OK, -1 on error
|
2019-08-01 23:46:36 +08:00
|
|
|
*/
|
|
|
|
int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zunzip() - Uncompress blocks compressed with zlib without headers
|
|
|
|
*
|
|
|
|
* @dst: Destination for uncompressed data
|
|
|
|
* @dstlen: Size of destination buffer
|
|
|
|
* @src: Source data to decompress
|
|
|
|
* @lenp: On entry, length data at @src. On exit, number of bytes used from @src
|
|
|
|
* @stoponerr: 0 to continue when a decode error is found, 1 to stop
|
|
|
|
* @offset: start offset within the src buffer
|
2022-01-20 01:05:50 +08:00
|
|
|
* Return: 0 if OK, -1 on error
|
2019-08-01 23:46:36 +08:00
|
|
|
*/
|
|
|
|
int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
|
|
|
|
int stoponerr, int offset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gzwrite progress indicators: defined weak to allow board-specific
|
|
|
|
* overrides:
|
|
|
|
*
|
|
|
|
* gzwrite_progress_init called on startup
|
|
|
|
* gzwrite_progress called during decompress/write loop
|
|
|
|
* gzwrite_progress_finish called at end of loop to
|
|
|
|
* indicate success (retcode=0) or failure
|
|
|
|
*/
|
2021-09-25 21:03:13 +08:00
|
|
|
void gzwrite_progress_init(ulong expected_size);
|
2019-08-01 23:46:36 +08:00
|
|
|
|
2021-09-25 21:03:13 +08:00
|
|
|
void gzwrite_progress(int iteration, ulong bytes_written, ulong total_bytes);
|
2019-08-01 23:46:36 +08:00
|
|
|
|
2021-09-25 21:03:13 +08:00
|
|
|
void gzwrite_progress_finish(int retcode, ulong totalwritten, ulong totalsize,
|
2019-08-01 23:46:36 +08:00
|
|
|
u32 expected_crc, u32 calculated_crc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gzwrite() - decompress and write gzipped image from memory to block device
|
|
|
|
*
|
|
|
|
* @src: compressed image address
|
|
|
|
* @len: compressed image length in bytes
|
|
|
|
* @dev: block device descriptor
|
|
|
|
* @szwritebuf: bytes per write (pad to erase size)
|
|
|
|
* @startoffs: offset in bytes of first write
|
|
|
|
* @szexpected: expected uncompressed length, may be zero to use gzip trailer
|
|
|
|
* for files under 4GiB
|
2022-01-20 01:05:50 +08:00
|
|
|
* Return: 0 if OK, -1 on error
|
2019-08-01 23:46:36 +08:00
|
|
|
*/
|
|
|
|
int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf,
|
2021-09-25 21:03:13 +08:00
|
|
|
ulong startoffs, ulong szexpected);
|
2019-08-01 23:46:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gzip()- Compress data into a buffer using the gzip algorithm
|
|
|
|
*
|
|
|
|
* @dst: Destination buffer for compressed data
|
|
|
|
* @lenp: On entry, space available in destination buffer (in bytes). On exit,
|
|
|
|
* number of bytes used in the buffer
|
|
|
|
* @src: Source data to compress
|
|
|
|
* @srclen: Size of source data
|
2022-01-20 01:05:50 +08:00
|
|
|
* Return: 0 if OK, -1 on error
|
2019-08-01 23:46:36 +08:00
|
|
|
*/
|
|
|
|
int gzip(void *dst, unsigned long *lenp, unsigned char *src, ulong srclen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zzip() - Compress blocks with zlib
|
|
|
|
*
|
|
|
|
* @dst: Destination for compressed data
|
|
|
|
* @lenp: On entry, length data at @dst. On exit, number of bytes written to
|
|
|
|
* @dst
|
|
|
|
* @src: Source data to compress
|
|
|
|
* @srclen: Size of source data
|
|
|
|
* @stoponerr: 0 to continue when a decode error is found, 1 to stop
|
|
|
|
* @func: Some sort of function that is called to do something. !ADD DOCS HERE!
|
|
|
|
*/
|
|
|
|
int zzip(void *dst, ulong *lenp, unsigned char *src, ulong srclen,
|
|
|
|
int stoponerr, int (*func)(ulong, ulong));
|
|
|
|
|
|
|
|
#endif
|