This library attempts to detect QEMU flash. If writable flash is
detected, then PcdOvmfFlashVariablesEnable is set to TRUE.
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
---
.../DetectFlashNullLib.c | 41 +++++++++++++++
.../DetectFlashNullLib.inf | 60 ++++++++++++++++++++++
2 files changed, 101 insertions(+)
create mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.c
create mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.inf
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.c
new file mode 100644
index 0000000000..cfa6026ff2
--- /dev/null
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.c
@@ -0,0 +1,41 @@
+/** @file
+ OVMF support for QEMU system firmware flash device
+
+ Copyright (c) 2009 - 2017, 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/PcdLib.h>
+#include <Uefi.h>
+
+#include "QemuFlash.h"
+
+
+/**
+ Initializes QEMU flash memory support
+
+ @retval !RETURN_SUCCESS Failed to set the PCD
+ @retval RETURN_SUCCESS The constructor was successful
+
+**/
+RETURN_STATUS
+EFIAPI
+DetectFlashConstructor (
+ VOID
+ )
+{
+ if (QemuFlashDetected ()) {
+ return PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE);
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.inf b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.inf
new file mode 100644
index 0000000000..1b7717af3e
--- /dev/null
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/DetectFlashNullLib.inf
@@ -0,0 +1,60 @@
+## @file
+# This is a small library with a constructor that will set a PCD if
+# writable flash is detected.
+#
+# Copyright (c) 2006 - 2017, 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 = DetectFlashNullLib
+ FILE_GUID = 6ec93337-513a-4188-bf57-7bb746c6e8ac
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NULL|PEIM DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+ CONSTRUCTOR = DetectFlashConstructor
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ DetectFlashNullLib.c
+ QemuFlash.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+
+[FixedPcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
+
+[FeaturePcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
+
+[Depex]
+ TRUE
--
2.11.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel