fit_common.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2014
  4. */
  5. #ifndef _FIT_COMMON_H_
  6. #define _FIT_COMMON_H_
  7. #include "imagetool.h"
  8. #include "mkimage.h"
  9. #include <image.h>
  10. void fit_print_header(const void *fit, struct image_tool_params *params);
  11. /**
  12. * Verify the format of FIT header pointed to by ptr
  13. *
  14. * @ptr: image header to be verified
  15. * @image_size: size of while image
  16. * @params: mkimage parameters
  17. * Return: 0 if OK, -1 on error
  18. */
  19. int fit_verify_header(unsigned char *ptr, int image_size,
  20. struct image_tool_params *params);
  21. int fit_check_image_types(uint8_t type);
  22. /**
  23. * Map an FDT into memory, optionally increasing its size
  24. *
  25. * @cmdname: Tool name (for displaying with error messages)
  26. * @fname: Filename containing FDT
  27. * @size_inc: Amount to increase size by (0 = leave it alone)
  28. * @blobp: Returns pointer to FDT blob
  29. * @sbuf: File status information is stored here
  30. * @delete_on_error: true to delete the file if we get an error
  31. * @read_only: true to open in read-only mode
  32. * Return: 0 if OK, -1 on error.
  33. */
  34. int mmap_fdt(const char *cmdname, const char *fname, size_t size_inc,
  35. void **blobp, struct stat *sbuf, bool delete_on_error,
  36. bool read_only);
  37. /**
  38. * copyfile() - Copy a file
  39. *
  40. * This uses read()/write() to copy file @src to file @dst
  41. *
  42. * If @dst exists, it is overwritten and truncated to the correct size.
  43. *
  44. * @src: Filename to read from
  45. * @dst: Filename to write to
  46. * @return 0 if OK, -1 on error
  47. */
  48. int copyfile(const char *src, const char *dst);
  49. /**
  50. * summary_show() - Show summary information about the signing process
  51. *
  52. * @summary: Summary info to show
  53. * @imagefile: Filename of the output image
  54. * @keydest: Filename where the key information is written (NULL if none)
  55. */
  56. void summary_show(struct image_summary *summary, const char *imagefile,
  57. const char *keydest);
  58. #endif /* _FIT_COMMON_H_ */