blob: cf30841a35947e141aa2741a0f6f778cdc82979e [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamadabb92b422017-01-30 11:12:07 +09002/*
3 * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamadabb92b422017-01-30 11:12:07 +09004 */
5
6#include <common.h>
7#include <command.h>
Simon Glass1a974af2019-08-01 09:46:36 -06008#include <gzip.h>
Masahiro Yamadabb92b422017-01-30 11:12:07 +09009#include <malloc.h>
10
11#include "config_data_gz.h"
12#include "config_data_size.h"
13
Simon Glassed38aef2020-05-10 11:40:03 -060014static int do_config(struct cmd_tbl *cmdtp, int flag, int argc,
15 char *const argv[])
Masahiro Yamadabb92b422017-01-30 11:12:07 +090016{
17 char *dst;
18 unsigned long len = data_size;
19 int ret = CMD_RET_SUCCESS;
20
21 dst = malloc(data_size + 1);
22 if (!dst)
23 return CMD_RET_FAILURE;
24
25 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
26 if (ret) {
27 printf("failed to uncompress .config data\n");
28 ret = CMD_RET_FAILURE;
29 goto free;
30 }
31
32 dst[data_size] = 0;
33 puts(dst);
34
35free:
36 free(dst);
37
38 return ret;
39}
40
41U_BOOT_CMD(
42 config, 1, 1, do_config,
43 "print .config",
44 ""
45);