From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LzV5y-00069x-JP for qemu-devel@nongnu.org; Thu, 30 Apr 2009 08:10:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LzV5u-00063z-1a for qemu-devel@nongnu.org; Thu, 30 Apr 2009 08:10:30 -0400 Received: from [199.232.76.173] (port=36868 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LzV5t-00063e-Rt for qemu-devel@nongnu.org; Thu, 30 Apr 2009 08:10:25 -0400 Received: from mx2.redhat.com ([66.187.237.31]:52743) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LzV5t-0004K1-9Y for qemu-devel@nongnu.org; Thu, 30 Apr 2009 08:10:25 -0400 Date: Thu, 30 Apr 2009 15:10:21 +0300 From: Gleb Natapov Message-ID: <20090430121021.GA9795@redhat.com> References: <20090430094054.GI5082@redhat.com> <49F97CEF.8020505@siemens.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49F97CEF.8020505@siemens.com> Subject: [Qemu-devel] Re: [PATCH] Add ACPI power button emulation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: qemu-devel@nongnu.org On Thu, Apr 30, 2009 at 12:26:55PM +0200, Jan Kiszka wrote: > Gleb Natapov wrote: > > Signed-off-by: Gleb Natapov > > diff --git a/hw/acpi.c b/hw/acpi.c > > index 53c1fec..6141522 100644 > > --- a/hw/acpi.c > > +++ b/hw/acpi.c > > @@ -752,6 +752,15 @@ void qemu_system_device_hot_add(int bus, int slot, int state) > > } > > } > > > > +void qemu_press_power_button(void) > > +{ > > + gpe.sts |= (1 << 8); > > + if (gpe.en & (1 << 8)) { > > + qemu_set_irq(pm_state->irq, 1); > > + qemu_set_irq(pm_state->irq, 0); > > + } > > +} > > + > > struct acpi_table_header > > { > > char signature [4]; /* ACPI signature (4 ASCII characters) */ > > diff --git a/monitor.c b/monitor.c > > index b33fea1..35202aa 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -1211,6 +1211,11 @@ static void do_system_reset(Monitor *mon) > > qemu_system_reset_request(); > > } > > > > +static void do_press_pwrb(Monitor *mon) > > +{ > > + qemu_press_power_button(); > > +} > > + > > static void do_system_powerdown(Monitor *mon) > > { > > qemu_system_powerdown_request(); > > @@ -1733,6 +1738,7 @@ static const mon_cmd_t mon_cmds[] = { > > #if defined(TARGET_I386) > > { "nmi", "i", do_inject_nmi, > > "cpu", "inject an NMI on the given CPU", }, > > + { "press_power_button", "", do_press_pwrb, "", "press power button" }, > > Dumb question: Why do we need a new monitor command? In qemu-kvm, I can > currently issue a power button event via system_powerdown (while this > command has currently no effect in qemu). Why not reuse it? Or what is > the job of system_powerdown when ACPI is present? > Actually this is not a dump question :) If there is no advantage to use ACPI for power button (and I don't know if there is) better leave it as is. And patch bellow should make system_powerdown work on qemu too. Enable power button even generation. Signed-off-by: Gleb Natapov diff --git a/pc-bios/bios-pq/0015_enable-power-button-even-generation.patch b/pc-bios/bios-pq/0015_enable-power-button-even-generation.patch new file mode 100644 index 0000000..96cc2b2 --- /dev/null +++ b/pc-bios/bios-pq/0015_enable-power-button-even-generation.patch @@ -0,0 +1,17 @@ +Enable power button event generation. + +diff --git a/bios/rombios32.c b/bios/rombios32.c +index 81e3bad..9986531 100644 +--- a/bios/rombios32.c ++++ b/bios/rombios32.c +@@ -1767,8 +1767,8 @@ void acpi_bios_init(void) + fadt->plvl3_lat = cpu_to_le16(0xfff); // C3 state not supported + fadt->gpe0_blk = cpu_to_le32(0xafe0); + fadt->gpe0_blk_len = 4; +- /* WBINVD + PROC_C1 + PWR_BUTTON + SLP_BUTTON + FIX_RTC */ +- fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 6)); ++ /* WBINVD + PROC_C1 + SLP_BUTTON + FIX_RTC */ ++ fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 5) | (1 << 6)); + acpi_build_table_header((struct acpi_table_header *)fadt, "FACP", + sizeof(*fadt), 1); + diff --git a/pc-bios/bios-pq/series b/pc-bios/bios-pq/series index fdef179..aa5a375 100644 --- a/pc-bios/bios-pq/series +++ b/pc-bios/bios-pq/series @@ -12,3 +12,4 @@ 0012-load-smbios-entries-and-files-from-qemu.patch 0013_fix-non-acpi-timer-interrupt-routing.patch 0014_add-srat-acpi-table-support.patch +0015_enable-power-button-even-generation.patch -- Gleb.