rksd.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 int rksd_verify_header(unsigned char *buf, int size,
  15. struct image_tool_params *params)
  16. {
  17. return 0;
  18. }
  19. static void rksd_print_header(const void *buf)
  20. {
  21. }
  22. static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
  23. struct image_tool_params *params)
  24. {
  25. unsigned int size;
  26. int ret;
  27. printf("params->file_size %d\n", params->file_size);
  28. printf("params->orig_file_size %d\n", params->orig_file_size);
  29. /*
  30. * We need to calculate this using 'RK_SPL_HDR_START' and not using
  31. * 'tparams->header_size', as the additional byte inserted when
  32. * 'is_boot0' is true counts towards the payload.
  33. */
  34. size = params->file_size - RK_SPL_HDR_START;
  35. ret = rkcommon_set_header(buf, size, params);
  36. if (ret) {
  37. /* TODO(sjg@chromium.org): This method should return an error */
  38. printf("Warning: SPL image is too large (size %#x) and will "
  39. "not boot\n", size);
  40. }
  41. }
  42. static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
  43. {
  44. return 0;
  45. }
  46. static int rksd_check_image_type(uint8_t type)
  47. {
  48. if (type == IH_TYPE_RKSD)
  49. return EXIT_SUCCESS;
  50. else
  51. return EXIT_FAILURE;
  52. }
  53. static int rksd_vrec_header(struct image_tool_params *params,
  54. struct image_type_params *tparams)
  55. {
  56. /*
  57. * Pad to the RK_BLK_SIZE (512 bytes) to be consistent with init_size
  58. * being encoded in RK_BLK_SIZE units in header0 (see rkcommon.c).
  59. */
  60. return rkcommon_vrec_header(params, tparams, RK_BLK_SIZE);
  61. }
  62. /*
  63. * rk_sd parameters
  64. */
  65. U_BOOT_IMAGE_TYPE(
  66. rksd,
  67. "Rockchip SD Boot Image support",
  68. 0,
  69. NULL,
  70. rkcommon_check_params,
  71. rksd_verify_header,
  72. rksd_print_header,
  73. rksd_set_header,
  74. rksd_extract_subimage,
  75. rksd_check_image_type,
  76. NULL,
  77. rksd_vrec_header
  78. );