+// SPDX-License-Identifier: GPL-2.0+
/*
*
- * SPDX-License-Identifier: GPL-2.0+
- *
* The following Boot Header format/structures and values are defined in the
* following documents:
* * Xilinx Zynq-7000 Technical Reference Manual (Section 6.3)
if (image_size < sizeof(struct zynq_header))
return -1;
+ if (zynqhdr->__reserved1 != 0)
+ return -1;
+
+ if (zynqhdr->__reserved2 != 0)
+ return -1;
+
if (zynqhdr->width_detection != HEADER_WIDTHDETECTION)
return -1;
if (zynqhdr->image_identifier != HEADER_IMAGEIDENTIFIER)
return -1;
}
- return !((params->lflag || params->dflag) ||
- (params->dflag && params->eflag));
+ return !(params->lflag || params->dflag);
}
static int zynqimage_check_image_types(uint8_t type)
return EXIT_FAILURE;
}
+static void zynqimage_parse_initparams(struct zynq_header *zynqhdr,
+ const char *filename)
+{
+ FILE *fp;
+ struct zynq_reginit reginit;
+ unsigned int reg_count = 0;
+ int r, err;
+ struct stat path_stat;
+
+ /* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */
+ fp = fopen(filename, "r");
+ if (!fp) {
+ fprintf(stderr, "Cannot open initparams file: %s\n", filename);
+ exit(1);
+ }
+
+ err = fstat(fileno(fp), &path_stat);
+ if (err) {
+ fclose(fp);
+ return;
+ }
+
+ if (!S_ISREG(path_stat.st_mode)) {
+ fclose(fp);
+ return;
+ }
+
+ do {
+ r = fscanf(fp, "%x %x", ®init.address, ®init.data);
+ if (r == 2) {
+ zynqhdr->register_init[reg_count] = reginit;
+ ++reg_count;
+ }
+ r = fscanf(fp, "%*[^\n]\n"); /* Skip to next line */
+ } while ((r != EOF) && (reg_count < HEADER_REGINITS));
+ fclose(fp);
+}
+
static void zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd,
struct image_tool_params *params)
{
if (params->eflag)
zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep);
+ /* User can pass in text file with init list */
+ if (strlen(params->imagename2))
+ zynqimage_parse_initparams(zynqhdr, params->imagename2);
+
zynqhdr->checksum = zynqimage_checksum(zynqhdr);
}