Skip to content

Commit

Permalink
hw/i386/pc_piix: Wire PIIX3's ISA interrupts by new "isa-irqs" property
Browse files Browse the repository at this point in the history
Avoid assigning the private member of struct PIIX3State from outside which goes
against best QOM practices. Instead, implement best QOM practice by adding an
"isa-irqs" array property to TYPE_PIIX3_DEVICE and assign it in board code, i.e.
from outside.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-Id: <20231007123843.127151-6-shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
shentok authored and mstsirkin committed Oct 18, 2023
1 parent 7958323 commit c794a1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion hw/i386/pc_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,15 @@ static void pc_init1(MachineState *machine,
if (pcmc->pci_enabled) {
PIIX3State *piix3;
PCIDevice *pci_dev;
DeviceState *dev;
size_t i;

pci_dev = pci_new_multifunction(-1, TYPE_PIIX3_DEVICE);
piix3 = PIIX3_PCI_DEVICE(pci_dev);
piix3->pic = x86ms->gsi;
dev = DEVICE(pci_dev);
for (i = 0; i < ISA_NUM_IRQS; i++) {
qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]);
}
pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);

if (xen_enabled()) {
Expand Down
2 changes: 2 additions & 0 deletions hw/isa/piix3.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ static void pci_piix3_init(Object *obj)
{
PIIX3State *d = PIIX3_PCI_DEVICE(obj);

qdev_init_gpio_out_named(DEVICE(obj), d->pic, "isa-irqs", ISA_NUM_IRQS);

object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC);
}

Expand Down
2 changes: 1 addition & 1 deletion include/hw/southbridge/piix.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct PIIXState {
#endif
uint64_t pic_levels;

qemu_irq *pic;
qemu_irq pic[ISA_NUM_IRQS];

/* This member isn't used. Just for save/load compatibility */
int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS];
Expand Down

0 comments on commit c794a1f

Please sign in to comment.