]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuFwCfgLib: introduce InternalQemuFwCfgIsAvailable()
authorLaszlo Ersek <lersek@redhat.com>
Fri, 3 Jan 2014 19:57:17 +0000 (19:57 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Jan 2014 19:57:17 +0000 (19:57 +0000)
This internal function allows separation of library-internal and
for-clients external availability of fw_cfg.

The interface contract of QemuFwCfgIsAvailable() is changed so that now it
may modify fw_cfg state. All current users are compliant with the new
contract.

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@15044 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/Library/QemuFwCfgLib.h
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c

index 9d023777c9d8cd8d00d38fff5dda997983b24baf..2519fc297f5ce36a543bee9ee0ca624564e8f4b3 100644 (file)
@@ -2,6 +2,8 @@
   QEMU/KVM Firmware Configuration access\r
 \r
   Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (C) 2013, Red Hat, Inc.\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
@@ -56,6 +58,8 @@ typedef enum {
   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
@@ -193,5 +197,22 @@ QemuFwCfgFindFile (
   OUT  FIRMWARE_CONFIG_ITEM  *Item,\r
   OUT  UINTN                 *Size\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
 #endif\r
 \r
index 7e5ea00bf96b061f6804d6e714a6b8efb4f5da4f..985b383c26b80249a9542f821c89fabafc9db53b 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
 \r
   Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (C) 2013, Red Hat, Inc.\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -81,6 +82,8 @@ IoWriteFifo8 (
   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
@@ -91,7 +94,7 @@ QemuFwCfgIsAvailable (
   VOID\r
   )\r
 {\r
-  return mQemuFwCfgSupported;\r
+  return InternalQemuFwCfgIsAvailable ();\r
 }\r
 \r
 \r
@@ -151,7 +154,7 @@ QemuFwCfgReadBytes (
   IN VOID                   *Buffer\r
   )\r
 {\r
-  if (mQemuFwCfgSupported) {\r
+  if (InternalQemuFwCfgIsAvailable ()) {\r
     InternalQemuFwCfgReadBytes (Size, Buffer);\r
   } else {\r
     ZeroMem (Buffer, Size);\r
@@ -176,7 +179,7 @@ QemuFwCfgWriteBytes (
   IN VOID                   *Buffer\r
   )\r
 {\r
-  if (mQemuFwCfgSupported) {\r
+  if (InternalQemuFwCfgIsAvailable ()) {\r
     IoWriteFifo8 (0x511, Size, Buffer);\r
   }\r
 }\r
@@ -319,7 +322,7 @@ QemuFwCfgFindFile (
   UINT32 Count;\r
   UINT32 Idx;\r
 \r
-  if (!mQemuFwCfgSupported) {\r
+  if (!InternalQemuFwCfgIsAvailable ()) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
 \r
@@ -346,3 +349,22 @@ QemuFwCfgFindFile (
 \r
   return RETURN_NOT_FOUND;\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
+  return mQemuFwCfgSupported;\r
+}\r