From: Paul Durrant <paul.durrant@citrix.com>
To: qemu-devel@nongnu.org, xen-devel@lists.xen.org
Cc: Paul Durrant <paul.durrant@citrix.com>
Subject: [Qemu-devel] [PATCH] Add Xen platform PCI device version 2.
Date: Wed, 19 Jun 2013 10:32:13 +0100 [thread overview]
Message-ID: <1371634333-23565-1-git-send-email-paul.durrant@citrix.com> (raw)
The XenServer 6.1+ Citrix Windows PV bus driver binds to a new version
of the Xen platform device (since the newer driver set cannot co-exist
with previous drivers which bind to the existing "xen-platform" type of
device). This patch introduces a new "xen-platform-2" device type with
the appropriate device_id and revision.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
hw/xen/xen_platform.c | 75 ++++++++++++++++++++++++++++++++++++++--------
include/hw/pci/pci_ids.h | 1 +
2 files changed, 63 insertions(+), 13 deletions(-)
diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
index b6c6793..6edb850 100644
--- a/hw/xen/xen_platform.c
+++ b/hw/xen/xen_platform.c
@@ -48,6 +48,20 @@
#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
+typedef struct {
+ const char *name;
+ const char *desc;
+ uint16_t device_id;
+ uint8_t revision;
+ uint16_t subsystem_vendor_id;
+ uint16_t subsystem_id;
+} PCIXenPlatformDeviceInfo;
+
+typedef struct PCIXenPlatformDeviceClass {
+ PCIDeviceClass parent_class;
+ PCIXenPlatformDeviceInfo info;
+} PCIXenPlatformDeviceClass;
+
typedef struct PCIXenPlatformState {
PCIDevice pci_dev;
MemoryRegion fixed_io;
@@ -372,8 +386,13 @@ static const VMStateDescription vmstate_xen_platform = {
static int xen_platform_initfn(PCIDevice *dev)
{
PCIXenPlatformState *d = DO_UPCAST(PCIXenPlatformState, pci_dev, dev);
+ PCIDeviceClass *k = PCI_DEVICE_GET_CLASS(dev);
+ __attribute__((unused)) PCIXenPlatformDeviceClass *u;
uint8_t *pci_conf;
+ u = container_of(k, PCIXenPlatformDeviceClass, parent_class);
+ DPRINTF("initializing %s\n", u->info.name);
+
pci_conf = d->pci_dev.config;
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
@@ -402,33 +421,63 @@ static void platform_reset(DeviceState *dev)
platform_fixed_ioport_reset(s);
}
+static PCIXenPlatformDeviceInfo platform_devices[] = {
+ {
+ .name = "xen-platform",
+ .desc = "XEN platform pci device (version 1)",
+ .device_id = PCI_DEVICE_ID_XEN_PLATFORM,
+ .revision = 1,
+ .subsystem_vendor_id = PCI_VENDOR_ID_XEN,
+ .subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM,
+ }, {
+ .name = "xen-platform-2",
+ .desc = "XEN platform pci device (version 2)",
+ .device_id = PCI_DEVICE_ID_XEN_PLATFORM_V2,
+ .revision = 2,
+ .subsystem_vendor_id = PCI_VENDOR_ID_XEN,
+ .subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM_V2,
+ }
+};
+
static void xen_platform_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+ PCIXenPlatformDeviceInfo *info = data;
+ PCIXenPlatformDeviceClass *u;
+
+ u = container_of(k, PCIXenPlatformDeviceClass, parent_class);
k->init = xen_platform_initfn;
k->vendor_id = PCI_VENDOR_ID_XEN;
- k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
+ k->device_id = info->device_id;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
- k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;
- k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;
- k->revision = 1;
- dc->desc = "XEN platform pci device";
+ k->subsystem_vendor_id = info->subsystem_vendor_id;
+ k->subsystem_id = info->subsystem_id;
+ k->revision = info->revision;
+ dc->desc = info->desc;
dc->reset = platform_reset;
dc->vmsd = &vmstate_xen_platform;
+ u->info = *info;
}
-static const TypeInfo xen_platform_info = {
- .name = "xen-platform",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PCIXenPlatformState),
- .class_init = xen_platform_class_init,
-};
-
static void xen_platform_register_types(void)
{
- type_register_static(&xen_platform_info);
+ TypeInfo type_info = {
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCIXenPlatformState),
+ .class_size = sizeof(PCIXenPlatformDeviceClass),
+ .class_init = xen_platform_class_init,
+ };
+ int i;
+ for (i = 0; i < ARRAY_SIZE(platform_devices); i++) {
+ PCIXenPlatformDeviceInfo *info = &platform_devices[i];
+
+ type_info.name = info->name;
+ type_info.class_data = info;
+
+ type_register(&type_info);
+ }
}
type_init(xen_platform_register_types)
diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
index d8dc2f1..2039fba 100644
--- a/include/hw/pci/pci_ids.h
+++ b/include/hw/pci/pci_ids.h
@@ -144,6 +144,7 @@
#define PCI_VENDOR_ID_XEN 0x5853
#define PCI_DEVICE_ID_XEN_PLATFORM 0x0001
+#define PCI_DEVICE_ID_XEN_PLATFORM_V2 0x0002
#define PCI_VENDOR_ID_NEC 0x1033
#define PCI_DEVICE_ID_NEC_UPD720200 0x0194
--
1.7.10.4
next reply other threads:[~2013-06-19 9:32 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 9:32 Paul Durrant [this message]
2013-06-19 9:42 ` [Qemu-devel] [Xen-devel] [PATCH] Add Xen platform PCI device version 2 Ian Campbell
2013-06-19 9:43 ` Paul Durrant
2013-06-19 10:07 ` Ian Campbell
2013-06-19 10:13 ` Paul Durrant
2013-06-19 10:42 ` Alex Bligh
2013-06-19 11:35 ` Paul Durrant
2013-06-19 18:21 ` Matt Wilson
2013-06-19 20:15 ` Tim Deegan
2013-06-20 7:47 ` Paul Durrant
2013-06-20 8:08 ` Alex Bligh
2013-06-20 8:19 ` Paul Durrant
2013-06-20 8:56 ` Tim Deegan
2013-06-20 9:25 ` Paul Durrant
2013-06-26 10:39 ` Ian Campbell
2013-06-26 11:23 ` Paul Durrant
2013-06-26 11:53 ` Ian Campbell
2013-06-26 11:57 ` Tim Deegan
2013-06-26 12:06 ` Paul Durrant
2013-06-26 12:36 ` Tim Deegan
2013-06-26 13:00 ` Paul Durrant
2013-06-26 20:00 ` Alex Bligh
2013-06-27 8:29 ` Paul Durrant
2013-06-27 10:58 ` Paul Durrant
2013-06-19 10:43 ` Ian Campbell
2013-06-19 10:36 ` Tim Deegan
2013-06-19 11:31 ` Paul Durrant
2013-06-19 16:40 ` Paolo Bonzini
2013-06-26 10:38 ` Ian Campbell
2013-06-19 10:54 ` James Harper
2013-06-19 11:23 ` Paul Durrant
2013-06-19 15:46 ` Tim Deegan
2013-06-19 16:03 ` Paul Durrant
2013-06-19 11:40 ` Paul Durrant
2013-06-20 12:17 ` [Qemu-devel] " Anthony Liguori
2013-06-20 12:44 ` Paul Durrant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371634333-23565-1-git-send-email-paul.durrant@citrix.com \
--to=paul.durrant@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).