OvmfPkg QemuFwCfgLib: determine if S3 support is explicitly enabled
authorLaszlo Ersek <lersek@redhat.com>
Tue, 4 Mar 2014 08:01:49 +0000 (08:01 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 4 Mar 2014 08:01:49 +0000 (08:01 +0000)
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 <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
[jordan.l.justen@intel.com: check for enabled rather than disabled]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15292 6f19259b-4bc3-4df7-8a09-765794883524

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

index 2519fc297f5ce36a543bee9ee0ca624564e8f4b3..8d3b835d431c8b9e65aecd10ac609a4e26189b8c 100644 (file)
@@ -214,5 +214,19 @@ InternalQemuFwCfgIsAvailable (
   VOID\r
   );\r
 \r
+\r
+/**\r
+  Determine if S3 support is explicitly enabled.\r
+\r
+  @retval  TRUE   if S3 support is explicitly enabled.\r
+           FALSE  otherwise. This includes unavailability of the firmware\r
+                  configuration interface.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+QemuFwCfgS3Enabled (\r
+  VOID\r
+  );\r
+\r
 #endif\r
 \r
index 3c5963f31b52ecfe1ec7f1671f558cd15425ed4b..92c85c1d3d52a27dd9a2a2240f6a5a998ff63368 100644 (file)
@@ -294,3 +294,31 @@ QemuFwCfgFindFile (
 \r
   return RETURN_NOT_FOUND;\r
 }\r
+\r
+\r
+/**\r
+  Determine if S3 support is explicitly enabled.\r
+\r
+  @retval  TRUE   if S3 support is explicitly enabled.\r
+           FALSE  otherwise. This includes unavailability of the firmware\r
+                  configuration interface.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+QemuFwCfgS3Enabled (\r
+  VOID\r
+  )\r
+{\r
+  RETURN_STATUS        Status;\r
+  FIRMWARE_CONFIG_ITEM FwCfgItem;\r
+  UINTN                FwCfgSize;\r
+  UINT8                SystemStates[6];\r
+\r
+  Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize);\r
+  if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) {\r
+    return FALSE;\r
+  }\r
+  QemuFwCfgSelectItem (FwCfgItem);\r
+  QemuFwCfgReadBytes (sizeof SystemStates, SystemStates);\r
+  return (BOOLEAN) (SystemStates[3] & BIT7);\r
+}\r