]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: add QemuFwCfgToPcdDxe
authorLaszlo Ersek <lersek@redhat.com>
Sun, 26 Jul 2015 08:02:50 +0000 (08:02 +0000)
committerjljusten <jljusten@Edk2>
Sun, 26 Jul 2015 08:02:50 +0000 (08:02 +0000)
Many universal DXE drivers in edk2 can be controlled by setting dynamic
PCDs. Such a PCD must be set before the consumer DXE driver is dispatched.

(In general we assume that the DXE driver will consume the PCD in its
entry point, or in the constructor of a library instance it links against.
In special cases this requirement can be relaxed a bit, if we know that
the DXE driver accesses the PCD only in a protocol member function that it
exports.)

On the QEMU platform, the PCD values to be set for the universal drivers
are frequently derived from fw_cfg files that QEMU exports.

In OvmfPkg we tend to handle this in the following way:

- For IA32 and X64, OvmfPkg provides a QemuFwCfgLib instance that is
  usable in PEI.

- In PlatformPei, fw_cfg files can be loaded and transformed to PCD
  values.

- Any DXE driver is bound to be dispatched after the PEI phase is done.

(In specific cases other ordering solutions might be possible, via Depex
or protocol notify, etc.)

In ArmVirtPkg/ArmVirtQemu, things differ a bit:

- We don't have an ArmVirtPkg-specific ("Platform") PEIM. This is actually
  a good thing for now, so let's not introduce one just for this purpose.

- Even if we had such a PEIM, it could not easily access fw_cfg: the MMIO
  addresses of the fw_cfg device are available only in the DTB that QEMU
  exports.

  (Accordingly, our QemuFwCfgLib instance is restricted to DXE_DRIVER
  modules: VirtFdtDxe parses the DTB, stores the fw_cfg addresses in PCDs,
  and then QemuFwCfgLib's constructor fetches those PCDs.)

  There are some examples in ArmVirtPkg where early code is forced to
  parse the DTB manually, but those examples are all painful, and our goal
  here (controlling universal DXE drivers) doesn't justify more of that
  pain.

Therefore, introduce a separate, minimal DXE driver that is dispatched
strictly after VirtFdtDxe (so that it can use QemuFwCfgLib), and strictly
before other DXE drivers (so that it can set dynamic PCDs for them).
Because VirtFdtDxe is already ordered with the APRIORI DXE file, it is
simplest to do the same for the new driver.

Actual fw_cfg files and PCDs shall be accessed in future patches.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18042 6f19259b-4bc3-4df7-8a09-765794883524

ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/ArmVirtQemu.fdf
ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c [new file with mode: 0644]
ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf [new file with mode: 0644]

index be2b9840027f4e5ed6075ac704bd182f46e24020..07d5a87e661d61097163060d93f49e925ba20cd3 100644 (file)
   # Platform Driver\r
   #\r
   ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf\r
+  ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf\r
   OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
   OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
index 41bcda8060f77c75d773866f6dcef50496504363..5b6bda8c5191ac6dfc7163dd74fca17a01b00b2b 100644 (file)
@@ -104,10 +104,12 @@ READ_LOCK_STATUS   = TRUE
   APRIORI DXE {\r
     INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
     INF ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf\r
+    INF ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf\r
   }\r
   INF MdeModulePkg/Core/Dxe/DxeMain.inf\r
   INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
   INF ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf\r
+  INF ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf\r
 \r
   #\r
   # PI DXE Drivers producing Architectural Protocols (EFI Services)\r
diff --git a/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c b/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c
new file mode 100644 (file)
index 0000000..8f60e21
--- /dev/null
@@ -0,0 +1,33 @@
+/** @file\r
+*  An "early" DXE driver that parses well-known fw-cfg files into dynamic PCDs\r
+*  that control other (universal) DXE drivers.\r
+*\r
+*  Copyright (C) 2015, Red Hat, Inc.\r
+*  Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
+*\r
+*  This program and the accompanying materials are licensed and made available\r
+*  under the terms and conditions of the BSD License which accompanies this\r
+*  distribution.  The full text of the license may be found at\r
+*  http://opensource.org/licenses/bsd-license.php\r
+*\r
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR\r
+*  IMPLIED.\r
+*\r
+**/\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Uefi/UefiSpec.h>\r
+\r
+#include <Library/PcdLib.h>\r
+#include <Library/QemuFwCfgLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ParseQemuFwCfgToPcd (\r
+  IN EFI_HANDLE       ImageHandle,\r
+  IN EFI_SYSTEM_TABLE *SystemTable\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf b/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf
new file mode 100644 (file)
index 0000000..a9983be
--- /dev/null
@@ -0,0 +1,42 @@
+## @file\r
+#  An "early" DXE driver that parses well-known fw-cfg files into dynamic PCDs\r
+#  that control other (universal) DXE drivers.\r
+#\r
+#  Copyright (C) 2015, Red Hat, Inc.\r
+#  Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials are licensed and made available\r
+#  under the terms and conditions of the BSD License which accompanies this\r
+#  distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR\r
+#  IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = QemuFwCfgToPcdDxe\r
+  FILE_GUID                      = 5bb7cc92-1a36-4833-84cf-db7f8258e48d\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = ParseQemuFwCfgToPcd\r
+\r
+[Sources]\r
+  QemuFwCfgToPcd.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+  PcdLib\r
+  QemuFwCfgLib\r
+  UefiDriverEntryPoint\r
+\r
+[Pcd]\r
+\r
+[Depex]\r
+  TRUE\r