Revision: 18042
          http://sourceforge.net/p/edk2/code/18042
Author:   jljusten
Date:     2015-07-26 08:02:50 +0000 (Sun, 26 Jul 2015)
Log Message:
-----------
ArmVirtPkg: add QemuFwCfgToPcdDxe

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 <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmVirtPkg/ArmVirtQemu.dsc
    trunk/edk2/ArmVirtPkg/ArmVirtQemu.fdf

Added Paths:
-----------
    trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/
    trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c
    trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf

Modified: trunk/edk2/ArmVirtPkg/ArmVirtQemu.dsc
===================================================================
--- trunk/edk2/ArmVirtPkg/ArmVirtQemu.dsc       2015-07-26 08:02:45 UTC (rev 
18041)
+++ trunk/edk2/ArmVirtPkg/ArmVirtQemu.dsc       2015-07-26 08:02:50 UTC (rev 
18042)
@@ -310,6 +310,7 @@
   # Platform Driver
   #
   ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf
+  ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf
   OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
   OvmfPkg/VirtioNetDxe/VirtioNet.inf

Modified: trunk/edk2/ArmVirtPkg/ArmVirtQemu.fdf
===================================================================
--- trunk/edk2/ArmVirtPkg/ArmVirtQemu.fdf       2015-07-26 08:02:45 UTC (rev 
18041)
+++ trunk/edk2/ArmVirtPkg/ArmVirtQemu.fdf       2015-07-26 08:02:50 UTC (rev 
18042)
@@ -104,10 +104,12 @@
   APRIORI DXE {
     INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
     INF ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf
+    INF ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf
   }
   INF MdeModulePkg/Core/Dxe/DxeMain.inf
   INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
   INF ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf
+  INF ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf
 
   #
   # PI DXE Drivers producing Architectural Protocols (EFI Services)

Added: trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c
===================================================================
--- trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c                    
        (rev 0)
+++ trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.c    2015-07-26 
08:02:50 UTC (rev 18042)
@@ -0,0 +1,33 @@
+/** @file
+*  An "early" DXE driver that parses well-known fw-cfg files into dynamic PCDs
+*  that control other (universal) DXE drivers.
+*
+*  Copyright (C) 2015, Red Hat, Inc.
+*  Copyright (c) 2014, Linaro 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 <Uefi/UefiBaseType.h>
+#include <Uefi/UefiSpec.h>
+
+#include <Library/PcdLib.h>
+#include <Library/QemuFwCfgLib.h>
+
+EFI_STATUS
+EFIAPI
+ParseQemuFwCfgToPcd (
+  IN EFI_HANDLE       ImageHandle,
+  IN EFI_SYSTEM_TABLE *SystemTable
+  )
+{
+  return EFI_SUCCESS;
+}

Added: trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf
===================================================================
--- trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf                  
        (rev 0)
+++ trunk/edk2/ArmVirtPkg/QemuFwCfgToPcdDxe/QemuFwCfgToPcd.inf  2015-07-26 
08:02:50 UTC (rev 18042)
@@ -0,0 +1,42 @@
+## @file
+#  An "early" DXE driver that parses well-known fw-cfg files into dynamic PCDs
+#  that control other (universal) DXE drivers.
+#
+#  Copyright (C) 2015, Red Hat, Inc.
+#  Copyright (c) 2014, Linaro 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                      = QemuFwCfgToPcdDxe
+  FILE_GUID                      = 5bb7cc92-1a36-4833-84cf-db7f8258e48d
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = ParseQemuFwCfgToPcd
+
+[Sources]
+  QemuFwCfgToPcd.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  PcdLib
+  QemuFwCfgLib
+  UefiDriverEntryPoint
+
+[Pcd]
+
+[Depex]
+  TRUE


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to