rkimage.c 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. *
  6. * See README.rockchip for details of the rkimage format
  7. */
  8. #include "imagetool.h"
  9. #include <image.h>
  10. #include "rkcommon.h"
  11. static uint32_t header;
  12. static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
  13. struct image_tool_params *params)
  14. {
  15. memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
  16. RK_SPL_HDR_SIZE);
  17. if (rkcommon_need_rc4_spl(params))
  18. rkcommon_rc4_encode_spl(buf, 4, params->file_size);
  19. }
  20. static int rkimage_check_image_type(uint8_t type)
  21. {
  22. if (type == IH_TYPE_RKIMAGE)
  23. return EXIT_SUCCESS;
  24. else
  25. return EXIT_FAILURE;
  26. }
  27. /*
  28. * rk_image parameters
  29. */
  30. U_BOOT_IMAGE_TYPE(
  31. rkimage,
  32. "Rockchip Boot Image support",
  33. 4,
  34. &header,
  35. rkcommon_check_params,
  36. NULL,
  37. NULL,
  38. rkimage_set_header,
  39. NULL,
  40. rkimage_check_image_type,
  41. NULL,
  42. NULL
  43. );