From patchwork Wed Jul 24 16:02:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 261466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9BD6D2C00A8 for ; Thu, 25 Jul 2013 02:50:47 +1000 (EST) Received: from localhost ([::1]:34265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21XS-0005Vq-8k for incoming@patchwork.ozlabs.org; Wed, 24 Jul 2013 12:03:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21V4-0002cs-8A for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V21V1-0002UN-Ex for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:01:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21V1-0002UD-6x for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:01:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6OG0rvw022923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Jul 2013 12:00:54 -0400 Received: from redhat.com (vpn-201-81.tlv.redhat.com [10.35.201.81]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r6OG0oJ0031253; Wed, 24 Jul 2013 12:00:51 -0400 Date: Wed, 24 Jul 2013 19:02:14 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1374681580-17439-12-git-send-email-mst@redhat.com> References: <1374681580-17439-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1374681580-17439-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Aurelien Jarno Subject: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components. Signed-off-by: Michael S. Tsirkin Reviewed-by: Gerd Hoffmann --- hw/acpi/piix4.c | 29 +++++++++++++++++++++++++++-- hw/mips/mips_malta.c | 2 +- hw/pci-host/piix.c | 8 ++++++++ include/hw/i386/pc.h | 1 + include/qemu/typedefs.h | 1 + 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index c885690..2128f13 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -29,6 +29,7 @@ #include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/piix4.h" //#define DEBUG @@ -63,7 +64,7 @@ typedef struct CPUStatus { uint8_t sts[PIIX4_PROC_LEN]; } CPUStatus; -typedef struct PIIX4PMState { +struct PIIX4PMState { /*< private >*/ PCIDevice parent_obj; /*< public >*/ @@ -96,7 +97,7 @@ typedef struct PIIX4PMState { CPUStatus gpe_cpu; Notifier cpu_added_notifier; -} PIIX4PMState; +}; #define TYPE_PIIX4_PM "PIIX4_PM" @@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev) return 0; } +PIIX4PMState *piix4_pm_find(void) +{ + bool ambig; + Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig); + + if (ambig || !o) { + return NULL; + } + return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM"); +} + +void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info) +{ + info->s3_disabled = s->disable_s3; + info->s4_disabled = s->disable_s4; + info->s4_val = s->s4_val; + + info->acpi_enable_cmd = ACPI_ENABLE; + info->acpi_disable_cmd = ACPI_DISABLE; + info->gpe0_blk = GPE_BASE; + info->gpe0_blk_len = GPE_LEN; + info->sci_int = 9; +} + i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, int kvm_enabled, FWCfgState *fw_cfg) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index de87241..14573ab 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args) pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, - isa_get_irq(NULL, 9), NULL, 0, NULL); + isa_get_irq(NULL, 9), NULL, 0, NULL, NULL); /* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(smbus, 8, NULL, 0); pit = pit_init(isa_bus, 0x40, 0, NULL); diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 3908860..daefdfb 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, return b; } +PCIBus *find_i440fx(void) +{ + PCIHostState *s = OBJECT_CHECK(PCIHostState, + object_resolve_path("/machine/i440fx", NULL), + TYPE_PCI_HOST_BRIDGE); + return s ? s->bus : NULL; +} + /* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq) { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 7c0bd50..76af5cd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx(void); /* piix4.c */ extern PCIDevice *piix4_dev; int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index cb66e19..7d42693 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList; typedef struct SHPCDevice SHPCDevice; typedef struct FWCfgState FWCfgState; typedef struct PcGuestInfo PcGuestInfo; +typedef struct PIIX4PMState PIIX4PMState; typedef struct AcpiPmInfo AcpiPmInfo; #endif /* QEMU_TYPEDEFS_H */