qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC PATCH 02/11] hw/ide: Add PCIIDEState::isa_bus link


From: Mark Cave-Ayland
Subject: Re: [RFC PATCH 02/11] hw/ide: Add PCIIDEState::isa_bus link
Date: Thu, 20 May 2021 09:29:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0

On 20/05/2021 08:41, Mark Cave-Ayland wrote:

3) Add a new pci_isa_bridge_get_isabus(PCIDevice *d) function that the devices such as via-ide can use to obtain a reference to the ISABus from their own PCIDevice. It should hopefully be quite simple like this:

ISABus *pci_isa_bridge_get_isabus(PCIDevice *d)
{
    PCIISABridge *s = PCI_ISA_BRIDGE(d);

    return s->isa_bus;
}

Oops - have just realised that PCIDevice in this case is the PCI/ISA device and not the bridge itself. This means there is a bit more work to do, perhaps something like:

   ISABus *pci_device_get_isabus(PCIDevice *d)
   {
        PCIBus *bus = pci_get_bus(d);
        PCIDeviceClass *k;
        int devfn;

        for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
            PCIDevice *pd = bus->devices[devfn];
            PCIDeviceClass *k = PCI_DEVICE_GET_CLASS(d);
            PCIISABridge *s;
            if (object_dynamic_cast(OBJECT(pd), TYPE_PCI_ISA_BRIDGE)) {
                s = PCI_ISA_BRIDGE(pd);
                return s->isa_bus;
            }
        }

        return NULL;
   }

Given that a PCI-ISA bridge effectively manages the bottom part of the single IO address space then I believe there can only be one PCI-ISA bridge per PCI host bridge, and therefore bus.


ATB,

Mark.



reply via email to

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