This DXE driver will collect OVMF config knobs into an HII form. Right now
it only adds a new menu entry in the Device Manager window that opens an
empty form.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/PlatformConfigDxe/PlatformConfig.inf      |  48 +++++
 OvmfPkg/PlatformConfigDxe/PlatformConfig.h        |  23 +++
 OvmfPkg/PlatformConfigDxe/PlatformConfigForms.vfr |  38 ++++
 OvmfPkg/PlatformConfigDxe/PlatformConfig.c        | 216 ++++++++++++++++++++++
 OvmfPkg/OvmfPkgIa32.dsc                           |   2 +
 OvmfPkg/OvmfPkgIa32.fdf                           |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                        |   2 +
 OvmfPkg/OvmfPkgIa32X64.fdf                        |   1 +
 OvmfPkg/OvmfPkgX64.dsc                            |   2 +
 OvmfPkg/OvmfPkgX64.fdf                            |   1 +
 OvmfPkg/PlatformConfigDxe/PlatformConfig.uni      | Bin 0 -> 1944 bytes
 11 files changed, 334 insertions(+)
 create mode 100644 OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
 create mode 100644 OvmfPkg/PlatformConfigDxe/PlatformConfig.h
 create mode 100644 OvmfPkg/PlatformConfigDxe/PlatformConfigForms.vfr
 create mode 100644 OvmfPkg/PlatformConfigDxe/PlatformConfig.c
 create mode 100644 OvmfPkg/PlatformConfigDxe/PlatformConfig.uni

