summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-09-06 20:26:52 -0600
committerTom Rini <trini@konsulko.com>2022-09-29 16:07:57 -0400
commitf3543e69442ca393e52df253d9c5d45bc189d471 (patch)
tree99423df56b15a01188099161332c6c8aed301972 /tools
parentda79b2f25e5352a8e09b96ecef56df009f03c0b5 (diff)
downloadu-boot-f3543e69442ca393e52df253d9c5d45bc189d471.tar.gz
u-boot-f3543e69442ca393e52df253d9c5d45bc189d471.tar.bz2
u-boot-f3543e69442ca393e52df253d9c5d45bc189d471.zip
treewide: Drop image_header_t typedef
This is not needed and we should avoid typedefs. Use the struct instead and rename it to indicate that it really is a legacy struct. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/ftest.py4
-rw-r--r--tools/default_image.c31
-rw-r--r--tools/fit_image.c4
-rw-r--r--tools/imx8mimage.c8
-rw-r--r--tools/mkimage.c2
-rw-r--r--tools/mtk_image.c10
6 files changed, 29 insertions, 30 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index ecb3595603..261107b335 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5782,7 +5782,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
# Check that the data appears in the file somewhere
self.assertIn(U_BOOT_SPL_DATA, data)
- # Get struct image_header -> ih_name
+ # Get struct legacy_img_hdr -> ih_name
name = data[0x20:0x40]
# Build the filename that we expect to be placed in there, by virtue of
@@ -5799,7 +5799,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
# Check that the data appears in the file somewhere
self.assertIn(U_BOOT_SPL_DATA, data)
- # Get struct image_header -> ih_name
+ # Get struct legacy_img_hdr -> ih_name
name = data[0x20:0x40]
# Build the filename that we expect to be placed in there, by virtue of
diff --git a/tools/default_image.c b/tools/default_image.c
index e164c0c27d..4a067e6586 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -22,7 +22,7 @@
#include <u-boot/crc.h>
#include <imximage.h>
-static image_header_t header;
+static struct legacy_img_hdr header;
static int image_check_image_types(uint8_t type)
{
@@ -46,15 +46,15 @@ static int image_verify_header(unsigned char *ptr, int image_size,
uint32_t len;
const unsigned char *data;
uint32_t checksum;
- image_header_t header;
- image_header_t *hdr = &header;
+ struct legacy_img_hdr header;
+ struct legacy_img_hdr *hdr = &header;
/*
* create copy of header so that we can blank out the
* checksum field for checking - this can't be done
* on the PROT_READ mapped data.
*/
- memcpy(hdr, ptr, sizeof(image_header_t));
+ memcpy(hdr, ptr, sizeof(struct legacy_img_hdr));
if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
@@ -63,7 +63,7 @@ static int image_verify_header(unsigned char *ptr, int image_size,
}
data = (const unsigned char *)hdr;
- len = sizeof(image_header_t);
+ len = sizeof(struct legacy_img_hdr);
checksum = be32_to_cpu(hdr->ih_hcrc);
hdr->ih_hcrc = cpu_to_be32(0); /* clear for re-calculation */
@@ -74,8 +74,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,
return -FDT_ERR_BADSTATE;
}
- data = (const unsigned char *)ptr + sizeof(image_header_t);
- len = image_size - sizeof(image_header_t) ;
+ data = (const unsigned char *)ptr + sizeof(struct legacy_img_hdr);
+ len = image_size - sizeof(struct legacy_img_hdr);
checksum = be32_to_cpu(hdr->ih_dcrc);
if (crc32(0, data, len) != checksum) {
@@ -94,13 +94,12 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
uint32_t imagesize;
uint32_t ep;
uint32_t addr;
-
- image_header_t * hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
checksum = crc32(0,
(const unsigned char *)(ptr +
- sizeof(image_header_t)),
- sbuf->st_size - sizeof(image_header_t));
+ sizeof(struct legacy_img_hdr)),
+ sbuf->st_size - sizeof(struct legacy_img_hdr));
time = imagetool_get_source_date(params->cmdname, sbuf->st_mtime);
ep = params->ep;
@@ -108,11 +107,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
if (params->type == IH_TYPE_FIRMWARE_IVT)
/* Add size of CSF minus IVT */
- imagesize = sbuf->st_size - sizeof(image_header_t)
+ imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr)
+ 0x2060 - sizeof(flash_header_v2_t);
else
- imagesize = sbuf->st_size - sizeof(image_header_t);
+ imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr);
if (params->os == IH_OS_TEE) {
addr = optee_image_get_load_addr(hdr);
@@ -134,14 +133,14 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
image_set_name(hdr, params->imagename);
checksum = crc32(0, (const unsigned char *)hdr,
- sizeof(image_header_t));
+ sizeof(struct legacy_img_hdr));
image_set_hcrc(hdr, checksum);
}
static int image_extract_subimage(void *ptr, struct image_tool_params *params)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
ulong file_data;
ulong file_len;
@@ -175,7 +174,7 @@ static int image_extract_subimage(void *ptr, struct image_tool_params *params)
U_BOOT_IMAGE_TYPE(
defimage,
"Default Image support",
- sizeof(image_header_t),
+ sizeof(struct legacy_img_hdr),
(void *)&header,
image_check_params,
image_verify_header,
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 979f2411ee..923a9755b7 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -22,7 +22,7 @@
#include <version.h>
#include <u-boot/crc.h>
-static image_header_t header;
+static struct legacy_img_hdr header;
static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
const char *tmpfile)
@@ -915,7 +915,7 @@ static int fit_check_params(struct image_tool_params *params)
U_BOOT_IMAGE_TYPE(
fitimage,
"FIT Image support",
- sizeof(image_header_t),
+ sizeof(struct legacy_img_hdr),
(void *)&header,
fit_check_params,
fit_verify_header,
diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c
index a4699decf9..35d0a92bfd 100644
--- a/tools/imx8mimage.c
+++ b/tools/imx8mimage.c
@@ -318,7 +318,7 @@ err_mmap:
static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,
uint32_t *fit_load_addr)
{
- image_header_t image_header;
+ struct legacy_img_hdr image_header;
int ret;
uint32_t fit_size, load_addr;
@@ -330,8 +330,8 @@ static int generate_ivt_for_fit(int fd, int fit_offset, uint32_t ep,
exit(EXIT_FAILURE);
}
- if (read(fd, (char *)&image_header, sizeof(image_header_t)) !=
- sizeof(image_header_t)) {
+ if (read(fd, (char *)&image_header, sizeof(struct legacy_img_hdr)) !=
+ sizeof(struct legacy_img_hdr)) {
fprintf(stderr, "generate_ivt_for_fit read failed: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
@@ -600,7 +600,7 @@ void build_image(int ofd)
close(sld_fd);
file_off = sld_header_off;
- file_off += sbuf.st_size + sizeof(image_header_t);
+ file_off += sbuf.st_size + sizeof(struct legacy_img_hdr);
}
}
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 597cb3a5ce..30c6df7708 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -845,7 +845,7 @@ copy_file (int ifd, const char *datafile, int pad)
if (params.xflag) {
unsigned char *p = NULL;
/*
- * XIP: do not append the image_header_t at the
+ * XIP: do not append the struct legacy_img_hdr at the
* beginning of the file, but consume the space
* reserved for it.
*/
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index 9b3136afa3..5ef9334163 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -427,10 +427,10 @@ static uint32_t crc32be_cal(const void *data, size_t length)
static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
struct mt7621_nand_header *nhdr;
uint32_t spl_size, crcval;
- image_header_t header;
+ struct legacy_img_hdr header;
int ret;
spl_size = image_get_size(hdr);
@@ -490,7 +490,7 @@ static int mtk_image_verify_mt7621_header(const uint8_t *ptr, int print)
static int mtk_image_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
union lk_hdr *lk = (union lk_hdr *)ptr;
/* nothing to verify for LK image header */
@@ -512,7 +512,7 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,
static void mtk_image_print_header(const void *ptr)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
union lk_hdr *lk = (union lk_hdr *)ptr;
if (le32_to_cpu(lk->magic) == LK_PART_MAGIC) {
@@ -691,7 +691,7 @@ static void mtk_image_set_nand_header(void *ptr, off_t filesize,
static void mtk_image_set_mt7621_header(void *ptr, off_t filesize,
uint32_t loadaddr)
{
- image_header_t *hdr = (image_header_t *)ptr;
+ struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
struct mt7621_stage1_header *shdr;
struct mt7621_nand_header *nhdr;
uint32_t datasize, crcval;