From patchwork Mon Jun 6 16:20:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 98992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E9F71B6FAC for ; Tue, 7 Jun 2011 04:53:44 +1000 (EST) Received: from localhost ([::1]:50716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTevl-00086X-7Q for incoming@patchwork.ozlabs.org; Mon, 06 Jun 2011 14:53:41 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTcZn-0002cN-JT for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTcZj-00038U-Em for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:22:50 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:42906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTcZi-000380-Pa for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:22:47 -0400 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id 8CB081910E25B; Mon, 6 Jun 2011 18:21:03 +0200 (CEST) Received: from [87.173.123.2] (helo=af.local) by smtp06.web.de with asmtp (WEB.DE 4.110 #2) id 1QTcY3-00089p-00; Mon, 06 Jun 2011 18:21:03 +0200 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2011 18:20:54 +0200 Message-Id: <1307377259-41434-6-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1307377259-41434-5-git-send-email-andreas.faerber@web.de> References: <1307377259-41434-1-git-send-email-andreas.faerber@web.de> <1307377259-41434-2-git-send-email-andreas.faerber@web.de> <1307377259-41434-3-git-send-email-andreas.faerber@web.de> <1307377259-41434-4-git-send-email-andreas.faerber@web.de> <1307377259-41434-5-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 X-Sender: Andreas.Faerber@web.de X-Provags-ID: V01U2FsdGVkX18my6qNaHXHx23E7R4zaAWEvd7wAqUUcFpKd8KS Vt1xF22hJpEx8KhVMztEyiNdoTosZ3FQ1LEQdXMMfW/ZMw95UV 5Nbo7WzOz4Vonew4B1kA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.221 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , hpoussin@reactos.org, kraxel@redhat.com Subject: [Qemu-devel] [RFC 05/10] serial: Allow to reconfigure ISA I/O base 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: Andreas Färber --- hw/isa.h | 3 +++ hw/serial.c | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/hw/isa.h b/hw/isa.h index 54698b5..8bd082a 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -45,6 +45,9 @@ void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size); void parallel_isa_reconfigure_iobase(ISADevice *dev, uint32_t base); void parallel_isa_reconfigure_irq(ISADevice *dev, uint32_t isairq); +/* serial.c */ +void serial_isa_reconfigure_iobase(ISADevice *dev, uint32_t base); + /* dma.c */ int DMA_get_channel_mode (int nchan); int DMA_read_memory (int nchan, void *buf, int pos, int size); diff --git a/hw/serial.c b/hw/serial.c index 0ee61dd..dd91272 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -752,6 +752,25 @@ void serial_set_frequency(SerialState *s, uint32_t frequency) serial_update_parameters(s); } +static void serial_isa_init_iobase(ISASerialState *isa) +{ + SerialState *s = &isa->state; + + register_ioport_write(isa->iobase, 8, 1, serial_ioport_write, s); + register_ioport_read(isa->iobase, 8, 1, serial_ioport_read, s); + isa_init_ioport_range(&isa->dev, isa->iobase, 8); +} + +void serial_isa_reconfigure_iobase(ISADevice *dev, uint32_t iobase) +{ + ISASerialState *isa = DO_UPCAST(ISASerialState, dev, dev); + + if (iobase != isa->iobase) { + isa->iobase = iobase; + serial_isa_init_iobase(isa); + } +} + static const int isa_serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; static const int isa_serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 }; @@ -776,9 +795,7 @@ static int serial_isa_initfn(ISADevice *dev) serial_init_core(s); qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 3); - register_ioport_write(isa->iobase, 8, 1, serial_ioport_write, s); - register_ioport_read(isa->iobase, 8, 1, serial_ioport_read, s); - isa_init_ioport_range(dev, isa->iobase, 8); + serial_isa_init_iobase(isa); return 0; }