]> git.ipfire.org Git - people/ms/u-boot.git/blame - common/cmd_lzmadec.c
board: ti: beagle_x15: added USB initializtion code
[people/ms/u-boot.git] / common / cmd_lzmadec.c
CommitLineData
5527f832
PB
1/*
2 * (C) Copyright 2013 Patrice Bouchand <pbfwdlist_gmail_com>
3 * lzma uncompress command in Uboot
4 *
5 * made from existing cmd_unzip.c file of Uboot
6 *
7 * (C) Copyright 2000
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 */
12
13#include <common.h>
14#include <command.h>
0eb25b61 15#include <mapmem.h>
5527f832
PB
16#include <asm/io.h>
17
18#include <lzma/LzmaTools.h>
19
20static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
21{
22 unsigned long src, dst;
23 unsigned long src_len = ~0UL, dst_len = ~0UL;
24 int ret;
25
26 switch (argc) {
27 case 4:
28 dst_len = simple_strtoul(argv[3], NULL, 16);
29 /* fall through */
30 case 3:
31 src = simple_strtoul(argv[1], NULL, 16);
32 dst = simple_strtoul(argv[2], NULL, 16);
33 break;
34 default:
35 return CMD_RET_USAGE;
36 }
37
38 ret = lzmaBuffToBuffDecompress(map_sysmem(dst, dst_len), &src_len,
39 map_sysmem(src, 0), dst_len);
40
41 if (ret != SZ_OK)
42 return 1;
43 printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
44 setenv_hex("filesize", src_len);
45
46 return 0;
47}
48
49U_BOOT_CMD(
50 lzmadec, 4, 1, do_lzmadec,
51 "lzma uncompress a memory region",
52 "srcaddr dstaddr [dstsize]"
53);