From nobody Wed Nov 27 20:40:16 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=1697645377; cv=none; d=zohomail.com; s=zohoarc; b=kNZ9rD2H+tn1bmd0YS9sP9hflSQAt9tNu/ILva1HIxulhqRLGS5AVCM4vNYUdyACEUz33uap8KYjfjOwmf00fMf2GYmoyZO1+XgFM6vvQnbyd9j4k8oswqnWI0KqIkRVMtnEekC6Yft0/DFANTp6tlNGKAxo5SQoFOI2VxwfAm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697645377; 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=QIsk84vIr5hHq0622B9+grIg7lzh0totJeP5ech72TgLsp8qGdXAVy3kZtaX+5y8ovUv5nJ4NbgO6ypON37d3i73yB86UF3Djv54YjTRbKDADDtHMWSVn3hxvFenNYwDwHVGlWDnFHIKaOJKIQV/rkd+ZoSMu8fy0vXuwuCr0+g= 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 1697645377478625.4066829857416; Wed, 18 Oct 2023 09:09:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt8x1-0001Yn-FS; Wed, 18 Oct 2023 11:59:15 -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 1qt8wI-0000nG-SF for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:58:32 -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 1qt8wG-0007QJ-Jz for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:58:30 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-u0kUVv8WPsyTJxO9q_b7GQ-1; Wed, 18 Oct 2023 11:58:26 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-406de77fb85so44717085e9.0 for ; Wed, 18 Oct 2023 08:58:26 -0700 (PDT) Received: from redhat.com ([2a02:14f:1f2:2037:f34:d61b:7da0:a7be]) by smtp.gmail.com with ESMTPSA id d14-20020a056000114e00b003232380ffd5sm2367853wrx.106.2023.10.18.08.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697644707; 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=fbni68jq7Aa0xYuxBjQ+3ukqcZeaYpuLPHGWvsSP0O0deYtSjuFNWviVZmXrGlu9KA/kb9 trPp9E7Di2mX4qz3l+ySkVFfeCsXC+CM7o18P+71TlBrUW5SpvuhEZYcIkvrdCOal7kk4R vua0CrrU914E5mE8EXW3zeS0OHa9Igw= X-MC-Unique: u0kUVv8WPsyTJxO9q_b7GQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697644704; x=1698249504; 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=VLT4iaq/1WYFlZKWXUa8U533ZprEcf1Ul1fcE00ZkpN07WYq9W6zS5M1PSeg4RomHh ToQoXluHTvwLriOhOHQznAAgpfbiFX6VNQ6IT2oS7bXK8F343dyfBlvPo4HULu5c4Ivb xFmwi7XI6Z70PaSLJcziSC/xpOEjqIBqGdI3mSXGNVyMaZT7kSvnzS/+e6LwN/9+KEAn ytxKQXcmsla0GlSh74Y3etFlnCD503ShGIYwBMYuftwKyk/K8hNs8D0l84kG1c6Gm70V NcJZ3uguHyWqAwqnKgElz0Mf9gt7DVToUut841w29E9AeBO8hW+YMGWPGf6/aAdfhOfo LM7w== X-Gm-Message-State: AOJu0YxIgfGhtjvrtokwVFlZO8MUJ+9vCQOlQYl9M5kmMbN3Yih4Vl52 9AxK7+1G0WnbRsKpyxv2fQSkdc2Wliaw4bpEPXF1Bdsq4TJ3hFfYw1QMvGCraDJ8seHqXMQjgPW jOGwAc3C1ZYr2C2lTZdGzPPPcx0KklyoaG/oL8dUQdnfH3y8LfZYOZw2UlZ6bWBIMr0KMUpw= X-Received: by 2002:a05:600c:19cc:b0:408:41e7:96ea with SMTP id u12-20020a05600c19cc00b0040841e796eamr506370wmq.31.1697644704384; Wed, 18 Oct 2023 08:58:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCTgU10MKtkgsXnc48adbiH+Yvo7soLEuoLU13e3EMkDSSS1Xi8aokSZCLVyPvKy6Uhvjfuw== X-Received: by 2002:a05:600c:19cc:b0:408:41e7:96ea with SMTP id u12-20020a05600c19cc00b0040841e796eamr506352wmq.31.1697644703992; Wed, 18 Oct 2023 08:58:23 -0700 (PDT) Date: Wed, 18 Oct 2023 11:58:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Aurelien Jarno , =?utf-8?B?SGVydsOp?= Poussineau , Marcel Apfelbaum Subject: [PULL 65/83] hw/isa/piix: Share PIIX3's base class with PIIX4 Message-ID: <1c976935844adb2b940ec5973a5e2d5ee0465845.1697644299.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: 1697645379516100003 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