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