From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LzTTs-0003JN-Vd for qemu-devel@nongnu.org; Thu, 30 Apr 2009 06:27:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LzTTn-0003J4-Co for qemu-devel@nongnu.org; Thu, 30 Apr 2009 06:27:03 -0400 Received: from [199.232.76.173] (port=58088 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LzTTn-0003J1-5f for qemu-devel@nongnu.org; Thu, 30 Apr 2009 06:26:59 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:22496) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LzTTm-0002RI-DV for qemu-devel@nongnu.org; Thu, 30 Apr 2009 06:26:58 -0400 Message-ID: <49F97CEF.8020505@siemens.com> Date: Thu, 30 Apr 2009 12:26:55 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20090430094054.GI5082@redhat.com> In-Reply-To: <20090430094054.GI5082@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: Gleb Natapov Cc: qemu-devel@nongnu.org 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? > #endif > { "migrate", "-ds", do_migrate, > "[-d] uri", "migrate to URI (using -d to not wait for completion)" }, > diff --git a/pc-bios/bios-pq/0015_add-power_button_aml_object.patch b/pc-bios/bios-pq/0015_add-power_button_aml_object.patch > new file mode 100644 > index 0000000..7477b71 > --- /dev/null > +++ b/pc-bios/bios-pq/0015_add-power_button_aml_object.patch > @@ -0,0 +1,27 @@ > +Add power button device object to AML. > + > +diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl > +index 7bff30a..0ca129d 100644 > +--- a/bios/acpi-dsdt.dsl > ++++ b/bios/acpi-dsdt.dsl > +@@ -38,6 +38,11 @@ DefinitionBlock ( > + > + /* PCI Bus definition */ > + Scope(\_SB) { > ++ Device (PWRB) { > ++ Name (_HID, EisaId ("PNP0C0C")) > ++ Name (_STA, 0x0B) > ++ } > ++ > + Device(PCI0) { > + Name (_HID, EisaId ("PNP0A03")) > + Name (_ADR, 0x00) > +@@ -724,7 +729,7 @@ DefinitionBlock ( > + Return(0x01) > + } > + Method(_L08) { > +- Return(0x01) > ++ Notify(\_SB.PWRB, 0x80) > + } > + Method(_L09) { > + Return(0x01) > diff --git a/pc-bios/bios-pq/series b/pc-bios/bios-pq/series > index fdef179..85e587e 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 > +015_add-power_button_aml_object.patch > diff --git a/sysemu.h b/sysemu.h > index 50438a6..a8abb3c 100644 > --- a/sysemu.h > +++ b/sysemu.h > @@ -38,6 +38,8 @@ void qemu_system_powerdown_request(void); > int qemu_shutdown_requested(void); > int qemu_reset_requested(void); > int qemu_powerdown_requested(void); > +void qemu_press_power_button(void); > + > #if !defined(TARGET_SPARC) && !defined(TARGET_I386) > // Please implement a power failure function to signal the OS > #define qemu_system_powerdown() do{}while(0) > -- > Gleb. > Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux