]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c
OvmfPkg/QemuFwCfgLib: Prepare for SEV support
[mirror_edk2.git] / OvmfPkg / Library / QemuFwCfgS3Lib / QemuFwCfgS3PeiDxe.c
CommitLineData
5e4d5b10
LE
1/** @file\r
2 Shared code for the PEI fw_cfg and DXE fw_cfg instances of the QemuFwCfgS3Lib\r
3 class.\r
4\r
5 Copyright (C) 2017, Red Hat, Inc.\r
6\r
7 This program and the accompanying materials are licensed and made available\r
8 under the terms and conditions of the BSD License which accompanies this\r
9 distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14**/\r
15\r
16#include <Library/QemuFwCfgLib.h>\r
17#include <Library/QemuFwCfgS3Lib.h>\r
18\r
19/**\r
20 Determine if S3 support is explicitly enabled.\r
21\r
22 @retval TRUE If S3 support is explicitly enabled. Other functions in this\r
23 library may be called (subject to their individual\r
24 restrictions).\r
25\r
26 FALSE Otherwise. This includes unavailability of the firmware\r
27 configuration interface. No other function in this library\r
28 must be called.\r
29**/\r
30BOOLEAN\r
31EFIAPI\r
32QemuFwCfgS3Enabled (\r
33 VOID\r
34 )\r
35{\r
36 RETURN_STATUS Status;\r
37 FIRMWARE_CONFIG_ITEM FwCfgItem;\r
38 UINTN FwCfgSize;\r
39 UINT8 SystemStates[6];\r
40\r
41 Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize);\r
42 if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) {\r
43 return FALSE;\r
44 }\r
45 QemuFwCfgSelectItem (FwCfgItem);\r
46 QemuFwCfgReadBytes (sizeof SystemStates, SystemStates);\r
47 return (BOOLEAN) (SystemStates[3] & BIT7);\r
48}\r