From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOeJz-0006jI-Ho for qemu-devel@nongnu.org; Wed, 08 Jul 2009 17:04:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOeJu-0006cI-T2 for qemu-devel@nongnu.org; Wed, 08 Jul 2009 17:04:54 -0400 Received: from [199.232.76.173] (port=42017 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOeJu-0006c4-Eu for qemu-devel@nongnu.org; Wed, 08 Jul 2009 17:04:50 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56416) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOeJt-0003N2-QH for qemu-devel@nongnu.org; Wed, 08 Jul 2009 17:04:50 -0400 Date: Wed, 8 Jul 2009 18:04:18 -0300 From: Marcelo Tosatti Subject: Re: [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent. Message-ID: <20090708210418.GA9580@amt.cnet> References: <1246948560-1978-1-git-send-email-yamahata@valinux.co.jp> <1246948560-1978-4-git-send-email-yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1246948560-1978-4-git-send-email-yamahata@valinux.co.jp> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org On Tue, Jul 07, 2009 at 03:35:46PM +0900, Isaku Yamahata wrote: > Make qemu_system_powerdown() piix independent by > registering callback function. > > Signed-off-by: Isaku Yamahata > --- > hw/acpi.c | 30 ++++++++++++++++++++++++++---- > hw/acpi.h | 29 +++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+), 4 deletions(-) > create mode 100644 hw/acpi.h > > diff --git a/hw/acpi.c b/hw/acpi.c > index 7351947..14015cd 100644 > --- a/hw/acpi.c > +++ b/hw/acpi.c > @@ -26,6 +26,7 @@ > #include "i2c.h" > #include "smbus.h" > #include "kvm.h" > +#include "acpi.h" > > //#define DEBUG > > @@ -323,6 +324,18 @@ static void piix4_reset(void *opaque) > } > } > > +#if defined(TARGET_I386) > +static void piix4_pm_powerdown(void *arg) > +{ > + PIIX4PMState *pm_state = (PIIX4PMState*) arg; > + > + if (pm_state->pmen & PWRBTN_EN) { > + pm_state->pmsts |= PWRBTN_EN; > + pm_update_sci(pm_state); > + } > +} > +#endif > + > i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, > qemu_irq sci_irq) > { > @@ -377,18 +390,27 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, > pc_smbus_init(&s->smb); > s->irq = sci_irq; > qemu_register_reset(piix4_reset, s); > + qemu_system_powerdown_register(piix4_pm_powerdown, pm_state); > > return s->smb.smbus; > } > > #if defined(TARGET_I386) > +static qemu_powerdown_t qemu_powerdown_callback; > +static void *qemu_powerdown_arg; > + > +void qemu_system_powerdown_register(qemu_powerdown_t callback, void *arg) > +{ > + qemu_powerdown_callback = callback; > + qemu_powerdown_arg = arg; > +} > + > void qemu_system_powerdown(void) > { > - if (!pm_state) { > + if (!qemu_powerdown_callback) { > qemu_system_shutdown_request(); > - } else if (pm_state->pmen & PWRBTN_EN) { > - pm_state->pmsts |= PWRBTN_EN; > - pm_update_sci(pm_state); > + } else { > + qemu_powerdown_callback(qemu_powerdown_arg); > } > } > #endif > diff --git a/hw/acpi.h b/hw/acpi.h > new file mode 100644 > index 0000000..884512c > --- /dev/null > +++ b/hw/acpi.h > @@ -0,0 +1,29 @@ > +#ifndef QEMU_HW_ACPI_H > +#define QEMU_HW_ACPI_H > +/* > + * Copyright (c) 2009 Isaku Yamahata > + * VA Linux Systems Japan K.K. > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA > + */ > + > +#if defined(TARGET_I386) > +typedef void (*qemu_powerdown_t)(void *arg); > +void qemu_system_powerdown_register(qemu_powerdown_t callback, void *arg); > +#else > +#define qemu_system_powerdown_register(callback, arg) do { } while (0) > +#endif > + > +#endif /* !QEMU_HW_ACPI_H */ This should probably live in vl.c along with qemu_register_reset and friends. Can also get rid of the TARGET_SPARC/TARGET_I386 ifdefs in sysemu.h (and the empty qemu_system_powerdown in sun4u.c).