blob: f0d2033c61f4a7c31c40b7924589f88872f6162d [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
Masahiro Yamadabb92b422017-01-30 11:12:07 +09006#include <command.h>
Simon Glass1a974af2019-08-01 09:46:36 -06007#include <gzip.h>
Masahiro Yamadabb92b422017-01-30 11:12:07 +09008#include <malloc.h>
9
10#include "config_data_gz.h"
11#include "config_data_size.h"
12
Simon Glassed38aef2020-05-10 11:40:03 -060013static int do_config(struct cmd_tbl *cmdtp, int flag, int argc,
14 char *const argv[])
Masahiro Yamadabb92b422017-01-30 11:12:07 +090015{
16 char *dst;
17 unsigned long len = data_size;
18 int ret = CMD_RET_SUCCESS;
19
20 dst = malloc(data_size + 1);
21 if (!dst)
22 return CMD_RET_FAILURE;
23
24 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
25 if (ret) {
26 printf("failed to uncompress .config data\n");
27 ret = CMD_RET_FAILURE;
28 goto free;
29 }
30
31 dst[data_size] = 0;
32 puts(dst);
33
34free:
35 free(dst);
36
37 return ret;
38}
39
40U_BOOT_CMD(
41 config, 1, 1, do_config,
42 "print .config",
43 ""
44);