From patchwork Wed Jun 19 09:32:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 252533 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 396902C02AC for ; Wed, 19 Jun 2013 19:32:50 +1000 (EST) Received: from localhost ([::1]:58998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpEky-0005om-4X for incoming@patchwork.ozlabs.org; Wed, 19 Jun 2013 05:32:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpEkd-0005hR-5G for qemu-devel@nongnu.org; Wed, 19 Jun 2013 05:32:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpEkX-0001l5-VX for qemu-devel@nongnu.org; Wed, 19 Jun 2013 05:32:27 -0400 Received: from smtp.citrix.com ([66.165.176.89]:46108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpEkX-0001kv-Pq for qemu-devel@nongnu.org; Wed, 19 Jun 2013 05:32:21 -0400 X-IronPort-AV: E=Sophos;i="4.87,895,1363132800"; d="scan'208";a="32058450" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/AES128-SHA; 19 Jun 2013 09:32:20 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Wed, 19 Jun 2013 05:32:19 -0400 Received: from york.uk.xensource.com ([10.80.228.45] helo=york.uk.xensource.com.) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1UpEkV-0003X0-6t; Wed, 19 Jun 2013 10:32:19 +0100 From: Paul Durrant To: , Date: Wed, 19 Jun 2013 10:32:13 +0100 Message-ID: <1371634333-23565-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Cc: Paul Durrant Subject: [Qemu-devel] [PATCH] Add Xen platform PCI device version 2. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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