Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Heiko Schocher | 6bf4ca0 | 2014-03-03 12:19:29 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 |
Heiko Schocher | 6bf4ca0 | 2014-03-03 12:19:29 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _FIT_COMMON_H_ |
| 7 | #define _FIT_COMMON_H_ |
| 8 | |
| 9 | #include "imagetool.h" |
| 10 | #include "mkimage.h" |
| 11 | #include <image.h> |
| 12 | |
Pali Rohár | 2972d7d | 2023-03-29 21:25:54 +0200 | [diff] [blame] | 13 | void fit_print_header(const void *fit, struct image_tool_params *params); |
| 14 | |
Jordan Hand | d32aa3c | 2019-03-05 14:47:56 -0800 | [diff] [blame] | 15 | /** |
| 16 | * Verify the format of FIT header pointed to by ptr |
| 17 | * |
| 18 | * @ptr: image header to be verified |
| 19 | * @image_size: size of while image |
| 20 | * @params: mkimage parameters |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 21 | * Return: 0 if OK, -1 on error |
Jordan Hand | d32aa3c | 2019-03-05 14:47:56 -0800 | [diff] [blame] | 22 | */ |
Heiko Schocher | 6bf4ca0 | 2014-03-03 12:19:29 +0100 | [diff] [blame] | 23 | int fit_verify_header(unsigned char *ptr, int image_size, |
| 24 | struct image_tool_params *params); |
| 25 | |
| 26 | int fit_check_image_types(uint8_t type); |
| 27 | |
Simon Glass | ef0af64 | 2014-06-02 22:04:52 -0600 | [diff] [blame] | 28 | /** |
| 29 | * Map an FDT into memory, optionally increasing its size |
| 30 | * |
| 31 | * @cmdname: Tool name (for displaying with error messages) |
| 32 | * @fname: Filename containing FDT |
Simon Glass | a946811 | 2014-06-02 22:04:53 -0600 | [diff] [blame] | 33 | * @size_inc: Amount to increase size by (0 = leave it alone) |
Simon Glass | ef0af64 | 2014-06-02 22:04:52 -0600 | [diff] [blame] | 34 | * @blobp: Returns pointer to FDT blob |
| 35 | * @sbuf: File status information is stored here |
| 36 | * @delete_on_error: true to delete the file if we get an error |
Luca Boccassi | 7d57485 | 2019-05-14 19:35:02 +0100 | [diff] [blame] | 37 | * @read_only: true to open in read-only mode |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 38 | * Return: 0 if OK, -1 on error. |
Simon Glass | ef0af64 | 2014-06-02 22:04:52 -0600 | [diff] [blame] | 39 | */ |
Simon Glass | a946811 | 2014-06-02 22:04:53 -0600 | [diff] [blame] | 40 | int mmap_fdt(const char *cmdname, const char *fname, size_t size_inc, |
Luca Boccassi | 7d57485 | 2019-05-14 19:35:02 +0100 | [diff] [blame] | 41 | void **blobp, struct stat *sbuf, bool delete_on_error, |
| 42 | bool read_only); |
Heiko Schocher | 6bf4ca0 | 2014-03-03 12:19:29 +0100 | [diff] [blame] | 43 | |
Simon Glass | e291a5c | 2021-11-12 12:28:04 -0700 | [diff] [blame] | 44 | /** |
| 45 | * copyfile() - Copy a file |
| 46 | * |
| 47 | * This uses read()/write() to copy file @src to file @dst |
| 48 | * |
Simon Glass | 7ae46c3 | 2021-11-12 12:28:05 -0700 | [diff] [blame] | 49 | * If @dst exists, it is overwritten and truncated to the correct size. |
| 50 | * |
Simon Glass | e291a5c | 2021-11-12 12:28:04 -0700 | [diff] [blame] | 51 | * @src: Filename to read from |
| 52 | * @dst: Filename to write to |
| 53 | * @return 0 if OK, -1 on error |
| 54 | */ |
| 55 | int copyfile(const char *src, const char *dst); |
| 56 | |
Simon Glass | 2d2384b | 2021-11-12 12:28:13 -0700 | [diff] [blame] | 57 | /** |
| 58 | * summary_show() - Show summary information about the signing process |
| 59 | * |
| 60 | * @summary: Summary info to show |
| 61 | * @imagefile: Filename of the output image |
| 62 | * @keydest: Filename where the key information is written (NULL if none) |
| 63 | */ |
| 64 | void summary_show(struct image_summary *summary, const char *imagefile, |
| 65 | const char *keydest); |
| 66 | |
Heiko Schocher | 6bf4ca0 | 2014-03-03 12:19:29 +0100 | [diff] [blame] | 67 | #endif /* _FIT_COMMON_H_ */ |