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 SPDX-License-Identifier: BSD-2-Clause-Patent 8 **/ 9 10 #include <Library/QemuFwCfgLib.h> 11 #include <Library/QemuFwCfgS3Lib.h> 12 13 /** 14 Determine if S3 support is explicitly enabled. 15 16 @retval TRUE If S3 support is explicitly enabled. Other functions in this 17 library may be called (subject to their individual 18 restrictions). 19 20 FALSE Otherwise. This includes unavailability of the firmware 21 configuration interface. No other function in this library 22 must be called. 23 **/ 24 BOOLEAN 25 EFIAPI QemuFwCfgS3Enabled(VOID)26QemuFwCfgS3Enabled ( 27 VOID 28 ) 29 { 30 RETURN_STATUS Status; 31 FIRMWARE_CONFIG_ITEM FwCfgItem; 32 UINTN FwCfgSize; 33 UINT8 SystemStates[6]; 34 35 Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize); 36 if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) { 37 return FALSE; 38 } 39 QemuFwCfgSelectItem (FwCfgItem); 40 QemuFwCfgReadBytes (sizeof SystemStates, SystemStates); 41 return (BOOLEAN) (SystemStates[3] & BIT7); 42 } 43