From nobody Wed Nov 27 16:41:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697740145; cv=none; d=zohomail.com; s=zohoarc; b=kCoVjXz2et0KKyWbCg1/osMjXKRKn04OYUarbPi95WgOLwavSDtNdBKwkiKSbcN3S4C2jjyA7Ejw4Ht9vUJl2xqfKKhwj123hAlbOlGHa0lm1dENCIGK6eAt+9nYsnHEFuvqbWJ+7swA8fztisy4nQ1AnZaWleOb3amAtYAS2dY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697740145; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PPLQmXXxzBmAon2V0X2xj7Rza3f9PZpdzyLrBWWg/e4=; b=SyX26mYdWGPh7zOVMc8B+qUHTBQHoHaUNJGob0TjLGLkuSF1g5CGvS01qjXg0xbkW4AYv4wN8PJzIfkFoismrwQP1tG6zXBkagfdVz2pM23b+m6EemAOgau8XTP09gGcCdd3y7JXymG/X6ucfMoqx9s9PD2Vd8sPQdz5JtcMwkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697740145599348.1744281308826; Thu, 19 Oct 2023 11:29:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtXho-0001h6-O0; Thu, 19 Oct 2023 14:25:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtXhd-0001NS-Lf for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:25:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtXha-0004U4-TS for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:25:01 -0400 Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-4n7Tvc4jO6KXWk_immWPeA-1; Thu, 19 Oct 2023 14:24:08 -0400 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2c512a53e82so54887561fa.0 for ; Thu, 19 Oct 2023 11:24:00 -0700 (PDT) Received: from redhat.com ([2a06:c701:73d2:bf00:e379:826:5137:6b23]) by smtp.gmail.com with ESMTPSA id j15-20020a05600c1c0f00b003fefb94ccc9sm221179wms.11.2023.10.19.11.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697739895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PPLQmXXxzBmAon2V0X2xj7Rza3f9PZpdzyLrBWWg/e4=; b=C4uk42G2x7s7XyvKs6WkLEap19YlovYl7cPF/UwA4XEUCU2BjNxRBYdLCLQeregnVqSz3x sMwyLEIknMgi85CVF5CpoQwGvmeJ5bEEC8HxZ1Zb2USpcJCX4oBhbPA2Lg8JD5eDFwDzEu 6Y5Lbvj+n1TJmYuHOZYMxL4J7+OV1VM= X-MC-Unique: 4n7Tvc4jO6KXWk_immWPeA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697739834; x=1698344634; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PPLQmXXxzBmAon2V0X2xj7Rza3f9PZpdzyLrBWWg/e4=; b=r93CvSJg7oYRBas9sH+6FPQadGMCb5AxiR09u1ayBX9YPzaIUVQ+Jr3+mikkAThZsC dyrLA9+PVU5FUWG+0jpc3sxQ725v/8DJJ62QcSY6ZS+pPyiyXzxrtq+lvoP8zaq0cokN q+ZQIUwanWNQQjmYPCmlP4lfX422KV6HS9vfJWn0/63GBdwS+8NM8NZEceZEy4ca64Zn 9+T+WBdlznwBcxr0gZ3wtf3W8uxylT8SbKGtPIuCdAalg6ZChK15G5M+Ch1M7EYQOas7 xV16OFIMWnZawjS24d6Cw7iDBzXoFmKS1U0m4l1OXJbFRMIOjQwTCpVLpB1BnhQvQY/1 EJTQ== X-Gm-Message-State: AOJu0Yz+0zB2soASMmH3eM3De8thixyEQilmtRmHBUFm8YDw4XXuzvZY tVFnfKNsrnUa2rrl0ba0HgmqNBBxfrjFbZ+p4ZPfJwOO+MJbyLqFTZUGp/tvzK5qLtp6VmQlPGx BNgVjaKPQusiFKZpkWm2M6RFQ99tzfKJYP7Y8LH0ALKboLDJOe4RZ+Dz/HHN/2U7JMWNM X-Received: by 2002:a05:651c:229:b0:2bf:ab17:d48b with SMTP id z9-20020a05651c022900b002bfab17d48bmr2022538ljn.34.1697739834678; Thu, 19 Oct 2023 11:23:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpvmuCEX25gIjCTzrWQrrMq69ULKaqccDamS67lWnVBW+F3lRUu8uUL9gBVOKMMAVRtGlI5w== X-Received: by 2002:a05:651c:229:b0:2bf:ab17:d48b with SMTP id z9-20020a05651c022900b002bfab17d48bmr2022519ljn.34.1697739834335; Thu, 19 Oct 2023 11:23:54 -0700 (PDT) Date: Thu, 19 Oct 2023 14:23:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , =?utf-8?B?SGVydsOp?= Poussineau , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Aurelien Jarno , Marcel Apfelbaum Subject: [PULL v2 60/78] hw/isa/piix: Share PIIX3's base class with PIIX4 Message-ID: <3ee54f65f4bbcd566ff2e564cfa88080e0461cc2.1697739629.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697740146156100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Having a common base class will allow for futher code sharing between PIIX3= and PIIX4. Moreover, it makes PIIX4 implement the acpi-dev-aml-interface. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Message-Id: <20231007123843.127151-24-shentey@gmail.com> Signed-off-by: Michael S. Tsirkin --- hw/isa/piix.c | 85 ++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/hw/isa/piix.c b/hw/isa/piix.c index bd66fb7475..8f7d6c56a8 100644 --- a/hw/isa/piix.c +++ b/hw/isa/piix.c @@ -38,10 +38,6 @@ #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" =20 -typedef struct PIIXState PIIX4State; - -DECLARE_INSTANCE_CHECKER(PIIX4State, PIIX4_PCI_DEVICE, TYPE_PIIX4_PCI_DEVI= CE) - static void piix3_set_irq_pic(PIIXState *piix3, int pic_irq) { qemu_set_irq(piix3->isa_irqs_in[pic_irq], @@ -88,7 +84,7 @@ static void piix3_set_irq(void *opaque, int pirq, int lev= el) static void piix4_set_irq(void *opaque, int irq_num, int level) { int i, pic_irq, pic_level; - PIIX4State *s =3D opaque; + PIIXState *s =3D opaque; PCIBus *bus =3D pci_get_bus(&s->dev); =20 /* now we change the pic irq level according to the piix irq mappings = */ @@ -108,7 +104,7 @@ static void piix4_set_irq(void *opaque, int irq_num, in= t level) =20 static void piix_request_i8259_irq(void *opaque, int irq, int level) { - PIIX4State *s =3D opaque; + PIIXState *s =3D opaque; qemu_set_irq(s->cpu_intr, level); } =20 @@ -156,8 +152,9 @@ static void piix3_write_config(PCIDevice *dev, } } =20 -static void piix_reset(PIIXState *d) +static void piix_reset(DeviceState *dev) { + PIIXState *d =3D PIIX_PCI_DEVICE(dev); uint8_t *pci_conf =3D d->dev.config; =20 pci_conf[0x04] =3D 0x07; /* master, memory and I/O */ @@ -196,13 +193,6 @@ static void piix_reset(PIIXState *d) d->rcr =3D 0; } =20 -static void piix3_reset(DeviceState *dev) -{ - PIIXState *d =3D PIIX_PCI_DEVICE(dev); - - piix_reset(d); -} - static int piix3_post_load(void *opaque, int version_id) { PIIXState *piix3 =3D opaque; @@ -227,7 +217,7 @@ static int piix3_post_load(void *opaque, int version_id) =20 static int piix4_post_load(void *opaque, int version_id) { - PIIX4State *s =3D opaque; + PIIXState *s =3D opaque; =20 if (version_id =3D=3D 2) { s->rcr =3D 0; @@ -291,8 +281,8 @@ static const VMStateDescription vmstate_piix4 =3D { .minimum_version_id =3D 2, .post_load =3D piix4_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, PIIX4State), - VMSTATE_UINT8_V(rcr, PIIX4State, 3), + VMSTATE_PCI_DEVICE(dev, PIIXState), + VMSTATE_UINT8_V(rcr, PIIXState, 3), VMSTATE_END_OF_LIST() } }; @@ -426,7 +416,7 @@ static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml *= scope) qbus_build_aml(bus, scope); } =20 -static void pci_piix3_init(Object *obj) +static void pci_piix_init(Object *obj) { PIIXState *d =3D PIIX_PCI_DEVICE(obj); =20 @@ -434,7 +424,6 @@ static void pci_piix3_init(Object *obj) ISA_NUM_IRQS); =20 object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC); - object_initialize_child(obj, "ide", &d->ide, TYPE_PIIX3_IDE); } =20 static Property pci_piix3_props[] =3D { @@ -447,27 +436,22 @@ static Property pci_piix3_props[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static void pci_piix3_class_init(ObjectClass *klass, void *data) +static void pci_piix_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); AcpiDevAmlIfClass *adevc =3D ACPI_DEV_AML_IF_CLASS(klass); =20 - k->config_write =3D piix3_write_config; - dc->reset =3D piix3_reset; + dc->reset =3D piix_reset; dc->desc =3D "ISA bridge"; - dc->vmsd =3D &vmstate_piix3; dc->hotpluggable =3D false; k->vendor_id =3D PCI_VENDOR_ID_INTEL; - /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ - k->device_id =3D PCI_DEVICE_ID_INTEL_82371SB_0; k->class_id =3D PCI_CLASS_BRIDGE_ISA; /* - * Reason: part of PIIX3 southbridge, needs to be wired up by + * Reason: part of PIIX southbridge, needs to be wired up by e.g. * pc_piix.c's pc_init1() */ dc->user_creatable =3D false; - device_class_set_props(dc, pci_piix3_props); adevc->build_dev_aml =3D build_pci_isa_aml; } =20 @@ -475,9 +459,9 @@ static const TypeInfo piix_pci_type_info =3D { .name =3D TYPE_PIIX_PCI_DEVICE, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(PIIXState), - .instance_init =3D pci_piix3_init, + .instance_init =3D pci_piix_init, .abstract =3D true, - .class_init =3D pci_piix3_class_init, + .class_init =3D pci_piix_class_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { TYPE_ACPI_DEV_AML_IF }, @@ -500,22 +484,36 @@ static void piix3_realize(PCIDevice *dev, Error **err= p) pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq); } =20 +static void piix3_init(Object *obj) +{ + PIIXState *d =3D PIIX_PCI_DEVICE(obj); + + object_initialize_child(obj, "ide", &d->ide, TYPE_PIIX3_IDE); +} + static void piix3_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 + k->config_write =3D piix3_write_config; k->realize =3D piix3_realize; + /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ + k->device_id =3D PCI_DEVICE_ID_INTEL_82371SB_0; + dc->vmsd =3D &vmstate_piix3; + device_class_set_props(dc, pci_piix3_props); } =20 static const TypeInfo piix3_info =3D { .name =3D TYPE_PIIX3_DEVICE, .parent =3D TYPE_PIIX_PCI_DEVICE, + .instance_init =3D piix3_init, .class_init =3D piix3_class_init, }; =20 static void piix4_realize(PCIDevice *dev, Error **errp) { - PIIX4State *s =3D PIIX4_PCI_DEVICE(dev); + PIIXState *s =3D PIIX_PCI_DEVICE(dev); PCIBus *pci_bus =3D pci_get_bus(dev); ISABus *isa_bus; qemu_irq *i8259_out_irq; @@ -584,18 +582,10 @@ static void piix4_realize(PCIDevice *dev, Error **err= p) pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); } =20 -static void piix4_isa_reset(DeviceState *dev) -{ - PIIX4State *s =3D PIIX4_PCI_DEVICE(dev); - - piix_reset(s); -} - static void piix4_init(Object *obj) { - PIIX4State *s =3D PIIX4_PCI_DEVICE(obj); + PIIXState *s =3D PIIX_PCI_DEVICE(obj); =20 - object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE); object_initialize_child(obj, "uhci", &s->uhci, TYPE_PIIX4_USB_UHCI); =20 @@ -610,30 +600,15 @@ static void piix4_class_init(ObjectClass *klass, void= *data) PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D piix4_realize; - k->vendor_id =3D PCI_VENDOR_ID_INTEL; k->device_id =3D PCI_DEVICE_ID_INTEL_82371AB_0; - k->class_id =3D PCI_CLASS_BRIDGE_ISA; - dc->reset =3D piix4_isa_reset; - dc->desc =3D "ISA bridge"; dc->vmsd =3D &vmstate_piix4; - /* - * Reason: part of PIIX4 southbridge, needs to be wired up, - * e.g. by mips_malta_init() - */ - dc->user_creatable =3D false; - dc->hotpluggable =3D false; } =20 static const TypeInfo piix4_info =3D { .name =3D TYPE_PIIX4_PCI_DEVICE, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(PIIX4State), + .parent =3D TYPE_PIIX_PCI_DEVICE, .instance_init =3D piix4_init, .class_init =3D piix4_class_init, - .interfaces =3D (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, }; =20 static void piix3_register_types(void) --=20 MST