diff --git a/OvmfPkg/PlatformConfigDxe/PlatformConfig.inf 
b/OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
new file mode 100644
index 0000000..7f04c23
--- /dev/null
+++ b/OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
@@ -0,0 +1,48 @@
+## @file
+#  This driver exposes OVMF's platform configuration settings via HII.
+#
+#  Copyright (C) 2014, Red Hat, Inc.
+#  Copyright (c) 2009 - 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                      = PlatformConfigDxe
+  FILE_GUID                      = D9DCC5DF-4007-435E-9098-8970935504B2
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = PlatformConfigInit
+  UNLOAD_IMAGE                   = PlatformConfigUnload
+
+[Sources]
+  PlatformConfig.c
+  PlatformConfig.uni
+  PlatformConfigForms.vfr
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  DevicePathLib
+  HiiLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiDevicePathProtocolGuid      ## PRODUCES
+  gEfiHiiConfigAccessProtocolGuid ## PRODUCES
+
+[Depex]
+  TRUE
diff --git a/OvmfPkg/PlatformConfigDxe/PlatformConfig.h 
b/OvmfPkg/PlatformConfigDxe/PlatformConfig.h
new file mode 100644
index 0000000..8efe789
--- /dev/null
+++ b/OvmfPkg/PlatformConfigDxe/PlatformConfig.h
@@ -0,0 +1,23 @@
+/** @file
+  This driver exposes OVMF's platform configuration settings via HII.
+
+  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 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 _PLATFORM_CONFIG_H_
+#define _PLATFORM_CONFIG_H_
+
+//
+// Macro and type definitions that connect the form with the HII driver code.
+//
+#define FORMID_MAIN_FORM       1
+
+#endif // _PLATFORM_CONFIG_H_
diff --git a/OvmfPkg/PlatformConfigDxe/PlatformConfigForms.vfr 
b/OvmfPkg/PlatformConfigDxe/PlatformConfigForms.vfr
new file mode 100644
index 0000000..1576199
--- /dev/null
+++ b/OvmfPkg/PlatformConfigDxe/PlatformConfigForms.vfr
@@ -0,0 +1,38 @@
+// *++
+//
+// Copyright (C) 2014, Red Hat, Inc.
+// Copyright (c) 2009 - 2011, 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.
+//
+// Module Name:
+//
+//   PlatformConfigForms.vfr
+//
+// Abstract:
+//
+//   Form definitions for exposing some of OVMF's platform knobs via HII.
+//
+// --*/
+
+#include <Guid/OvmfPlatformConfig.h>
+#include "PlatformConfig.h"
+
+formset
+  guid  = OVMF_PLATFORM_CONFIG_GUID,
+  title = STRING_TOKEN(STR_FORMSET_TITLE),
+  help  = STRING_TOKEN(STR_FORMSET_HELP),
+
+  form
+    formid = FORMID_MAIN_FORM,
+    title  = STRING_TOKEN(STR_MAIN_FORM_TITLE);
+  endform;
+
+endformset;
diff --git a/OvmfPkg/PlatformConfigDxe/PlatformConfig.c 
b/OvmfPkg/PlatformConfigDxe/PlatformConfig.c
new file mode 100644
index 0000000..eb03dd8
--- /dev/null
+++ b/OvmfPkg/PlatformConfigDxe/PlatformConfig.c
@@ -0,0 +1,216 @@
+/** @file
+  This driver exposes OVMF's platform configuration settings via HII.
+
+  Copyright (C) 2014, Red Hat, Inc.
+  Copyright (c) 2009 - 2011, 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/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/HiiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/HiiConfigAccess.h>
+
+//
+// The HiiAddPackages() library function requires that any controller (or
+// image) handle, to be associated with the HII packages under installation, be
+// "decorated" with a device path. The tradition seems to be a vendor device
+// path.
+//
+// We'd like to associate our HII packages with the driver's image handle. The
+// first idea is to use the driver image's device path. Unfortunately, loaded
+// images only come with an EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL (not the
+// usual EFI_DEVICE_PATH_PROTOCOL), ie. a different GUID. In addition, even the
+// EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL interface may be NULL, if the image
+// has been loaded from an "unnamed" memory source buffer.
+//
+// Hence let's just stick with the tradition -- use a dedicated vendor device
+// path, with the driver's FILE_GUID.
+//
+#pragma pack(1)
+typedef struct {
+  VENDOR_DEVICE_PATH       VendorDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL End;
+} PKG_DEVICE_PATH;
+#pragma pack()
+
+STATIC PKG_DEVICE_PATH mPkgDevicePath = {
+  {
+    {
+      HARDWARE_DEVICE_PATH,
+      HW_VENDOR_DP,
+      {
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH)     ),
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH) >> 8)
+      }
+    },
+    EFI_CALLER_ID_GUID
+  },
+  {
+    END_DEVICE_PATH_TYPE,
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,
+    {
+      (UINT8) (END_DEVICE_PATH_LENGTH     ),
+      (UINT8) (END_DEVICE_PATH_LENGTH >> 8)
+    }
+  }
+};
+
+//
+// The configuration interface between the HII engine (form display etc) and
+// this driver.
+//
+STATIC EFI_HII_CONFIG_ACCESS_PROTOCOL mConfigAccess;
+
+//
+// The handle representing our list of packages after installation.
+//
+STATIC EFI_HII_HANDLE mInstalledPackages;
+
+//
+// The arrays below constitute our HII package list. They are auto-generated by
+// the VFR compiler and linked into the driver image during the build.
+//
+// - The strings package receives its C identifier from the driver's BASE_NAME,
+//   plus "Strings".
+//
+// - The forms package receives its C identifier from the VFR file's basename,
+//   plus "Bin".
+//
+//
+extern UINT8 PlatformConfigDxeStrings[];
+extern UINT8 PlatformConfigFormsBin[];
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+ExtractConfig (
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,
+  IN CONST  EFI_STRING                      Request,
+  OUT       EFI_STRING                      *Progress,
+  OUT       EFI_STRING                      *Results
+)
+{
+  return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+RouteConfig (
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,
+  IN CONST  EFI_STRING                      Configuration,
+  OUT       EFI_STRING                      *Progress
+)
+{
+  return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+Callback (
+  IN     CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
+  IN     EFI_BROWSER_ACTION                     Action,
+  IN     EFI_QUESTION_ID                        QuestionId,
+  IN     UINT8                                  Type,
+  IN OUT EFI_IFR_TYPE_VALUE                     *Value,
+  OUT    EFI_BROWSER_ACTION_REQUEST             *ActionRequest
+  )
+{
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Entry point for this driver.
+
+  @param[in] ImageHandle  Image handle of this driver.
+  @param[in] SystemTable  Pointer to SystemTable.
+
+  @retval EFI_SUCESS            Driver has loaded successfully.
+  @retval EFI_OUT_OF_RESOURCES  Failed to install HII packages.
+  @return                       Error codes from lower level functions.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformConfigInit (
+  IN  EFI_HANDLE        ImageHandle,
+  IN  EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS Status;
+
+  mConfigAccess.ExtractConfig = &ExtractConfig;
+  mConfigAccess.RouteConfig   = &RouteConfig;
+  mConfigAccess.Callback      = &Callback;
+
+  //
+  // Declare ourselves suitable for HII communication.
+  //
+  Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
+                  &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,
+                  &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,
+                  NULL);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Publish the HII package list to HII Database.
+  //
+  mInstalledPackages = HiiAddPackages (
+                         &gEfiCallerIdGuid,        // PackageListGuid
+                         ImageHandle,              // associated DeviceHandle
+                         PlatformConfigDxeStrings, // 1st package
+                         PlatformConfigFormsBin,   // 2nd package
+                         NULL                      // terminator
+                         );
+  if (mInstalledPackages == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto UninstallProtocols;
+  }
+
+  return EFI_SUCCESS;
+
+UninstallProtocols:
+  gBS->UninstallMultipleProtocolInterfaces (ImageHandle,
+         &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,
+         &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,
+         NULL);
+  return Status;
+}
+
+/**
+  Unload the driver.
+
+  @param[in]  ImageHandle  Handle that identifies the image to evict.
+
+  @retval EFI_SUCCESS  The image has been unloaded.
+**/
+EFI_STATUS
+EFIAPI
+PlatformConfigUnload (
+  IN  EFI_HANDLE  ImageHandle
+  )
+{
+  HiiRemovePackages (mInstalledPackages);
+  gBS->UninstallMultipleProtocolInterfaces (ImageHandle,
+         &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,
+         &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,
+         NULL);
+  return EFI_SUCCESS;
+}
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 435a625..cd3ee90 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -545,3 +545,5 @@
   }
   OvmfPkg/SecureBootConfigDxe/SecureBootConfigDxe.inf
 !endif
