diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-03-04 22:24:52 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-03-12 22:35:01 -0400 |
commit | ad9d2716cfc1cda5a7e0d7bc0db45e3af8a4adbb (patch) | |
tree | d91ea074bd35c61c86b3c012a41622d5016fc919 /arch/powerpc/boot/gunzip_util.h | |
parent | cfbff8a3802542c4d8b2290c49b1a59128c4a380 (diff) |
[POWERPC] zImage: Add more flexible gunzip convenience functions
At present, arch/powerpc/boot/main.c includes a gunzip() function
which is a convenient wrapper around zlib. However, it doesn't
conveniently allow decompressing part of an image to one location,
then the remainder to a different address.
This patch adds a new set of more flexible convenience wrappers around
zlib, moving them to their own file, gunzip_util.c, in the process.
These wrappers allow decompressing sections of the compressed image to
different locations. In addition, they transparently handle
uncompressed data, avoiding special case code to handle uncompressed
vmlinux images.
The patch also converts main.c to use the new wrappers, using the new
flexibility to avoid decompressing the vmlinux's ELF header twice as
we did previously. That in turn means we avoid extending our
allocations for the vmlinux to allow space for the extra copy of the
ELF header.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/gunzip_util.h')
-rw-r--r-- | arch/powerpc/boot/gunzip_util.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/powerpc/boot/gunzip_util.h b/arch/powerpc/boot/gunzip_util.h new file mode 100644 index 00000000000..950f62fe0a6 --- /dev/null +++ b/arch/powerpc/boot/gunzip_util.h | |||
@@ -0,0 +1,30 @@ | |||
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 | /* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */ | ||
16 | #define GUNZIP_SCRATCH_SIZE 46912 | ||
17 | |||
18 | struct gunzip_state { | ||
19 | z_stream s; | ||
20 | char scratch[46912]; | ||
21 | }; | ||
22 | |||
23 | void gunzip_start(struct gunzip_state *state, void *src, int srclen); | ||
24 | int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen); | ||
25 | void gunzip_exactly(struct gunzip_state *state, void *dst, int len); | ||
26 | void gunzip_discard(struct gunzip_state *state, int len); | ||
27 | int gunzip_finish(struct gunzip_state *state, void *dst, int len); | ||
28 | |||
29 | #endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */ | ||
30 | |||