Lei Wen | e4e248d | 2012-09-28 04:26:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2012 |
| 3 | * Lei Wen <leiwen@marvell.com>, Marvell Inc. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Lei Wen | e4e248d | 2012-09-28 04:26:47 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | |
| 11 | static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 12 | { |
| 13 | unsigned long src, dst; |
| 14 | unsigned long src_len, dst_len = ~0UL; |
Lei Wen | e4e248d | 2012-09-28 04:26:47 +0000 | [diff] [blame] | 15 | |
| 16 | switch (argc) { |
| 17 | case 5: |
| 18 | dst_len = simple_strtoul(argv[4], NULL, 16); |
| 19 | /* fall through */ |
| 20 | case 4: |
| 21 | src = simple_strtoul(argv[1], NULL, 16); |
| 22 | src_len = simple_strtoul(argv[2], NULL, 16); |
| 23 | dst = simple_strtoul(argv[3], NULL, 16); |
| 24 | break; |
| 25 | default: |
| 26 | return cmd_usage(cmdtp); |
| 27 | } |
| 28 | |
| 29 | if (gzip((void *) dst, &dst_len, (void *) src, src_len) != 0) |
| 30 | return 1; |
| 31 | |
| 32 | printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len); |
Simon Glass | 103789d | 2013-02-24 17:33:22 +0000 | [diff] [blame] | 33 | setenv_hex("filesize", dst_len); |
Lei Wen | e4e248d | 2012-09-28 04:26:47 +0000 | [diff] [blame] | 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | U_BOOT_CMD( |
| 39 | zip, 5, 1, do_zip, |
| 40 | "zip a memory region", |
| 41 | "srcaddr srcsize dstaddr [dstsize]" |
| 42 | ); |