config.c 786 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <gzip.h>
  8. #include <malloc.h>
  9. #include "config_data_gz.h"
  10. #include "config_data_size.h"
  11. static int do_config(struct cmd_tbl *cmdtp, int flag, int argc,
  12. char *const argv[])
  13. {
  14. char *dst;
  15. unsigned long len = data_size;
  16. int ret = CMD_RET_SUCCESS;
  17. dst = malloc(data_size + 1);
  18. if (!dst)
  19. return CMD_RET_FAILURE;
  20. ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
  21. if (ret) {
  22. printf("failed to uncompress .config data\n");
  23. ret = CMD_RET_FAILURE;
  24. goto free;
  25. }
  26. dst[data_size] = 0;
  27. puts(dst);
  28. free:
  29. free(dst);
  30. return ret;
  31. }
  32. U_BOOT_CMD(
  33. config, 1, 1, do_config,
  34. "print .config",
  35. ""
  36. );