1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 * gzip_parse_header() - Parse a header from a gzip file
13 * This returns the length of the header.
15 * @src: Pointer to gzip file
16 * @len: Length of data
17 * @return length of header in bytes, or -1 if not enough data
19 int gzip_parse_header(const unsigned char *src, unsigned long len);
22 * gunzip() - Decompress gzipped data
24 * @dst: Destination for uncompressed data
25 * @dstlen: Size of destination buffer
26 * @src: Source data to decompress
27 * @lenp: Returns length of uncompressed data
28 * @return 0 if OK, -1 on error
30 int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
33 * zunzip() - Uncompress blocks compressed with zlib without headers
35 * @dst: Destination for uncompressed data
36 * @dstlen: Size of destination buffer
37 * @src: Source data to decompress
38 * @lenp: On entry, length data at @src. On exit, number of bytes used from @src
39 * @stoponerr: 0 to continue when a decode error is found, 1 to stop
40 * @offset: start offset within the src buffer
41 * @return 0 if OK, -1 on error
43 int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
44 int stoponerr, int offset);
47 * gzwrite progress indicators: defined weak to allow board-specific
50 * gzwrite_progress_init called on startup
51 * gzwrite_progress called during decompress/write loop
52 * gzwrite_progress_finish called at end of loop to
53 * indicate success (retcode=0) or failure
55 void gzwrite_progress_init(u64 expected_size);
57 void gzwrite_progress(int iteration, u64 bytes_written, u64 total_bytes);
59 void gzwrite_progress_finish(int retcode, u64 totalwritten, u64 totalsize,
60 u32 expected_crc, u32 calculated_crc);
63 * gzwrite() - decompress and write gzipped image from memory to block device
65 * @src: compressed image address
66 * @len: compressed image length in bytes
67 * @dev: block device descriptor
68 * @szwritebuf: bytes per write (pad to erase size)
69 * @startoffs: offset in bytes of first write
70 * @szexpected: expected uncompressed length, may be zero to use gzip trailer
71 * for files under 4GiB
72 * @return 0 if OK, -1 on error
74 int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf,
75 u64 startoffs, u64 szexpected);
78 * gzip()- Compress data into a buffer using the gzip algorithm
80 * @dst: Destination buffer for compressed data
81 * @lenp: On entry, space available in destination buffer (in bytes). On exit,
82 * number of bytes used in the buffer
83 * @src: Source data to compress
84 * @srclen: Size of source data
85 * @return 0 if OK, -1 on error
87 int gzip(void *dst, unsigned long *lenp, unsigned char *src, ulong srclen);
90 * zzip() - Compress blocks with zlib
92 * @dst: Destination for compressed data
93 * @lenp: On entry, length data at @dst. On exit, number of bytes written to
95 * @src: Source data to compress
96 * @srclen: Size of source data
97 * @stoponerr: 0 to continue when a decode error is found, 1 to stop
98 * @func: Some sort of function that is called to do something. !ADD DOCS HERE!
100 int zzip(void *dst, ulong *lenp, unsigned char *src, ulong srclen,
101 int stoponerr, int (*func)(ulong, ulong));