config.c 775 B

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