]> Git Repo - J-u-boot.git/blame - cmd/lzmadec.c
cmd: upl: correct printf code
[J-u-boot.git] / cmd / lzmadec.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
5527f832
PB
2/*
3 * (C) Copyright 2013 Patrice Bouchand <pbfwdlist_gmail_com>
4 * lzma uncompress command in Uboot
5 *
6 * made from existing cmd_unzip.c file of Uboot
7 *
8 * (C) Copyright 2000
9 * Wolfgang Denk, DENX Software Engineering, [email protected].
5527f832
PB
10 */
11
5527f832 12#include <command.h>
c7694dd4 13#include <env.h>
0eb25b61 14#include <mapmem.h>
03de305e 15#include <vsprintf.h>
5527f832
PB
16#include <asm/io.h>
17
18#include <lzma/LzmaTools.h>
19
09140113
SG
20static int do_lzmadec(struct cmd_tbl *cmdtp, int flag, int argc,
21 char *const argv[])
5527f832
PB
22{
23 unsigned long src, dst;
1bb718cd 24 SizeT src_len = ~0UL, dst_len = ~0UL;
5527f832
PB
25 int ret;
26
27 switch (argc) {
28 case 4:
7e5f460e 29 dst_len = hextoul(argv[3], NULL);
5527f832
PB
30 /* fall through */
31 case 3:
7e5f460e
SG
32 src = hextoul(argv[1], NULL);
33 dst = hextoul(argv[2], NULL);
5527f832
PB
34 break;
35 default:
36 return CMD_RET_USAGE;
37 }
38
39 ret = lzmaBuffToBuffDecompress(map_sysmem(dst, dst_len), &src_len,
40 map_sysmem(src, 0), dst_len);
41
42 if (ret != SZ_OK)
43 return 1;
1bb718cd
SG
44 printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
45 (ulong)src_len);
018f5303 46 env_set_hex("filesize", src_len);
5527f832
PB
47
48 return 0;
49}
50
51U_BOOT_CMD(
52 lzmadec, 4, 1, do_lzmadec,
53 "lzma uncompress a memory region",
54 "srcaddr dstaddr [dstsize]"
55);
This page took 0.36615 seconds and 4 git commands to generate.