diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/IndustryStandard/Bhyve.h index 02ce5587ee..ab8f2b0729 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_REG 0x404 + #endif // __BHYVE_H__ 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 + Copyright (C) 2020, Red Hat, Inc. + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include // BIT13 + +#include // BHYVE_PM_REG +#include // CpuDeadLoop() +#include // IoOr16() +#include // 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 +# Copyright (C) 2020, Red Hat, Inc. +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# +# 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 +