qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix


From: Marcelo Tosatti
Subject: Re: [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent.
Date: Wed, 8 Jul 2009 18:04:18 -0300
User-agent: Mutt/1.5.19 (2009-01-05)

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 <address@hidden>
> ---
>  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 via email to

[Prev in Thread] Current Thread [Next in Thread]