gpimage.c 1.8 KB

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