expose QEMU's fw_cfg boot order to ARM guest firmware (Intel BDS)
Hi,
this message is meant as a short, cross-posted thread starter, so that both qemu- and edk2-side comments can be kept in one thread. I'll follow up with two series:
- the first small series for qemu adds fw_cfg to the arm "virt" machine type in qemu, automatically exposing the "bootorder" fw_cfg file to the guest (when at least one bootindex=N device property is specified on the command line),
- the second, not so small, dependent series for edk2:
- adds an MMIO-based fw_cfg client to the ARM guest firmware in edk2,
- makes the OpenFirmware-to-UEFI devpath translation stuff in OvmfPkg reusable for the ArmVirtualizationQemu platform,
- makes the virtio-pci specific bits in that logic conditional, and introduces (similarly conditional) coverage for virtio-mmio.
Thanks
Laszlo
cover DTB- and MMIO-based fw_cfg for hw/arm/virt
A number of ARM guest firmware features [1] would like to rely on a "fw_cfg-like conduit device" [2], so let's add just that.
[1] boot order, ACPI linker/loader, '-kernel' booting, maybe SMBIOS tables, etc
[2] http://thread.gmane.org/gmane.comp.emulators.qemu/304059/focus=306834
Thanks,
Laszlo
Laszlo Ersek (2):
fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public
arm: add fw_cfg to "virt" board
include/hw/nvram/fw_cfg.h | 3 +++ hw/arm/virt.c | 21 +++++++++++++++++++++ hw/nvram/fw_cfg.c | 2 -- 3 files changed, 24 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public
We'll use them in board-specific code in the next patch.
--- include/hw/nvram/fw_cfg.h | 3 +++ hw/nvram/fw_cfg.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
include/hw/nvram/fw_cfg.h +3 -0
@@ -9,6 +9,9 @@#include "qemu/typedefs.h" #endif +#define FW_CFG_SIZE 2 +#define FW_CFG_DATA_SIZE 1 +#define FW_CFG_SIGNATURE 0x00#define FW_CFG_ID 0x01#define FW_CFG_UUID 0x02
hw/nvram/fw_cfg.c +0 -2
@@ -30,8 +30,6 @@#include "qemu/error-report.h" #include "qemu/config-file.h" -#define FW_CFG_SIZE 2 -#define FW_CFG_DATA_SIZE 1#define TYPE_FW_CFG "fw_cfg"#define FW_CFG_NAME "fw_cfg"#define FW_CFG_PATH "/machine/" FW_CFG_NAME
Signature · 1 line
1.8.3.1
PATCH 2/2 arm: add fw_cfg to "virt" board
In reply to Laszlo Ersekfw_cfg already supports exposure over MMIO (used in ppc/mac_newworld.c, ppc/mac_oldworld.c, sparc/sun4m.c); we can easily add it to the "virt" board.
The mmio register block of fw_cfg is advertized in the device tree. As base address we pick 0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfg automatically exports a number of files to the guest; for example, "bootorder" (see fw_cfg_machine_reset()).
--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/arm/virt.c +21 -0
@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {
@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */
@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename; + +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE ); +g_free (nodename); +} +static void *machvirt_dtb (const struct arm_boot_info *binfo,int *fdt_size) {const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
@@ -604,6 +623,8 @@ static void machvirt_init(MachineState *machine)*/ create_virtio_devices (vbi, pic); +create_fw_cfg (vbi); + vbi->bootinfo.ram_size = machine->ram_size; vbi->bootinfo.kernel_filename = machine->kernel_filename; vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 9 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 538
Quoted 8 lines
hw/arm/virt.c +8
-0+ nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE ); +g_free (nodename);
Are you planning to submit this DT binding to the kernel folks as a proper official one (ie documented)? I know the kernel doesn't need to read/write it, but the kernel doc tree is AFAIK the only place that's actually documenting ARM DT bindings right now...
thanks
-- PMM
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 19 lines · Peter Maydell
Quoted 9 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 538
Quoted 8 lines
hw/arm/virt.c +8
-0+ nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE ); +g_free (nodename);
Quoted 5 lines
Are you planning to submit this DT binding to the kernel folks as a proper official one (ie documented)? I know the kernel doesn't need to read/write it, but the kernel doc tree is AFAIK the only place that's actually documenting ARM DT bindings right now...
Thanks for the hint, I was actually wondering if some official registry existed for the node names and types. So yeah I'll attempt to get it in there. (Once I find the docs in question in the kernel :))
Thanks!
Laszlo
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 3 lines · Laszlo Ersek
Thanks for the hint, I was actually wondering if some official registry existed for the node names and types. So yeah I'll attempt to get it in there. (Once I find the docs in question in the kernel :))
Documentation/devicetree is probably a good place to start looking.
-- PMM
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
In reply to Laszlo ErsekQuoted 45 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfgautomatically exports a number of files to the guest; for example, "bootorder" (seefw_cfg_machine_reset()).Signed-off-by Laszlo Ersek <[email protected]>--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/arm/virt.c +6
-0@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename;
hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 537
Quoted 10 lines
hw/arm/virt.c +10
-0+ +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE );
Overkill suggestion alert, but how about defining something like
#define FW_CFG_SIZE_ALIGNED \
MIN(QEMU_ALIGN_UP(FW_CFG_SIZE, FW_CFG_DATA_SIZE), \
QEMU_ALIGN_UP(FW_CFG_SIZE, 4))and then using that in your memmap size calculation and fw-cfg-data base address calculation. The only reason I suggest this is because it's hard to tell that fw-cfg-data's address will be naturally aligned without hunting down the definition of FW_CFG_DATA_SIZE. And, if it were to change (which it probably never will), then it may not be.
Quoted 18 lines
hw/arm/virt.c +5
-0+g_free (nodename); +} +static void *machvirt_dtb (const struct arm_boot_info *binfo,int *fdt_size) {const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;@@ -604,6 +623,8 @@ static void machvirt_init(MachineState *machine)*/ create_virtio_devices (vbi, pic); +create_fw_cfg (vbi); + vbi->bootinfo.ram_size = machine->ram_size; vbi->bootinfo.kernel_filename = machine->kernel_filename; vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 63 lines · Andrew Jones
Quoted 45 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfgautomatically exports a number of files to the guest; for example, "bootorder" (seefw_cfg_machine_reset()).Signed-off-by Laszlo Ersek <[email protected]>--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/arm/virt.c +6
-0@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename;hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 537
Quoted 10 lines
hw/arm/virt.c +10
-0+ +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE );Overkill suggestion alert, but how about defining something like
#define FW_CFG_SIZE_ALIGNED \ MIN(QEMU_ALIGN_UP(FW_CFG_SIZE, FW_CFG_DATA_SIZE), \ QEMU_ALIGN_UP(FW_CFG_SIZE, 4))
Quoted 5 lines
and then using that in your memmap size calculation and fw-cfg-data base address calculation. The only reason I suggest this is because it's hard to tell that fw-cfg-data's address will be naturally aligned without hunting down the definition of
FW_CFG_DATA_SIZE. And, if it were to change (which it probably never will), then it may not be.
Why does it need to be aligned?
The selector register is aligned at a 64KB boundary (for independent, strict reasons).
The data register is not aligned at all, and -- AFAICS -- it need not be, because it's 1 byte wide. (In fact the ARM-specific Mmio(Read|Write)XX functions in edk2 enforce natural alignment, and the above layout passes without problems.)
The full register block is 3 bytes wide. Is that a problem?
Thanks
Laszlo
Quoted 19 lines
Quoted 19 lines
hw/arm/virt.c +5
-0+g_free (nodename); +} +static void *machvirt_dtb (const struct arm_boot_info *binfo,int *fdt_size) {const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;@@ -604,6 +623,8 @@ static void machvirt_init(MachineState *machine)*/ create_virtio_devices (vbi, pic); +create_fw_cfg (vbi); + vbi->bootinfo.ram_size = machine->ram_size; vbi->bootinfo.kernel_filename = machine->kernel_filename; vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 75 lines · Laszlo Ersek
Quoted 63 lines · Andrew Jones
Quoted 45 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfgautomatically exports a number of files to the guest; for example, "bootorder" (seefw_cfg_machine_reset()).Signed-off-by Laszlo Ersek <[email protected]>--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/arm/virt.c +6
-0@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename;hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 537
Quoted 10 lines
hw/arm/virt.c +10
-0+ +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE );Overkill suggestion alert, but how about defining something like
#define FW_CFG_SIZE_ALIGNED \ MIN(QEMU_ALIGN_UP(FW_CFG_SIZE, FW_CFG_DATA_SIZE), \ QEMU_ALIGN_UP(FW_CFG_SIZE, 4))Quoted 5 lines
and then using that in your memmap size calculation and fw-cfg-data base address calculation. The only reason I suggest this is because it's hard to tell that fw-cfg-data's address will be naturally aligned without hunting down the definition of
FW_CFG_DATA_SIZE. And, if it were to change (which it probably never will), then it may not be.Why does it need to be aligned?
The selector register is aligned at a 64KB boundary (for independent, strict reasons).
Quoted 6 lines
The data register is not aligned at all, and -- AFAICS -- it need not be, because it's 1 byte wide. (In fact the ARM-specific Mmio(Read|Write)XX functions in edk2 enforce natural alignment, and the above layout passes without problems.)
The full register block is 3 bytes wide. Is that a problem?
Hm, I think I get it now. If FW_CFG_DATA_SIZE were to increase, then its alignment would have to increase as well, and whatever alignment FW_CFG_SIZE provides might not suffice. So, you'd calculate the natural alignment, but wouldn't increase it beyond 4.
I do think this is a bit overkill :) but I can do it. Let's wait for more review comments first.
Thanks!
Laszlo
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
Quoted 83 lines · Laszlo Ersek
Quoted 75 lines · Laszlo Ersek
Quoted 63 lines · Andrew Jones
Quoted 45 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfgautomatically exports a number of files to the guest; for example, "bootorder" (seefw_cfg_machine_reset()).Signed-off-by Laszlo Ersek <[email protected]>--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/arm/virt.c +6
-0@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename;hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 537
Quoted 10 lines
hw/arm/virt.c +10
-0+ +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE );Overkill suggestion alert, but how about defining something like
#define FW_CFG_SIZE_ALIGNED \ MIN(QEMU_ALIGN_UP(FW_CFG_SIZE, FW_CFG_DATA_SIZE), \ QEMU_ALIGN_UP(FW_CFG_SIZE, 4))Quoted 5 lines
and then using that in your memmap size calculation and fw-cfg-data base address calculation. The only reason I suggest this is because it's hard to tell that fw-cfg-data's address will be naturally aligned without hunting down the definition of
FW_CFG_DATA_SIZE. And, if it were to change (which it probably never will), then it may not be.Why does it need to be aligned?
The selector register is aligned at a 64KB boundary (for independent, strict reasons).
Quoted 6 lines
The data register is not aligned at all, and -- AFAICS -- it need not be, because it's 1 byte wide. (In fact the ARM-specific Mmio(Read|Write)XX functions in edk2 enforce natural alignment, and the above layout passes without problems.)
The full register block is 3 bytes wide. Is that a problem?
Quoted 7 lines
Hm, I think I get it now. If
FW_CFG_DATA_SIZEwere to increase, then its alignment would have to increase as well, and whatever alignmentFW_CFG_SIZEprovides might not suffice. So, you'd calculate the natural alignment, but wouldn't increase it beyond 4.I do think this is a bit overkill :) but I can do it. Let's wait for more review comments first.
Actually, on second thought, completely scratch my overkill suggestion. It's actually wrong to be concerned with it anyway. FW_CFG_DATA_SIZE doesn't dictate how we should access the data port, the fw-cfg protocol does, and that says we should access exactly one byte. So, regardless of the fw-cfg-data size, we'll never have to worry about the data port's alignment, as we'll never access more than one byte from it.
Quoted 3 lines
Thanks!
Laszlo
Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
In reply to Laszlo ErsekQuoted 64 lines · Laszlo Ersek
Quoted 63 lines · Andrew Jones
Quoted 45 lines · Laszlo Ersek
fw_cfgalready supports exposure over MMIO (used inppc/mac_newworld.c,ppc/mac_oldworld.c,sparc/sun4m.c); we can easily add it to the "virt" board.The mmio register block of
fw_cfgis advertized in the device tree. As base address we pick0x09020000, which conforms to the comment preceding "a15memmap": it falls in the miscellaneous device I/O range 128MB..256MB, and it is aligned at 64KB.
fw_cfgautomatically exports a number of files to the guest; for example, "bootorder" (seefw_cfg_machine_reset()).Signed-off-by Laszlo Ersek <[email protected]>--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)hw/arm/virt.c +6
-0@@ -68,6 +68,7 @@ enum {VIRT_UART ,VIRT_MMIO ,VIRT_RTC , + VIRT_FW_CFG, }; typedef struct MemMapEntry {@@ -107,6 +108,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_UART] = { 0x09000000, 0x00001000 }, [VIRT_RTC] = { 0x09010000, 0x00001000 }, + [VIRT_FW_CFG] = { 0x09020000, FW_CFG_SIZE + FW_CFG_DATA_SIZE }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 },/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ /* 0x10000000 .. 0x40000000 reserved for PCI */@@ -519,6 +521,23 @@ static void create_flash(const VirtBoardInfo *vbi)g_free (nodename); } +static void create_fw_cfg (const VirtBoardInfo *vbi) +{ +hwaddr base = vbi->memmap[VIRT_FW_CFG ].base; +char *nodename;hw/arm/virt.c static void create_flash(const VirtBoardInfo *vbi) · line 537
Quoted 10 lines
hw/arm/virt.c +10
-0+ +fw_cfg_init (0 ,0 , base, base +FW_CFG_SIZE ); + + nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename, +"compatible" ,"fw-cfg,mmio" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 ,FW_CFG_SIZE , +2 , base +FW_CFG_SIZE ,2 ,FW_CFG_DATA_SIZE );Overkill suggestion alert, but how about defining something like
#define FW_CFG_SIZE_ALIGNED \ MIN(QEMU_ALIGN_UP(FW_CFG_SIZE, FW_CFG_DATA_SIZE), \ QEMU_ALIGN_UP(FW_CFG_SIZE, 4))
Quoted 7 lines
Quoted 5 lines
and then using that in your memmap size calculation and fw-cfg-data base address calculation. The only reason I suggest this is because it's hard to tell that fw-cfg-data's address will be naturally aligned without hunting down the definition of
FW_CFG_DATA_SIZE. And, if it were to change (which it probably never will), then it may not be.Why does it need to be aligned?
Natural alignment is more efficient.
Quoted 8 lines
The selector register is aligned at a 64KB boundary (for independent, strict reasons).
The data register is not aligned at all, and -- AFAICS -- it need not be, because it's 1 byte wide. (In fact the ARM-specific Mmio(Read|Write)XX functions in edk2 enforce natural alignment, and the above layout passes without problems.)
Right. As FW_CFG_DATA_SIZE is currently 1 byte, it's already naturally aligned, and the macro definition I have above actually doesn't change anything (which is why I gave the overkill alert). However if FW_CFG_DATA_SIZE was to change, then the natural alignment could be lost.
Quoted 2 lines
The full register block is 3 bytes wide. Is that a problem?
No, it's fine as is, and the FW_CFG_SIZE_ALIGNED would leave it 3 bytes wide too. FW_CFG_SIZE_ALIGNED only adds future-proofing. However it really is overkill as the chance that FW_CFG_DATA_SIZE will change is nil.
Quoted 24 lines
Thanks
LaszloQuoted 19 lines
Quoted 19 lines
hw/arm/virt.c +5
-0+g_free (nodename); +} +static void *machvirt_dtb (const struct arm_boot_info *binfo,int *fdt_size) {const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;@@ -604,6 +623,8 @@ static void machvirt_init(MachineState *machine)*/ create_virtio_devices (vbi, pic); +create_fw_cfg (vbi); + vbi->bootinfo.ram_size = machine->ram_size; vbi->bootinfo.kernel_filename = machine->kernel_filename; vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;Signature · 1 line
1.8.3.1
cover consume fw_cfg boot order in ArmVirtualizationQemu
In reply to Laszlo ErsekThe series
- adds a DTB- and MMIO-based fw_cfg client library to the ArmVirtualizationQemu platform (patches #1 and #2),
- makes OvmfPkg's OpenFirmware to UEFI devpath translation logic reusable for the ArmVirtualizationQemu platform, making the virtio-pci specific bits conditional (patches #5 and #6),
- introduces (similarly conditional) coverage for virtio-mmio device paths (patches #7, #8, #9, #10),
- introduces a new Intel BDS boot policy for ArmVirtualizationQemu that considers the QEMU boot order, similarly to OVMF (patches #3, #4, #11),
- somewhat independently, ensures that the UEFI shell is always present as a boot option (patch #12).
The patches are interleaved in a "demand driven" order, showing the dependencies between ArmVirtualizationPkg and OvmfPkg. ArmVirtualizationPkg takes the edges, providing the low level fw_cfg client service and consuming the top-level feature, whereas OvmfPkg sits in the middle, consuming the fw_cfg capability and providing the boot order logic.
The patchset compiles at each step, for OvmfPkg, for ArmVirtualizationPkg without -D INTEL_BDS, and for ArmVirtualizationPkg with -D INTEL_BDS.
Public branch:
https://github.com/lersek/edk2/commits/armvirt_fwcfg
Thanks
Laszlo
Laszlo Ersek (12):
ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to
PCDs
ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers
ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg
ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy
OvmfPkg: extract QemuBootOrderLib
OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation
OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID
ArmVirtualizationPkg: VirtFdtDxe: use dedicated
VIRTIO_MMIO_TRANSPORT_GUID
OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64
OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio
ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order
ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel
BDS
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 67 ++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf | 52 ++++++++
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 5 +-
OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf | 3 +-
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 59 +++++++++
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h | 41 ++++++
OvmfPkg/Include/Guid/VirtioMmioTransport.h | 25 ++++
OvmfPkg/{Library/PlatformBdsLib/QemuBootOrder.h => Include/Library/QemuBootOrderLib.h} | 6 +-
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 326 +++++++++++++++++++++++++++++++++++++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 30 ++++-
OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c | 2 +-
OvmfPkg/Library/{PlatformBdsLib/QemuBootOrder.c => QemuBootOrderLib/QemuBootOrderLib.c} | 299 +++++++++++++++++++++++++++++++++++++----
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 3 +
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 13 +-
OvmfPkg/OvmfPkg.dec | 8 ++
OvmfPkg/OvmfPkgIa32.dsc | 1 +
OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
OvmfPkg/OvmfPkgX64.dsc | 1 +
19 files changed, 1301 insertions(+), 31 deletions(-)
create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
create mode 100644 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
create mode 100644 OvmfPkg/Include/Guid/VirtioMmioTransport.h
rename OvmfPkg/{Library/PlatformBdsLib/QemuBootOrder.h => Include/Library/QemuBootOrderLib.h} (91%)
create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
create mode 100644 ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
rename OvmfPkg/Library/{PlatformBdsLib/QemuBootOrder.c => QemuBootOrderLib/QemuBootOrderLib.c} (77%)Signature · 1 line
1.8.3.1
PATCH 1/12 ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs
Qemu's firmware configuration interface consists of two MMIO registers, a 16-bit selector and an 8-bit data register. Parse their addresses and verify their sizes from the DTB, and expose them to the rest of DXE by storing them in dynamic PCDs.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 2 ++ ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 26 ++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 3 +++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 3 +++ 4 files changed, 34 insertions(+)
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +2 -0
@@ -47,6 +47,8 @@ [Pcd] gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress gArmTokenSpaceGuid.PcdGicDistributorBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +26 -0
@@ -44,6 +44,7 @@ typedef enum { PropertyTypeUart, PropertyTypeTimer, PropertyTypePsci, + PropertyTypeFwCfg, } PROPERTY_TYPE; typedef struct {
@@ -59,6 +60,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypeTimer, "arm,armv7-timer" }, { PropertyTypeTimer, "arm,armv8-timer" }, { PropertyTypePsci, "arm,psci-0.2" }, + { PropertyTypeFwCfg, "fw-cfg,mmio" }, { PropertyTypeUnknown, "" } };
@@ -115,6 +117,10 @@ InitializeVirtFdtDxe ( CONST INTERRUPT_PROPERTY *InterruptProp;INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum; CONST CHAR8 *PsciMethod; +UINT64 FwCfgSelectorAddress; +UINT64 FwCfgSelectorSize; +UINT64 FwCfgDataAddress; +UINT64 FwCfgDataSize; DeviceTreeBase = (VOID *)(UINTN )PcdGet64 (PcdDeviceTreeBaseAddress);ASSERT (DeviceTreeBase !=NULL );
@@ -160,6 +166,26 @@ InitializeVirtFdtDxe ( (PropType == PropertyTypePsci));switch (PropType) { +case PropertyTypeFwCfg: +ASSERT (Len ==4 *sizeof (UINT64 )); + + FwCfgSelectorAddress =fdt64_to_cpu (((UINT64 *)RegProp)[0 ]); + FwCfgSelectorSize =fdt64_to_cpu (((UINT64 *)RegProp)[1 ]); + FwCfgDataAddress =fdt64_to_cpu (((UINT64 *)RegProp)[2 ]); + FwCfgDataSize =fdt64_to_cpu (((UINT64 *)RegProp)[3 ]); + +ASSERT (FwCfgSelectorSize ==2 ); +ASSERT (FwCfgDataSize ==1 ); +ASSERT (FwCfgSelectorAddress <=MAX_UINTN - FwCfgSelectorSize +1 ); +ASSERT (FwCfgDataAddress <=MAX_UINTN - FwCfgDataSize +1 ); + +PcdSet64 (PcdFwCfgSelectorAddress, FwCfgSelectorAddress); +PcdSet64 (PcdFwCfgDataAddress, FwCfgDataAddress); + +DEBUG ((EFI_D_INFO ,"Found FwCfg @ 0x%Lx/0x%Lx\n" , FwCfgSelectorAddress, + FwCfgDataAddress)); +break ; +case PropertyTypeVirtio:ASSERT (Len ==16 );//
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec +3 -0
@@ -53,3 +53,6 @@ # PcdArmPsciMethod == 2 : use SMC # gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0|UINT32|0x00000003 + + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0|UINT64|0x00000004 + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0|UINT64|0x00000005
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +3 -0
@@ -173,6 +173,9 @@ gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0 + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0 + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [edk2] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs
Quoted 40 lines · Laszlo Ersek
Qemu's firmware configuration interface consists of two MMIO registers, a 16-bit selector and an 8-bit data register. Parse their addresses and verify their sizes from the DTB, and expose them to the rest of DXE by storing them in dynamic PCDs.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>--- ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 2 ++ ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 26 ++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 3 +++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 3 +++ 4 files changed, 34 insertions(+)ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +2
-0@@ -47,6 +47,8 @@ [Pcd] gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress gArmTokenSpaceGuid.PcdGicDistributorBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNumArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +1
-0@@ -44,6 +44,7 @@ typedef enum { PropertyTypeUart, PropertyTypeTimer, PropertyTypePsci, + PropertyTypeFwCfg, } PROPERTY_TYPE; typedef struct {
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c STATIC CONST PROPERTY CompatibleProperties[] = { · line 63
Quoted 4 lines
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +1
-0@@ -59,6 +60,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypeTimer, "arm,armv7-timer" }, { PropertyTypeTimer, "arm,armv8-timer" }, { PropertyTypePsci, "arm,psci-0.2" }, + { PropertyTypeFwCfg, "fw-cfg,mmio" },
The part of the DTB that exposes this device was slightly changed. Since there were no review comments thus far, I'll post a v2 of this edk2 series.
Thanks
Laszlo
PATCH 2/12 ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers
In reply to Laszlo ErsekAfter reviewing OvmfPkg's use of its own QemuFwCfgLib instances, it is clear that its only pre-DXE fw_cfg dependency concerns S3 support (the QemuFwCfgS3Enabled() call in "PlatformPei/Platform.c").
For ARM guests, S3 is in the distant future, but we can see several shorter term applications for fw_cfg that all reside in DXE:
- controlling boot order (to be implemented in PlatformBdsLib for Intel BDS),
- loading and linking ACPI tables,
- installing SMBIOS tables.
Therefore it makes sense to add a simple MMIO-based fw_cfg client library to ArmVirtualizationPkg that for the moment is only available to DXE_DRIVER modules.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf | 52 +++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 + 3 files changed, 379 insertions(+)
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf new file +52 -0
@@ -0,0 +1,52 @@ +## @file +# +# Stateful, implicitly initialized fw_cfg library. +# +# Copyright (C) 2013 - 2014, Red Hat, Inc. +# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR> +# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR +# IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = QemuFwCfgLib + FILE_GUID = B271F41F-B841-48A9-BA8D-545B4BC2E2BF + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = QemuFwCfgLib|DXE_DRIVER + + CONSTRUCTOR = QemuFwCfgInitialize + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 +# + +[Sources] + QemuFwCfgLib.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + IoLib + PcdLib + +[Pcd] + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c new file +326 -0
326 lines not on this page · raw message
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +1 -0
@@ -42,6 +42,7 @@ # Virtio Support VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf + QemuFwCfgLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf ArmPlatformLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf ArmPlatformSysConfigLib|ArmPlatformPkg/Library/ArmPlatformSysConfigLibNull/ArmPlatformSysConfigLibNull.inf
Signature · 1 line
1.8.3.1
PATCH 3/12 ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg
In reply to Laszlo ErsekIn the next patch(es) we'll customize the PlatformBdsLib instance used by ArmVirtualizationQemu.dsc. Let's clone it first verbatim from ArmPlatformPkg/Library/PlatformIntelBdsLib, changing only its FILE_GUID.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 65 ++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h | 35 +++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 2 +- 4 files changed, 477 insertions(+), 1 deletion(-)
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf new file +65 -0
@@ -0,0 +1,65 @@ +## @file +# Implementation for PlatformBdsLib library class interfaces. +# using ARM Platform framework. +# +# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2014, ARM Ltd. All rights reserved.<BR> +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformIntelBdsLib + FILE_GUID = 46DF84EB-F603-4D39-99D8-E1E86B50BCC2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER + CONSTRUCTOR = PlatformIntelBdsConstructor + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 +# + +[Sources] + IntelBdsPlatform.c + IntelBdsPlatform.h + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + BdsLib + DebugLib + DevicePathLib + MemoryAllocationLib + UefiBootServicesTableLib + PcdLib + GenericBdsLib + +[Guids] + gArmGlobalVariableGuid + +[Pcd] + gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths + gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths + gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut + +[Protocols] + gEfiDevicePathFromTextProtocolGuid + gEfiDevicePathToTextProtocolGuid
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h new file +35 -0
@@ -0,0 +1,35 @@ +/** @file +Head file for BDS Platform specific code + +Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR> +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _INTEL_BDS_PLATFORM_H_ +#define _INTEL_BDS_PLATFORM_H_ + +#include <Protocol/DevicePathFromText.h> +#include <Protocol/DevicePathToText.h> + +#include <Library/BaseMemoryLib.h> +#include <Library/BdsLib.h> +#include <Library/DebugLib.h> +#include <Library/DevicePathLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/BaseLib.h> +#include <Library/PcdLib.h> +#include <Library/GenericBdsLib.h> +#include <Library/PlatformBdsLib.h> + +#include <Guid/GlobalVariable.h> + +#endif // _INTEL_BDS_PLATFORM_H
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c new file +376 -0
376 lines not on this page · raw message
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +1 -1
@@ -52,7 +52,7 @@ !ifdef INTEL_BDS CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf - PlatformBdsLib|ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf + PlatformBdsLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf !endif
Signature · 1 line
1.8.3.1
PATCH 4/12 ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy
In reply to Laszlo ErsekIn PlatformBdsPolicyBehavior() we should follow the same pattern as in OvmfPkg's: after the consoles are connected,
- connect all drivers and devices,
- enumerate all boot options,
- enter the Intel BDS FrontPage if the user presses a key different from Enter.
We set the countdown to 3 seconds, similarly to the timeout that we specify for ARM BDS.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h | 6 ++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 4 ++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 2 ++ 3 files changed, 12 insertions(+)
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h +6 -0
@@ -32,4 +32,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.#include <Guid/GlobalVariable.h> +VOID +PlatformBdsEnterFrontPage ( + IN UINT16 TimeoutDefault, + IN BOOLEAN ConnectAllHappened + ); +#endif // _INTEL_BDS_PLATFORM_H
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c +4 -0
@@ -302,6 +302,10 @@ PlatformBdsPolicyBehavior ( Status =PlatformBdsConnectConsole ();ASSERT_EFI_ERROR (Status); + +BdsLibConnectAll (); +BdsLibEnumerateAllBootOption (BootOptionList); +PlatformBdsEnterFrontPage (gPlatformBootTimeOutDefault, TRUE); }/**
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +2 -0
@@ -177,6 +177,8 @@ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0 gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0 + gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform
Signature · 1 line
1.8.3.1
PATCH 5/12 OvmfPkg: extract QemuBootOrderLib
In reply to Laszlo Ersekand rebase OvmfPkg's PlatformBdsLib on the standalone library.
Contributed-under: TianoCore Contribution Agreement 1.0
---
OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf | 3 +--
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
OvmfPkg/{Library/PlatformBdsLib/QemuBootOrder.h => Include/Library/QemuBootOrderLib.h} | 6 +++++-
OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c | 2 +-
OvmfPkg/Library/{PlatformBdsLib/QemuBootOrder.c => QemuBootOrderLib/QemuBootOrderLib.c} | 3 ++-
OvmfPkg/OvmfPkg.dec | 5 +++++
OvmfPkg/OvmfPkgIa32.dsc | 1 +
OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
OvmfPkg/OvmfPkgX64.dsc | 1 +
9 files changed, 70 insertions(+), 5 deletions(-)OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf +1 -2
@@ -29,10 +29,8 @@ [Sources] BdsPlatform.c PlatformData.c - QemuBootOrder.c QemuKernel.c BdsPlatform.h - QemuBootOrder.h [Packages] MdePkg/MdePkg.dec
@@ -52,6 +50,7 @@ NvVarsFileLib QemuFwCfgLib LoadLinuxLib + QemuBootOrderLib [Pcd] gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf new file +53 -0
53 lines not on this page · raw message
OvmfPkg/Include/Library/QemuBootOrderLib.h renamed from OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.h +5 -1
@@ -2,7 +2,7 @@ Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file -- include file. - Copyright (C) 2012, Red Hat, Inc. + Copyright (C) 2012-2014, Red Hat, Inc. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this
@@ -13,6 +13,8 @@WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ +#ifndef __QEMU_BOOT_ORDER_LIB_H__ +#define __QEMU_BOOT_ORDER_LIB_H__#include <Uefi/UefiBaseType.h> #include <Base.h>
@@ -51,3 +53,5 @@ RETURN_STATUSSetBootOrderFromQemu ( IN CONST LIST_ENTRY *BootOptionList ); + +#endif
OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c +1 -1
@@ -13,7 +13,7 @@**/ #include "BdsPlatform.h" -#include "QemuBootOrder.h" +#include <Library/QemuBootOrderLib.h> //
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c renamed from OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c +2 -1
@@ -1,7 +1,7 @@/** @file Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file. -Copyright (C) 2012 - 2013, Red Hat, Inc. +Copyright (C) 2012 - 2014, Red Hat, Inc. Copyright (c) 2013, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available
@@ -22,6 +22,7 @@#include <Library/BaseLib.h> #include <Library/PrintLib.h> #include <Library/DevicePathLib.h> +#include <Library/QemuBootOrderLib.h> #include <Guid/GlobalVariable.h>
OvmfPkg/OvmfPkg.dec +5 -0
@@ -35,6 +35,11 @@ # QemuFwCfgLib|Include/Library/QemuFwCfgLib.h + ## @libraryclass Rewrite the BootOrder NvVar based on QEMU's "bootorder" + # fw_cfg file. + # + QemuBootOrderLib|Include/Library/QemuBootOrderLib.h + ## @libraryclass Serialize (and deserialize) variables # SerializeVariablesLib|Include/Library/SerializeVariablesLib.h
OvmfPkg/OvmfPkgIa32.dsc +1 -0
@@ -256,6 +256,7 @@ !ifdef $(SOURCE_DEBUG_ENABLE) DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif + QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf [LibraryClasses.common.UEFI_APPLICATION] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
OvmfPkg/OvmfPkgIa32X64.dsc +1 -0
@@ -261,6 +261,7 @@ !ifdef $(SOURCE_DEBUG_ENABLE) DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif + QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf [LibraryClasses.common.UEFI_APPLICATION] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
OvmfPkg/OvmfPkgX64.dsc +1 -0
@@ -261,6 +261,7 @@ !ifdef $(SOURCE_DEBUG_ENABLE) DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf !endif + QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf [LibraryClasses.common.UEFI_APPLICATION] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
Signature · 1 line
1.8.3.1
PATCH 6/12 OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation
In reply to Laszlo ErsekIn preparation for adding OpenFirmware-to-UEFI translation for "MMIO-like" OFW device path fragments, let's turn the currently exclusive "PCI-like" translation into "just one" of the possible translations.
- Rename TranslateOfwNodes() to TranslatePciOfwNodes(), because it is tightly coupled to "PCI-like" translations.
- Rename REQUIRED_OFW_NODES to REQUIRED_PCI_OFW_NODES, because this macro is specific to TranslatePciOfwNodes().
- Introduce a new wrapper function under the original TranslateOfwNodes() name. This function is supposed to try translations in some order until a specific translation returns a status different from RETURN_UNSUPPORTED.
- Introduce a new Feature PCD that controls whether PCI translation is attempted at all.
- The boot option "survival policy" in BootOrderComplete() must take into account if the user was able to select PCI-like boot options. If the user had no such possibility (because the Feature PCD was off for PCI-like translation), then we ought to keep any such unselected boot options.
Contributed-under: TianoCore Contribution Agreement 1.0
--- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 +++ OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- OvmfPkg/OvmfPkg.dec | 1 + 3 files changed, 65 insertions(+), 7 deletions(-)
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf +3 -0
@@ -51,3 +51,6 @@ [Guids] gEfiGlobalVariableGuid + +[FeaturePcd] + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +61 -7
105 lines not on this page · raw message
OvmfPkg/OvmfPkg.dec +1 -0
@@ -107,3 +107,4 @@ [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3 + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
Signature · 1 line
1.8.3.1
PATCH 7/12 OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID
In reply to Laszlo ErsekSoon there will be more than one modules (in separate packages) that need to have an understanding about the GUID used in the VenHw() device path nodes that describe virtio-mmio transports. Define such a GUID explicitly.
Preserve the current value (which happens to be the FILE_GUID of ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf) for compatibility with external users.
Contributed-under: TianoCore Contribution Agreement 1.0
--- OvmfPkg/Include/Guid/VirtioMmioTransport.h | 25 +++++++++++++++++++++++++ OvmfPkg/OvmfPkg.dec | 1 + 2 files changed, 26 insertions(+)
OvmfPkg/Include/Guid/VirtioMmioTransport.h new file +25 -0
@@ -0,0 +1,25 @@ +/** @file +Recommended GUID to be used in the Vendor Hardware device path nodes that +identify virtio-mmio transports. + +Copyright (C) 2014, Red Hat, Inc. + +This program and the accompanying materials are licensed and made available +under the terms and conditions of the BSD License that accompanies this +distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __VIRTIO_MMIO_TRANSPORT_H__ +#define __VIRTIO_MMIO_TRANSPORT_H__ + +#define VIRTIO_MMIO_TRANSPORT_GUID \ +{0x837dca9e, 0xe874, 0x4d82, {0xb2, 0x9a, 0x23, 0xfe, 0x0e, 0x23, 0xd1, 0xe2}} + +extern EFI_GUID gVirtioMmioTransportGuid; + +#endif
OvmfPkg/OvmfPkg.dec +1 -0
@@ -52,6 +52,7 @@ gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}} gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}} gOvmfPlatformConfigGuid = {0x7235c51c, 0x0c80, 0x4cab, {0x87, 0xac, 0x3b, 0x08, 0x4a, 0x63, 0x04, 0xb1}} + gVirtioMmioTransportGuid = {0x837dca9e, 0xe874, 0x4d82, {0xb2, 0x9a, 0x23, 0xfe, 0x0e, 0x23, 0xd1, 0xe2}} [Protocols] gVirtioDeviceProtocolGuid = {0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a}}
Signature · 1 line
1.8.3.1
PATCH 8/12 ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID
In reply to Laszlo ErsekInstalling VenHw() device paths with this GUID, for the virtio-mmio transports that we detect, enables other modules to recognize those VenHw() nodes. (Note that the actual value doesn't change.)
In addition, to avoid reusing GUIDs in unrelated contexts, detach the driver's FILE_GUID from its previous value.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 3 ++- ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +2 -1
@@ -16,7 +16,7 @@ [Defines] INF_VERSION = 0x00010005 BASE_NAME = VirtFdtDxe - FILE_GUID = 837DCA9E-E874-4D82-B29A-23FE0E23D1E2 + FILE_GUID = 9AD7DCB4-E6EC-472E-96BF-81C219A3F77E MODULE_TYPE = DXE_DRIVER VERSION_STRING = 1.0
@@ -43,6 +43,7 @@ [Guids] gFdtTableGuid + gVirtioMmioTransportGuid [Pcd] gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +3 -1
@@ -27,6 +27,7 @@#include <libfdt.h> #include <Guid/Fdt.h> +#include <Guid/VirtioMmioTransport.h> #pragma pack (1) typedef struct {
@@ -201,7 +202,8 @@ InitializeVirtFdtDxe (break ; } -CopyMem (&DevicePath->Vendor.Guid, &gEfiCallerIdGuid,sizeof (EFI_GUID )); +CopyMem (&DevicePath->Vendor.Guid, &gVirtioMmioTransportGuid, +sizeof (EFI_GUID )); DevicePath->PhysBase = RegBase;SetDevicePathNodeLength (&DevicePath->Vendor,sizeof (*DevicePath) -sizeof (DevicePath->End));
Signature · 1 line
1.8.3.1
PATCH 9/12 OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64
In reply to Laszlo ErsekThe OpenFirmware device path nodes that QEMU generates for virtio-mmio transports contain 64-bit hexadecimal values (16 nibbles) -- the base addresses of the register blocks. In order to parse them soon, ParseUnitAddressHexList() must parse UINT64 values.
Call sites need to be adapted, as expected.
Contributed-under: TianoCore Contribution Agreement 1.0
--- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +15 -15
@@ -128,7 +128,7 @@ SubstringEq (/** Parse a comma-separated list of hexadecimal integers into the elements of an -UINT32 array. +UINT64 array. Whitespace, "0x" prefixes, leading or trailing commas, sequences of commas, or an empty string are not allowed; they are rejected.
@@ -168,12 +168,12 @@ STATICRETURN_STATUS ParseUnitAddressHexList ( IN SUBSTRING UnitAddress, - OUT UINT32 *Result, + OUT UINT64 *Result, IN OUT UINTN *NumResults ) {UINTN Entry;// number of entry currently being parsed -UINT32 EntryVal;// value being constructed for current entry +UINT64 EntryVal;// value being constructed for current entry CHAR8 PrevChr;// UnitAddress character previously checked UINTN Pos;// current position within UnitAddress RETURN_STATUS Status;
@@ -193,10 +193,10 @@ ParseUnitAddressHexList (-1 ;if (Val >=0 ) { -if (EntryVal >0xFFFFFFF ) { +if (EntryVal >0xFFFFFFFFFFFFFFFull ) {return RETURN_INVALID_PARAMETER ; } - EntryVal = (EntryVal <<4 ) | Val; + EntryVal =LShiftU64 (EntryVal,4 ) | Val; }else if (Chr ==',' ) {if (PrevChr ==',' ) {return RETURN_INVALID_PARAMETER ;
@@ -578,7 +578,7 @@ TranslatePciOfwNodes ( IN OUT UINTN *TranslatedSize ) { -UINT32 PciDevFun[2 ]; +UINT64 PciDevFun[2 ];UINTN NumEntries;UINTN Written;
@@ -622,8 +622,8 @@ TranslatePciOfwNodes (// ^ // fixed LUN // -UINT32 Secondary; -UINT32 Slave; +UINT64 Secondary; +UINT64 Slave; NumEntries =1 ; if (ParseUnitAddressHexList (
@@ -645,7 +645,7 @@ TranslatePciOfwNodes ( Written = UnicodeSPrintAsciiFormat ( Translated, *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x0)/Pci(0x%x,0x%x)/Ata(%a,%a,0x0)", + "PciRoot(0x0)/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)", PciDevFun[0], PciDevFun[1], Secondary ? "Secondary" : "Primary",
@@ -672,7 +672,7 @@ TranslatePciOfwNodes (// ^ // ACPI UID // -UINT32 AcpiUid; +UINT64 AcpiUid; NumEntries =1 ; if (ParseUnitAddressHexList (
@@ -688,7 +688,7 @@ TranslatePciOfwNodes ( Written =UnicodeSPrintAsciiFormat ( Translated, *TranslatedSize *sizeof (*Translated),// BufferSize in bytes -"PciRoot(0x0)/Pci(0x%x,0x%x)/Floppy(0x%x)" , +"PciRoot(0x0)/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)" , PciDevFun[0 ], PciDevFun[1 ], AcpiUid
@@ -715,7 +715,7 @@ TranslatePciOfwNodes ( Written =UnicodeSPrintAsciiFormat ( Translated, *TranslatedSize *sizeof (*Translated),// BufferSize in bytes -"PciRoot(0x0)/Pci(0x%x,0x%x)/HD(" , +"PciRoot(0x0)/Pci(0x%Lx,0x%Lx)/HD(" , PciDevFun[0 ], PciDevFun[1 ] );
@@ -742,7 +742,7 @@ TranslatePciOfwNodes (// PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3) // -- if PCI function is present and nonzero // -UINT32 TargetLun[2 ]; +UINT64 TargetLun[2 ]; TargetLun[1 ] =0 ; NumEntries =sizeof (TargetLun) /sizeof (TargetLun[0 ]);
@@ -758,7 +758,7 @@ TranslatePciOfwNodes ( Written = UnicodeSPrintAsciiFormat ( Translated, *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x0)/Pci(0x%x,0x%x)/Scsi(0x%x,0x%x)", + "PciRoot(0x0)/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)", PciDevFun[0], PciDevFun[1], TargetLun[0],
@@ -781,7 +781,7 @@ TranslatePciOfwNodes ( Written =UnicodeSPrintAsciiFormat ( Translated, *TranslatedSize *sizeof (*Translated),// BufferSize in bytes -"PciRoot(0x0)/Pci(0x%x,0x%x)" , +"PciRoot(0x0)/Pci(0x%Lx,0x%Lx)" , PciDevFun[0 ], PciDevFun[1 ] );
Signature · 1 line
1.8.3.1
PATCH 10/12 OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio
In reply to Laszlo ErsekThe TranslateMmioOfwNodes() function recognizes the following OpenFirmware device paths:
virtio-blk: /virtio-mmio@000000000a003c00/disk@0,0
virtio-scsi disk: /virtio-mmio@000000000a003a00/channel@0/disk@2,3
virtio-net NIC: /virtio-mmio@000000000a003e00/ethernet-phy@0
The new translation can be enabled with the "PcdQemuBootOrderMmioTranslation" Feature PCD. This PCD also controls if the "survival policy" covers unselected boot options that start with the virtio-mmio VenHw() node.
Contributed-under: TianoCore Contribution Agreement 1.0
--- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 ++ OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- OvmfPkg/OvmfPkg.dec | 1 + 3 files changed, 201 insertions(+), 1 deletion(-)
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf +3 -0
@@ -48,9 +48,12 @@ BaseLib PrintLib DevicePathLib + BaseMemoryLib [Guids] gEfiGlobalVariableGuid + gVirtioMmioTransportGuid [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +197 -1
235 lines not on this page · raw message
OvmfPkg/OvmfPkg.dec +1 -0
@@ -109,3 +109,4 @@ [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3 gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
Signature · 1 line
1.8.3.1
PATCH 11/12 ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order
In reply to Laszlo ErsekWe have all the required pieces in place. Let's call SetBootOrderFromQemu() in PlatformBdsPolicyBehavior().
We disable OFW-to-UEFI device path fragment translation for virtio-pci, and enable it only virtio-mmio at this time.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 2 ++ ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 10 ++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 4 ++++ 3 files changed, 16 insertions(+)
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf +2 -0
@@ -40,6 +40,7 @@ MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] BaseLib
@@ -51,6 +52,7 @@ UefiBootServicesTableLib PcdLib GenericBdsLib + QemuBootOrderLib [Guids] gArmGlobalVariableGuid
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c +10 -0
@@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.#include "IntelBdsPlatform.h" +#include <Library/QemuBootOrderLib.h> +/// /// Predefined platform default time out value ///
@@ -305,6 +307,14 @@ PlatformBdsPolicyBehavior (BdsLibConnectAll ();BdsLibEnumerateAllBootOption (BootOptionList); + +SetBootOrderFromQemu (BootOptionList); +// +// The BootOrder variable may have changed, reload the in-memory list with +// it. +// +BdsLibBuildOptionFromVar (BootOptionList,L"BootOrder" ); +PlatformBdsEnterFrontPage (gPlatformBootTimeOutDefault, TRUE); }
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +4 -0
@@ -54,6 +54,7 @@ GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf PlatformBdsLib|ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf + QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf !endif [LibraryClasses.common.UEFI_DRIVER]
@@ -78,6 +79,9 @@ ################################################################################ [PcdsFeatureFlag.common] + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|FALSE + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE + ## If TRUE, Graphics Output Protocol will be installed on virtual handle created by ConsplitterDxe. # It could be set FALSE to save size. gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|FALSE
Signature · 1 line
1.8.3.1
PATCH 12/12 ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS
In reply to Laszlo ErsekThe default value of this PCD (in "IntelFrameworkModulePkg.dec") identifies the "old shell" from EdkShellBinPkg. Our build includes the "new" shell from ShellBinPkg/UefiShell/UefiShell.inf; let's specify the FILE_GUID of that.
Otherwise, no boot option will be generated for the Shell application.
Contributed-under: TianoCore Contribution Agreement 1.0
--- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 + 1 file changed, 1 insertion(+)
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +1 -0
@@ -153,6 +153,7 @@ !ifdef INTEL_BDS gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE + gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } !endif [PcdsDynamicDefault.common]
Signature · 1 line
1.8.3.1