summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library/ResetSystemLib
diff options
context:
space:
mode:
authorRebecca Cran <rebecca@bsdio.com>2020-05-03 20:18:53 -0600
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-05-05 19:40:40 +0000
commitf159102a130fac9b416418eb9b6fa35b63426ca5 (patch)
tree0b5ad151ce7cf39effdd881b740b14abce685b94 /OvmfPkg/Library/ResetSystemLib
parent245bdd2cb94beef807ff12263b6060d6fdb40c9a (diff)
downloadedk2-f159102a130fac9b416418eb9b6fa35b63426ca5.tar.gz
edk2-f159102a130fac9b416418eb9b6fa35b63426ca5.tar.bz2
edk2-f159102a130fac9b416418eb9b6fa35b63426ca5.zip
OvmfPkg: Add BaseResetSystemLibBhyve
Introduce BaseResetSystemLibBhyve.inf, 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> Message-Id: <20200504021853.76658-1-rebecca@bsdio.com> [lersek@redhat.com: MODULE_TYPE: replace DXE_DRIVER with BASE] [lersek@redhat.com: replace <OvmfPlatforms.h> with <IndustryStandard/Bhyve.h>] [lersek@redhat.com: strip ".inf" from subject line] Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg/Library/ResetSystemLib')
-rw-r--r--OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c34
-rw-r--r--OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf40
2 files changed, 74 insertions, 0 deletions
diff --git a/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c
new file mode 100644
index 0000000000..c2ac847877
--- /dev/null
+++ b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c
@@ -0,0 +1,34 @@
+/** @file
+ Base 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 <IndustryStandard/Bhyve.h> // BHYVE_PM_REG
+#include <Library/BaseLib.h> // CpuDeadLoop()
+#include <Library/IoLib.h> // IoOr16()
+#include <Library/ResetSystemLib.h> // ResetShutdown()
+
+/**
+ 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_REG, 10, 13, 5);
+ IoOr16 (BHYVE_PM_REG, BIT13);
+ CpuDeadLoop ();
+}
diff --git a/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf b/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf
new file mode 100644
index 0000000000..74124aed38
--- /dev/null
+++ b/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf
@@ -0,0 +1,40 @@
+## @file
+# Base library instance for ResetSystem library class for bhyve
+#
+# Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>
+# 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 = BaseResetSystemLibBhyve
+ FILE_GUID = 5c71b08f-0ade-4607-8b9d-946c2757fee8
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ResetSystemLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ BaseResetShutdownBhyve.c
+ ResetSystemLib.c
+
+[Packages]
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ IoLib
+ TimerLib
+