--- /dev/null
+/** @file\r
+ Shared code for the PEI fw_cfg and DXE fw_cfg instances of the QemuFwCfgS3Lib\r
+ class.\r
+\r
+ Copyright (C) 2017, Red Hat, Inc.\r
+\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/QemuFwCfgLib.h>\r
+#include <Library/QemuFwCfgS3Lib.h>\r
+\r
+/**\r
+ Determine if S3 support is explicitly enabled.\r
+\r
+ @retval TRUE If S3 support is explicitly enabled. Other functions in this\r
+ library may be called (subject to their individual\r
+ restrictions).\r
+\r
+ FALSE Otherwise. This includes unavailability of the firmware\r
+ configuration interface. No other function in this library\r
+ must be called.\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