gpimage.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2014
  4. * Texas Instruments Incorporated
  5. * Add gpimage format for keystone devices to format spl image. This is
  6. * Based on omapimage.c
  7. *
  8. * (C) Copyright 2010
  9. * Linaro LTD, www.linaro.org
  10. * Author: John Rigby <john.rigby@linaro.org>
  11. * Based on TI's signGP.c
  12. *
  13. * (C) Copyright 2009
  14. * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
  15. *
  16. * (C) Copyright 2008
  17. * Marvell Semiconductor <www.marvell.com>
  18. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  19. */
  20. #include "imagetool.h"
  21. #include <compiler.h>
  22. #include <image.h>
  23. #include "gpheader.h"
  24. static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
  25. /* to be in keystone gpimage */
  26. static int gpimage_check_image_types(uint8_t type)
  27. {
  28. if (type == IH_TYPE_GPIMAGE)
  29. return EXIT_SUCCESS;
  30. return EXIT_FAILURE;
  31. }
  32. static int gpimage_verify_header(unsigned char *ptr, int image_size,
  33. struct image_tool_params *params)
  34. {
  35. struct gp_header *gph = (struct gp_header *)ptr;
  36. return gph_verify_header(gph, 1);
  37. }
  38. static void gpimage_print_header(const void *ptr)
  39. {
  40. const struct gp_header *gph = (struct gp_header *)ptr;
  41. gph_print_header(gph, 1);
  42. }
  43. static void gpimage_set_header(void *ptr, struct stat *sbuf, int ifd,
  44. struct image_tool_params *params)
  45. {
  46. struct gp_header *gph = (struct gp_header *)ptr;
  47. gph_set_header(gph, sbuf->st_size - GPIMAGE_HDR_SIZE, params->addr, 1);
  48. }
  49. /*
  50. * gpimage parameters
  51. */
  52. U_BOOT_IMAGE_TYPE(
  53. gpimage,
  54. "TI KeyStone GP Image support",
  55. GPIMAGE_HDR_SIZE,
  56. (void *)&gpimage_header,
  57. gpimage_check_params,
  58. gpimage_verify_header,
  59. gpimage_print_header,
  60. gpimage_set_header,
  61. NULL,
  62. gpimage_check_image_types,
  63. NULL,
  64. NULL
  65. );