rkimage.c 926 B

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