-/**
- * write_uboot() - Write U-Boot, device tree and microcode pointer
- *
- * This writes U-Boot into a place in the flash, followed by its device tree.
- * The microcode pointer is written so that U-Boot can find the microcode in
- * the device tree very early in boot.
- *
- * @image: Pointer to image
- * @size: Size of image in bytes
- * @uboot: Input file information for u-boot.bin
- * @fdt: Input file information for u-boot.dtb
- * @ucode_ptr: Address in U-Boot where the microcode pointer should be placed
- * @return 0 if OK, -ve on error
- */
-static int write_uboot(char *image, int size, struct input_file *uboot,
- struct input_file *fdt, unsigned int ucode_ptr)
-{
- const void *blob;
- const char *data;
- int uboot_size;
- uint32_t *ptr;
- int data_size;
- int offset;
- int node;
- int ret;
-
- uboot_size = write_data(image, size, uboot->addr, uboot->fname);
- if (uboot_size < 0)
- return uboot_size;
- fdt->addr = uboot->addr + uboot_size;
- debug("U-Boot size %#x, FDT at %#x\n", uboot_size, fdt->addr);
- ret = write_data(image, size, fdt->addr, fdt->fname);
- if (ret < 0)
- return ret;
-
- if (ucode_ptr) {
- blob = (void *)image + (uint32_t)(fdt->addr + size);
- debug("DTB at %lx\n", (char *)blob - image);
- node = fdt_node_offset_by_compatible(blob, 0,
- "intel,microcode");
- if (node < 0) {
- debug("No microcode found in FDT: %s\n",
- fdt_strerror(node));
- return -ENOENT;
- }
- data = fdt_getprop(blob, node, "data", &data_size);
- if (!data) {
- debug("No microcode data found in FDT: %s\n",
- fdt_strerror(data_size));
- return -ENOENT;
- }
- offset = (uint32_t)(ucode_ptr + size);
- ptr = (void *)image + offset;
- ptr[0] = (data - image) - size;
- ptr[1] = data_size;
- debug("Wrote microcode pointer at %x: addr=%x, size=%x\n",
- ucode_ptr, ptr[0], ptr[1]);
- }
-
- return 0;
-}
-