* [Qemu-devel] expose QEMU's fw_cfg boot order to ARM guest firmware (Intel BDS)
@ 2014-11-27 23:17 Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
0 siblings, 2 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:17 UTC (permalink / raw)
To: qemu devel list, edk2-devel list
Cc: Peter Maydell, Drew Jones, Michael S. Tsirkin, Igor Mammedov,
Ard Biesheuvel
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt
2014-11-27 23:17 [Qemu-devel] expose QEMU's fw_cfg boot order to ARM guest firmware (Intel BDS) Laszlo Ersek
@ 2014-11-27 23:18 ` Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 1/2] fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
1 sibling, 2 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:18 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
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(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [qemu PATCH 1/2] fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt Laszlo Ersek
@ 2014-11-27 23:18 ` Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board Laszlo Ersek
1 sibling, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:18 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
We'll use them in board-specific code in the next patch.
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
include/hw/nvram/fw_cfg.h | 3 +++
hw/nvram/fw_cfg.c | 2 --
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 56e1ed7..286d94b 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -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
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index a7122ee..86d53d7 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 1/2] fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public Laszlo Ersek
@ 2014-11-27 23:18 ` Laszlo Ersek
2014-11-27 23:28 ` Peter Maydell
2014-11-28 10:38 ` Andrew Jones
1 sibling, 2 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:18 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
fw_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()).
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
hw/arm/virt.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 314e55b..070bd34 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu
2014-11-27 23:17 [Qemu-devel] expose QEMU's fw_cfg boot order to ARM guest firmware (Intel BDS) Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs Laszlo Ersek
` (11 more replies)
1 sibling, 12 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
The 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%)
--
1.8.3.1
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-12-05 17:39 ` [Qemu-devel] [edk2] " Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 02/12] ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers Laszlo Ersek
` (10 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
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 <lersek@redhat.com>
---
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(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
index 1c9dd20..daafe6c 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
@@ -47,6 +47,8 @@
[Pcd]
gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod
+ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
+ gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
gArmTokenSpaceGuid.PcdGicDistributorBase
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
index d002e66..f1b5283 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
@@ -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);
//
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
index b581add..9941154 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
@@ -53,3 +53,6 @@
# PcdArmPsciMethod == 2 : use SMC
#
gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0|UINT32|0x00000003
+
+ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0|UINT64|0x00000004
+ gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0|UINT64|0x00000005
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index 61689b7..1f3ddea 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 02/12] ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 03/12] ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg Laszlo Ersek
` (9 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
After 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf | 52 +++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 +
3 files changed, 379 insertions(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
new file mode 100644
index 0000000..21ab2bf
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
new file mode 100644
index 0000000..fbc0dfb
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -0,0 +1,326 @@
+/** @file
+
+ Stateful and implicitly initialized fw_cfg library implementation.
+
+ Copyright (C) 2013 - 2014, Red Hat, Inc.
+ Copyright (c) 2011 - 2013, 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.
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/IoLib.h>
+#include <Library/PcdLib.h>
+#include <Library/QemuFwCfgLib.h>
+
+STATIC UINTN mFwCfgSelectorAddress;
+STATIC UINTN mFwCfgDataAddress;
+
+
+/**
+ Returns a boolean indicating if the firmware configuration interface is
+ available for library-internal purposes.
+
+ This function never changes fw_cfg state.
+
+ @retval TRUE The interface is available internally.
+ @retval FALSE The interface is not available internally.
+**/
+BOOLEAN
+EFIAPI
+InternalQemuFwCfgIsAvailable (
+ VOID
+ )
+{
+ return (BOOLEAN)(mFwCfgSelectorAddress != 0 && mFwCfgDataAddress != 0);
+}
+
+
+/**
+ Returns a boolean indicating if the firmware configuration interface
+ is available or not.
+
+ This function may change fw_cfg state.
+
+ @retval TRUE The interface is available
+ @retval FALSE The interface is not available
+
+**/
+BOOLEAN
+EFIAPI
+QemuFwCfgIsAvailable (
+ VOID
+ )
+{
+ return InternalQemuFwCfgIsAvailable ();
+}
+
+
+RETURN_STATUS
+EFIAPI
+QemuFwCfgInitialize (
+ VOID
+ )
+{
+ mFwCfgSelectorAddress = (UINTN)PcdGet64 (PcdFwCfgSelectorAddress);
+ mFwCfgDataAddress = (UINTN)PcdGet64 (PcdFwCfgDataAddress);
+
+ if (InternalQemuFwCfgIsAvailable ()) {
+ UINT32 Signature;
+
+ QemuFwCfgSelectItem (QemuFwCfgItemSignature);
+ Signature = QemuFwCfgRead32 ();
+ if (Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) {
+ mFwCfgSelectorAddress = 0;
+ mFwCfgDataAddress = 0;
+ }
+ }
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Selects a firmware configuration item for reading.
+
+ Following this call, any data read from this item will start from the
+ beginning of the configuration item's data.
+
+ @param[in] QemuFwCfgItem Firmware Configuration item to read
+
+**/
+VOID
+EFIAPI
+QemuFwCfgSelectItem (
+ IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem
+ )
+{
+ if (InternalQemuFwCfgIsAvailable ()) {
+ MmioWrite16 (mFwCfgSelectorAddress, (UINT16)QemuFwCfgItem);
+ }
+}
+
+
+/**
+ Reads firmware configuration bytes into a buffer
+
+ @param[in] Size Size in bytes to read
+ @param[in] Buffer Buffer to store data into (OPTIONAL if Size is 0)
+
+**/
+STATIC
+VOID
+EFIAPI
+InternalQemuFwCfgReadBytes (
+ IN UINTN Size,
+ IN VOID *Buffer OPTIONAL
+ )
+{
+ UINTN Idx;
+
+ for (Idx = 0; Idx < Size; ++Idx) {
+ ((UINT8 *)Buffer)[Idx] = MmioRead8 (mFwCfgDataAddress);
+ }
+}
+
+
+/**
+ Reads firmware configuration bytes into a buffer
+
+ If called multiple times, then the data read will continue at the offset of
+ the firmware configuration item where the previous read ended.
+
+ @param[in] Size Size in bytes to read
+ @param[in] Buffer Buffer to store data into
+
+**/
+VOID
+EFIAPI
+QemuFwCfgReadBytes (
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ if (InternalQemuFwCfgIsAvailable ()) {
+ InternalQemuFwCfgReadBytes (Size, Buffer);
+ } else {
+ ZeroMem (Buffer, Size);
+ }
+}
+
+/**
+ Write firmware configuration bytes from a buffer
+
+ If called multiple times, then the data written will continue at the offset
+ of the firmware configuration item where the previous write ended.
+
+ @param[in] Size Size in bytes to write
+ @param[in] Buffer Buffer to read data from
+
+**/
+VOID
+EFIAPI
+QemuFwCfgWriteBytes (
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ if (InternalQemuFwCfgIsAvailable ()) {
+ UINTN Idx;
+
+ for (Idx = 0; Idx < Size; ++Idx) {
+ MmioWrite8 (mFwCfgDataAddress, ((UINT8 *)Buffer)[Idx]);
+ }
+ }
+}
+
+
+/**
+ Reads a UINT8 firmware configuration value
+
+ @return Value of Firmware Configuration item read
+
+**/
+UINT8
+EFIAPI
+QemuFwCfgRead8 (
+ VOID
+ )
+{
+ UINT8 Result;
+
+ QemuFwCfgReadBytes (sizeof Result, &Result);
+ return Result;
+}
+
+
+/**
+ Reads a UINT16 firmware configuration value
+
+ @return Value of Firmware Configuration item read
+
+**/
+UINT16
+EFIAPI
+QemuFwCfgRead16 (
+ VOID
+ )
+{
+ UINT16 Result;
+
+ QemuFwCfgReadBytes (sizeof Result, &Result);
+ return Result;
+}
+
+
+/**
+ Reads a UINT32 firmware configuration value
+
+ @return Value of Firmware Configuration item read
+
+**/
+UINT32
+EFIAPI
+QemuFwCfgRead32 (
+ VOID
+ )
+{
+ UINT32 Result;
+
+ QemuFwCfgReadBytes (sizeof Result, &Result);
+ return Result;
+}
+
+
+/**
+ Reads a UINT64 firmware configuration value
+
+ @return Value of Firmware Configuration item read
+
+**/
+UINT64
+EFIAPI
+QemuFwCfgRead64 (
+ VOID
+ )
+{
+ UINT64 Result;
+
+ QemuFwCfgReadBytes (sizeof Result, &Result);
+ return Result;
+}
+
+
+/**
+ Find the configuration item corresponding to the firmware configuration file.
+
+ @param[in] Name Name of file to look up.
+ @param[out] Item Configuration item corresponding to the file, to be passed
+ to QemuFwCfgSelectItem ().
+ @param[out] Size Number of bytes in the file.
+
+ @retval RETURN_SUCCESS If file is found.
+ @retval RETURN_NOT_FOUND If file is not found.
+ @retval RETURN_UNSUPPORTED If firmware configuration is unavailable.
+
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgFindFile (
+ IN CONST CHAR8 *Name,
+ OUT FIRMWARE_CONFIG_ITEM *Item,
+ OUT UINTN *Size
+ )
+{
+ UINT32 Count;
+ UINT32 Idx;
+
+ if (!InternalQemuFwCfgIsAvailable ()) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ QemuFwCfgSelectItem (QemuFwCfgItemFileDir);
+ Count = SwapBytes32 (QemuFwCfgRead32 ());
+
+ for (Idx = 0; Idx < Count; ++Idx) {
+ UINT32 FileSize;
+ UINT16 FileSelect;
+ CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
+
+ FileSize = QemuFwCfgRead32 ();
+ FileSelect = QemuFwCfgRead16 ();
+ QemuFwCfgRead16 (); // skip the field called "reserved"
+ InternalQemuFwCfgReadBytes (sizeof (FName), FName);
+
+ if (AsciiStrCmp (Name, FName) == 0) {
+ *Item = SwapBytes16 (FileSelect);
+ *Size = SwapBytes32 (FileSize);
+ return RETURN_SUCCESS;
+ }
+ }
+
+ return RETURN_NOT_FOUND;
+}
+
+
+/**
+ Determine if S3 support is explicitly enabled.
+
+ @retval TRUE if S3 support is explicitly enabled.
+ FALSE otherwise. This includes unavailability of the firmware
+ configuration interface.
+**/
+BOOLEAN
+EFIAPI
+QemuFwCfgS3Enabled (
+ VOID
+ )
+{
+ return FALSE;
+}
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index 1f3ddea..60f7d7f 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 03/12] ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 02/12] ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 04/12] ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy Laszlo Ersek
` (8 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
In 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
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(-)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
new file mode 100644
index 0000000..d635f13
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
new file mode 100644
index 0000000..a244ac9
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
new file mode 100644
index 0000000..c07fc0f
--- /dev/null
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -0,0 +1,376 @@
+/** @file
+
+Copyright (c) 2004 - 2008, 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.
+
+**/
+
+#include "IntelBdsPlatform.h"
+
+///
+/// Predefined platform default time out value
+///
+UINT16 gPlatformBootTimeOutDefault;
+
+EFI_STATUS
+EFIAPI
+PlatformIntelBdsConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ gPlatformBootTimeOutDefault = (UINT16)PcdGet16 (PcdPlatformBootTimeOut);
+ return EFI_SUCCESS;
+}
+
+//
+// BDS Platform Functions
+//
+/**
+ Platform Bds init. Include the platform firmware vendor, revision
+ and so crc check.
+
+**/
+VOID
+EFIAPI
+PlatformBdsInit (
+ VOID
+ )
+{
+}
+
+STATIC
+EFI_STATUS
+GetConsoleDevicePathFromVariable (
+ IN CHAR16* ConsoleVarName,
+ IN CHAR16* DefaultConsolePaths,
+ OUT EFI_DEVICE_PATH** DevicePaths
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ EFI_DEVICE_PATH_PROTOCOL* DevicePathInstances;
+ EFI_DEVICE_PATH_PROTOCOL* DevicePathInstance;
+ CHAR16* DevicePathStr;
+ CHAR16* NextDevicePathStr;
+ EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;
+
+ Status = GetGlobalEnvironmentVariable (ConsoleVarName, NULL, NULL, (VOID**)&DevicePathInstances);
+ if (EFI_ERROR(Status)) {
+ // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)
+ if ((DefaultConsolePaths == NULL) || (DefaultConsolePaths[0] == L'\0')) {
+ *DevicePaths = NULL;
+ return EFI_SUCCESS;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
+ ASSERT_EFI_ERROR(Status);
+
+ DevicePathInstances = NULL;
+
+ // Extract the Device Path instances from the multi-device path string
+ while ((DefaultConsolePaths != NULL) && (DefaultConsolePaths[0] != L'\0')) {
+ NextDevicePathStr = StrStr (DefaultConsolePaths, L";");
+ if (NextDevicePathStr == NULL) {
+ DevicePathStr = DefaultConsolePaths;
+ DefaultConsolePaths = NULL;
+ } else {
+ DevicePathStr = (CHAR16*)AllocateCopyPool ((NextDevicePathStr - DefaultConsolePaths + 1) * sizeof(CHAR16), DefaultConsolePaths);
+ *(DevicePathStr + (NextDevicePathStr - DefaultConsolePaths)) = L'\0';
+ DefaultConsolePaths = NextDevicePathStr;
+ if (DefaultConsolePaths[0] == L';') {
+ DefaultConsolePaths++;
+ }
+ }
+
+ DevicePathInstance = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (DevicePathStr);
+ ASSERT(DevicePathInstance != NULL);
+ DevicePathInstances = AppendDevicePathInstance (DevicePathInstances, DevicePathInstance);
+
+ if (NextDevicePathStr != NULL) {
+ FreePool (DevicePathStr);
+ }
+ FreePool (DevicePathInstance);
+ }
+
+ // Set the environment variable with this device path multi-instances
+ Size = GetDevicePathSize (DevicePathInstances);
+ if (Size > 0) {
+ gRT->SetVariable (
+ ConsoleVarName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ Size,
+ DevicePathInstances
+ );
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ }
+ }
+
+ if (!EFI_ERROR(Status)) {
+ *DevicePaths = DevicePathInstances;
+ }
+ return Status;
+}
+
+STATIC
+EFI_STATUS
+InitializeConsolePipe (
+ IN EFI_DEVICE_PATH *ConsoleDevicePaths,
+ IN EFI_GUID *Protocol,
+ OUT EFI_HANDLE *Handle,
+ OUT VOID* *Interface
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN NoHandles;
+ EFI_HANDLE *Buffer;
+ EFI_DEVICE_PATH_PROTOCOL* DevicePath;
+
+ // Connect all the Device Path Consoles
+ while (ConsoleDevicePaths != NULL) {
+ DevicePath = GetNextDevicePathInstance (&ConsoleDevicePaths, &Size);
+
+ Status = BdsConnectDevicePath (DevicePath, Handle, NULL);
+ DEBUG_CODE_BEGIN();
+ if (EFI_ERROR(Status)) {
+ // We convert back to the text representation of the device Path
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
+ CHAR16* DevicePathTxt;
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+ if (!EFI_ERROR(Status)) {
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (DevicePath, TRUE, TRUE);
+
+ DEBUG((EFI_D_ERROR,"Fail to start the console with the Device Path '%s'. (Error '%r')\n", DevicePathTxt, Status));
+
+ FreePool (DevicePathTxt);
+ }
+ }
+ DEBUG_CODE_END();
+
+ // If the console splitter driver is not supported by the platform then use the first Device Path
+ // instance for the console interface.
+ if (!EFI_ERROR(Status) && (*Interface == NULL)) {
+ Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
+ }
+ }
+
+ // No Device Path has been defined for this console interface. We take the first protocol implementation
+ if (*Interface == NULL) {
+ Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);
+ if (EFI_ERROR (Status)) {
+ BdsConnectAllDrivers ();
+ Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);
+ }
+
+ if (!EFI_ERROR(Status)) {
+ *Handle = Buffer[0];
+ Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
+ ASSERT_EFI_ERROR (Status);
+ }
+ FreePool (Buffer);
+ } else {
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+/**
+ Connect the predefined platform default console device. Always try to find
+ and enable the vga device if have.
+
+ @param PlatformConsole Predefined platform default console device array.
+
+ @retval EFI_SUCCESS Success connect at least one ConIn and ConOut
+ device, there must have one ConOut device is
+ active vga device.
+ @return Return the status of BdsLibConnectAllDefaultConsoles ()
+
+**/
+EFI_STATUS
+PlatformBdsConnectConsole (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH* ConOutDevicePaths;
+ EFI_DEVICE_PATH* ConInDevicePaths;
+ EFI_DEVICE_PATH* ConErrDevicePaths;
+
+ // By getting the Console Device Paths from the environment variables before initializing the console pipe, we
+ // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface
+ // of newly installed console drivers
+ Status = GetConsoleDevicePathFromVariable (L"ConOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConOutDevicePaths);
+ ASSERT_EFI_ERROR (Status);
+ Status = GetConsoleDevicePathFromVariable (L"ConIn", (CHAR16*)PcdGetPtr(PcdDefaultConInPaths), &ConInDevicePaths);
+ ASSERT_EFI_ERROR (Status);
+ Status = GetConsoleDevicePathFromVariable (L"ErrOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConErrDevicePaths);
+ ASSERT_EFI_ERROR (Status);
+
+ // Initialize the Consoles
+ Status = InitializeConsolePipe (ConOutDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST->ConOut);
+ ASSERT_EFI_ERROR (Status);
+ Status = InitializeConsolePipe (ConInDevicePaths, &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST->ConIn);
+ ASSERT_EFI_ERROR (Status);
+ Status = InitializeConsolePipe (ConErrDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **)&gST->StdErr);
+ if (EFI_ERROR(Status)) {
+ // In case of error, we reuse the console output for the error output
+ gST->StandardErrorHandle = gST->ConsoleOutHandle;
+ gST->StdErr = gST->ConOut;
+ }
+
+ return Status;
+}
+
+/**
+ Connect with predefined platform connect sequence,
+ the OEM/IBV can customize with their own connect sequence.
+**/
+VOID
+PlatformBdsConnectSequence (
+ VOID
+ )
+{
+}
+
+/**
+ Load the predefined driver option, OEM/IBV can customize this
+ to load their own drivers
+
+ @param BdsDriverLists - The header of the driver option link list.
+
+**/
+VOID
+PlatformBdsGetDriverOption (
+ IN OUT LIST_ENTRY *BdsDriverLists
+ )
+{
+}
+
+/**
+ Perform the platform diagnostic, such like test memory. OEM/IBV also
+ can customize this function to support specific platform diagnostic.
+
+ @param MemoryTestLevel The memory test intensive level
+ @param QuietBoot Indicate if need to enable the quiet boot
+ @param BaseMemoryTest A pointer to BdsMemoryTest()
+
+**/
+VOID
+PlatformBdsDiagnostics (
+ IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
+ IN BOOLEAN QuietBoot,
+ IN BASEM_MEMORY_TEST BaseMemoryTest
+ )
+{
+}
+
+/**
+ The function will execute with as the platform policy, current policy
+ is driven by boot mode. IBV/OEM can customize this code for their specific
+ policy action.
+
+ @param DriverOptionList The header of the driver option link list
+ @param BootOptionList The header of the boot option link list
+ @param ProcessCapsules A pointer to ProcessCapsules()
+ @param BaseMemoryTest A pointer to BaseMemoryTest()
+
+**/
+VOID
+EFIAPI
+PlatformBdsPolicyBehavior (
+ IN LIST_ENTRY *DriverOptionList,
+ IN LIST_ENTRY *BootOptionList,
+ IN PROCESS_CAPSULES ProcessCapsules,
+ IN BASEM_MEMORY_TEST BaseMemoryTest
+ )
+{
+ EFI_STATUS Status;
+
+ Status = PlatformBdsConnectConsole ();
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Hook point after a boot attempt succeeds. We don't expect a boot option to
+ return, so the UEFI 2.0 specification defines that you will default to an
+ interactive mode and stop processing the BootOrder list in this case. This
+ is also a platform implementation and can be customized by IBV/OEM.
+
+ @param Option Pointer to Boot Option that succeeded to boot.
+
+**/
+VOID
+EFIAPI
+PlatformBdsBootSuccess (
+ IN BDS_COMMON_OPTION *Option
+ )
+{
+}
+
+/**
+ Hook point after a boot attempt fails.
+
+ @param Option Pointer to Boot Option that failed to boot.
+ @param Status Status returned from failed boot.
+ @param ExitData Exit data returned from failed boot.
+ @param ExitDataSize Exit data size returned from failed boot.
+
+**/
+VOID
+EFIAPI
+PlatformBdsBootFail (
+ IN BDS_COMMON_OPTION *Option,
+ IN EFI_STATUS Status,
+ IN CHAR16 *ExitData,
+ IN UINTN ExitDataSize
+ )
+{
+}
+
+/**
+ This function locks platform flash that is not allowed to be updated during normal boot path.
+ The flash layout is platform specific.
+**/
+VOID
+EFIAPI
+PlatformBdsLockNonUpdatableFlash (
+ VOID
+ )
+{
+ return;
+}
+
+
+/**
+ Lock the ConsoleIn device in system table. All key
+ presses will be ignored until the Password is typed in. The only way to
+ disable the password is to type it in to a ConIn device.
+
+ @param Password Password used to lock ConIn device.
+
+ @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
+ @retval EFI_UNSUPPORTED Password not found
+
+**/
+EFI_STATUS
+EFIAPI
+LockKeyboards (
+ IN CHAR16 *Password
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index 60f7d7f..c825340 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 04/12] ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (2 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 03/12] ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 05/12] OvmfPkg: extract QemuBootOrderLib Laszlo Ersek
` (7 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
In 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h | 6 ++++++
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 4 ++++
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 2 ++
3 files changed, 12 insertions(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
index a244ac9..c50bda2 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.h
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index c07fc0f..75b956b 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -302,6 +302,10 @@ PlatformBdsPolicyBehavior (
Status = PlatformBdsConnectConsole ();
ASSERT_EFI_ERROR (Status);
+
+ BdsLibConnectAll ();
+ BdsLibEnumerateAllBootOption (BootOptionList);
+ PlatformBdsEnterFrontPage (gPlatformBootTimeOutDefault, TRUE);
}
/**
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index c825340..e16c02e 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 05/12] OvmfPkg: extract QemuBootOrderLib
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (3 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 04/12] ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 06/12] OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation Laszlo Ersek
` (6 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
and rebase OvmfPkg's PlatformBdsLib on the standalone library.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
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(-)
diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
index 03f5b22..1adc289 100644
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
@@ -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
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
new file mode 100644
index 0000000..12419cd
--- /dev/null
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
@@ -0,0 +1,53 @@
+## @file
+# Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file.
+#
+# Copyright (C) 2012 - 2014, Red Hat, Inc.
+# Copyright (c) 2007 - 2010, 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 = QemuBootOrderLib
+ FILE_GUID = 4FFFA9E1-103D-4CF2-9C06-563BDD03050E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = QemuBootOrderLib|DXE_DRIVER
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM AARCH64
+#
+
+[Sources]
+ QemuBootOrderLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ QemuFwCfgLib
+ DebugLib
+ MemoryAllocationLib
+ GenericBdsLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ BaseLib
+ PrintLib
+ DevicePathLib
+
+[Guids]
+ gEfiGlobalVariableGuid
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.h b/OvmfPkg/Include/Library/QemuBootOrderLib.h
similarity index 91%
rename from OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.h
rename to OvmfPkg/Include/Library/QemuBootOrderLib.h
index 8d4ca2b..12cda6a 100644
--- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.h
+++ b/OvmfPkg/Include/Library/QemuBootOrderLib.h
@@ -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_STATUS
SetBootOrderFromQemu (
IN CONST LIST_ENTRY *BootOptionList
);
+
+#endif
diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
index df07281..341f5c1 100644
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
@@ -13,7 +13,7 @@
**/
#include "BdsPlatform.h"
-#include "QemuBootOrder.h"
+#include <Library/QemuBootOrderLib.h>
//
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
similarity index 96%
rename from OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
rename to OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index bd0fb76..2ff6854 100644
--- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -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>
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index e43ee4f..0eeda6d 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -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
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index f759bfe..ff57dc1 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -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
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index c676347..17e8af3 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -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
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 083418b..80ea6ed 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 06/12] OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (4 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 05/12] OvmfPkg: extract QemuBootOrderLib Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 07/12] OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
` (5 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
In 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 +++
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
OvmfPkg/OvmfPkg.dec | 1 +
3 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
index 12419cd..5aa4e6e 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
@@ -51,3 +51,6 @@
[Guids]
gEfiGlobalVariableGuid
+
+[FeaturePcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 2ff6854..174fd1f 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -35,8 +35,8 @@
/**
Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
-#define REQUIRED_OFW_NODES 2
-#define EXAMINED_OFW_NODES 4
+#define REQUIRED_PCI_OFW_NODES 2
+#define EXAMINED_OFW_NODES 4
/**
@@ -539,7 +539,7 @@ ParseOfwNode (
/**
- Translate an array of OpenFirmware device nodes to a UEFI device path
+ Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path
fragment.
@param[in] OfwNode Array of OpenFirmware device nodes to
@@ -571,7 +571,7 @@ ParseOfwNode (
**/
STATIC
RETURN_STATUS
-TranslateOfwNodes (
+TranslatePciOfwNodes (
IN CONST OFW_NODE *OfwNode,
IN UINTN NumNodes,
OUT CHAR16 *Translated,
@@ -585,7 +585,7 @@ TranslateOfwNodes (
//
// Get PCI device and optional PCI function. Assume a single PCI root.
//
- if (NumNodes < REQUIRED_OFW_NODES ||
+ if (NumNodes < REQUIRED_PCI_OFW_NODES ||
!SubstringEq (OfwNode[0].DriverName, "pci")
) {
return RETURN_UNSUPPORTED;
@@ -803,6 +803,58 @@ TranslateOfwNodes (
/**
+ Translate an array of OpenFirmware device nodes to a UEFI device path
+ fragment.
+
+ @param[in] OfwNode Array of OpenFirmware device nodes to
+ translate, constituting the beginning of an
+ OpenFirmware device path.
+
+ @param[in] NumNodes Number of elements in OfwNode.
+
+ @param[out] Translated Destination array receiving the UEFI path
+ fragment, allocated by the caller. If the
+ return value differs from RETURN_SUCCESS, its
+ contents is indeterminate.
+
+ @param[in out] TranslatedSize On input, the number of CHAR16's in
+ Translated. On RETURN_SUCCESS this parameter
+ is assigned the number of non-NUL CHAR16's
+ written to Translated. In case of other return
+ values, TranslatedSize is indeterminate.
+
+
+ @retval RETURN_SUCCESS Translation successful.
+
+ @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number
+ of bytes provided.
+
+ @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't
+ be translated in the current implementation.
+
+**/
+STATIC
+RETURN_STATUS
+TranslateOfwNodes (
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
+ )
+{
+ RETURN_STATUS Status;
+
+ Status = RETURN_UNSUPPORTED;
+
+ if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
+ Status = TranslatePciOfwNodes (OfwNode, NumNodes, Translated,
+ TranslatedSize);
+ }
+ return Status;
+}
+
+/**
+
Translate an OpenFirmware device path fragment to a UEFI device path
fragment, and advance in the input string.
@@ -1083,9 +1135,11 @@ BootOrderComplete (
if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
//
- // drop PciRoot()
+ // drop PciRoot() if we enabled the user to select PCI-like boot
+ // options, by providing translation for such OFW device path
+ // fragments
//
- Keep = FALSE;
+ Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);
}
}
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 0eeda6d..8802392 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -107,3 +107,4 @@
[PcdsFeatureFlag]
gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 07/12] OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (5 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 06/12] OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 08/12] ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
` (4 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
Soon 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Include/Guid/VirtioMmioTransport.h | 25 +++++++++++++++++++++++++
OvmfPkg/OvmfPkg.dec | 1 +
2 files changed, 26 insertions(+)
diff --git a/OvmfPkg/Include/Guid/VirtioMmioTransport.h b/OvmfPkg/Include/Guid/VirtioMmioTransport.h
new file mode 100644
index 0000000..f17d7b1
--- /dev/null
+++ b/OvmfPkg/Include/Guid/VirtioMmioTransport.h
@@ -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
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 8802392..41db92d 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -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}}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 08/12] ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (6 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 07/12] OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 09/12] OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64 Laszlo Ersek
` (3 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
Installing 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 3 ++-
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
index daafe6c..514ce2f 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
index f1b5283..2191078 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
@@ -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));
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 09/12] OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (7 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 08/12] ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 10/12] OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio Laszlo Ersek
` (2 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
The 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 174fd1f..3599437 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -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 @@ STATIC
RETURN_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]
);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 10/12] OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (8 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 09/12] OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64 Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 11/12] ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 12/12] ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS Laszlo Ersek
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
The 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 ++
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
OvmfPkg/OvmfPkg.dec | 1 +
3 files changed, 201 insertions(+), 1 deletion(-)
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
index 5aa4e6e..6289e6a 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
@@ -48,9 +48,12 @@
BaseLib
PrintLib
DevicePathLib
+ BaseMemoryLib
[Guids]
gEfiGlobalVariableGuid
+ gVirtioMmioTransportGuid
[FeaturePcd]
gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 3599437..bc2fb56 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -23,7 +23,9 @@
#include <Library/PrintLib.h>
#include <Library/DevicePathLib.h>
#include <Library/QemuBootOrderLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Guid/GlobalVariable.h>
+#include <Guid/VirtioMmioTransport.h>
/**
@@ -36,6 +38,7 @@
Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
#define REQUIRED_PCI_OFW_NODES 2
+#define REQUIRED_MMIO_OFW_NODES 1
#define EXAMINED_OFW_NODES 4
@@ -801,6 +804,182 @@ TranslatePciOfwNodes (
}
+//
+// A type providing easy raw access to the base address of a virtio-mmio
+// transport.
+//
+typedef union {
+ UINT64 Uint64;
+ UINT8 Raw[8];
+} VIRTIO_MMIO_BASE_ADDRESS;
+
+
+/**
+
+ Translate an MMIO-like array of OpenFirmware device nodes to a UEFI device
+ path fragment.
+
+ @param[in] OfwNode Array of OpenFirmware device nodes to
+ translate, constituting the beginning of an
+ OpenFirmware device path.
+
+ @param[in] NumNodes Number of elements in OfwNode.
+
+ @param[out] Translated Destination array receiving the UEFI path
+ fragment, allocated by the caller. If the
+ return value differs from RETURN_SUCCESS, its
+ contents is indeterminate.
+
+ @param[in out] TranslatedSize On input, the number of CHAR16's in
+ Translated. On RETURN_SUCCESS this parameter
+ is assigned the number of non-NUL CHAR16's
+ written to Translated. In case of other return
+ values, TranslatedSize is indeterminate.
+
+
+ @retval RETURN_SUCCESS Translation successful.
+
+ @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number
+ of bytes provided.
+
+ @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't
+ be translated in the current implementation.
+
+**/
+STATIC
+RETURN_STATUS
+TranslateMmioOfwNodes (
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
+ )
+{
+ VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase;
+ CHAR16 VenHwString[60 + 1];
+ UINTN NumEntries;
+ UINTN Written;
+
+ //
+ // Get the base address of the virtio-mmio transport.
+ //
+ if (NumNodes < REQUIRED_MMIO_OFW_NODES ||
+ !SubstringEq (OfwNode[0].DriverName, "virtio-mmio")
+ ) {
+ return RETURN_UNSUPPORTED;
+ }
+ NumEntries = 1;
+ if (ParseUnitAddressHexList (
+ OfwNode[0].UnitAddress,
+ &VirtioMmioBase.Uint64,
+ &NumEntries
+ ) != RETURN_SUCCESS
+ ) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ UnicodeSPrintAsciiFormat (VenHwString, sizeof VenHwString,
+ "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)", &gVirtioMmioTransportGuid,
+ VirtioMmioBase.Raw[0], VirtioMmioBase.Raw[1], VirtioMmioBase.Raw[2],
+ VirtioMmioBase.Raw[3], VirtioMmioBase.Raw[4], VirtioMmioBase.Raw[5],
+ VirtioMmioBase.Raw[6], VirtioMmioBase.Raw[7]);
+
+ if (NumNodes >= 2 &&
+ SubstringEq (OfwNode[1].DriverName, "disk")) {
+ //
+ // OpenFirmware device path (virtio-blk disk):
+ //
+ // /virtio-mmio@000000000a003c00/disk@0,0
+ // ^ ^ ^
+ // | fixed
+ // base address of virtio-mmio register block
+ //
+ // UEFI device path prefix:
+ //
+ // <VenHwString>/HD(
+ //
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "%s/HD(",
+ VenHwString
+ );
+ } else if (NumNodes >= 3 &&
+ SubstringEq (OfwNode[1].DriverName, "channel") &&
+ SubstringEq (OfwNode[2].DriverName, "disk")) {
+ //
+ // OpenFirmware device path (virtio-scsi disk):
+ //
+ // /virtio-mmio@000000000a003a00/channel@0/disk@2,3
+ // ^ ^ ^ ^
+ // | | | LUN
+ // | | target
+ // | channel (unused, fixed 0)
+ // base address of virtio-mmio register block
+ //
+ // UEFI device path prefix:
+ //
+ // <VenHwString>/Scsi(0x2,0x3)
+ //
+ UINT64 TargetLun[2];
+
+ TargetLun[1] = 0;
+ NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);
+ if (ParseUnitAddressHexList (
+ OfwNode[2].UnitAddress,
+ TargetLun,
+ &NumEntries
+ ) != RETURN_SUCCESS
+ ) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "%s/Scsi(0x%Lx,0x%Lx)",
+ VenHwString,
+ TargetLun[0],
+ TargetLun[1]
+ );
+ } else if (NumNodes >= 2 &&
+ SubstringEq (OfwNode[1].DriverName, "ethernet-phy")) {
+ //
+ // OpenFirmware device path (virtio-net NIC):
+ //
+ // /virtio-mmio@000000000a003e00/ethernet-phy@0
+ // ^ ^
+ // | fixed
+ // base address of virtio-mmio register block
+ //
+ // UEFI device path prefix (dependent on presence of nonzero PCI function):
+ //
+ // <VenHwString>/MAC(
+ //
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "%s/MAC(",
+ VenHwString
+ );
+ } else {
+ return RETURN_UNSUPPORTED;
+ }
+
+ //
+ // There's no way to differentiate between "completely used up without
+ // truncation" and "truncated", so treat the former as the latter, and return
+ // success only for "some room left unused".
+ //
+ if (Written + 1 < *TranslatedSize) {
+ *TranslatedSize = Written;
+ return RETURN_SUCCESS;
+ }
+
+ return RETURN_BUFFER_TOO_SMALL;
+}
+
+
/**
Translate an array of OpenFirmware device nodes to a UEFI device path
@@ -850,6 +1029,11 @@ TranslateOfwNodes (
Status = TranslatePciOfwNodes (OfwNode, NumNodes, Translated,
TranslatedSize);
}
+ if (Status == RETURN_UNSUPPORTED &&
+ FeaturePcdGet (PcdQemuBootOrderMmioTranslation)) {
+ Status = TranslateMmioOfwNodes (OfwNode, NumNodes, Translated,
+ TranslatedSize);
+ }
return Status;
}
@@ -1069,7 +1253,7 @@ Exit:
This function should accommodate any further policy changes in "boot option
survival". Currently we're adding back everything that starts with neither
- PciRoot() nor HD().
+ PciRoot() nor HD() nor a virtio-mmio VenHw() node.
@param[in,out] BootOrder The structure holding the boot order to
complete. The caller is responsible for
@@ -1141,6 +1325,18 @@ BootOrderComplete (
//
Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);
}
+ } else if (DevicePathType(FirstNode) == HARDWARE_DEVICE_PATH &&
+ DevicePathSubType(FirstNode) == HW_VENDOR_DP) {
+ VENDOR_DEVICE_PATH *VenHw;
+
+ VenHw = (VENDOR_DEVICE_PATH *)FirstNode;
+ if (CompareGuid (&VenHw->Guid, &gVirtioMmioTransportGuid)) {
+ //
+ // drop virtio-mmio if we enabled the user to select boot options
+ // referencing such device paths
+ //
+ Keep = !FeaturePcdGet (PcdQemuBootOrderMmioTranslation);
+ }
}
if (Keep) {
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 41db92d..e3a09cf 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -109,3 +109,4 @@
[PcdsFeatureFlag]
gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 11/12] ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (9 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 10/12] OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 12/12] ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS Laszlo Ersek
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
We 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 2 ++
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 10 ++++++++++
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 4 ++++
3 files changed, 16 insertions(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index d635f13..efd50f3 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -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
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 75b956b..9b91368 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -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);
}
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index e16c02e..d2419d2 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [edk2 PATCH 12/12] ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
` (10 preceding siblings ...)
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 11/12] ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order Laszlo Ersek
@ 2014-11-27 23:19 ` Laszlo Ersek
11 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:19 UTC (permalink / raw)
To: qemu-devel, edk2-devel, drjones, ard.biesheuvel, peter.maydell,
imammedo, mst
The 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
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 +
1 file changed, 1 insertion(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index d2419d2..51d5042 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -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]
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board Laszlo Ersek
@ 2014-11-27 23:28 ` Peter Maydell
2014-11-27 23:34 ` Laszlo Ersek
2014-11-28 10:38 ` Andrew Jones
1 sibling, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2014-11-27 23:28 UTC (permalink / raw)
To: Laszlo Ersek
Cc: Andrew Jones, Ard Biesheuvel, Michael S. Tsirkin,
edk2-devel@lists.sourceforge.net, QEMU Developers, Igor Mammedov
On 27 November 2014 at 23:18, Laszlo Ersek <lersek@redhat.com> wrote:
> fw_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.
> + 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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-27 23:28 ` Peter Maydell
@ 2014-11-27 23:34 ` Laszlo Ersek
2014-11-27 23:37 ` Peter Maydell
0 siblings, 1 reply; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-27 23:34 UTC (permalink / raw)
To: Peter Maydell
Cc: Andrew Jones, Ard Biesheuvel, Michael S. Tsirkin,
edk2-devel@lists.sourceforge.net, QEMU Developers, Igor Mammedov
On 11/28/14 00:28, Peter Maydell wrote:
> On 27 November 2014 at 23:18, Laszlo Ersek <lersek@redhat.com> wrote:
>> fw_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.
>
>> + 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 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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-27 23:34 ` Laszlo Ersek
@ 2014-11-27 23:37 ` Peter Maydell
0 siblings, 0 replies; 26+ messages in thread
From: Peter Maydell @ 2014-11-27 23:37 UTC (permalink / raw)
To: Laszlo Ersek
Cc: Andrew Jones, Ard Biesheuvel, Michael S. Tsirkin,
edk2-devel@lists.sourceforge.net, QEMU Developers, Igor Mammedov
On 27 November 2014 at 23:34, Laszlo Ersek <lersek@redhat.com> wrote:
> 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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board Laszlo Ersek
2014-11-27 23:28 ` Peter Maydell
@ 2014-11-28 10:38 ` Andrew Jones
2014-11-28 10:43 ` Laszlo Ersek
1 sibling, 1 reply; 26+ messages in thread
From: Andrew Jones @ 2014-11-28 10:38 UTC (permalink / raw)
To: Laszlo Ersek
Cc: peter.maydell, ard.biesheuvel, mst, edk2-devel, qemu-devel,
imammedo
On Fri, Nov 28, 2014 at 12:18:27AM +0100, Laszlo Ersek wrote:
> fw_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()).
>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> hw/arm/virt.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 314e55b..070bd34 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -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);
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.
> + 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;
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-28 10:38 ` Andrew Jones
@ 2014-11-28 10:43 ` Laszlo Ersek
2014-11-28 10:49 ` Laszlo Ersek
2014-11-28 10:51 ` Andrew Jones
0 siblings, 2 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-28 10:43 UTC (permalink / raw)
To: Andrew Jones
Cc: peter.maydell, ard.biesheuvel, mst, edk2-devel, qemu-devel,
imammedo
On 11/28/14 11:38, Andrew Jones wrote:
> On Fri, Nov 28, 2014 at 12:18:27AM +0100, Laszlo Ersek wrote:
>> fw_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()).
>>
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>> hw/arm/virt.c | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 314e55b..070bd34 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -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);
>
> 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.
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
>
>> + 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;
>> --
>> 1.8.3.1
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-28 10:43 ` Laszlo Ersek
@ 2014-11-28 10:49 ` Laszlo Ersek
2014-11-28 11:17 ` Andrew Jones
2014-11-28 10:51 ` Andrew Jones
1 sibling, 1 reply; 26+ messages in thread
From: Laszlo Ersek @ 2014-11-28 10:49 UTC (permalink / raw)
To: Andrew Jones
Cc: peter.maydell, ard.biesheuvel, mst, edk2-devel, qemu-devel,
imammedo
On 11/28/14 11:43, Laszlo Ersek wrote:
> On 11/28/14 11:38, Andrew Jones wrote:
>> On Fri, Nov 28, 2014 at 12:18:27AM +0100, Laszlo Ersek wrote:
>>> fw_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()).
>>>
>>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>>> ---
>>> hw/arm/virt.c | 21 +++++++++++++++++++++
>>> 1 file changed, 21 insertions(+)
>>>
>>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>>> index 314e55b..070bd34 100644
>>> --- a/hw/arm/virt.c
>>> +++ b/hw/arm/virt.c
>>> @@ -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);
>>
>> 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.
>
> 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?
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-28 10:43 ` Laszlo Ersek
2014-11-28 10:49 ` Laszlo Ersek
@ 2014-11-28 10:51 ` Andrew Jones
1 sibling, 0 replies; 26+ messages in thread
From: Andrew Jones @ 2014-11-28 10:51 UTC (permalink / raw)
To: Laszlo Ersek
Cc: peter.maydell, ard.biesheuvel, mst, edk2-devel, qemu-devel,
imammedo
On Fri, Nov 28, 2014 at 11:43:32AM +0100, Laszlo Ersek wrote:
> On 11/28/14 11:38, Andrew Jones wrote:
> > On Fri, Nov 28, 2014 at 12:18:27AM +0100, Laszlo Ersek wrote:
> >> fw_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()).
> >>
> >> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> >> ---
> >> hw/arm/virt.c | 21 +++++++++++++++++++++
> >> 1 file changed, 21 insertions(+)
> >>
> >> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> >> index 314e55b..070bd34 100644
> >> --- a/hw/arm/virt.c
> >> +++ b/hw/arm/virt.c
> >> @@ -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);
> >
> > 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.
>
> Why does it need to be aligned?
Natural alignment is more efficient.
>
> 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.
>
> 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.
>
> Thanks
> Laszlo
>
> >
> >> + 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;
> >> --
> >> 1.8.3.1
> >>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board
2014-11-28 10:49 ` Laszlo Ersek
@ 2014-11-28 11:17 ` Andrew Jones
0 siblings, 0 replies; 26+ messages in thread
From: Andrew Jones @ 2014-11-28 11:17 UTC (permalink / raw)
To: Laszlo Ersek
Cc: peter.maydell, ard.biesheuvel, mst, edk2-devel, qemu-devel,
imammedo
On Fri, Nov 28, 2014 at 11:49:48AM +0100, Laszlo Ersek wrote:
> On 11/28/14 11:43, Laszlo Ersek wrote:
> > On 11/28/14 11:38, Andrew Jones wrote:
> >> On Fri, Nov 28, 2014 at 12:18:27AM +0100, Laszlo Ersek wrote:
> >>> fw_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()).
> >>>
> >>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> >>> ---
> >>> hw/arm/virt.c | 21 +++++++++++++++++++++
> >>> 1 file changed, 21 insertions(+)
> >>>
> >>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> >>> index 314e55b..070bd34 100644
> >>> --- a/hw/arm/virt.c
> >>> +++ b/hw/arm/virt.c
> >>> @@ -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);
> >>
> >> 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.
> >
> > 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?
>
> 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.
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.
>
> Thanks!
> Laszlo
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [edk2] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs Laszlo Ersek
@ 2014-12-05 17:39 ` Laszlo Ersek
0 siblings, 0 replies; 26+ messages in thread
From: Laszlo Ersek @ 2014-12-05 17:39 UTC (permalink / raw)
To: Olivier Martin
Cc: peter.maydell, drjones, edk2-devel, qemu-devel, ard.biesheuvel
On 11/28/14 00:19, Laszlo Ersek wrote:
> 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 <lersek@redhat.com>
> ---
> 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(+)
>
> diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> index 1c9dd20..daafe6c 100644
> --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> @@ -47,6 +47,8 @@
> [Pcd]
> gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
> gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod
> + gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
> + gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
> gArmTokenSpaceGuid.PcdGicDistributorBase
> gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
> gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
> diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> index d002e66..f1b5283 100644
> --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> @@ -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" },
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
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2014-12-05 17:40 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-27 23:17 [Qemu-devel] expose QEMU's fw_cfg boot order to ARM guest firmware (Intel BDS) Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 0/2] DTB- and MMIO-based fw_cfg for hw/arm/virt Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 1/2] fw_cfg: make the FW_CFG_SIZE and FW_CFG_DATA_SIZE macros public Laszlo Ersek
2014-11-27 23:18 ` [Qemu-devel] [qemu PATCH 2/2] arm: add fw_cfg to "virt" board Laszlo Ersek
2014-11-27 23:28 ` Peter Maydell
2014-11-27 23:34 ` Laszlo Ersek
2014-11-27 23:37 ` Peter Maydell
2014-11-28 10:38 ` Andrew Jones
2014-11-28 10:43 ` Laszlo Ersek
2014-11-28 10:49 ` Laszlo Ersek
2014-11-28 11:17 ` Andrew Jones
2014-11-28 10:51 ` Andrew Jones
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 00/12] consume fw_cfg boot order in ArmVirtualizationQemu Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs Laszlo Ersek
2014-12-05 17:39 ` [Qemu-devel] [edk2] " Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 02/12] ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 03/12] ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 04/12] ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 05/12] OvmfPkg: extract QemuBootOrderLib Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 06/12] OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 07/12] OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 08/12] ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 09/12] OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64 Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 10/12] OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 11/12] ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order Laszlo Ersek
2014-11-27 23:19 ` [Qemu-devel] [edk2 PATCH 12/12] ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).