Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | |
| 11 | static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 12 | { |
| 13 | unsigned long src, dst; |
| 14 | unsigned long src_len = ~0UL, dst_len = ~0UL; |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 15 | |
| 16 | switch (argc) { |
| 17 | case 4: |
| 18 | dst_len = simple_strtoul(argv[3], NULL, 16); |
| 19 | /* fall through */ |
| 20 | case 3: |
| 21 | src = simple_strtoul(argv[1], NULL, 16); |
| 22 | dst = simple_strtoul(argv[2], NULL, 16); |
| 23 | break; |
| 24 | default: |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 25 | return CMD_RET_USAGE; |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0) |
| 29 | return 1; |
| 30 | |
| 31 | printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); |
Simon Glass | 41ef372 | 2013-02-24 17:33:22 +0000 | [diff] [blame] | 32 | setenv_hex("filesize", src_len); |
Mike Frysinger | c3d2a17 | 2011-04-02 21:40:19 -0400 | [diff] [blame] | 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | U_BOOT_CMD( |
| 38 | unzip, 4, 1, do_unzip, |
| 39 | "unzip a memory region", |
| 40 | "srcaddr dstaddr [dstsize]" |
| 41 | ); |