diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2017-06-04 20:25:17 +1000 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-06-06 09:23:46 +1000 |
commit | 2d33581899edcaba9b7e48def11c4ddfcd2423ec (patch) | |
tree | b87f31deb4d65e238b93e3f7bdfba6ee07d1cfad /include | |
parent | a32e900b8abf3541414ef192ef72b6381fde8d0c (diff) | |
download | qemu-2d33581899edcaba9b7e48def11c4ddfcd2423ec.zip qemu-2d33581899edcaba9b7e48def11c4ddfcd2423ec.tar.gz qemu-2d33581899edcaba9b7e48def11c4ddfcd2423ec.tar.bz2 |
spapr: Introduce DRC subclasses
Currently we only have a single QOM type for all DRCs, but lots of
places where we switch behaviour based on the DRC's PAPR defined type.
This is a poor use of our existing type system.
So, instead create QOM subclasses for each PAPR defined DRC type. We
also introduce intermediate subclasses for physical and logical DRCs,
a division which will be useful later on.
Instead of being stored in the DRC object itself, the PAPR type is now
stored in the class structure. There are still many places where we
switch directly on the PAPR type value, but this at least provides the
basis to start to remove those.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/ppc/spapr_drc.h | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 10e7c24..969c16d 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -26,6 +26,48 @@ #define SPAPR_DR_CONNECTOR(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ TYPE_SPAPR_DR_CONNECTOR) +#define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical" +#define SPAPR_DRC_PHYSICAL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PHYSICAL) +#define SPAPR_DRC_PHYSICAL_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \ + TYPE_SPAPR_DRC_PHYSICAL) +#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_PHYSICAL) + +#define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical" +#define SPAPR_DRC_LOGICAL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LOGICAL) +#define SPAPR_DRC_LOGICAL_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \ + TYPE_SPAPR_DRC_LOGICAL) +#define SPAPR_DRC_LOGICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_LOGICAL) + +#define TYPE_SPAPR_DRC_CPU "spapr-drc-cpu" +#define SPAPR_DRC_CPU_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_CPU) +#define SPAPR_DRC_CPU_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_CPU) +#define SPAPR_DRC_CPU(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_CPU) + +#define TYPE_SPAPR_DRC_PCI "spapr-drc-pci" +#define SPAPR_DRC_PCI_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PCI) +#define SPAPR_DRC_PCI_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_PCI) +#define SPAPR_DRC_PCI(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_PCI) + +#define TYPE_SPAPR_DRC_LMB "spapr-drc-lmb" +#define SPAPR_DRC_LMB_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LMB) +#define SPAPR_DRC_LMB_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_LMB) +#define SPAPR_DRC_LMB(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_LMB) + /* * Various hotplug types managed by sPAPRDRConnector * @@ -134,7 +176,6 @@ typedef struct sPAPRDRConnector { /*< private >*/ DeviceState parent; - sPAPRDRConnectorType type; uint32_t id; Object *owner; const char *name; @@ -163,6 +204,7 @@ typedef struct sPAPRDRConnectorClass { DeviceClass parent; /*< public >*/ + sPAPRDRConnectorTypeShift typeshift; /* accessors for guest-visible (generally via RTAS) DR state */ uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, @@ -186,8 +228,7 @@ typedef struct sPAPRDRConnectorClass { uint32_t spapr_drc_index(sPAPRDRConnector *drc); sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); -sPAPRDRConnector *spapr_dr_connector_new(Object *owner, - sPAPRDRConnectorType type, +sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, uint32_t id); sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index); sPAPRDRConnector *spapr_dr_connector_by_id(sPAPRDRConnectorType type, |