From: "Rebecca Cran" <rebecca@bsdio.com>
To: devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Ard Biesheuvel <ard.biesheuvel@arm.com>,
Rebecca Cran <rebecca@bsdio.com>
Subject: [PATCH 04/13] OvmfPkg: Add QemuFwCfgS3LibNull
Date: Wed, 15 Apr 2020 17:09:30 -0600 [thread overview]
Message-ID: <1e62907d1bae3e60ebe2be8dd23f07dd65cb9049.1586991816.git.rebecca@bsdio.com> (raw)
In-Reply-To: <cover.1586991816.git.rebecca@bsdio.com>
Add a null implementation library fof QemuFwCfgS3Lib, to support bhyve.
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
.../DxeQemuFwCfgS3LibFwCfgNull.inf | 32 ++
.../QemuFwCfgS3LibNull/QemuFwCfgS3DxeNull.c | 307 ++++++++++++++++++
.../QemuFwCfgS3PeiDxeNull.c | 31 ++
3 files changed, 370 insertions(+)
create mode 100644 OvmfPkg/Library/QemuFwCfgS3LibNull/DxeQemuFwCfgS3LibFwCfgNull.inf
create mode 100644 OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3DxeNull.c
create mode 100644 OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3PeiDxeNull.c
diff --git a/OvmfPkg/Library/QemuFwCfgS3LibNull/DxeQemuFwCfgS3LibFwCfgNull.inf b/OvmfPkg/Library/QemuFwCfgS3LibNull/DxeQemuFwCfgS3LibFwCfgNull.inf
new file mode 100644
index 0000000000..48e6d36a29
--- /dev/null
+++ b/OvmfPkg/Library/QemuFwCfgS3LibNull/DxeQemuFwCfgS3LibFwCfgNull.inf
@@ -0,0 +1,32 @@
+## @file
+# Full functionality QemuFwCfgS3Lib instance, for DXE phase modules.
+#
+# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (C) 2017, Red Hat, Inc.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = DxeQemuFwCfgS3LibFwCfgNull
+ FILE_GUID = 1E5E5B60-C524-49CE-8D6B-AB151BEC28F6
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = QemuFwCfgS3Lib|DXE_DRIVER DXE_RUNTIME_DRIVER
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 EBC
+#
+
+[Sources]
+ QemuFwCfgS3DxeNull.c
+ QemuFwCfgS3PeiDxeNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
diff --git a/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3DxeNull.c b/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3DxeNull.c
new file mode 100644
index 0000000000..441fcb1c5b
--- /dev/null
+++ b/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3DxeNull.c
@@ -0,0 +1,307 @@
+/** @file
+ Full functionality QemuFwCfgS3Lib instance, for DXE phase modules.
+
+ Copyright (C) 2017, Red Hat, Inc.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/QemuFwCfgLib.h>
+#include <Library/QemuFwCfgS3Lib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/S3SaveState.h>
+
+
+/**
+ Event notification function for mS3SaveStateInstalledEvent.
+**/
+//STATIC
+//VOID
+//EFIAPI
+//S3SaveStateInstalledNotify (
+// IN EFI_EVENT Event,
+// IN VOID *Context
+// )
+//{
+//
+//}
+
+
+/**
+ Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for
+ when the production of ACPI S3 Boot Script opcodes becomes possible.
+
+ Take ownership of the client-provided Context, and pass it to the callback
+ function, when the latter is invoked.
+
+ Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon
+ that the client will produce in the callback function.
+
+ @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke
+ when the production of ACPI S3 Boot Script
+ opcodes becomes possible. Callback() may be
+ called immediately from
+ QemuFwCfgS3CallWhenBootScriptReady().
+
+ @param[in,out] Context Client-provided data structure for the
+ Callback() callback function to consume.
+
+ If Context points to dynamically allocated
+ memory, then Callback() must release it.
+
+ If Context points to dynamically allocated
+ memory, and
+ QemuFwCfgS3CallWhenBootScriptReady() returns
+ successfully, then the caller of
+ QemuFwCfgS3CallWhenBootScriptReady() must
+ neither dereference nor even evaluate Context
+ any longer, as ownership of the referenced area
+ has been transferred to Callback().
+
+ @param[in] ScratchBufferSize The size of the scratch buffer that will hold,
+ in reserved memory, all client data read,
+ written, and checked by the ACPI S3 Boot Script
+ opcodes produced by Callback().
+
+ @retval RETURN_UNSUPPORTED The library instance does not support this
+ function.
+
+ @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is
+ unavailable.
+
+ @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large.
+
+ @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
+
+ @retval RETURN_SUCCESS Callback() has been installed, and the
+ ownership of Context has been transferred.
+ Reserved memory has been allocated for the
+ scratch buffer.
+
+ A successful invocation of
+ QemuFwCfgS3CallWhenBootScriptReady() cannot
+ be rolled back.
+
+ @return Error codes from underlying functions.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3CallWhenBootScriptReady (
+ IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
+ IN OUT VOID *Context, OPTIONAL
+ IN UINTN ScratchBufferSize
+ )
+{
+ return RETURN_NOT_FOUND;
+}
+
+
+/**
+ Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
+ and transfer data to it.
+
+ The opcodes produced by QemuFwCfgS3ScriptWriteBytes() will first restore
+ NumberOfBytes bytes in ScratchBuffer in-place, in reserved memory, then write
+ them to fw_cfg using DMA.
+
+ If the operation fails during S3 resume, the boot script will hang.
+
+ This function may only be called from the client module's
+ FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady() as Callback.
+
+ @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config
+ item to write, expressed as INT32. If
+ FirmwareConfigItem is -1, no selection is
+ made, the write will occur to the currently
+ selected item, at its currently selected
+ offset. Otherwise, the specified item will be
+ selected, and the write will occur at offset
+ 0.
+
+ @param[in] NumberOfBytes Size of the data to restore in ScratchBuffer,
+ and to write from ScratchBuffer, during S3
+ resume. NumberOfBytes must not exceed
+ ScratchBufferSize, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady().
+
+ @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3
+ Boot Script successfully. There is no way
+ to undo this action.
+
+ @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid.
+
+ @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than
+ ScratchBufferSize.
+
+ @return Error codes from underlying functions.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3ScriptWriteBytes (
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
+ and transfer data from it.
+
+ The opcodes produced by QemuFwCfgS3ScriptReadBytes() will read NumberOfBytes
+ bytes from fw_cfg using DMA, storing the result in ScratchBuffer, in reserved
+ memory.
+
+ If the operation fails during S3 resume, the boot script will hang.
+
+ This function may only be called from the client module's
+ FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady() as Callback.
+
+ @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config
+ item to read, expressed as INT32. If
+ FirmwareConfigItem is -1, no selection is
+ made, the read will occur from the currently
+ selected item, from its currently selected
+ offset. Otherwise, the specified item will be
+ selected, and the read will occur from offset
+ 0.
+
+ @param[in] NumberOfBytes Size of the data to read during S3 resume.
+ NumberOfBytes must not exceed
+ ScratchBufferSize, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady().
+
+ @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3
+ Boot Script successfully. There is no way
+ to undo this action.
+
+ @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid.
+
+ @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than
+ ScratchBufferSize.
+
+ @return Error codes from underlying functions.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3ScriptReadBytes (
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
+ )
+{
+
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item,
+ and increase its offset.
+
+ If the operation fails during S3 resume, the boot script will hang.
+
+ This function may only be called from the client module's
+ FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady() as Callback.
+
+ @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config
+ item to advance the offset of, expressed as
+ INT32. If FirmwareConfigItem is -1, no
+ selection is made, and the offset for the
+ currently selected item is increased.
+ Otherwise, the specified item will be
+ selected, and the offset increment will occur
+ from offset 0.
+
+ @param[in] NumberOfBytes The number of bytes to skip in the subject
+ fw_cfg item.
+
+ @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3
+ Boot Script successfully. There is no way
+ to undo this action.
+
+ @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid.
+
+ @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is too large.
+
+ @return Error codes from underlying functions.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3ScriptSkipBytes (
+ IN INT32 FirmwareConfigItem,
+ IN UINTN NumberOfBytes
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer.
+
+ If the check fails during S3 resume, the boot script will hang.
+
+ This function may only be called from the client module's
+ FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to
+ QemuFwCfgS3CallWhenBootScriptReady() as Callback.
+
+ @param[in] ScratchData Pointer to the UINT8, UINT16, UINT32 or UINT64 field
+ in ScratchBuffer that should be checked. The caller
+ is responsible for populating the field during S3
+ resume, by calling QemuFwCfgS3ScriptReadBytes() ahead
+ of QemuFwCfgS3ScriptCheckValue().
+
+ ScratchData must point into ScratchBuffer, which was
+ allocated, and passed to Callback(), by
+ QemuFwCfgS3CallWhenBootScriptReady().
+
+ ScratchData must be aligned at ValueSize bytes.
+
+ @param[in] ValueSize One of 1, 2, 4 or 8, specifying the size of the field
+ to check.
+
+ @param[in] ValueMask The value read from ScratchData is binarily AND-ed
+ with ValueMask, and the result is compared against
+ Value. If the masked data equals Value, the check
+ passes, and the boot script can proceed. Otherwise,
+ the check fails, and the boot script hangs.
+
+ @param[in] Value Refer to ValueMask.
+
+ @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3
+ Boot Script successfully. There is no way
+ to undo this action.
+
+ @retval RETURN_INVALID_PARAMETER ValueSize is invalid.
+
+ @retval RETURN_INVALID_PARAMETER ValueMask or Value cannot be represented in
+ ValueSize bytes.
+
+ @retval RETURN_INVALID_PARAMETER ScratchData is not aligned at ValueSize
+ bytes.
+
+ @retval RETURN_BAD_BUFFER_SIZE The ValueSize bytes at ScratchData aren't
+ wholly contained in the ScratchBufferSize
+ bytes at ScratchBuffer.
+
+ @return Error codes from underlying functions.
+**/
+RETURN_STATUS
+EFIAPI
+QemuFwCfgS3ScriptCheckValue (
+ IN VOID *ScratchData,
+ IN UINT8 ValueSize,
+ IN UINT64 ValueMask,
+ IN UINT64 Value
+ )
+{
+ return RETURN_SUCCESS;
+}
diff --git a/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3PeiDxeNull.c b/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3PeiDxeNull.c
new file mode 100644
index 0000000000..722d02ce3a
--- /dev/null
+++ b/OvmfPkg/Library/QemuFwCfgS3LibNull/QemuFwCfgS3PeiDxeNull.c
@@ -0,0 +1,31 @@
+/** @file
+ Shared code for the PEI fw_cfg and DXE fw_cfg instances of the QemuFwCfgS3Lib
+ class.
+
+ Copyright (C) 2017, Red Hat, Inc.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/QemuFwCfgLib.h>
+#include <Library/QemuFwCfgS3Lib.h>
+
+/**
+ Determine if S3 support is explicitly enabled.
+
+ @retval TRUE If S3 support is explicitly enabled. Other functions in this
+ library may be called (subject to their individual
+ restrictions).
+
+ FALSE Otherwise. This includes unavailability of the firmware
+ configuration interface. No other function in this library
+ must be called.
+**/
+BOOLEAN
+EFIAPI
+QemuFwCfgS3Enabled (
+ VOID
+ )
+{
+ return FALSE;
+}
--
2.26.1
next prev parent reply other threads:[~2020-04-15 23:12 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 23:09 [PATCH 00/13] BhyvePkg - initial patch series for review Rebecca Cran
2020-04-15 23:09 ` [PATCH 01/13] OvmfPkg: Add bhyve support into AcpiTimerLib Rebecca Cran
2020-04-17 8:07 ` [edk2-devel] " Laszlo Ersek
2020-04-15 23:09 ` [PATCH 02/13] OvmfPkg: support powering off bhyve guests Rebecca Cran
2020-04-17 8:55 ` [edk2-devel] " Laszlo Ersek
2020-04-17 18:56 ` Rebecca Cran
2020-04-21 22:14 ` Rebecca Cran
2020-04-22 15:49 ` Laszlo Ersek
2020-04-15 23:09 ` [PATCH 03/13] BhyvePkg: Add BhyveFwCtlLibNull Rebecca Cran
2020-04-15 23:09 ` Rebecca Cran [this message]
2020-04-17 16:37 ` [edk2-devel] [PATCH 04/13] OvmfPkg: Add QemuFwCfgS3LibNull Laszlo Ersek
2020-04-15 23:09 ` [PATCH 05/13] OvmfPkg: Add VBE2 mode info structure to LegacyVgaBios.h Rebecca Cran
2020-04-17 16:43 ` [edk2-devel] " Laszlo Ersek
2020-04-15 23:09 ` [PATCH 06/13] OvmfPkg: add QemuFwCfgPeiLibNull Rebecca Cran
2020-04-17 16:57 ` [edk2-devel] " Laszlo Ersek
2020-04-15 23:09 ` [PATCH 07/13] OvmfPkg: add QemuFwCfgS3LibNull Rebecca Cran
2020-04-17 17:01 ` [edk2-devel] " Laszlo Ersek
2020-04-15 23:09 ` [PATCH 08/13] Add BhyvePkg, to support the bhyve hypervisor Rebecca Cran
2020-04-15 23:09 ` [PATCH 09/13] OvmfPkg: Add bhyve support to PlatformPei Rebecca Cran
2020-04-15 23:09 ` [PATCH 10/13] OvmfPkg: Add bhyve support to AcpiPlatformDxe Rebecca Cran
2020-04-15 23:09 ` [PATCH 11/13] BhyvePkg: Add InstrincsLib to BhyveFwCtlLib Rebecca Cran
2020-04-15 23:09 ` [PATCH 12/13] BhyvePkg: __attribute__ doesn't exist on MSVC toolchains Rebecca Cran
2020-04-15 23:09 ` [PATCH 13/13] BhyvePkg: fix BhyveSetGraphicsMode call for VS2019 build Rebecca Cran
2020-04-16 20:47 ` [edk2-devel] [PATCH 00/13] BhyvePkg - initial patch series for review Laszlo Ersek
2020-04-16 22:43 ` Laszlo Ersek
2020-04-17 6:46 ` Rebecca Cran
2020-04-17 6:55 ` Rebecca Cran
2020-04-20 9:51 ` Laszlo Ersek
2020-04-20 9:57 ` Laszlo Ersek
2020-04-21 17:12 ` Rebecca Cran
2020-04-17 7:55 ` Laszlo Ersek
2020-04-17 15:31 ` Rebecca Cran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e62907d1bae3e60ebe2be8dd23f07dd65cb9049.1586991816.git.rebecca@bsdio.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox