diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-11-09 07:52:27 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-11-09 07:52:27 +0000 |
commit | ab77e81f6521e97ac2fe2218013d5871a893db0f (patch) | |
tree | b9a2ce5ef8aa85c01c304eeea6ae6c965dda2947 /xen/common/decompress.c | |
parent | 14ec087884b13aa9de838ab11fd4e67e255d4ded (diff) | |
download | xen-ab77e81f6521e97ac2fe2218013d5871a893db0f.tar.gz xen-ab77e81f6521e97ac2fe2218013d5871a893db0f.tar.bz2 xen-ab77e81f6521e97ac2fe2218013d5871a893db0f.zip |
x86/dom0: support bzip2 and lzma compressed bzImage payloads
This matches functionality in the tools already supporting the same
for DomU-s.
Code taken from Linux 2.6.32-rc and adjusted as little as possible to
be usable in Xen.
The question is whether, particularly for non-Linux Dom0-s, plain ELF
images compressed by bzip2 or lzma should also be supported.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/common/decompress.c')
-rw-r--r-- | xen/common/decompress.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xen/common/decompress.c b/xen/common/decompress.c new file mode 100644 index 0000000000..de9950c3a7 --- /dev/null +++ b/xen/common/decompress.c @@ -0,0 +1,27 @@ +#include <xen/config.h> +#include <xen/init.h> +#include <xen/lib.h> +#include <xen/string.h> +#include <xen/decompress.h> + +static void __init error(const char *msg) +{ + printk("%s\n", msg); +} + +int __init decompress(void *inbuf, unsigned int len, void *outbuf) +{ +#if 0 /* Not needed here yet. */ + if ( len >= 2 && + (!memcmp(inbuf, "\037\213", 2) || !memcmp(inbuf, "\037\236", 2)) ) + return gunzip(inbuf, len, NULL, NULL, outbuf, NULL, error); +#endif + + if ( len >= 3 && !memcmp(inbuf, "\x42\x5a\x68", 3) ) + return bunzip2(inbuf, len, NULL, NULL, outbuf, NULL, error); + + if ( len >= 2 && !memcmp(inbuf, "\135\000", 2) ) + return unlzma(inbuf, len, NULL, NULL, outbuf, NULL, error); + + return 1; +} |