On 01.05.14 19:22, Gabriel L. Somlo wrote:
On Wed, Apr 30, 2014 at 09:44:32PM +0200, Alexander Graf wrote:
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 2f40cba..4480bc4 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -32,6 +32,8 @@
#define SYNC_TO_VAPIC 0x2
#define SYNC_ISR_IRR_TO_VAPIC 0x4
+uint8_t apic_version = 0x14;
Is there any way to make this a qdev/qom device property rather than
a global?
If there is, and anyone with a better understanding of qom/qdev
has an example I could follow, that would be much appreciated!
As far as I could comprehend it since I started looking at it last
night, the apic_class_init() functions run before pci_init() in
pc_[q35|piix].c knows which machine type we have, but the
apic_realize() functions (which appear to be the actual apic
"constructors") run after that.
The obvious alternative to having one global apic version would be
to add a field to APICCommonClass or APICCommonState, and then somehow
modify the default (set in apic_class_init()) from pci_init()
according to the machine version; After that, each apic may refer to
its private data member "version" when needed.
So, is qom/qdev basically boiling down to a set of macros that can
translate something like "qom_set_property(apic_instance, version, 0x14);"
into "apic_instance.version = 0x14;" ?
With qdev we basically had an array of constructor parameters in the qdev
definition. You could set these from the outside between create and init,
basically:
dev = dev_create()
set_prop(dev, "foo", bar);
dev_init(dev)
which semantically translated to
dev = new dev(foo = bar);
The way to do this with QOM is similar, but I keep forgetting the details. I'm
sure you'll easily find out :).