]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
f2b96dfb LW |
2 | /* |
3 | * (C) Copyright 2012 | |
4 | * Lei Wen <[email protected]>, Marvell Inc. | |
f2b96dfb LW |
5 | */ |
6 | ||
7 | #include <common.h> | |
8 | #include <command.h> | |
c7694dd4 | 9 | #include <env.h> |
2843444a | 10 | #include <gzip.h> |
f2b96dfb | 11 | |
09140113 | 12 | static int do_zip(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
f2b96dfb LW |
13 | { |
14 | unsigned long src, dst; | |
15 | unsigned long src_len, dst_len = ~0UL; | |
f2b96dfb LW |
16 | |
17 | switch (argc) { | |
18 | case 5: | |
7e5f460e | 19 | dst_len = hextoul(argv[4], NULL); |
f2b96dfb LW |
20 | /* fall through */ |
21 | case 4: | |
7e5f460e SG |
22 | src = hextoul(argv[1], NULL); |
23 | src_len = hextoul(argv[2], NULL); | |
24 | dst = hextoul(argv[3], NULL); | |
f2b96dfb LW |
25 | break; |
26 | default: | |
27 | return cmd_usage(cmdtp); | |
28 | } | |
29 | ||
30 | if (gzip((void *) dst, &dst_len, (void *) src, src_len) != 0) | |
31 | return 1; | |
32 | ||
d6670909 | 33 | printf("Compressed size: %lu = 0x%lX\n", dst_len, dst_len); |
018f5303 | 34 | env_set_hex("filesize", dst_len); |
f2b96dfb LW |
35 | |
36 | return 0; | |
37 | } | |
38 | ||
39 | U_BOOT_CMD( | |
40 | zip, 5, 1, do_zip, | |
41 | "zip a memory region", | |
42 | "srcaddr srcsize dstaddr [dstsize]" | |
43 | ); |