2020-02-20 19:48:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020
|
|
|
|
* FUJITSU COMPUTERTECHNOLOGIES LIMITED. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <env.h>
|
2021-10-09 23:28:21 +08:00
|
|
|
#include <u-boot/lz4.h>
|
2020-02-20 19:48:01 +08:00
|
|
|
|
2020-05-11 01:40:03 +08:00
|
|
|
static int do_unlz4(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2020-02-20 19:48:01 +08:00
|
|
|
{
|
|
|
|
unsigned long src, dst;
|
|
|
|
size_t src_len = ~0UL, dst_len = ~0UL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (argc) {
|
|
|
|
case 4:
|
2021-07-24 23:03:29 +08:00
|
|
|
src = hextoul(argv[1], NULL);
|
|
|
|
dst = hextoul(argv[2], NULL);
|
|
|
|
dst_len = hextoul(argv[3], NULL);
|
2020-02-20 19:48:01 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ulz4fn((void *)src, src_len, (void *)dst, &dst_len);
|
|
|
|
if (ret) {
|
|
|
|
printf("Uncompressed err :%d\n", ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Uncompressed size: %zd = 0x%zX\n", dst_len, dst_len);
|
|
|
|
env_set_hex("filesize", dst_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(unlz4, 4, 1, do_unlz4,
|
|
|
|
"lz4 uncompress a memory region",
|
|
|
|
"srcaddr dstaddr dstsize\n"
|
|
|
|
"NOTE: Specify the destination size that is sufficiently larger\n"
|
|
|
|
" than the source size.\n"
|
|
|
|
);
|