4
* Copyright (C) 1999 Linus Torvalds
5
* Copyright (C) 2000-2002 Transmeta Corporation
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License (Version 2) as
9
* published by the Free Software Foundation.
11
* cramfs interfaces to the uncompression library. There's really just
14
* - cramfs_uncompress_init() - called to initialize the thing.
15
* - cramfs_uncompress_exit() - tell me when you're done
16
* - cramfs_uncompress_block() - uncompress a block.
18
* NOTE NOTE NOTE! The uncompression is entirely single-threaded. We
19
* only have one stream, and we'll initialize it only once even if it
20
* then is used by multiple filesystems.
26
#include <u-boot/zlib.h>
28
static z_stream stream;
30
/* Returns length of decompressed data. */
31
int cramfs_uncompress_block (void *dst, void *src, int srclen)
35
inflateReset (&stream);
38
stream.avail_in = srclen;
40
stream.next_out = dst;
41
stream.avail_out = 4096 * 2;
43
err = inflate (&stream, Z_FINISH);
45
if (err != Z_STREAM_END)
47
return stream.total_out;
50
/*printf ("Error %d while decompressing!\n", err); */
51
/*printf ("%p(%d)->%p\n", src, srclen, dst); */
55
int cramfs_uncompress_init (void)
59
stream.zalloc = gzalloc;
60
stream.zfree = gzfree;
64
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
65
stream.outcb = (cb_func) WATCHDOG_RESET;
67
stream.outcb = Z_NULL;
68
#endif /* CONFIG_HW_WATCHDOG */
70
err = inflateInit (&stream);
72
printf ("Error: inflateInit2() returned %d\n", err);
79
int cramfs_uncompress_exit (void)