From patchwork Fri Aug 17 20:59:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 178390 X-Patchwork-Delegate: trini@ti.com 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 1E3B82C009F for ; Sat, 18 Aug 2012 07:00:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D565228D44; Fri, 17 Aug 2012 23:00:02 +0200 (CEST) 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 wNkxGDfG3urb; Fri, 17 Aug 2012 23:00:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55FE528D36; Fri, 17 Aug 2012 22:59:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6C4D28D2E for ; Fri, 17 Aug 2012 22:59:54 +0200 (CEST) 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 QeaoNqB8S9-q for ; Fri, 17 Aug 2012 22:59:54 +0200 (CEST) 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 spamkiller05.natinst.com (mailserver5.natinst.com [130.164.80.5]) by theia.denx.de (Postfix) with ESMTP id F005D28D29 for ; Fri, 17 Aug 2012 22:59:53 +0200 (CEST) Received: from mailserv59-us.natinst.com (nb-hsrp-1338.natinst.com [130.164.19.133]) by spamkiller05.natinst.com (8.14.4/8.14.4) with ESMTP id q7HKxphT021115; Fri, 17 Aug 2012 15:59:51 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.197]) by mailserv59-us.natinst.com (Lotus Domino Release 8.5.2FP3) with ESMTP id 2012081715595229-1210134 ; Fri, 17 Aug 2012 15:59:52 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Fri, 17 Aug 2012 15:59:44 -0500 Message-Id: <1345237184-20849-2-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1345237184-20849-1-git-send-email-joe.hershberger@ni.com> References: <1345237184-20849-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on MailServ59-US/AUS/H/NIC(Release 8.5.2FP3|July 10, 2011) at 08/17/2012 03:59:52 PM, Serialize by Router on MailServ59-US/AUS/H/NIC(Release 8.5.2FP3|July 10, 2011) at 08/17/2012 03:59:52 PM, Serialize complete at 08/17/2012 03:59:52 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855, 1.0.260, 0.0.0000 definitions=2012-08-17_05:2012-08-17, 2012-08-17, 1970-01-01 signatures=0 Cc: Joe Hershberger Subject: [U-Boot] [PATCH 2/2] Add unlzo command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Provide access to the lzo decompressor from the command line. Signed-off-by: Joe Hershberger --- common/Makefile | 3 +++ common/cmd_unlzo.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 common/cmd_unlzo.c diff --git a/common/Makefile b/common/Makefile index b8568ba..0793e50 100644 --- a/common/Makefile +++ b/common/Makefile @@ -156,6 +156,9 @@ COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o ifdef CONFIG_LZMA COBJS-$(CONFIG_CMD_UNLZMA) += cmd_unlzma.o endif +ifdef CONFIG_LZO +COBJS-$(CONFIG_CMD_UNLZO) += cmd_unlzo.o +endif COBJS-$(CONFIG_CMD_UNZIP) += cmd_unzip.o ifdef CONFIG_CMD_USB COBJS-y += cmd_usb.o diff --git a/common/cmd_unlzo.c b/common/cmd_unlzo.c new file mode 100644 index 0000000..f7312c5 --- /dev/null +++ b/common/cmd_unlzo.c @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2011 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include + +int do_unlzo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + unsigned long src, dst; + unsigned long src_len = ~0UL; + size_t dst_len = ~0UL; + int ret; + char buf[32]; + + switch (argc) { + case 5: + dst_len = simple_strtoul(argv[4], NULL, 16); + /* fall through */ + case 4: + src = simple_strtoul(argv[1], NULL, 16); + src_len = simple_strtoul(argv[2], NULL, 16); + dst = simple_strtoul(argv[3], NULL, 16); + break; + default: + return CMD_RET_USAGE; + } + + ret = lzop_decompress((void *)src, src_len, (void *)dst, &dst_len); + if (ret != LZO_E_OK) { + printf("unlzo: uncompress or overwrite error %d\n", ret); + return -1; + } + printf("Uncompressed size: %u\n", dst_len); + sprintf(buf, "%lX", (unsigned long) dst_len); + setenv("filesize", buf); + + return 0; +} + +U_BOOT_CMD( + unlzo, 5, 1, do_unlzo, + "unlzo a memory region", + "srcaddr srcsize dstaddr [dstsize]" +);