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