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 Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Laszlo Ersek <[email protected]> --- OvmfPkg/Include/Library/QemuFwCfgLib.h | 19 ++++++++++++++++++ OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 30 +++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Include/Library/QemuFwCfgLib.h b/OvmfPkg/Include/Library/QemuFwCfgLib.h index bad0fbb..51098d7 100644 --- a/OvmfPkg/Include/Library/QemuFwCfgLib.h +++ b/OvmfPkg/Include/Library/QemuFwCfgLib.h @@ -1,6 +1,7 @@ /** @file QEMU/KVM Firmware Configuration access + Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2011 - 2013, 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 @@ -56,6 +57,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 @@ -207,5 +210,21 @@ EFIAPI QemuFwCfgS3Disabled ( VOID ); + + +/** + 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 32c82da..f322e9c 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c @@ -1,5 +1,6 @@ /** @file + Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials @@ -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; } @@ -374,3 +377,22 @@ QemuFwCfgS3Disabled ( QemuFwCfgReadBytes (sizeof SystemStates, SystemStates); return !(SystemStates[3] & BIT7); } + + +/** + 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; +} -- 1.8.3.1 ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
