From: "Rebecca Cran" <rebecca@bsdio.com>
To: devel@edk2.groups.io, Jordan Justen <jordan.l.justen@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Subject: [PATCH 1/2] OvmfPkg: Add DxeResetSystemLibBhyve
Date: Wed, 22 Apr 2020 21:02:13 -0600 [thread overview]
Message-ID: <20200423030214.57861-2-rebecca@bsdio.com> (raw)
In-Reply-To: <20200423030214.57861-1-rebecca@bsdio.com>
Introduce the DxeResetSystemLibBhyve library to support powering off
bhyve guests.
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
OvmfPkg/Include/IndustryStandard/Bhyve.h | 2 +
.../ResetSystemLib/DxeResetShutdownBhyve.c | 43 +++++++++++++++++++
.../ResetSystemLib/DxeResetSystemLibBhyve.inf | 38 ++++++++++++++++
3 files changed, 83 insertions(+)
create mode 100644 OvmfPkg/Library/ResetSystemLib/DxeResetShutdownBhyve.c
create mode 100644 OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibBhyve.inf
diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/IndustryStandard/Bhyve.h
index 02ce5587ee..9745d62688 100644
--- a/OvmfPkg/Include/IndustryStandard/Bhyve.h
+++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h
@@ -13,4 +13,6 @@
#define BHYVE_ACPI_TIMER_IO_ADDR 0x408
+#define BHYVE_PM_VALUE 0x408
+
#endif // __BHYVE_H__
diff --git a/OvmfPkg/Library/ResetSystemLib/DxeResetShutdownBhyve.c b/OvmfPkg/Library/ResetSystemLib/DxeResetShutdownBhyve.c
new file mode 100644
index 0000000000..cb30d75ee2
--- /dev/null
+++ b/OvmfPkg/Library/ResetSystemLib/DxeResetShutdownBhyve.c
@@ -0,0 +1,43 @@
+/** @file
+ DXE Reset System Library Shutdown API implementation for bhyve.
+
+ Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>
+ Copyright (C) 2020, Red Hat, Inc.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Base.h> // BIT13
+
+#include <Library/BaseLib.h> // CpuDeadLoop()
+#include <Library/IoLib.h> // IoOr16()
+#include <Library/ResetSystemLib.h> // ResetShutdown()
+#include <OvmfPlatforms.h> // BHYVE_PM_VALUE
+
+EFI_STATUS
+EFIAPI
+DxeResetInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ Calling this function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ System shutdown should not return, if it returns, it means the system does
+ not support shut down reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+ IoBitFieldWrite16 (BHYVE_PM_VALUE, 10, 13, 5);
+ IoOr16 (BHYVE_PM_VALUE, BIT13);
+ CpuDeadLoop ();
+}
diff --git a/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibBhyve.inf b/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibBhyve.inf
new file mode 100644
index 0000000000..c7923a4755
--- /dev/null
+++ b/OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibBhyve.inf
@@ -0,0 +1,38 @@
+## @file
+# DXE library instance for ResetSystem library class for bhyve
+#
+# Copyright (C) 2020, Red Hat, Inc.
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 1.29
+ BASE_NAME = DxeResetSystemLibBhyve
+ FILE_GUID = 88a12688-98f5-44a6-bf4b-7894706a2d11
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ResetSystemLib|DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION
+ CONSTRUCTOR = DxeResetInit
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ DxeResetShutdownBhyve.c
+ ResetSystemLib.c
+
+[Packages]
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ IoLib
+ TimerLib
--
2.20.1
next prev parent reply other threads:[~2020-04-23 3:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 3:02 [PATCH 0/2] Add DxeResetSystemLibBhyve Rebecca Cran
2020-04-23 3:02 ` Rebecca Cran [this message]
2020-04-24 17:35 ` [edk2-devel] [PATCH 1/2] OvmfPkg: " Laszlo Ersek
2020-04-23 3:02 ` [PATCH 2/2] BhyvePkg: Update BhyvePkgX64.dsc to use DxeResetSystemLibBhyve Rebecca Cran
2020-04-24 16:48 ` [edk2-devel] " Laszlo Ersek
2020-04-23 3:03 ` [PATCH 0/2] Add DxeResetSystemLibBhyve 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=20200423030214.57861-2-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