]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuFwCfgS3Lib: implement opcode APIs for PEI fw_cfg instance
authorLaszlo Ersek <lersek@redhat.com>
Wed, 22 Feb 2017 09:34:48 +0000 (10:34 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 14 Mar 2017 20:49:32 +0000 (21:49 +0100)
In the PEI fw_cfg instance:

- QemuFwCfgS3Enabled() queries S3 enablement via fw_cfg. This behavior is
  shared with the DXE fw_cfg instance, and the PEI fw_cfg instance already
  pulls in the function from "QemuFwCfgS3PeiDxe.c".

- If QemuFwCfgS3Enabled() returns TRUE, the client module is permitted to
  call QemuFwCfgS3CallWhenBootScriptReady(). However, in the PEI phase we
  have no support for capturing ACPI S3 Boot Script opcodes, hence we
  return RETURN_UNSUPPORTED unconditionally. This behavior is unique to
  the PEI fw_cfg instance, so add the function to "QemuFwCfgS3Pei.c".

- Consequently, the QemuFwCfgS3ScriptWriteBytes(),
  QemuFwCfgS3ScriptReadBytes(), QemuFwCfgS3ScriptSkipBytes(), and
  QemuFwCfgS3ScriptCheckValue() functions must never be called. (They
  could only be called from the client module's callback, but
  QemuFwCfgS3CallWhenBootScriptReady() will never install such callback in
  the PEI fw_cfg instance -- see above.)

  This behavior is not unique to the PEI fw_cfg instance (it is shared
  with the Base Null instance), so pull in these functions from
  "QemuFwCfgS3BasePei.c".

Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=394
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf
OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c [new file with mode: 0644]

index 2593af8e5b4cc82d66f615d2c79643aa0e548ede..890862076e81833b22a875da86b5c317cdfa3088 100644 (file)
@@ -31,6 +31,8 @@
 #\r
 \r
 [Sources]\r
+  QemuFwCfgS3BasePei.c\r
+  QemuFwCfgS3Pei.c\r
   QemuFwCfgS3PeiDxe.c\r
 \r
 [Packages]\r
@@ -38,4 +40,5 @@
   OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
+  DebugLib\r
   QemuFwCfgLib\r
diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c
new file mode 100644 (file)
index 0000000..d447e36
--- /dev/null
@@ -0,0 +1,86 @@
+/** @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