qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent.
Date: Wed, 8 Jul 2009 18:04:18 -0300	[thread overview]
Message-ID: <20090708210418.GA9580@amt.cnet> (raw)
In-Reply-To: <1246948560-1978-4-git-send-email-yamahata@valinux.co.jp>

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 <yamahata@valinux.co.jp>
> ---
>  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 <yamahata at valinux co jp>
> + *                     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).

  reply	other threads:[~2009-07-08 21:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  6:35 [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v3 Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 01/17] acpi.c: split out pc smbus routines from acpi.c into pc_smbus.c Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 02/17] acpi.c: split out apm register emulation Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent Isaku Yamahata
2009-07-08 21:04   ` Marcelo Tosatti [this message]
2009-07-07  6:35 ` [Qemu-devel] [PATCH 04/17] acpi: add acpi constants from linux header files and use them Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 05/17] acpi.c: split acpi.c into the common part and the piix4 part Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx independent Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 07/17] pc.c: remove unnecessary global variables, pit and ioapic Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 08/17] pc.c: remove a global variable, floppy_controller Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc_state Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 10/17] pc.c: introduce a function to allocate cpu irq Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 11/17] pc.c: make pc_init1() not refer ferr_irq directly Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 12/17] pc.c: split out cpu initialization from pc_init1() into pc_cpus_init() Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 13/17] pc.c: split out memory allocation from pc_init1() into pc_memory_init() Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 14/17] pc.c: split out vga initialization from pc_init1() into pc_vga_init() Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 15/17] pc.c: split out basic device init from pc_init1() into pc_basic_device_init() Isaku Yamahata
2009-07-07  6:35 ` [Qemu-devel] [PATCH 16/17] pc.c: split out pci device init from pc_init1() into pc_pci_device_init() Isaku Yamahata
2009-07-07  6:36 ` [Qemu-devel] [PATCH 17/17] pc.c: split out piix specific part from pc.c into pc_piix.c Isaku Yamahata
  -- strict thread matches above, loose matches on Subject: below --
2009-07-17  7:22 [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. V6 Isaku Yamahata
2009-07-17  7:22 ` [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent Isaku Yamahata
2009-07-15  7:19 [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v5 Isaku Yamahata
2009-07-15  7:19 ` [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent Isaku Yamahata
2009-07-15 14:53   ` Blue Swirl
2009-07-09  8:13 [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v3 Isaku Yamahata
2009-07-09  8:13 ` [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent Isaku Yamahata
2009-07-03  7:11 [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v2 Isaku Yamahata
2009-07-03  7:11 ` [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent Isaku Yamahata

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=20090708210418.GA9580@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /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).