rksd.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 rksd format
  8. */
  9. #include "imagetool.h"
  10. #include <image.h>
  11. #include <rc4.h>
  12. #include "mkimage.h"
  13. #include "rkcommon.h"
  14. static char dummy_hdr[RK_IMAGE_HEADER_LEN];
  15. static int rksd_verify_header(unsigned char *buf, int size,
  16. struct image_tool_params *params)
  17. {
  18. return 0;
  19. }
  20. static void rksd_print_header(const void *buf)
  21. {
  22. }
  23. static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
  24. struct image_tool_params *params)
  25. {
  26. unsigned int size;
  27. int ret;
  28. size = params->file_size - RK_SPL_HDR_START;
  29. ret = rkcommon_set_header(buf, size, params);
  30. if (ret) {
  31. /* TODO(sjg@chromium.org): This method should return an error */
  32. printf("Warning: SPL image is too large (size %#x) and will not boot\n",
  33. size);
  34. }
  35. memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
  36. RK_SPL_HDR_SIZE);
  37. }
  38. static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
  39. {
  40. return 0;
  41. }
  42. static int rksd_check_image_type(uint8_t type)
  43. {
  44. if (type == IH_TYPE_RKSD)
  45. return EXIT_SUCCESS;
  46. else
  47. return EXIT_FAILURE;
  48. }
  49. /* We pad the file out to a fixed size - this method returns that size */
  50. static int rksd_vrec_header(struct image_tool_params *params,
  51. struct image_type_params *tparams)
  52. {
  53. int pad_size;
  54. pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params);
  55. debug("pad_size %x\n", pad_size);
  56. return pad_size - params->file_size;
  57. }
  58. /*
  59. * rk_sd parameters
  60. */
  61. U_BOOT_IMAGE_TYPE(
  62. rksd,
  63. "Rockchip SD Boot Image support",
  64. RK_IMAGE_HEADER_LEN,
  65. dummy_hdr,
  66. rkcommon_check_params,
  67. rksd_verify_header,
  68. rksd_print_header,
  69. rksd_set_header,
  70. rksd_extract_subimage,
  71. rksd_check_image_type,
  72. NULL,
  73. rksd_vrec_header
  74. );