config.c 757 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <malloc.h>
  8. #include "config_data_gz.h"
  9. #include "config_data_size.h"
  10. static int do_config(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  11. {
  12. char *dst;
  13. unsigned long len = data_size;
  14. int ret = CMD_RET_SUCCESS;
  15. dst = malloc(data_size + 1);
  16. if (!dst)
  17. return CMD_RET_FAILURE;
  18. ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
  19. if (ret) {
  20. printf("failed to uncompress .config data\n");
  21. ret = CMD_RET_FAILURE;
  22. goto free;
  23. }
  24. dst[data_size] = 0;
  25. puts(dst);
  26. free:
  27. free(dst);
  28. return ret;
  29. }
  30. U_BOOT_CMD(
  31. config, 1, 1, do_config,
  32. "print .config",
  33. ""
  34. );