--- /dev/null
+/** @file\r
+ Limited functionality QemuFwCfgS3Lib instance, for PEI phase modules.\r
+\r
+ QemuFwCfgS3Enabled() queries S3 enablement via fw_cfg. Other library APIs\r
+ will report lack of support.\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/QemuFwCfgS3Lib.h>\r
+\r
+/**\r
+ Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for\r
+ when the production of ACPI S3 Boot Script opcodes becomes possible.\r
+\r
+ Take ownership of the client-provided Context, and pass it to the callback\r
+ function, when the latter is invoked.\r
+\r
+ Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon\r
+ that the client will produce in the callback function.\r
+\r
+ @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke\r
+ when the production of ACPI S3 Boot Script\r
+ opcodes becomes possible. Callback() may be\r
+ called immediately from\r
+ QemuFwCfgS3CallWhenBootScriptReady().\r
+\r
+ @param[in,out] Context Client-provided data structure for the\r
+ Callback() callback function to consume.\r
+\r
+ If Context points to dynamically allocated\r
+ memory, then Callback() must release it.\r
+\r
+ If Context points to dynamically allocated\r
+ memory, and\r
+ QemuFwCfgS3CallWhenBootScriptReady() returns\r
+ successfully, then the caller of\r
+ QemuFwCfgS3CallWhenBootScriptReady() must\r
+ neither dereference nor even evaluate Context\r
+ any longer, as ownership of the referenced area\r
+ has been transferred to Callback().\r
+\r
+ @param[in] ScratchBufferSize The size of the scratch buffer that will hold,\r
+ in reserved memory, all client data read,\r
+ written, and checked by the ACPI S3 Boot Script\r
+ opcodes produced by Callback().\r
+\r
+ @retval RETURN_UNSUPPORTED The library instance does not support this\r
+ function.\r
+\r
+ @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is\r
+ unavailable.\r
+\r
+ @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large.\r
+\r
+ @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.\r
+\r
+ @retval RETURN_SUCCESS Callback() has been installed, and the\r
+ ownership of Context has been transferred.\r
+ Reserved memory has been allocated for the\r
+ scratch buffer.\r
+\r
+ A successful invocation of\r
+ QemuFwCfgS3CallWhenBootScriptReady() cannot\r
+ be rolled back.\r
+\r
+ @return Error codes from underlying functions.\r
+**/\r
+EFIAPI\r
+RETURN_STATUS\r
+QemuFwCfgS3CallWhenBootScriptReady (\r
+ IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,\r
+ IN OUT VOID *Context, OPTIONAL\r
+ IN UINTN ScratchBufferSize\r
+ )\r
+{\r
+ return RETURN_UNSUPPORTED;\r
+}\r