+
+  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 4ec4224..3efb32b 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -414,6 +414,7 @@ INF  RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf
 !endif
 
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+INF  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
 
 
################################################################################
 
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 04896f1..94bb92f 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -552,3 +552,5 @@
   }
   OvmfPkg/SecureBootConfigDxe/SecureBootConfigDxe.inf
 !endif
+
+  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 42eda89..14400cb 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -414,6 +414,7 @@ INF  RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf
 !endif
 
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+INF  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
 
 
################################################################################
 
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 8dd11b8..2df0218 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -572,3 +572,5 @@
   }
   OvmfPkg/SecureBootConfigDxe/SecureBootConfigDxe.inf
 !endif
+
+  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 53e3611..65838d1 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -414,6 +414,7 @@ INF  RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf
 !endif
 
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+INF  OvmfPkg/PlatformConfigDxe/PlatformConfig.inf
 
 
################################################################################
 
diff --git a/OvmfPkg/PlatformConfigDxe/PlatformConfig.uni 
b/OvmfPkg/PlatformConfigDxe/PlatformConfig.uni
new file mode 100644
index 
0000000000000000000000000000000000000000..6890b5a4d22d9eb510572d25e835e10322d5cd05
GIT binary patch
literal 1944
zcmai!TTdG?5QXQtQvZV$URnwXt@={bRtgYGR6-C5y*#1ZfR#vsc0(wCzU_DH-F33!
zq9|*RJw9`0&e;F{HmqUJHtik1*Y*mlQI5{`ZEm;rV5uc`W!JXA_YJFW89&&Ly|<6H
z#r(`BHfB7s0X|x3+ssB*e-Ud`V(r+c^5g=%8&DKKg@L|8PMFO=b=G8G9+6q*t%+rv
zO>OBJ)$OzG!R~9xqsY-&pL`O$9r!7@S3brRdq50jv%q8G?Gd@mZHlM%9ym9{-?1WA
zikC3E@n{1qow{Ld#BAmn39rD_sd0|HWS-zVup!?`$<x`LXCds!B*dELaRN&*(<~|L
zqnze;xpHpLdUk+)yvE7dy|2NDuh^|;nZQO!s)FhiE2mf)>&kiv&sAMiRb_w4dQeE5
z|KL;Qv|gW3%LlxM`T2QX0Wn*wL{}FsP-55js`@k3SpKQ6c%AH1^l4Ny$XFS|d~Dm5
zojNGj{EHlmQC)ImEm)n>MP2*Gw`m>hHWhW$RAZmjHhp%^tmW%`ZYPW_)+0jHpiN)5
z@aTEuE;IGBzBNYS3bn?#=WSVAB{ye3*%z;_k0`rIBr!W-y$z}`x<2|Dmbhz8G5dJQ
zM^S^<A-+2KoAEn4Vy+w9%A<rVTK22NDbQn;+SKHf?o#Z7m0KS@I%qQXJ)!P6LDMO^
z?Uq?ZPsjc#`bhOlujJIf12ZhWLUrF4$s;G5US0L2dU^3AdXGKzZn(p`i9(+7FFHAc
zLx}x6m&2T22CF3}(nnZr(`}pis~WQWVjJF1)`rhiOac$*yLlUBRplD>)Sm82Mu*l`
z&J{N>WD&aX!VbOe9j|uZF1*%#lu-|_|6=4j>UBljYV5B4Kv(rgRgds87mDcK#n(A-
z+$dj&=lSV&9fQBlP1ei&_Nj>8)WBUYsZ`ZFApIiy+e$Y%_9tj9wRKwRJ<qzs4bjbr
R^?j<cFSCxkdKDH?-TxBjCCvZ;

literal 0
HcmV?d00001

-- 
1.8.3.1



------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to