]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuFwCfgLib: implement for SEC
authorLaszlo Ersek <lersek@redhat.com>
Fri, 3 Jan 2014 19:57:36 +0000 (19:57 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Jan 2014 19:57:36 +0000 (19:57 +0000)
The QemuFwCfgSecLib library instance
- is stateless,
- has no library constructor,
- is available to SEC client code,
- must be queried with QemuFwCfgIsAvailable() before use,
- is restricted to SEC in order to limit the explicit querying
  requirement. (There is no current user.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15046 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c [new file with mode: 0644]
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf [new file with mode: 0644]
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc

diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
new file mode 100644 (file)
index 0000000..88c32ce
--- /dev/null
@@ -0,0 +1,81 @@
+/** @file\r
+\r
+  Stateless fw_cfg library implementation.\r
+\r
+  Clients must call QemuFwCfgIsAvailable() first.\r
+\r
+  Copyright (C) 2013, Red Hat, Inc.\r
+  Copyright (c) 2011 - 2013, Intel Corporation. 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, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/QemuFwCfgLib.h>\r
+\r
+\r
+/**\r
+  Returns a boolean indicating if the firmware configuration interface\r
+  is available or not.\r
+\r
+  This function may change fw_cfg state.\r
+\r
+  @retval    TRUE   The interface is available\r
+  @retval    FALSE  The interface is not available\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+QemuFwCfgIsAvailable (\r
+  VOID\r
+  )\r
+{\r
+  UINT32 Signature;\r
+  UINT32 Revision;\r
+\r
+  QemuFwCfgSelectItem (QemuFwCfgItemSignature);\r
+  Signature = QemuFwCfgRead32 ();\r
+  DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature));\r
+  QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);\r
+  Revision = QemuFwCfgRead32 ();\r
+  DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision));\r
+  if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||\r
+      (Revision < 1)\r
+     ) {\r
+    DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n"));\r
+    return FALSE;\r
+  }\r
+\r
+  DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n"));\r
+  return TRUE;\r
+}\r
+\r
+\r
+/**\r
+  Returns a boolean indicating if the firmware configuration interface is\r
+  available for library-internal purposes.\r
+\r
+  This function never changes fw_cfg state.\r
+\r
+  @retval    TRUE   The interface is available internally.\r
+  @retval    FALSE  The interface is not available internally.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+InternalQemuFwCfgIsAvailable (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // We always return TRUE, because the consumer of this library ought to have\r
+  // called QemuFwCfgIsAvailable before making other calls which would hit this\r
+  // path.\r
+  //\r
+  return TRUE;\r
+}\r
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
new file mode 100644 (file)
index 0000000..71beacb
--- /dev/null
@@ -0,0 +1,54 @@
+## @file\r
+#\r
+#  Stateless fw_cfg library that must be queried before use.\r
+#\r
+#  Copyright (C) 2013, Red Hat, Inc.\r
+#  Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this 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 IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = QemuFwCfgSecLib\r
+  FILE_GUID                      = 60a910e5-7443-413d-9a30-97e57497cd1b\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = QemuFwCfgLib|SEC\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  QemuFwCfgLib.c\r
+  QemuFwCfgSec.c\r
+\r
+[Sources.IA32]\r
+  Ia32/IoLibExAsm.asm\r
+  Ia32/IoLibExAsm.S\r
+\r
+[Sources.X64]\r
+  X64/IoLibExAsm.asm\r
+  X64/IoLibExAsm.S\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  IoLib\r
+  MemoryAllocationLib\r
+\r
index 2e13e0ed5d63acea92b57b450d21954a18d1a6f9..c7c90fb3dc4a9ca456c6d2f3a3f2730344ed8d6b 100644 (file)
 !endif\r
 \r
 [LibraryClasses.common.SEC]\r
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
 !ifdef $(DEBUG_ON_SERIAL_PORT)\r
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 !else\r
index 64404a664703301f8cb41a5cd152aca913a89e69..b8c569a1497ab7c1be7e44c26561222be4e93342 100644 (file)
 !endif\r
 \r
 [LibraryClasses.common.SEC]\r
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
 !ifdef $(DEBUG_ON_SERIAL_PORT)\r
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 !else\r
index 467260717e7b1639dedbe690574c0d4e5353f985..7b1fa521744f0fa4f485736a314a66eac21fd815 100644 (file)
 !endif\r
 \r
 [LibraryClasses.common.SEC]\r
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
 !ifdef $(DEBUG_ON_SERIAL_PORT)\r
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 !else\r