Add new UUIDs for QEMU x86/x86-64 EFI capsules and register them with update_info. Enable the config options to bind the pflash with dfu, expecting to follow the typical convention of the first bank (nor0) containing u-boot.
Signed-off-by: Elliot Berman <[email protected]> --- board/emulation/common/Kconfig | 2 ++ board/emulation/common/qemu_dfu.c | 16 ++++----------- board/emulation/common/qemu_mtdparts.c | 36 +++++++++++++++------------------ board/emulation/qemu-x86/Kconfig | 3 +++ board/emulation/qemu-x86/Makefile | 3 +++ board/emulation/qemu-x86/qemu-x86.c | 37 ++++++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 32 deletions(-) diff --git a/board/emulation/common/Kconfig b/board/emulation/common/Kconfig index 4c15c8bcb89..79e8a5cfb01 100644 --- a/board/emulation/common/Kconfig +++ b/board/emulation/common/Kconfig @@ -1,6 +1,8 @@ config MTDPARTS_NOR0 string "mtd boot partition for nor0" default "64m(u-boot)" if TARGET_QEMU_ARM_64BIT && !TFABOOT + default "2m(u-boot)" if TARGET_QEMU_X86_64 + default "1m(u-boot)" if TARGET_QEMU_X86 depends on SYS_MTDPARTS_RUNTIME help This define the partition of nor0 used to build mtparts dynamically diff --git a/board/emulation/common/qemu_dfu.c b/board/emulation/common/qemu_dfu.c index 8a59f5ade13..b0b3074162a 100644 --- a/board/emulation/common/qemu_dfu.c +++ b/board/emulation/common/qemu_dfu.c @@ -50,19 +50,11 @@ void set_dfu_alt_info(char *interface, char *devstr) memset(buf, 0, DFU_ALT_BUF_LEN); - /* - * Currently dfu_alt_info is needed on Qemu ARM64 for - * capsule updates - */ - if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) && - IS_ENABLED(CONFIG_TARGET_QEMU_ARM_64BIT)) { - /* probe all MTD devices */ - mtd_probe_devices(); + mtd_probe_devices(); - mtd = get_mtd_device_nm("nor0"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info(mtd, buf); - } + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) + board_get_alt_info(mtd, buf); env_set("dfu_alt_info", buf); printf("dfu_alt_info set\n"); diff --git a/board/emulation/common/qemu_mtdparts.c b/board/emulation/common/qemu_mtdparts.c index c1501276789..034280927aa 100644 --- a/board/emulation/common/qemu_mtdparts.c +++ b/board/emulation/common/qemu_mtdparts.c @@ -50,28 +50,24 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) memset(parts, 0, sizeof(parts)); memset(ids, 0, sizeof(ids)); - /* Currently mtdparts is needed on Qemu ARM64 for capsule updates */ - if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) && - IS_ENABLED(CONFIG_TARGET_QEMU_ARM_64BIT)) { - /* probe all MTD devices */ - for (uclass_first_device(UCLASS_MTD, &dev); dev; - uclass_next_device(&dev)) { - debug("mtd device = %s\n", dev->name); - } + /* probe all MTD devices */ + for (uclass_first_device(UCLASS_MTD, &dev); dev; + uclass_next_device(&dev)) { + debug("mtd device = %s\n", dev->name); + } - mtd = get_mtd_device_nm("nor0"); - if (!IS_ERR_OR_NULL(mtd)) { - mtd_partition = CONFIG_MTDPARTS_NOR0; - board_get_mtdparts("nor0", mtd_partition, ids, parts); - put_mtd_device(mtd); - } + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = CONFIG_MTDPARTS_NOR0; + board_get_mtdparts("nor0", mtd_partition, ids, parts); + put_mtd_device(mtd); + } - mtd = get_mtd_device_nm("nor1"); - if (!IS_ERR_OR_NULL(mtd)) { - mtd_partition = CONFIG_MTDPARTS_NOR1; - board_get_mtdparts("nor1", mtd_partition, ids, parts); - put_mtd_device(mtd); - } + mtd = get_mtd_device_nm("nor1"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = CONFIG_MTDPARTS_NOR1; + board_get_mtdparts("nor1", mtd_partition, ids, parts); + put_mtd_device(mtd); } mtd_initialized = true; diff --git a/board/emulation/qemu-x86/Kconfig b/board/emulation/qemu-x86/Kconfig index c1564fba7cd..0c2ded1515c 100644 --- a/board/emulation/qemu-x86/Kconfig +++ b/board/emulation/qemu-x86/Kconfig @@ -24,5 +24,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIRTIO_NET imply VIRTIO_BLK imply CMD_SMBIOS + imply SET_DFU_ALT_INFO + imply SYS_MTDPARTS_RUNTIME +source "board/emulation/common/Kconfig" endif diff --git a/board/emulation/qemu-x86/Makefile b/board/emulation/qemu-x86/Makefile new file mode 100644 index 00000000000..62f07a637c4 --- /dev/null +++ b/board/emulation/qemu-x86/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += qemu-x86.o diff --git a/board/emulation/qemu-x86/qemu-x86.c b/board/emulation/qemu-x86/qemu-x86.c new file mode 100644 index 00000000000..6b06f356d3b --- /dev/null +++ b/board/emulation/qemu-x86/qemu-x86.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <config.h> +#include <efi.h> +#include <efi_loader.h> +#include <linux/kernel.h> + +/* GUIDs for capsule updatable firmware images */ +#define QEMU_X86_UBOOT_IMAGE_GUID \ + EFI_GUID(0x8dfcd6f5, 0x42fe, 0x44c6, 0xa8, 0xae, \ + 0x63, 0x7d, 0xa6, 0x1b, 0x6b, 0x95) + +#define QEMU_X86_64_UBOOT_IMAGE_GUID \ + EFI_GUID(0x5bb9ce0d, 0xa389, 0x456f, 0x83, 0xa8, \ + 0x2b, 0xdf, 0xb8, 0xad, 0x01, 0xa1) + +struct efi_fw_image fw_images[] = { +#if IS_ENABLED(CONFIG_TARGET_QEMU_X86) + { + .image_type_id = QEMU_X86_UBOOT_IMAGE_GUID, + .fw_name = u"Qemu-X86-UBOOT", + .image_index = 1, + }, +#elif IS_ENABLED(CONFIG_TARGET_QEMU_X86_64) + { + .image_type_id = QEMU_X86_64_UBOOT_IMAGE_GUID, + .fw_name = u"Qemu-X86_64-UBOOT", + .image_index = 1, + }, +#endif +}; + +struct efi_capsule_update_info update_info = { + .num_images = ARRAY_SIZE(fw_images), + .images = fw_images, +}; + -- 2.54.0
