mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
common: Move gzip functions into a new gzip header
As part of the effort to remove things from common.h, create a new header for the gzip functions. Move the function declarations to it and add missing documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
This commit is contained in:
parent
0d6c7c60ea
commit
0c670fc148
18 changed files with 124 additions and 58 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <asm/spl.h>
|
#include <asm/spl.h>
|
||||||
#include <fdt_support.h>
|
#include <fdt_support.h>
|
||||||
#include <fsl_esdhc_imx.h>
|
#include <fsl_esdhc_imx.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <ipu_pixfmt.h>
|
#include <ipu_pixfmt.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
|
||||||
#include <lcd.h>
|
|
||||||
#include <mapmem.h>
|
|
||||||
#include <bmp_layout.h>
|
#include <bmp_layout.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <asm/byteorder.h>
|
#include <dm.h>
|
||||||
|
#include <gzip.h>
|
||||||
|
#include <lcd.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <splash.h>
|
#include <splash.h>
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
|
#include <asm/byteorder.h>
|
||||||
|
|
||||||
static int bmp_info (ulong addr);
|
static int bmp_info (ulong addr);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "config_data_gz.h"
|
#include "config_data_gz.h"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <fpga.h>
|
#include <fpga.h>
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
static long do_fpga_get_device(char *arg)
|
static long do_fpga_get_device(char *arg)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "license_data_gz.h"
|
#include "license_data_gz.h"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
|
|
||||||
static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
*/
|
*/
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <rtc.h>
|
#include <rtc.h>
|
||||||
|
|
||||||
#include <environment.h>
|
#include <environment.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fpga.h>
|
#include <fpga.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <linux/libfdt.h>
|
#include <linux/libfdt.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Matt Porter <mporter@ti.com>
|
* Matt Porter <mporter@ti.com>
|
||||||
*/
|
*/
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
#include <xyzModem.h>
|
#include <xyzModem.h>
|
||||||
#include <asm/u-boot.h>
|
#include <asm/u-boot.h>
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <fdtdec.h>
|
#include <fdtdec.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
#include "ubifs.h"
|
#include "ubifs.h"
|
||||||
#include <u-boot/zlib.h>
|
#include <u-boot/zlib.h>
|
||||||
|
|
|
@ -428,51 +428,6 @@ void wait_ticks (unsigned long);
|
||||||
ulong usec2ticks (unsigned long usec);
|
ulong usec2ticks (unsigned long usec);
|
||||||
ulong ticks2usec (unsigned long ticks);
|
ulong ticks2usec (unsigned long ticks);
|
||||||
|
|
||||||
/* lib/gunzip.c */
|
|
||||||
int gzip_parse_header(const unsigned char *src, unsigned long len);
|
|
||||||
int gunzip(void *, int, unsigned char *, unsigned long *);
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
void gzwrite_progress_init(u64 expected_size);
|
|
||||||
|
|
||||||
void gzwrite_progress(int iteration,
|
|
||||||
u64 bytes_written,
|
|
||||||
u64 total_bytes);
|
|
||||||
|
|
||||||
void gzwrite_progress_finish(int retcode,
|
|
||||||
u64 totalwritten,
|
|
||||||
u64 totalsize,
|
|
||||||
u32 expected_crc,
|
|
||||||
u32 calculated_crc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* decompress and write gzipped image from memory to block device
|
|
||||||
*
|
|
||||||
* @param src compressed image address
|
|
||||||
* @param len compressed image length in bytes
|
|
||||||
* @param dev block device descriptor
|
|
||||||
* @param szwritebuf bytes per write (pad to erase size)
|
|
||||||
* @param startoffs offset in bytes of first write
|
|
||||||
* @param szexpected expected uncompressed length
|
|
||||||
* may be zero to use gzip trailer
|
|
||||||
* for files under 4GiB
|
|
||||||
*/
|
|
||||||
int gzwrite(unsigned char *src, int len,
|
|
||||||
struct blk_desc *dev,
|
|
||||||
unsigned long szwritebuf,
|
|
||||||
u64 startoffs,
|
|
||||||
u64 szexpected);
|
|
||||||
|
|
||||||
/* lib/lz4_wrapper.c */
|
/* lib/lz4_wrapper.c */
|
||||||
int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
|
int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
|
||||||
|
|
||||||
|
@ -506,13 +461,6 @@ unsigned int rand_r(unsigned int *seedp);
|
||||||
int serial_printf (const char *fmt, ...)
|
int serial_printf (const char *fmt, ...)
|
||||||
__attribute__ ((format (__printf__, 1, 2)));
|
__attribute__ ((format (__printf__, 1, 2)));
|
||||||
|
|
||||||
/* lib/gzip.c */
|
|
||||||
int gzip(void *dst, unsigned long *lenp,
|
|
||||||
unsigned char *src, unsigned long srclen);
|
|
||||||
int zzip(void *dst, unsigned long *lenp, unsigned char *src,
|
|
||||||
unsigned long srclen, int stoponerr,
|
|
||||||
int (*func)(unsigned long, unsigned long));
|
|
||||||
|
|
||||||
/* lib/net_utils.c */
|
/* lib/net_utils.c */
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
static inline struct in_addr env_get_ip(char *var)
|
static inline struct in_addr env_get_ip(char *var)
|
||||||
|
|
103
include/gzip.h
Normal file
103
include/gzip.h
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2000-2009
|
||||||
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GZIP_H
|
||||||
|
#define __GZIP_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @return length of header in bytes, or -1 if not enough data
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return 0 if OK, -1 on error
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* @return 0 if OK, -1 on error
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
void gzwrite_progress_init(u64 expected_size);
|
||||||
|
|
||||||
|
void gzwrite_progress(int iteration, u64 bytes_written, u64 total_bytes);
|
||||||
|
|
||||||
|
void gzwrite_progress_finish(int retcode, u64 totalwritten, u64 totalsize,
|
||||||
|
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
|
||||||
|
* @return 0 if OK, -1 on error
|
||||||
|
*/
|
||||||
|
int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf,
|
||||||
|
u64 startoffs, u64 szexpected);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @return 0 if OK, -1 on error
|
||||||
|
*/
|
||||||
|
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
|
|
@ -11,6 +11,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fdtdec.h>
|
#include <fdtdec.h>
|
||||||
#include <fdt_support.h>
|
#include <fdt_support.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <linux/libfdt.h>
|
#include <linux/libfdt.h>
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <watchdog.h>
|
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
#include <div64.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
|
#include <watchdog.h>
|
||||||
#include <u-boot/zlib.h>
|
#include <u-boot/zlib.h>
|
||||||
#include <div64.h>
|
|
||||||
|
|
||||||
#define HEADER0 '\x1f'
|
#define HEADER0 '\x1f'
|
||||||
#define HEADER1 '\x8b'
|
#define HEADER1 '\x8b'
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <bootm.h>
|
#include <bootm.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <gzip.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
Loading…
Reference in a new issue