From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by mx.groups.io with SMTP id smtpd.web11.35423.1588558741478812102 for ; Sun, 03 May 2020 19:19:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bsdio.com header.s=xmission header.b=eRfiQep4; spf=pass (domain: bsdio.com, ip: 166.70.13.232, mailfrom: rebecca@bsdio.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=bsdio.com; s=xmission; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cyA8YVbGh5K68HGPwwBZk1Sz4Jbiwt0G6ulj/PXefU8=; b=eRfiQep4KuQD1wXcFak2h65Wz9 1qZezgp4jCaHtS1aM5RkO0zZwRmfqkHylLSNQHSZvzS7kfZ9IQmrMpSL4f2DZVk3KbXiR/FnNewJR YDPWEX4qxmQqS0MEc7veZU2zcEdcvqVJ7rJ/NjkndEWu8I70MTUs/x5yKFu3S5yfHc/I=; Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVQhA-0003wn-9w; Sun, 03 May 2020 20:19:00 -0600 Received: from mta3.zcs.xmission.com ([166.70.13.67]) by in02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jVQh9-0006s1-Jf; Sun, 03 May 2020 20:19:00 -0600 Received: from localhost (localhost [127.0.0.1]) by mta3.zcs.xmission.com (Postfix) with ESMTP id 5A9C5160B65; Sun, 3 May 2020 20:18:59 -0600 (MDT) X-Amavis-Modified: Mail body modified (using disclaimer) - mta3.zcs.xmission.com Received: from mta3.zcs.xmission.com ([127.0.0.1]) by localhost (mta3.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id m82XUwS6KAvC; Sun, 3 May 2020 20:18:59 -0600 (MDT) Received: from photon.int.bluestop.org (muon.bluestop.org [65.103.231.193]) (Authenticated sender: rebecca@bsdio.com) by mta3.zcs.xmission.com (Postfix) with ESMTPSA id EBF301606C5; Sun, 3 May 2020 20:18:58 -0600 (MDT) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Jordan Justen , Laszlo Ersek , Ard Biesheuvel Date: Sun, 3 May 2020 20:18:53 -0600 Message-Id: <20200504021853.76658-1-rebecca@bsdio.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-XM-SPF: eid=1jVQh9-0006s1-Jf;;;mid=<20200504021853.76658-1-rebecca@bsdio.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.67;;;frm=rebecca@bsdio.com;;;spf=pass X-SA-Exim-Connect-IP: 166.70.13.67 X-SA-Exim-Mail-From: rebecca@bsdio.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa03.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,LotsOfNums_01,T_TooManySym_01,XMNoVowels autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 1.2 LotsOfNums_01 BODY: Lots of long strings of numbers * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa03 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;devel@edk2.groups.io X-Spam-Relay-Country: X-Spam-Timing: total 459 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.4 (0.9%), b_tie_ro: 2.9 (0.6%), parse: 1.31 (0.3%), extract_message_metadata: 21 (4.6%), get_uri_detail_list: 3.1 (0.7%), tests_pri_-1000: 22 (4.7%), tests_pri_-950: 1.04 (0.2%), tests_pri_-900: 0.80 (0.2%), tests_pri_-90: 85 (18.5%), check_bayes: 82 (17.9%), b_tokenize: 8 (1.7%), b_tok_get_all: 9 (1.9%), b_comp_prob: 1.75 (0.4%), b_tok_touch_all: 61 (13.2%), b_finish: 0.80 (0.2%), tests_pri_0: 311 (67.9%), check_dkim_signature: 0.42 (0.1%), check_dkim_adsp: 25 (5.5%), poll_dns_idle: 23 (5.1%), tests_pri_10: 2.5 (0.5%), tests_pri_500: 7 (1.5%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 1/1] OvmfPkg: Add BaseResetSystemLibBhyve.inf X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Content-Transfer-Encoding: 8bit Introduce BaseResetSystemLibBhyve.inf, to support powering off bhyve guests. Signed-off-by: Rebecca Cran Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel --- Laszlo: I couldn't find your email specifying specific changes to make, so I hope I've caught all of them. OvmfPkg/Include/IndustryStandard/Bhyve.h | 2 + .../ResetSystemLib/BaseResetShutdownBhyve.c | 34 ++++++++++++++++ .../BaseResetSystemLibBhyve.inf | 40 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c create mode 100644 OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/IndustryStandard/Bhyve.h index 02ce5587ee0f..ab8f2b0729b4 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 000000000000..156e5ad0d797 --- /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 // CpuDeadLoop() +#include // IoOr16() +#include // ResetShutdown() +#include // BHYVE_PM_REG + +/** + 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 000000000000..33e4e2689e57 --- /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 = DXE_DRIVER + 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 + -- 2.25.1