Such a packaged query function will come in handy in the following
patches.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/Include/Library/QemuFwCfgLib.h      | 14 ++++++++++++++
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/OvmfPkg/Include/Library/QemuFwCfgLib.h 
b/OvmfPkg/Include/Library/QemuFwCfgLib.h
index 9d02377..bad0fbb 100644
--- a/OvmfPkg/Include/Library/QemuFwCfgLib.h
+++ b/OvmfPkg/Include/Library/QemuFwCfgLib.h
@@ -193,5 +193,19 @@ QemuFwCfgFindFile (
   OUT  FIRMWARE_CONFIG_ITEM  *Item,
   OUT  UINTN                 *Size
   );
+
+
+/**
+  Determine if S3 support is explicitly disabled.
+
+  @retval  TRUE   if S3 support is explicitly disabled.
+           FALSE  otherwise. This includes unavailability of the firmware
+                  configuration interface.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3Disabled (
+  VOID
+  );
 #endif
 
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 7e5ea00..32c82da 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -346,3 +346,31 @@ QemuFwCfgFindFile (
 
   return RETURN_NOT_FOUND;
 }
+
+
+/**
+  Determine if S3 support is explicitly disabled.
+
+  @retval  TRUE   if S3 support is explicitly disabled.
+           FALSE  otherwise. This includes unavailability of the firmware
+                  configuration interface.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3Disabled (
+  VOID
+  )
+{
+  RETURN_STATUS        Status;
+  FIRMWARE_CONFIG_ITEM FwCfgItem;
+  UINTN                FwCfgSize;
+  UINT8                SystemStates[6];
+
+  Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize);
+  if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) {
+    return FALSE;
+  }
+  QemuFwCfgSelectItem (FwCfgItem);
+  QemuFwCfgReadBytes (sizeof SystemStates, SystemStates);
+  return !(SystemStates[3] & BIT7);
+}
-- 
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

Reply via email to