From patchwork Sun Dec 5 15:16:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luigi.mantellini@idf-hit.com X-Patchwork-Id: 74300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 83CACB70CC for ; Mon, 6 Dec 2010 02:16:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3576828103; Sun, 5 Dec 2010 16:16:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mc0Q3TFQBpJU; Sun, 5 Dec 2010 16:16:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AC31F280EA; Sun, 5 Dec 2010 16:16:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B737280EA for ; Sun, 5 Dec 2010 16:16:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q5w0Lfge7ERl for ; Sun, 5 Dec 2010 16:16:33 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx101.fabbricadigitale.it (mx2.fabbricadigitale.it [217.169.111.37]) by theia.denx.de (Postfix) with ESMTPS id 099A1280E7 for ; Sun, 5 Dec 2010 16:16:31 +0100 (CET) Received: from localhost (mxnew.fabbricadigitale.it [127.0.0.1]) by mx101.fabbricadigitale.it (MM4Csmtpd) with ESMTP id 2B9B2E0001B2 for ; Sun, 5 Dec 2010 16:16:31 +0100 (CET) X-Virus-Scanned: amavisd-new at fabbricadigitale.it Received: from mx101.fabbricadigitale.it ([127.0.0.1]) by localhost (mx101.fabbricadigitale.it [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xdw3vpVJ1FUL for ; Sun, 5 Dec 2010 16:16:31 +0100 (CET) Received: from EX02MailShare.fdmsha.local (unknown [172.16.26.10]) by mx101.fabbricadigitale.it (MM4Csmtpd) with ESMTPS id 14412E000162 for ; Sun, 5 Dec 2010 16:16:31 +0100 (CET) Received: from abel.dialface.net (85.46.108.250) by EX02MailShare.fdmsha.local (172.16.26.10) with Microsoft SMTP Server id 8.1.340.0; Sun, 5 Dec 2010 16:16:28 +0100 From: Luigi 'Comio' Mantellini To: Date: Sun, 5 Dec 2010 16:16:24 +0100 Message-ID: <1291562184-27126-2-git-send-email-luigi.mantellini@idf-hit.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1291562184-27126-1-git-send-email-luigi.mantellini@idf-hit.com> References: <1291562184-27126-1-git-send-email-luigi.mantellini@idf-hit.com> MIME-Version: 1.0 Cc: Luigi 'Comio' Mantellini Subject: [U-Boot] [PATCH 2/2] Add XZ compressed uImage support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch permits to use XZ compressed uImages using the XZ embedded library code. Signed-off-by: Luigi 'Comio' Mantellini --- common/cmd_bootm.c | 27 +++++++++++++++++++++++++-- common/image.c | 1 + include/image.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 1a024f1..066b908 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -61,6 +61,10 @@ #include #endif /* CONFIG_LZO */ +#ifdef CONFIG_XZ +#include +#endif /* CONFIG_XZ */ + DECLARE_GLOBAL_DATA_PTR; #ifndef CONFIG_SYS_BOOTM_LEN @@ -338,9 +342,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) ulong image_start = os.image_start; ulong image_len = os.image_len; uint unc_len = CONFIG_SYS_BOOTM_LEN; -#if defined(CONFIG_LZMA) || defined(CONFIG_LZO) +#if defined(CONFIG_LZMA) || defined(CONFIG_LZO) || defined(CONFIG_XZ) int ret; -#endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */ +#endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) || defined(CONFIG_XZ) */ const char *type_name = genimg_get_type_name (os.type); @@ -430,6 +434,25 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) *load_end = load + unc_len; break; #endif /* CONFIG_LZO */ +#ifdef CONFIG_XZ + case IH_COMP_XZ: { + int in_used = unc_len; + printf (" Uncompressing %s ... ", type_name); + ret = unxz( + (unsigned char *)image_start, image_len, + (unsigned char *)load, &in_used); + unc_len = in_used; + if (ret != 0) { + printf ("XZ: uncompress or overwrite error %d " + "- must RESET board to recover\n", ret); + show_boot_progress (-6); + return BOOTM_ERR_RESET; + } + *load_end = load + unc_len; + break; + } + break; +#endif /* CONFIG_XZ */ default: printf ("Unimplemented compression type %d\n", comp); return BOOTM_ERR_UNIMPLEMENTED; diff --git a/common/image.c b/common/image.c index 42f5b79..4e31691 100644 --- a/common/image.c +++ b/common/image.c @@ -150,6 +150,7 @@ static table_entry_t uimage_comp[] = { { IH_COMP_GZIP, "gzip", "gzip compressed", }, { IH_COMP_LZMA, "lzma", "lzma compressed", }, { IH_COMP_LZO, "lzo", "lzo compressed", }, + { IH_COMP_XZ, "xz", "xz compressed", }, { -1, "", "", }, }; diff --git a/include/image.h b/include/image.h index 49d6280..5ba5afa 100644 --- a/include/image.h +++ b/include/image.h @@ -166,6 +166,7 @@ #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */ #define IH_COMP_LZMA 3 /* lzma Compression Used */ #define IH_COMP_LZO 4 /* lzo Compression Used */ +#define IH_COMP_XZ 5 /* xz Compression Used */ #define IH_MAGIC 0x27051956 /* Image Magic Number */ #define IH_NMLEN 32 /* Image Name Length */