]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/gpimage-common.c
3 * Texas Instruments Incorporated
4 * Refactored common functions in to gpimage-common.c.
7 * Linaro LTD, www.linaro.org
8 * Author: John Rigby <john.rigby@linaro.org>
9 * Based on TI's signGP.c
12 * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
15 * Marvell Semiconductor <www.marvell.com>
16 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
18 * SPDX-License-Identifier: GPL-2.0+
21 #include "imagetool.h"
26 /* Helper to convert size and load_addr to big endian */
27 void to_be32(uint32_t *gph_size
, uint32_t *gph_load_addr
)
29 *gph_size
= cpu_to_be32(*gph_size
);
30 *gph_load_addr
= cpu_to_be32(*gph_load_addr
);
33 int gph_verify_header(struct gp_header
*gph
, int be
)
35 uint32_t gph_size
= gph
->size
;
36 uint32_t gph_load_addr
= gph
->load_addr
;
39 to_be32(&gph_size
, &gph_load_addr
);
41 if (!gph_size
|| !gph_load_addr
)
47 void gph_print_header(const struct gp_header
*gph
, int be
)
49 uint32_t gph_size
= gph
->size
, gph_load_addr
= gph
->load_addr
;
52 to_be32(&gph_size
, &gph_load_addr
);
55 fprintf(stderr
, "Error: invalid image size %x\n", gph_size
);
60 fprintf(stderr
, "Error: invalid image load address %x\n",
64 printf("GP Header: Size %x LoadAddr %x\n", gph_size
, gph_load_addr
);
67 void gph_set_header(struct gp_header
*gph
, uint32_t size
, uint32_t load_addr
,
71 gph
->load_addr
= load_addr
;
73 to_be32(&gph
->size
, &gph
->load_addr
);
76 int gpimage_check_params(struct image_tool_params
*params
)
78 return (params
->dflag
&& (params
->fflag
|| params
->lflag
)) ||
79 (params
->fflag
&& (params
->dflag
|| params
->lflag
)) ||
80 (params
->lflag
&& (params
->dflag
|| params
->fflag
));