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