From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: "BALATON Zoltan" <balaton@eik.bme.hu>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Bernhard Beschow" <shentey@gmail.com>
Subject: [PATCH v5 4/5] hw/isa/vt82c686: Implement ACPI powerdown
Date: Sat, 28 Oct 2023 11:16:05 +0200 [thread overview]
Message-ID: <20231028091606.23700-5-shentey@gmail.com> (raw)
In-Reply-To: <20231028091606.23700-1-shentey@gmail.com>
Allows guests to be powered off via an ACPI power button event which can be
triggered e.g. through the GTK GUI.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/isa/vt82c686.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 7b44ad9485..e8ec63dea9 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -33,8 +33,10 @@
#include "qapi/error.h"
#include "qemu/log.h"
#include "qemu/module.h"
+#include "qemu/notify.h"
#include "qemu/range.h"
#include "qemu/timer.h"
+#include "sysemu/runstate.h"
#include "trace.h"
#define TYPE_VIA_PM "via-pm"
@@ -52,6 +54,8 @@ struct ViaPMState {
APMState apm;
PMSMBus smb;
+ Notifier powerdown_notifier;
+
qemu_irq sci_irq;
};
@@ -172,6 +176,13 @@ static void via_pm_reset(DeviceState *d)
smb_io_space_update(s);
}
+static void via_pm_powerdown_req(Notifier *n, void *opaque)
+{
+ ViaPMState *s = container_of(n, ViaPMState, powerdown_notifier);
+
+ acpi_pm1_evt_power_down(&s->ar);
+}
+
static void via_pm_realize(PCIDevice *dev, Error **errp)
{
ViaPMState *s = VIA_PM(dev);
@@ -193,6 +204,9 @@ static void via_pm_realize(PCIDevice *dev, Error **errp)
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false);
acpi_gpe_init(&s->ar, VIA_PM_GPE_LEN);
+
+ s->powerdown_notifier.notify = via_pm_powerdown_req;
+ qemu_register_powerdown_notifier(&s->powerdown_notifier);
}
static void via_pm_init(Object *obj)
--
2.42.0
next prev parent reply other threads:[~2023-10-28 9:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-28 9:16 [PATCH v5 0/5] VIA PM: Implement basic ACPI support Bernhard Beschow
2023-10-28 9:16 ` [PATCH v5 1/5] hw/isa/vt82c686: Respect SCI interrupt assignment Bernhard Beschow
2023-10-28 9:16 ` [PATCH v5 2/5] hw/isa/vt82c686: Add missing initialization of ACPI general purpose event registers Bernhard Beschow
2023-10-28 9:16 ` [PATCH v5 3/5] hw/isa/vt82c686: Reuse acpi_update_sci() Bernhard Beschow
2023-10-28 12:59 ` BALATON Zoltan
2023-10-28 15:40 ` Bernhard Beschow
2023-10-29 0:07 ` BALATON Zoltan
2023-10-29 1:07 ` Bernhard Beschow
2023-10-29 9:47 ` BALATON Zoltan
2023-10-30 9:45 ` Bernhard Beschow
2023-10-30 10:43 ` BALATON Zoltan
2023-10-28 9:16 ` Bernhard Beschow [this message]
2023-10-28 9:16 ` [PATCH v5 5/5] hw/isa/vt82c686: Implement software-based SMI triggering Bernhard Beschow
2023-10-28 13:03 ` BALATON Zoltan
2023-10-28 15:44 ` Bernhard Beschow
2023-10-28 17:41 ` BALATON Zoltan
2023-10-28 12:58 ` [PATCH v5 0/5] VIA PM: Implement basic ACPI support BALATON Zoltan
2023-10-28 15:20 ` Bernhard Beschow
2023-10-28 17:47 ` BALATON Zoltan
2023-10-29 0:03 ` BALATON Zoltan
2023-10-29 1:05 ` Bernhard Beschow
2023-10-29 9:46 ` BALATON Zoltan
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-all 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=20231028091606.23700-5-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=jiaxun.yang@flygoat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).