fit_common.h 1.8 KB

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