Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> writes: > On Wed, 2013-01-30 at 17:54 +0100, Andreas Färber wrote: >> >> That would require polymorphism since we already need to derive from >> PCIDevice or ISADevice respectively for interfacing with the bus... >> Modern object-oriented languages have tried to avoid multi-inheritence >> due to arising complications, I thought. Wouldn't object if someone >> wanted to do the dirty implementation work though. ;) >> >> Another such example is EHCI, with PCIDevice and SysBusDevice >> frontends, >> sharing an EHCIState struct and having helper functions operating on >> that core state only. Quite a few device share such a pattern today >> actually (serial, m48t59, ...). > > This is a design bug of your model :-) You shouldn't derive from your > bus interface IMHO but from your functional interface, and have an > ownership relation to the PCIDevice (a bit like IOKit does if my memory > serves me well). Ack. Hence: SerialPCIDevice is-a PCIDevice has-a SerialChipset The board that exports a bus interface is one object. The chipset that implements the functionality is another object. The former's job in life is to map the bus interface to whatever interface the functional object expects. In most cases, this is just a straight forward proxy of a MemoryRegion. Sometimes this involves address shifting, etc. Regards, Anthony Liguori > > Cheers, > Ben. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html