summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2014-01-03 19:57:17 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-03 19:57:17 +0000
commit0dc231c9bd1a5aecfbcd373a50dc348a5dfbd38a (patch)
treeebc9b077393d276d4caee5bc1c35bb2606e21a63
parente55bf53ba9f59f16a6dabe8ac08db25bc91df770 (diff)
OvmfPkg: QemuFwCfgLib: introduce InternalQemuFwCfgIsAvailable()
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
-rw-r--r--OvmfPkg/Include/Library/QemuFwCfgLib.h21
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c30
2 files changed, 47 insertions, 4 deletions
diff --git a/OvmfPkg/Include/Library/QemuFwCfgLib.h b/OvmfPkg/Include/Library/QemuFwCfgLib.h
index 9d023777c..2519fc297 100644
--- a/OvmfPkg/Include/Library/QemuFwCfgLib.h
+++ b/OvmfPkg/Include/Library/QemuFwCfgLib.h
@@ -2,6 +2,8 @@
QEMU/KVM Firmware Configuration access
Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2013, 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
@@ -56,6 +58,8 @@ typedef enum {
Returns a boolean indicating if the firmware configuration interface
is available or not.
+ This function may change fw_cfg state.
+
@retval TRUE The interface is available
@retval FALSE The interface is not available
@@ -193,5 +197,22 @@ QemuFwCfgFindFile (
OUT FIRMWARE_CONFIG_ITEM *Item,
OUT UINTN *Size
);
+
+
+/**
+ Returns a boolean indicating if the firmware configuration interface is
+ available for library-internal purposes.
+
+ This function never changes fw_cfg state.
+
+ @retval TRUE The interface is available internally.
+ @retval FALSE The interface is not available internally.
+**/
+BOOLEAN
+EFIAPI
+InternalQemuFwCfgIsAvailable (
+ VOID
+ );
+
#endif
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 7e5ea00bf..985b383c2 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -1,6 +1,7 @@
/** @file
Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2013, Red Hat, Inc.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -81,6 +82,8 @@ IoWriteFifo8 (
Returns a boolean indicating if the firmware configuration interface
is available or not.
+ This function may change fw_cfg state.
+
@retval TRUE The interface is available
@retval FALSE The interface is not available
@@ -91,7 +94,7 @@ QemuFwCfgIsAvailable (
VOID
)
{
- return mQemuFwCfgSupported;
+ return InternalQemuFwCfgIsAvailable ();
}
@@ -151,7 +154,7 @@ QemuFwCfgReadBytes (
IN VOID *Buffer
)
{
- if (mQemuFwCfgSupported) {
+ if (InternalQemuFwCfgIsAvailable ()) {
InternalQemuFwCfgReadBytes (Size, Buffer);
} else {
ZeroMem (Buffer, Size);
@@ -176,7 +179,7 @@ QemuFwCfgWriteBytes (
IN VOID *Buffer
)
{
- if (mQemuFwCfgSupported) {
+ if (InternalQemuFwCfgIsAvailable ()) {
IoWriteFifo8 (0x511, Size, Buffer);
}
}
@@ -319,7 +322,7 @@ QemuFwCfgFindFile (
UINT32 Count;
UINT32 Idx;
- if (!mQemuFwCfgSupported) {
+ if (!InternalQemuFwCfgIsAvailable ()) {
return RETURN_UNSUPPORTED;
}
@@ -346,3 +349,22 @@ QemuFwCfgFindFile (
return RETURN_NOT_FOUND;
}
+
+
+/**
+ Returns a boolean indicating if the firmware configuration interface is
+ available for library-internal purposes.
+
+ This function never changes fw_cfg state.
+
+ @retval TRUE The interface is available internally.
+ @retval FALSE The interface is not available internally.
+**/
+BOOLEAN
+EFIAPI
+InternalQemuFwCfgIsAvailable (
+ VOID
+ )
+{
+ return mQemuFwCfgSupported;
+}