diff options
author | Stefano Babic <sbabic@denx.de> | 2015-02-13 11:17:01 +0100 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2015-02-13 11:17:01 +0100 |
commit | e72d344386bf80738fab7a6bd37cb321f443093a (patch) | |
tree | d3e02055e6aa903ab80ef87c78d2f38e93981dcf /tools | |
parent | 258c98f8d36ef35d7cb7604847ba73e64d702c2a (diff) | |
parent | bd2a4888b123713adec271d6c8040ca9f609aa2f (diff) | |
download | u-boot-imx-e72d344386bf80738fab7a6bd37cb321f443093a.zip u-boot-imx-e72d344386bf80738fab7a6bd37cb321f443093a.tar.gz u-boot-imx-e72d344386bf80738fab7a6bd37cb321f443093a.tar.bz2 |
Merge branch 'master' of git://git.denx.de/u-boot
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile | 10 | ||||
-rw-r--r-- | tools/aisimage.c | 30 | ||||
-rw-r--r-- | tools/atmelimage.c | 30 | ||||
-rw-r--r-- | tools/default_image.c | 77 | ||||
-rw-r--r-- | tools/dumpimage.c | 170 | ||||
-rw-r--r-- | tools/fit_image.c | 121 | ||||
-rw-r--r-- | tools/gpimage-common.c | 3 | ||||
-rw-r--r-- | tools/gpimage.c | 29 | ||||
-rw-r--r-- | tools/imagetool.c | 124 | ||||
-rw-r--r-- | tools/imagetool.h | 115 | ||||
-rw-r--r-- | tools/imagetool.lds | 24 | ||||
-rw-r--r-- | tools/imximage.c | 30 | ||||
-rw-r--r-- | tools/kwbimage.c | 40 | ||||
-rwxr-xr-x | tools/microcode-tool.py | 90 | ||||
-rw-r--r-- | tools/mkimage.c | 113 | ||||
-rw-r--r-- | tools/mxsimage.c | 35 | ||||
-rw-r--r-- | tools/omapimage.c | 29 | ||||
-rw-r--r-- | tools/patman/README | 13 | ||||
-rw-r--r-- | tools/patman/gitutil.py | 3 | ||||
-rw-r--r-- | tools/patman/patchstream.py | 4 | ||||
-rw-r--r-- | tools/patman/series.py | 21 | ||||
-rw-r--r-- | tools/pblimage.c | 30 | ||||
-rw-r--r-- | tools/socfpgaimage.c | 36 | ||||
-rw-r--r-- | tools/ublimage.c | 29 |
24 files changed, 610 insertions, 596 deletions
diff --git a/tools/Makefile b/tools/Makefile index e549f8e..e4b23eb 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -60,7 +60,8 @@ FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o LIBFDT_OBJS := $(addprefix lib/libfdt/, \ fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o) RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \ - rsa-sign.o rsa-verify.o rsa-checksum.o) + rsa-sign.o rsa-verify.o rsa-checksum.o \ + rsa-mod-exp.o) # common objs for dumpimage and mkimage dumpimage-mkimage-objs := aisimage.o \ @@ -90,6 +91,7 @@ dumpimage-mkimage-objs := aisimage.o \ socfpgaimage.o \ lib/sha1.o \ lib/sha256.o \ + common/hash.o \ ublimage.o \ $(LIBFDT_OBJS) \ $(RSA_OBJS-y) @@ -113,6 +115,10 @@ ifdef CONFIG_FIT_SIGNATURE HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE endif +ifdef CONFIG_SYS_SPI_U_BOOT_OFFS +HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_SPI_U_BOOT_OFFS=$(CONFIG_SYS_SPI_U_BOOT_OFFS) +endif + # MXSImage needs LibSSL ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),) HOSTLOADLIBES_mkimage += -lssl -lcrypto @@ -122,6 +128,8 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage) HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage) +HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds + hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl HOSTCFLAGS_mkexynosspl.o := -pedantic diff --git a/tools/aisimage.c b/tools/aisimage.c index 8de370a..9338342 100644 --- a/tools/aisimage.c +++ b/tools/aisimage.c @@ -413,19 +413,17 @@ int aisimage_check_params(struct image_tool_params *params) /* * aisimage parameters */ -static struct image_type_params aisimage_params = { - .name = "TI Davinci AIS Boot Image support", - .header_size = 0, - .hdr = NULL, - .check_image_type = aisimage_check_image_types, - .verify_header = aisimage_verify_header, - .print_header = aisimage_print_header, - .set_header = aisimage_set_header, - .check_params = aisimage_check_params, - .vrec_header = aisimage_generate, -}; - -void init_ais_image_type(void) -{ - register_image_type(&aisimage_params); -} +U_BOOT_IMAGE_TYPE( + aisimage, + "TI Davinci AIS Boot Image support", + 0, + NULL, + aisimage_check_params, + aisimage_verify_header, + aisimage_print_header, + aisimage_set_header, + NULL, + aisimage_check_image_types, + NULL, + aisimage_generate +); diff --git a/tools/atmelimage.c b/tools/atmelimage.c index c8101d2..5b72ac5 100644 --- a/tools/atmelimage.c +++ b/tools/atmelimage.c @@ -324,19 +324,17 @@ static int atmel_vrec_header(struct image_tool_params *params, return EXIT_SUCCESS; } -static struct image_type_params atmelimage_params = { - .name = "ATMEL ROM-Boot Image support", - .header_size = 0, - .hdr = NULL, - .check_image_type = atmel_check_image_type, - .verify_header = atmel_verify_header, - .print_header = atmel_print_header, - .set_header = atmel_set_header, - .check_params = atmel_check_params, - .vrec_header = atmel_vrec_header, -}; - -void init_atmel_image_type(void) -{ - register_image_type(&atmelimage_params); -} +U_BOOT_IMAGE_TYPE( + atmelimage, + "ATMEL ROM-Boot Image support", + 0, + NULL, + atmel_check_params, + atmel_verify_header, + atmel_print_header, + atmel_set_header, + NULL, + atmel_check_image_type, + NULL, + atmel_vrec_header +); diff --git a/tools/default_image.c b/tools/default_image.c index 0a0792e..cf5c0d4 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -15,6 +15,8 @@ */ #include "imagetool.h" +#include "mkimage.h" + #include <image.h> #include <u-boot/crc.h> @@ -53,9 +55,8 @@ static int image_verify_header(unsigned char *ptr, int image_size, memcpy(hdr, ptr, sizeof(image_header_t)); if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) { - fprintf(stderr, - "%s: Bad Magic Number: \"%s\" is no valid image\n", - params->cmdname, params->imagefile); + debug("%s: Bad Magic Number: \"%s\" is no valid image\n", + params->cmdname, params->imagefile); return -FDT_ERR_BADMAGIC; } @@ -66,9 +67,8 @@ static int image_verify_header(unsigned char *ptr, int image_size, hdr->ih_hcrc = cpu_to_be32(0); /* clear for re-calculation */ if (crc32(0, data, len) != checksum) { - fprintf(stderr, - "%s: ERROR: \"%s\" has bad header checksum!\n", - params->cmdname, params->imagefile); + debug("%s: ERROR: \"%s\" has bad header checksum!\n", + params->cmdname, params->imagefile); return -FDT_ERR_BADSTATE; } @@ -77,9 +77,8 @@ static int image_verify_header(unsigned char *ptr, int image_size, checksum = be32_to_cpu(hdr->ih_dcrc); if (crc32(0, data, len) != checksum) { - fprintf(stderr, - "%s: ERROR: \"%s\" has corrupted data!\n", - params->cmdname, params->imagefile); + debug("%s: ERROR: \"%s\" has corrupted data!\n", + params->cmdname, params->imagefile); return -FDT_ERR_BADSTRUCTURE; } return 0; @@ -117,33 +116,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, image_set_hcrc(hdr, checksum); } -static int image_save_datafile(struct image_tool_params *params, - ulong file_data, ulong file_len) -{ - int dfd; - const char *datafile = params->outfile; - - dfd = open(datafile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, - S_IRUSR | S_IWUSR); - if (dfd < 0) { - fprintf(stderr, "%s: Can't open \"%s\": %s\n", - params->cmdname, datafile, strerror(errno)); - return -1; - } - - if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) { - fprintf(stderr, "%s: Write error on \"%s\": %s\n", - params->cmdname, datafile, strerror(errno)); - close(dfd); - return -1; - } - - close(dfd); - - return 0; -} - -static int image_extract_datafile(void *ptr, struct image_tool_params *params) +static int image_extract_subimage(void *ptr, struct image_tool_params *params) { const image_header_t *hdr = (const image_header_t *)ptr; ulong file_data; @@ -170,25 +143,23 @@ static int image_extract_datafile(void *ptr, struct image_tool_params *params) } /* save the "data file" into the file system */ - return image_save_datafile(params, file_data, file_len); + return imagetool_save_subimage(params->outfile, file_data, file_len); } /* * Default image type parameters definition */ -static struct image_type_params defimage_params = { - .name = "Default Image support", - .header_size = sizeof(image_header_t), - .hdr = (void*)&header, - .check_image_type = image_check_image_types, - .verify_header = image_verify_header, - .print_header = image_print_contents, - .set_header = image_set_header, - .extract_datafile = image_extract_datafile, - .check_params = image_check_params, -}; - -void init_default_image_type(void) -{ - register_image_type(&defimage_params); -} +U_BOOT_IMAGE_TYPE( + defimage, + "Default Image support", + sizeof(image_header_t), + (void *)&header, + image_check_params, + image_verify_header, + image_print_contents, + image_set_header, + image_extract_subimage, + image_check_image_types, + NULL, + NULL +); diff --git a/tools/dumpimage.c b/tools/dumpimage.c index 542ee28..75a5d47 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -12,112 +12,13 @@ static void usage(void); -/* image_type_params linked list to maintain registered image types supports */ -static struct image_type_params *dumpimage_tparams; - /* parameters initialized by core will be used by the image type code */ static struct image_tool_params params = { .type = IH_TYPE_KERNEL, }; -/** - * dumpimage_register() - register respective image generation/list support - * - * the input struct image_type_params is checked and appended to the link - * list, if the input structure is already registered, issue an error - * - * @tparams: Image type parameters - */ -static void dumpimage_register(struct image_type_params *tparams) -{ - struct image_type_params **tp; - - if (!tparams) { - fprintf(stderr, "%s: %s: Null input\n", params.cmdname, - __func__); - exit(EXIT_FAILURE); - } - - /* scan the linked list, check for registry and point the last one */ - for (tp = &dumpimage_tparams; *tp != NULL; tp = &(*tp)->next) { - if (!strcmp((*tp)->name, tparams->name)) { - fprintf(stderr, "%s: %s already registered\n", - params.cmdname, tparams->name); - return; - } - } - - /* add input struct entry at the end of link list */ - *tp = tparams; - /* mark input entry as last entry in the link list */ - tparams->next = NULL; - - debug("Registered %s\n", tparams->name); -} - -/** - * dumpimage_get_type() - find the image type params for a given image type - * - * Scan all registered image types and check the input type_id for each - * supported image type - * - * @return respective image_type_params pointer. If the input type is not - * supported by any of registered image types, returns NULL - */ -static struct image_type_params *dumpimage_get_type(int type) -{ - struct image_type_params *curr; - - for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) { - if (curr->check_image_type) { - if (!curr->check_image_type(type)) - return curr; - } - } - return NULL; -} - /* - * dumpimage_verify_print_header() - verifies the image header - * - * Scan registered image types and verify the image_header for each - * supported image type. If verification is successful, this prints - * the respective header. - * - * @return 0 on success, negative if input image format does not match with - * any of supported image types - */ -static int dumpimage_verify_print_header(void *ptr, struct stat *sbuf) -{ - int retval = -1; - struct image_type_params *curr; - - for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) { - if (curr->verify_header) { - retval = curr->verify_header((unsigned char *)ptr, - sbuf->st_size, ¶ms); - if (retval != 0) - continue; - /* - * Print the image information if verify is - * successful - */ - if (curr->print_header) { - curr->print_header(ptr); - } else { - fprintf(stderr, - "%s: print_header undefined for %s\n", - params.cmdname, curr->name); - } - break; - } - } - - return retval; -} - -/* - * dumpimage_extract_datafile - + * dumpimage_extract_subimage - * * It scans all registered image types, * verifies image_header for each supported image type @@ -127,29 +28,27 @@ static int dumpimage_verify_print_header(void *ptr, struct stat *sbuf) * returns negative if input image format does not match with any of * supported image types */ -static int dumpimage_extract_datafile(void *ptr, struct stat *sbuf) +static int dumpimage_extract_subimage(struct image_type_params *tparams, + void *ptr, struct stat *sbuf) { int retval = -1; - struct image_type_params *curr; - for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) { - if (curr->verify_header) { - retval = curr->verify_header((unsigned char *)ptr, - sbuf->st_size, ¶ms); - if (retval != 0) - continue; - /* - * Extract the file from the image - * if verify is successful - */ - if (curr->extract_datafile) { - curr->extract_datafile(ptr, ¶ms); - } else { - fprintf(stderr, - "%s: extract_datafile undefined for %s\n", - params.cmdname, curr->name); - break; - } + if (tparams->verify_header) { + retval = tparams->verify_header((unsigned char *)ptr, + sbuf->st_size, ¶ms); + if (retval != 0) + return -1; + /* + * Extract the file from the image + * if verify is successful + */ + if (tparams->extract_subimage) { + retval = tparams->extract_subimage(ptr, ¶ms); + } else { + fprintf(stderr, + "%s: extract_subimage undefined for %s\n", + params.cmdname, tparams->name); + return -2; } } @@ -165,12 +64,9 @@ int main(int argc, char **argv) int retval = 0; struct image_type_params *tparams = NULL; - /* Init all image generation/list support */ - register_image_tool(dumpimage_register); - params.cmdname = *argv; - while ((opt = getopt(argc, argv, "li:o:p:V")) != -1) { + while ((opt = getopt(argc, argv, "li:o:T:p:V")) != -1) { switch (opt) { case 'l': params.lflag = 1; @@ -182,6 +78,12 @@ int main(int argc, char **argv) case 'o': params.outfile = optarg; break; + case 'T': + params.type = genimg_get_type_id(optarg); + if (params.type < 0) { + usage(); + } + break; case 'p': params.pflag = strtoul(optarg, &ptr, 10); if (*ptr) { @@ -196,6 +98,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); default: usage(); + break; } } @@ -203,9 +106,9 @@ int main(int argc, char **argv) usage(); /* set tparams as per input type_id */ - tparams = dumpimage_get_type(params.type); + tparams = imagetool_get_type(params.type); if (tparams == NULL) { - fprintf(stderr, "%s: unsupported type %s\n", + fprintf(stderr, "%s: unsupported type: %s\n", params.cmdname, genimg_get_type_name(params.type)); exit(EXIT_FAILURE); } @@ -242,7 +145,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - if ((unsigned)sbuf.st_size < tparams->header_size) { + if ((uint32_t)sbuf.st_size < tparams->header_size) { fprintf(stderr, "%s: Bad size: \"%s\" is not valid image\n", params.cmdname, params.imagefile); @@ -267,13 +170,15 @@ int main(int argc, char **argv) * Extract the data files from within the matched * image type. Returns the error code if not matched */ - retval = dumpimage_extract_datafile(ptr, &sbuf); + retval = dumpimage_extract_subimage(tparams, ptr, + &sbuf); } else { /* * Print the image information for matched image type * Returns the error code if not matched */ - retval = dumpimage_verify_print_header(ptr, &sbuf); + retval = imagetool_verify_print_header(ptr, &sbuf, + tparams, ¶ms); } (void)munmap((void *)ptr, sbuf.st_size); @@ -293,9 +198,10 @@ static void usage(void) " -l ==> list image header information\n", params.cmdname); fprintf(stderr, - " %s -i image [-p position] [-o outfile] data_file\n" - " -i ==> extract from the 'image' a specific 'data_file'" - ", indexed by 'position' (starting at 0)\n", + " %s -i image -T type [-p position] [-o outfile] data_file\n" + " -i ==> extract from the 'image' a specific 'data_file'\n" + " -T ==> set image type to 'type'\n" + " -p ==> 'position' (starting at 0) of the 'data_file' inside the 'image'\n", params.cmdname); fprintf(stderr, " %s -V ==> print version information and exit\n", diff --git a/tools/fit_image.c b/tools/fit_image.c index 3ececf9..eb2a25e 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -155,6 +155,97 @@ err_system: return -1; } +/** + * fit_image_extract - extract a FIT component image + * @fit: pointer to the FIT format image header + * @image_noffset: offset of the component image node + * @file_name: name of the file to store the FIT sub-image + * + * returns: + * zero in case of success or a negative value if fail. + */ +static int fit_image_extract( + const void *fit, + int image_noffset, + const char *file_name) +{ + const void *file_data; + size_t file_size = 0; + + /* get the "data" property of component at offset "image_noffset" */ + fit_image_get_data(fit, image_noffset, &file_data, &file_size); + + /* save the "file_data" into the file specified by "file_name" */ + return imagetool_save_subimage(file_name, (ulong) file_data, file_size); +} + +/** + * fit_extract_contents - retrieve a sub-image component from the FIT image + * @ptr: pointer to the FIT format image header + * @params: command line parameters + * + * returns: + * zero in case of success or a negative value if fail. + */ +static int fit_extract_contents(void *ptr, struct image_tool_params *params) +{ + int images_noffset; + int noffset; + int ndepth; + const void *fit = ptr; + int count = 0; + const char *p; + + /* Indent string is defined in header image.h */ + p = IMAGE_INDENT_STRING; + + if (!fit_check_format(fit)) { + printf("Bad FIT image format\n"); + return -1; + } + + /* Find images parent node offset */ + images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); + if (images_noffset < 0) { + printf("Can't find images parent node '%s' (%s)\n", + FIT_IMAGES_PATH, fdt_strerror(images_noffset)); + return -1; + } + + /* Avoid any overrun */ + count = fit_get_subimage_count(fit, images_noffset); + if ((params->pflag < 0) || (count <= params->pflag)) { + printf("No such component at '%d'\n", params->pflag); + return -1; + } + + /* Process its subnodes, extract the desired component from image */ + for (ndepth = 0, count = 0, + noffset = fdt_next_node(fit, images_noffset, &ndepth); + (noffset >= 0) && (ndepth > 0); + noffset = fdt_next_node(fit, noffset, &ndepth)) { + if (ndepth == 1) { + /* + * Direct child node of the images parent node, + * i.e. component image node. + */ + if (params->pflag == count) { + printf("Extracted:\n%s Image %u (%s)\n", p, + count, fit_get_name(fit, noffset, NULL)); + + fit_image_print(fit, noffset, p); + + return fit_image_extract(fit, noffset, + params->outfile); + } + + count++; + } + } + + return 0; +} + static int fit_check_params(struct image_tool_params *params) { return ((params->dflag && (params->fflag || params->lflag)) || @@ -162,19 +253,17 @@ static int fit_check_params(struct image_tool_params *params) (params->lflag && (params->dflag || params->fflag))); } -static struct image_type_params fitimage_params = { - .name = "FIT Image support", - .header_size = sizeof(image_header_t), - .hdr = (void*)&header, - .verify_header = fit_verify_header, - .print_header = fit_print_contents, - .check_image_type = fit_check_image_types, - .fflag_handle = fit_handle_file, - .set_header = NULL, /* FIT images use DTB header */ - .check_params = fit_check_params, -}; - -void init_fit_image_type (void) -{ - register_image_type(&fitimage_params); -} +U_BOOT_IMAGE_TYPE( + fitimage, + "FIT Image support", + sizeof(image_header_t), + (void *)&header, + fit_check_params, + fit_verify_header, + fit_print_contents, + NULL, + fit_extract_contents, + fit_check_image_types, + fit_handle_file, + NULL /* FIT images use DTB header */ +); diff --git a/tools/gpimage-common.c b/tools/gpimage-common.c index b343a3a..5ad52be 100644 --- a/tools/gpimage-common.c +++ b/tools/gpimage-common.c @@ -32,7 +32,8 @@ void to_be32(uint32_t *gph_size, uint32_t *gph_load_addr) int gph_verify_header(struct gp_header *gph, int be) { - uint32_t gph_size = gph->size, gph_load_addr = gph->load_addr; + uint32_t gph_size = gph->size; + uint32_t gph_load_addr = gph->load_addr; if (be) to_be32(&gph_size, &gph_load_addr); diff --git a/tools/gpimage.c b/tools/gpimage.c index 1cabb5b..1adc55c 100644 --- a/tools/gpimage.c +++ b/tools/gpimage.c @@ -60,18 +60,17 @@ static void gpimage_set_header(void *ptr, struct stat *sbuf, int ifd, /* * gpimage parameters */ -static struct image_type_params gpimage_params = { - .name = "TI KeyStone GP Image support", - .header_size = GPIMAGE_HDR_SIZE, - .hdr = (void *)&gpimage_header, - .check_image_type = gpimage_check_image_types, - .verify_header = gpimage_verify_header, - .print_header = gpimage_print_header, - .set_header = gpimage_set_header, - .check_params = gpimage_check_params, -}; - -void init_gpimage_type(void) -{ - register_image_type(&gpimage_params); -} +U_BOOT_IMAGE_TYPE( + gpimage, + "TI KeyStone GP Image support", + GPIMAGE_HDR_SIZE, + (void *)&gpimage_header, + gpimage_check_params, + gpimage_verify_header, + gpimage_print_header, + gpimage_set_header, + NULL, + gpimage_check_image_types, + NULL, + NULL +); diff --git a/tools/imagetool.c b/tools/imagetool.c index 98717bd..148e466 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -8,57 +8,87 @@ #include "imagetool.h" -/* - * Callback function to register a image type within a tool - */ -static imagetool_register_t register_func; +#include <image.h> -/* - * register_image_tool - - * - * The tool provides its own registration function in order to all image - * types initialize themselves. - */ -void register_image_tool(imagetool_register_t image_register) +struct image_type_params *imagetool_get_type(int type) { - /* - * Save the image tool callback function. It will be used to register - * image types within that tool - */ - register_func = image_register; + struct image_type_params *curr; + struct image_type_params *start = ll_entry_start( + struct image_type_params, image_type); + struct image_type_params *end = ll_entry_end( + struct image_type_params, image_type); - /* Init ATMEL ROM Boot Image generation/list support */ - init_atmel_image_type(); - /* Init Freescale PBL Boot image generation/list support */ - init_pbl_image_type(); - /* Init Kirkwood Boot image generation/list support */ - init_kwb_image_type(); - /* Init Freescale imx Boot image generation/list support */ - init_imx_image_type(); - /* Init Freescale mxs Boot image generation/list support */ - init_mxs_image_type(); - /* Init FIT image generation/list support */ - init_fit_image_type(); - /* Init TI OMAP Boot image generation/list support */ - init_omap_image_type(); - /* Init Default image generation/list support */ - init_default_image_type(); - /* Init Davinci UBL support */ - init_ubl_image_type(); - /* Init Davinci AIS support */ - init_ais_image_type(); - /* Init Altera SOCFPGA support */ - init_socfpga_image_type(); - /* Init TI Keystone boot image generation/list support */ - init_gpimage_type(); + for (curr = start; curr != end; curr++) { + if (curr->check_image_type) { + if (!curr->check_image_type(type)) + return curr; + } + } + return NULL; } -/* - * register_image_type - - * - * Register a image type within a tool - */ -void register_image_type(struct image_type_params *tparams) +int imagetool_verify_print_header( + void *ptr, + struct stat *sbuf, + struct image_type_params *tparams, + struct image_tool_params *params) { - register_func(tparams); + int retval = -1; + struct image_type_params *curr; + + struct image_type_params *start = ll_entry_start( + struct image_type_params, image_type); + struct image_type_params *end = ll_entry_end( + struct image_type_params, image_type); + + for (curr = start; curr != end; curr++) { + if (curr->verify_header) { + retval = curr->verify_header((unsigned char *)ptr, + sbuf->st_size, params); + + if (retval == 0) { + /* + * Print the image information if verify is + * successful + */ + if (curr->print_header) { + curr->print_header(ptr); + } else { + fprintf(stderr, + "%s: print_header undefined for %s\n", + params->cmdname, curr->name); + } + break; + } + } + } + + return retval; +} + +int imagetool_save_subimage( + const char *file_name, + ulong file_data, + ulong file_len) +{ + int dfd; + + dfd = open(file_name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + S_IRUSR | S_IWUSR); + if (dfd < 0) { + fprintf(stderr, "Can't open \"%s\": %s\n", + file_name, strerror(errno)); + return -1; + } + + if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) { + fprintf(stderr, "Write error on \"%s\": %s\n", + file_name, strerror(errno)); + close(dfd); + return -1; + } + + close(dfd); + + return 0; } diff --git a/tools/imagetool.h b/tools/imagetool.h index 8bce059..f35dec7 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -19,6 +19,16 @@ #include <time.h> #include <unistd.h> #include <u-boot/sha1.h> + +/* define __KERNEL__ in order to get the definitions + * required by the linker list. This is probably not + * the best way to do this */ +#ifndef __KERNEL__ +#define __KERNEL__ +#include <linker_lists.h> +#undef __KERNEL__ +#endif /* __KERNEL__ */ + #include "fdt_host.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -100,14 +110,15 @@ struct image_type_params { void (*set_header) (void *, struct stat *, int, struct image_tool_params *); /* - * This function is used by the command to retrieve a data file from - * the image (i.e. dumpimage -i <image> -p <position> <data_file>). + * This function is used by the command to retrieve a component + * (sub-image) from the image (i.e. dumpimage -i <image> -p <position> + * <sub-image-name>). * Thus the code to extract a file from an image must be put here. * * Returns 0 if the file was successfully retrieved from the image, * or a negative value on error. */ - int (*extract_datafile) (void *, struct image_tool_params *); + int (*extract_subimage)(void *, struct image_tool_params *); /* * Some image generation support for ex (default image type) supports * more than one type_ids, this callback function is used to check @@ -127,50 +138,88 @@ struct image_type_params { */ int (*vrec_header) (struct image_tool_params *, struct image_type_params *); - /* pointer to the next registered entry in linked list */ - struct image_type_params *next; }; -/* - * Tool registration function. +/** + * imagetool_get_type() - find the image type params for a given image type + * + * It scans all registers image type supports + * checks the input type for each supported image type + * + * if successful, + * returns respective image_type_params pointer if success + * if input type_id is not supported by any of image_type_support + * returns NULL */ -typedef void (*imagetool_register_t)(struct image_type_params *); +struct image_type_params *imagetool_get_type(int type); /* - * Initializes all image types with the given registration callback - * function. - * An image tool uses this function to initialize all image types. + * imagetool_verify_print_header() - verifies the image header + * + * Scan registered image types and verify the image_header for each + * supported image type. If verification is successful, this prints + * the respective header. + * + * @return 0 on success, negative if input image format does not match with + * any of supported image types */ -void register_image_tool(imagetool_register_t image_register); +int imagetool_verify_print_header( + void *ptr, + struct stat *sbuf, + struct image_type_params *tparams, + struct image_tool_params *params); -/* - * Register a image type within a tool. - * An image type uses this function to register itself within - * all tools. +/** + * imagetool_save_subimage - store data into a file + * @file_name: name of the destination file + * @file_data: data to be written + * @file_len: the amount of data to store + * + * imagetool_save_subimage() store file_len bytes of data pointed by file_data + * into the file name by file_name. + * + * returns: + * zero in case of success or a negative value if fail. */ -void register_image_type(struct image_type_params *tparams); +int imagetool_save_subimage( + const char *file_name, + ulong file_data, + ulong file_len); /* * There is a c file associated with supported image type low level code * for ex. default_image.c, fit_image.c - * init_xxx_type() is the only function referred by image tool core to avoid - * a single lined header file, you can define them here - * - * Supported image types init functions */ -void init_default_image_type(void); -void init_atmel_image_type(void); -void init_pbl_image_type(void); -void init_ais_image_type(void); -void init_kwb_image_type(void); -void init_imx_image_type(void); -void init_mxs_image_type(void); -void init_fit_image_type(void); -void init_ubl_image_type(void); -void init_omap_image_type(void); -void init_socfpga_image_type(void); -void init_gpimage_type(void); + void pbl_load_uboot(int fd, struct image_tool_params *mparams); +#define U_BOOT_IMAGE_TYPE( \ + _id, \ + _name, \ + _header_size, \ + _header, \ + _check_params, \ + _verify_header, \ + _print_header, \ + _set_header, \ + _extract_subimage, \ + _check_image_type, \ + _fflag_handle, \ + _vrec_header \ + ) \ + ll_entry_declare(struct image_type_params, _id, image_type) = { \ + .name = _name, \ + .header_size = _header_size, \ + .hdr = _header, \ + .check_params = _check_params, \ + .verify_header = _verify_header, \ + .print_header = _print_header, \ + .set_header = _set_header, \ + .extract_subimage = _extract_subimage, \ + .check_image_type = _check_image_type, \ + .fflag_handle = _fflag_handle, \ + .vrec_header = _vrec_header \ + } + #endif /* _IMAGETOOL_H_ */ diff --git a/tools/imagetool.lds b/tools/imagetool.lds new file mode 100644 index 0000000..7e92b4a --- /dev/null +++ b/tools/imagetool.lds @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2011-2012 The Chromium OS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +SECTIONS +{ + + . = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + } + + __u_boot_sandbox_option_start = .; + _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } + __u_boot_sandbox_option_end = .; + + __bss_start = .; +} + +INSERT BEFORE .data; diff --git a/tools/imximage.c b/tools/imximage.c index f880edd..6f469ae 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -696,19 +696,17 @@ static int imximage_generate(struct image_tool_params *params, /* * imximage parameters */ -static struct image_type_params imximage_params = { - .name = "Freescale i.MX Boot Image support", - .header_size = 0, - .hdr = NULL, - .check_image_type = imximage_check_image_types, - .verify_header = imximage_verify_header, - .print_header = imximage_print_header, - .set_header = imximage_set_header, - .check_params = imximage_check_params, - .vrec_header = imximage_generate, -}; - -void init_imx_image_type(void) -{ - register_image_type(&imximage_params); -} +U_BOOT_IMAGE_TYPE( + imximage, + "Freescale i.MX Boot Image support", + 0, + NULL, + imximage_check_params, + imximage_verify_header, + imximage_print_header, + imximage_set_header, + NULL, + imximage_check_image_types, + NULL, + imximage_generate +); diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 807d466..de5c808 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -868,6 +868,16 @@ static int kwbimage_generate(struct image_tool_params *params, sizeof(struct ext_hdr_v0); } else { alloc_len = image_headersz_v1(params, NULL); +#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + if (alloc_len > CONFIG_SYS_SPI_U_BOOT_OFFS) { + fprintf(stderr, "Error: Image header (incl. SPL image) too big!\n"); + fprintf(stderr, "header=0x%x CONFIG_SYS_SPI_U_BOOT_OFFS=0x%x!\n", + alloc_len, CONFIG_SYS_SPI_U_BOOT_OFFS); + fprintf(stderr, "Increase CONFIG_SYS_SPI_U_BOOT_OFFS!\n"); + } else { + alloc_len = CONFIG_SYS_SPI_U_BOOT_OFFS; + } +#endif } hdr = malloc(alloc_len); @@ -905,19 +915,17 @@ static int kwbimage_check_params(struct image_tool_params *params) /* * kwbimage type parameters definition */ -static struct image_type_params kwbimage_params = { - .name = "Marvell MVEBU Boot Image support", - .header_size = 0, /* no fixed header size */ - .hdr = NULL, - .vrec_header = kwbimage_generate, - .check_image_type = kwbimage_check_image_types, - .verify_header = kwbimage_verify_header, - .print_header = kwbimage_print_header, - .set_header = kwbimage_set_header, - .check_params = kwbimage_check_params, -}; - -void init_kwb_image_type (void) -{ - register_image_type(&kwbimage_params); -} +U_BOOT_IMAGE_TYPE( + kwbimage, + "Marvell MVEBU Boot Image support", + 0, + NULL, + kwbimage_check_params, + kwbimage_verify_header, + kwbimage_print_header, + kwbimage_set_header, + NULL, + kwbimage_check_image_types, + NULL, + kwbimage_generate +); diff --git a/tools/microcode-tool.py b/tools/microcode-tool.py index 003716d..71c2e91 100755 --- a/tools/microcode-tool.py +++ b/tools/microcode-tool.py @@ -76,6 +76,35 @@ def ParseFile(fname): microcodes[name] = Microcode(name, data) return date, license_text, microcodes +def ParseHeaderFiles(fname_list): + """Parse a list of header files and return the component parts + + Args: + fname_list: List of files to parse + Returns: + date: String containing date from the file's header + license_text: List of text lines for the license file + microcodes: List of Microcode objects from the file + """ + microcodes = {} + license_text = [] + date = '' + name = None + for fname in fname_list: + name = os.path.basename(fname).lower() + name = os.path.splitext(name)[0] + data = [] + with open(fname) as fd: + for line in fd: + line = line.rstrip() + + # Omit anything after the last comma + words = line.split(',')[:-1] + data += [word + ',' for word in words] + microcodes[name] = Microcode(name, data) + return date, license_text, microcodes + + def List(date, microcodes, model): """List the available microcode chunks @@ -129,13 +158,13 @@ def FindMicrocode(microcodes, model): break return found, tried -def CreateFile(date, license_text, mcode, outfile): +def CreateFile(date, license_text, mcodes, outfile): """Create a microcode file in U-Boot's .dtsi format Args: date: String containing date of original microcode file license: List of text lines for the license file - mcode: Microcode object to write + mcodes: Microcode objects to write (normally only 1) outfile: Filename to write to ('-' for stdout) """ out = '''/*%s @@ -159,15 +188,22 @@ intel,processor-flags = <%#x>; data = <%s \t>;''' words = '' - for i in range(len(mcode.words)): - if not (i & 3): - words += '\n' - val = mcode.words[i] - # Change each word so it will be little-endian in the FDT - # This data is needed before RAM is available on some platforms so we - # cannot do an endianness swap on boot. - val = struct.unpack("<I", struct.pack(">I", val))[0] - words += '\t%#010x' % val + add_comments = len(mcodes) > 1 + for mcode in mcodes: + if add_comments: + words += '\n/* %s */' % mcode.name + for i in range(len(mcode.words)): + if not (i & 3): + words += '\n' + val = mcode.words[i] + # Change each word so it will be little-endian in the FDT + # This data is needed before RAM is available on some platforms so + # we cannot do an endianness swap on boot. + val = struct.unpack("<I", struct.pack(">I", val))[0] + words += '\t%#010x' % val + + # Use the first microcode for the headers + mcode = mcodes[0] # Take care to avoid adding a space before a tab text = '' @@ -187,8 +223,8 @@ data = <%s print >> sys.stderr, "Creating directory '%s'" % MICROCODE_DIR os.makedirs(MICROCODE_DIR) outfile = os.path.join(MICROCODE_DIR, mcode.name + '.dtsi') - print >> sys.stderr, "Writing microcode for '%s' to '%s'" % ( - mcode.name, outfile) + print >> sys.stderr, "Writing microcode for '%s' to '%s'" % ( + ', '.join([mcode.name for mcode in mcodes]), outfile) with open(outfile, 'w') as fd: print >> fd, out % tuple(args) @@ -198,8 +234,12 @@ def MicrocodeTool(): parser = OptionParser() parser.add_option('-d', '--mcfile', type='string', action='store', help='Name of microcode.dat file') + parser.add_option('-H', '--headerfile', type='string', action='append', + help='Name of .h file containing microcode') parser.add_option('-m', '--model', type='string', action='store', - help='Model name to extract') + help="Model name to extract ('all' for all)") + parser.add_option('-M', '--multiple', type='string', action='store', + help="Allow output of multiple models") parser.add_option('-o', '--outfile', type='string', action='store', help='Filename to use for output (- for stdout), default is' ' %s/<name>.dtsi' % MICROCODE_DIR) @@ -224,9 +264,14 @@ def MicrocodeTool(): if cmd not in commands: parser.error("Unknown command '%s'" % cmd) - if not options.mcfile: - parser.error('You must specify a microcode file') - date, license_text, microcodes = ParseFile(options.mcfile) + if (not not options.mcfile) != (not not options.mcfile): + parser.error("You must specify either header files or a microcode file, not both") + if options.headerfile: + date, license_text, microcodes = ParseHeaderFiles(options.headerfile) + elif options.mcfile: + date, license_text, microcodes = ParseFile(options.mcfile) + else: + parser.error('You must specify a microcode file (or header files)') if cmd == 'list': List(date, microcodes, options.model) @@ -236,16 +281,21 @@ def MicrocodeTool(): if not options.model: parser.error('You must specify a model to create') model = options.model.lower() - mcode_list, tried = FindMicrocode(microcodes, model) + if options.model == 'all': + options.multiple = True + mcode_list = microcodes.values() + tried = [] + else: + mcode_list, tried = FindMicrocode(microcodes, model) if not mcode_list: parser.error("Unknown model '%s' (%s) - try 'list' to list" % (model, ', '.join(tried))) - if len(mcode_list) > 1: + if not options.multiple and len(mcode_list) > 1: parser.error("Ambiguous model '%s' (%s) matched %s - try 'list' " "to list or specify a particular file" % (model, ', '.join(tried), ', '.join([m.name for m in mcode_list]))) - CreateFile(date, license_text, mcode_list[0], options.outfile) + CreateFile(date, license_text, mcode_list, options.outfile) else: parser.error("Unknown command '%s'" % cmd) diff --git a/tools/mkimage.c b/tools/mkimage.c index c70408c..5ccd951 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -15,9 +15,6 @@ static void copy_file(int, const char *, int); static void usage(void); -/* image_type_params link list to maintain registered image type supports */ -struct image_type_params *mkimage_tparams = NULL; - /* parameters initialized by core will be used by the image type code */ struct image_tool_params params = { .os = IH_OS_LINUX, @@ -29,106 +26,6 @@ struct image_tool_params params = { .imagename2 = "", }; -/* - * mkimage_register - - * - * It is used to register respective image generation/list support to the - * mkimage core - * - * the input struct image_type_params is checked and appended to the link - * list, if the input structure is already registered, error - */ -void mkimage_register (struct image_type_params *tparams) -{ - struct image_type_params **tp; - - if (!tparams) { - fprintf (stderr, "%s: %s: Null input\n", - params.cmdname, __FUNCTION__); - exit (EXIT_FAILURE); - } - - /* scan the linked list, check for registry and point the last one */ - for (tp = &mkimage_tparams; *tp != NULL; tp = &(*tp)->next) { - if (!strcmp((*tp)->name, tparams->name)) { - fprintf (stderr, "%s: %s already registered\n", - params.cmdname, tparams->name); - return; - } - } - - /* add input struct entry at the end of link list */ - *tp = tparams; - /* mark input entry as last entry in the link list */ - tparams->next = NULL; - - debug ("Registered %s\n", tparams->name); -} - -/* - * mkimage_get_type - - * - * It scans all registers image type supports - * checks the input type_id for each supported image type - * - * if successful, - * returns respective image_type_params pointer if success - * if input type_id is not supported by any of image_type_support - * returns NULL - */ -struct image_type_params *mkimage_get_type(int type) -{ - struct image_type_params *curr; - - for (curr = mkimage_tparams; curr != NULL; curr = curr->next) { - if (curr->check_image_type) { - if (!curr->check_image_type (type)) - return curr; - } - } - return NULL; -} - -/* - * mkimage_verify_print_header - - * - * It scans mkimage_tparams link list, - * verifies image_header for each supported image type - * if verification is successful, prints respective header - * - * returns negative if input image format does not match with any of - * supported image types - */ -int mkimage_verify_print_header (void *ptr, struct stat *sbuf) -{ - int retval = -1; - struct image_type_params *curr; - - for (curr = mkimage_tparams; curr != NULL; curr = curr->next ) { - if (curr->verify_header) { - retval = curr->verify_header ( - (unsigned char *)ptr, sbuf->st_size, - ¶ms); - - if (retval == 0) { - /* - * Print the image information - * if verify is successful - */ - if (curr->print_header) - curr->print_header (ptr); - else { - fprintf (stderr, - "%s: print_header undefined for %s\n", - params.cmdname, curr->name); - } - break; - } - } - } - return retval; -} - int main (int argc, char **argv) { @@ -139,9 +36,6 @@ main (int argc, char **argv) struct image_type_params *tparams = NULL; int pad_len = 0; - /* Init all image generation/list support */ - register_image_tool(mkimage_register); - params.cmdname = *argv; params.addr = params.ep = 0; @@ -279,7 +173,7 @@ NXTARG: ; usage (); /* set tparams as per input type_id */ - tparams = mkimage_get_type(params.type); + tparams = imagetool_get_type(params.type); if (tparams == NULL) { fprintf (stderr, "%s: unsupported type %s\n", params.cmdname, genimg_get_type_name(params.type)); @@ -363,7 +257,8 @@ NXTARG: ; * Print the image information for matched image type * Returns the error code if not matched */ - retval = mkimage_verify_print_header (ptr, &sbuf); + retval = imagetool_verify_print_header(ptr, &sbuf, + tparams, ¶ms); (void) munmap((void *)ptr, sbuf.st_size); (void) close (ifd); @@ -529,7 +424,7 @@ copy_file (int ifd, const char *datafile, int pad) uint8_t zeros[4096]; int offset = 0; int size; - struct image_type_params *tparams = mkimage_get_type (params.type); + struct image_type_params *tparams = imagetool_get_type(params.type); if (pad >= sizeof(zeros)) { fprintf(stderr, "%s: Can't pad to %d\n", diff --git a/tools/mxsimage.c b/tools/mxsimage.c index 04beefe..98fc644 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -2312,25 +2312,18 @@ fail: /* * mxsimage parameters */ -static struct image_type_params mxsimage_params = { - .name = "Freescale MXS Boot Image support", - .header_size = 0, - .hdr = NULL, - .check_image_type = mxsimage_check_image_types, - .verify_header = mxsimage_verify_header, - .print_header = mxsimage_print_header, - .set_header = mxsimage_set_header, - .check_params = mxsimage_check_params, - .vrec_header = mxsimage_generate, -}; - -void init_mxs_image_type(void) -{ - register_image_type(&mxsimage_params); -} - -#else -void init_mxs_image_type(void) -{ -} +U_BOOT_IMAGE_TYPE( + mxsimage, + "Freescale MXS Boot Image support", + 0, + NULL, + mxsimage_check_params, + mxsimage_verify_header, + mxsimage_print_header, + mxsimage_set_header, + NULL, + mxsimage_check_image_types, + NULL, + mxsimage_generate +); #endif diff --git a/tools/omapimage.c b/tools/omapimage.c index 1e0c164..7198b33 100644 --- a/tools/omapimage.c +++ b/tools/omapimage.c @@ -162,18 +162,17 @@ static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd, /* * omapimage parameters */ -static struct image_type_params omapimage_params = { - .name = "TI OMAP CH/GP Boot Image support", - .header_size = OMAP_FILE_HDR_SIZE, - .hdr = (void *)&omapimage_header, - .check_image_type = omapimage_check_image_types, - .verify_header = omapimage_verify_header, - .print_header = omapimage_print_header, - .set_header = omapimage_set_header, - .check_params = gpimage_check_params, -}; - -void init_omap_image_type(void) -{ - register_image_type(&omapimage_params); -} +U_BOOT_IMAGE_TYPE( + omapimage, + "TI OMAP CH/GP Boot Image support", + OMAP_FILE_HDR_SIZE, + (void *)&omapimage_header, + gpimage_check_params, + omapimage_verify_header, + omapimage_print_header, + omapimage_set_header, + NULL, + omapimage_check_image_types, + NULL, + NULL +); diff --git a/tools/patman/README b/tools/patman/README index e466886..7d039e8 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -52,12 +52,15 @@ will get a consistent result each time. How to configure it =================== -For most cases of using patman for U-Boot development, patman will -locate and use the file 'doc/git-mailrc' in your U-Boot directory. -This contains most of the aliases you will need. +For most cases of using patman for U-Boot development, patman can use the +file 'doc/git-mailrc' in your U-Boot directory to supply the email aliases +you need. To make this work, tell git where to find the file by typing +this once: -For Linux the 'scripts/get_maintainer.pl' handles figuring out where -to send patches pretty well. + git config sendemail.aliasesfile doc/git-mailrc + +For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles figuring +out where to send patches pretty well. During the first run patman creates a config file for you by taking the default user name and email address from the global .gitconfig file. diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index cc5a55a..c593070 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -392,7 +392,8 @@ def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname, "Or do something like this\n" "git config sendemail.to u-boot@lists.denx.de") return - cc = BuildEmailList(series.get('cc'), '--cc', alias, raise_on_error) + cc = BuildEmailList(list(set(series.get('cc')) - set(series.get('to'))), + '--cc', alias, raise_on_error) if self_only: to = BuildEmailList([os.getenv('USER')], '--to', alias, raise_on_error) cc = [] diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index da04883..8c3a0ec 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -139,6 +139,9 @@ class PatchStream: # Initially we have no output. Prepare the input line string out = [] line = line.rstrip('\n') + + commit_match = re_commit.match(line) if self.is_log else None + if self.is_log: if line[:4] == ' ': line = line[4:] @@ -146,7 +149,6 @@ class PatchStream: # Handle state transition and skipping blank lines series_tag_match = re_series_tag.match(line) commit_tag_match = re_commit_tag.match(line) - commit_match = re_commit.match(line) if self.is_log else None cover_cc_match = re_cover_cc.match(line) signoff_match = re_signoff.match(line) tag_match = None diff --git a/tools/patman/series.py b/tools/patman/series.py index b67f870..60ebc76 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -94,6 +94,9 @@ class Series(dict): cmd: The git command we would have run process_tags: Process tags as if they were aliases """ + to_set = set(gitutil.BuildEmailList(self.to)); + cc_set = set(gitutil.BuildEmailList(self.cc)); + col = terminal.Color() print 'Dry run, so not doing much. But I would do this:' print @@ -106,24 +109,16 @@ class Series(dict): commit = self.commits[upto] print col.Color(col.GREEN, ' %s' % args[upto]) cc_list = list(self._generated_cc[commit.patch]) - - # Skip items in To list - if 'to' in self: - try: - map(cc_list.remove, gitutil.BuildEmailList(self.to)) - except ValueError: - pass - - for email in cc_list: + for email in set(cc_list) - to_set - cc_set: if email == None: email = col.Color(col.YELLOW, "<alias '%s' not found>" % tag) if email: print ' Cc: ',email print - for item in gitutil.BuildEmailList(self.get('to', '<none>')): + for item in to_set: print 'To:\t ', item - for item in gitutil.BuildEmailList(self.cc): + for item in cc_set - to_set: print 'Cc:\t ', item print 'Version: ', self.get('version') print 'Prefix:\t ', self.get('prefix') @@ -131,7 +126,7 @@ class Series(dict): print 'Cover: %d lines' % len(self.cover) cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) all_ccs = itertools.chain(cover_cc, *self._generated_cc.values()) - for email in set(all_ccs): + for email in set(all_ccs) - to_set - cc_set: print ' Cc: ',email if cmd: print 'Git command: %s' % cmd @@ -230,7 +225,7 @@ class Series(dict): if add_maintainers: list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list - print >>fd, commit.patch, ', '.join(list) + print >>fd, commit.patch, ', '.join(set(list)) self._generated_cc[commit.patch] = list if cover_fname: diff --git a/tools/pblimage.c b/tools/pblimage.c index 2a799ab..d74fde9 100644 --- a/tools/pblimage.c +++ b/tools/pblimage.c @@ -308,19 +308,17 @@ int pblimage_check_params(struct image_tool_params *params) }; /* pblimage parameters */ -static struct image_type_params pblimage_params = { - .name = "Freescale PBL Boot Image support", - .header_size = sizeof(struct pbl_header), - .hdr = (void *)&pblimage_header, - .check_image_type = pblimage_check_image_types, - .check_params = pblimage_check_params, - .verify_header = pblimage_verify_header, - .print_header = pblimage_print_header, - .set_header = pblimage_set_header, -}; - -void init_pbl_image_type(void) -{ - pbl_size = 0; - register_image_type(&pblimage_params); -} +U_BOOT_IMAGE_TYPE( + pblimage, + "Freescale PBL Boot Image support", + sizeof(struct pbl_header), + (void *)&pblimage_header, + pblimage_check_params, + pblimage_verify_header, + pblimage_print_header, + pblimage_set_header, + NULL, + pblimage_check_image_types, + NULL, + NULL +); diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index 917873e..8fe91fe 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -33,6 +33,8 @@ #include "pbl_crc32.h" #include "imagetool.h" +#include "mkimage.h" + #include <image.h> #define HEADER_OFFSET 0x40 @@ -133,12 +135,12 @@ static int verify_buffer(const uint8_t *buf) len = verify_header(buf + HEADER_OFFSET); if (len < 0) { - fprintf(stderr, "Invalid header\n"); + debug("Invalid header\n"); return -1; } if (len < HEADER_OFFSET || len > PADDED_SIZE) { - fprintf(stderr, "Invalid header length (%i)\n", len); + debug("Invalid header length (%i)\n", len); return -1; } @@ -241,19 +243,17 @@ static void socfpgaimage_set_header(void *ptr, struct stat *sbuf, int ifd, sign_buffer(buf, 0, 0, data_size, 0); } -static struct image_type_params socfpgaimage_params = { - .name = "Altera SOCFPGA preloader support", - .vrec_header = socfpgaimage_vrec_header, - .header_size = 0, /* This will be modified by vrec_header() */ - .hdr = (void *)buffer, - .check_image_type = socfpgaimage_check_image_types, - .verify_header = socfpgaimage_verify_header, - .print_header = socfpgaimage_print_header, - .set_header = socfpgaimage_set_header, - .check_params = socfpgaimage_check_params, -}; - -void init_socfpga_image_type(void) -{ - register_image_type(&socfpgaimage_params); -} +U_BOOT_IMAGE_TYPE( + socfpgaimage, + "Altera SOCFPGA preloader support", + 0, /* This will be modified by vrec_header() */ + (void *)buffer, + socfpgaimage_check_params, + socfpgaimage_verify_header, + socfpgaimage_print_header, + socfpgaimage_set_header, + NULL, + socfpgaimage_check_image_types, + NULL, + socfpgaimage_vrec_header +); diff --git a/tools/ublimage.c b/tools/ublimage.c index cbbbe20..6ed1eef 100644 --- a/tools/ublimage.c +++ b/tools/ublimage.c @@ -244,18 +244,17 @@ int ublimage_check_params(struct image_tool_params *params) /* * ublimage parameters */ -static struct image_type_params ublimage_params = { - .name = "Davinci UBL boot support", - .header_size = sizeof(struct ubl_header), - .hdr = (void *)&ublimage_header, - .check_image_type = ublimage_check_image_types, - .verify_header = ublimage_verify_header, - .print_header = ublimage_print_header, - .set_header = ublimage_set_header, - .check_params = ublimage_check_params, -}; - -void init_ubl_image_type(void) -{ - register_image_type(&ublimage_params); -} +U_BOOT_IMAGE_TYPE( + ublimage, + "Davinci UBL boot support", + sizeof(struct ubl_header), + (void *)&ublimage_header, + ublimage_check_params, + ublimage_verify_header, + ublimage_print_header, + ublimage_set_header, + NULL, + ublimage_check_image_types, + NULL, + NULL +); |