From patchwork Thu Feb 27 01:05:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 348962 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3A7F6140086 for ; Thu, 15 May 2014 06:01:15 +1000 (EST) Received: from localhost ([::1]:54121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkfMX-0005VI-5J for incoming@patchwork.ozlabs.org; Wed, 14 May 2014 16:01:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkfMA-00057R-DK for qemu-devel@nongnu.org; Wed, 14 May 2014 16:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkfLz-0002DA-T1 for qemu-devel@nongnu.org; Wed, 14 May 2014 16:00:50 -0400 Received: from mono.eik.bme.hu ([152.66.115.2]:51401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkfLz-0002CP-HV; Wed, 14 May 2014 16:00:39 -0400 Received: from mono.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 5126C184CA; Wed, 14 May 2014 22:00:31 +0200 (CEST) Received: by mono.eik.bme.hu (Postfix, from userid 432) id E7E842F456; Wed, 14 May 2014 22:00:30 +0200 (CEST) From: BALATON Zoltan Date: Thu, 27 Feb 2014 02:05:05 +0100 To: qemu-devel@nongnu.org Message-Id: <20140514200030.E7E842F456@mono.eik.bme.hu> X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 152.66.115.2 Cc: qemu-trivial@nongnu.org, Paolo Bonzini , Michael Tokarev , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3] serial-pci: Set prog interface field of pci config to 16550 compatible 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 Signed-off-by: BALATON Zoltan Reviewed-by: Gerd Hoffmann --- v2: resubmission after pc-2.1 is added with the multiport case v3: added compatibility check to avoid changing earlier than pc-2.1 hw/char/serial-pci.c | 11 +++++++++++ include/hw/i386/pc.h | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index 991c99f..ae57098 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -34,6 +34,7 @@ typedef struct PCISerialState { PCIDevice dev; SerialState state; + uint8_t compat; } PCISerialState; typedef struct PCIMultiSerialState { @@ -44,6 +45,7 @@ typedef struct PCIMultiSerialState { SerialState state[PCI_SERIAL_MAX_PORTS]; uint32_t level[PCI_SERIAL_MAX_PORTS]; qemu_irq *irqs; + uint8_t compat; } PCIMultiSerialState; static int serial_pci_init(PCIDevice *dev) @@ -60,6 +62,9 @@ static int serial_pci_init(PCIDevice *dev) return -1; } + if (!pci->compat) { + pci->dev.config[PCI_CLASS_PROG] = 0x02; /* 16550 compatible */ + } pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; s->irq = pci_allocate_irq(&pci->dev); @@ -101,6 +106,9 @@ static int multi_serial_pci_init(PCIDevice *dev) assert(pci->ports > 0); assert(pci->ports <= PCI_SERIAL_MAX_PORTS); + if (!pci->compat) { + pci->dev.config[PCI_CLASS_PROG] = 0x02; /* 16550 compatible */ + } pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports); pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar); @@ -177,12 +185,14 @@ static const VMStateDescription vmstate_pci_multi_serial = { static Property serial_pci_properties[] = { DEFINE_PROP_CHR("chardev", PCISerialState, state.chr), + DEFINE_PROP_UINT8("compat", PCISerialState, compat, 0), DEFINE_PROP_END_OF_LIST(), }; static Property multi_2x_serial_pci_properties[] = { DEFINE_PROP_CHR("chardev1", PCIMultiSerialState, state[0].chr), DEFINE_PROP_CHR("chardev2", PCIMultiSerialState, state[1].chr), + DEFINE_PROP_UINT8("compat", PCIMultiSerialState, compat, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -191,6 +201,7 @@ static Property multi_4x_serial_pci_properties[] = { DEFINE_PROP_CHR("chardev2", PCIMultiSerialState, state[1].chr), DEFINE_PROP_CHR("chardev3", PCIMultiSerialState, state[2].chr), DEFINE_PROP_CHR("chardev4", PCIMultiSerialState, state[3].chr), + DEFINE_PROP_UINT8("compat", PCIMultiSerialState, compat, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 32a7687..8fb8046 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -271,6 +271,21 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "apic",\ .property = "version",\ .value = stringify(0x11),\ + },\ + {\ + .driver = "pci-serial",\ + .property = "compat",\ + .value = stringify(1),\ + },\ + {\ + .driver = "pci-serial-2x",\ + .property = "compat",\ + .value = stringify(1),\ + },\ + {\ + .driver = "pci-serial-4x",\ + .property = "compat",\ + .value = stringify(1),\ } #define PC_COMPAT_1_7 \