From patchwork Fri Apr 20 14:52:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 133889 Delivered-To: patches@linaro.org Received: by 10.46.66.142 with SMTP id h14csp374989ljf; Fri, 20 Apr 2018 07:52:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/dOwYsKNH/kWev17EF5vEyJE3bYNuHm63r+7dGWP918/8hwsz6eWw+vkbVHpWlA8Nj7PHl X-Received: by 2002:adf:b685:: with SMTP id j5-v6mr8551997wre.10.1524235978311; Fri, 20 Apr 2018 07:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524235978; cv=none; d=google.com; s=arc-20160816; b=Reb9UTmQ+XokgqYji2XKUIVbJW9o2mOYLYFZBys9UQscUqKXLuOzWUBDAXzUEgAh8E UoZxj11Lehf1KOuUjk1ha7jWzQwnXu1B7VPlpL9UDUChnxsApdmGCOwVUHzfUd7DKqIK mShBXnbogGs0J4LIwDY4EkHWc5D34jvCToSg7z9dtMI++wnYg6O4mKxwf273Fcuwpqrg J7Xgmrsgfmcfphgvb0W3fdrVjH8RT2E58JonSbJc0cru0HHeLD9dFWYeedzIUS6E3msl hY9HV/0bXoHi8J8C246E4W4OVB1AVs5j4JjVDDntWMoRiLGEafkzyPjT0IPojLmM+rjl cPjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=a77bDVwFmi+Y0vaOpuXIqo2ipQf7XO7Z89aiAxfma3U=; b=CjSfxCiMY9HaNOd4U1p8mk98pv9IJ/EnrCy9tJWnlbASEW9ph82mzq+sEN6O3PCAqW XCdFVHPohN+D0fV12h8tswpE/wkpexBF9d4ZFschXFEwCndMX1onxieLcGfjGVyC8h7E HoPertlucFque4C05QZh4NQJb2mMRgA10cVUf7E9r77+01wFuZIqFGS4RdVeLfMk+6BW 70XSLGLwQyrO7P91osj1sqGLrCLL2THIfTYUEoHuOQhMSmi9mmjzG2pXpY7x7Vr8gOPD dqpC+z0UeJyNpcPHA8t4mGU4tOoHR1gjm1gmLC1iRQRxRPoywDOvDcGFD6ZCv7cROVSj Eksw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id w9-v6si4914063wrg.13.2018.04.20.07.52.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Apr 2018 07:52:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f9XPF-0006bT-QH; Fri, 20 Apr 2018 15:52:57 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, "Michael S . Tsirkin" , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH 10/13] serial-isa: Use MAX_ISA_SERIAL_PORTS instead of MAX_SERIAL_PORTS Date: Fri, 20 Apr 2018 15:52:46 +0100 Message-Id: <20180420145249.32435-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420145249.32435-1-peter.maydell@linaro.org> References: <20180420145249.32435-1-peter.maydell@linaro.org> The ISA serial port handling in serial-isa.c imposes a limit of 4 serial ports. This is because we only know of 4 IO port and IRQ settings for them, and is unrelated to the generic MAX_SERIAL_PORTS limit, though they happen to both be set at 4 currently. Use a new MAX_ISA_SERIAL_PORTS wherever that is the correct limit to be checking against. Signed-off-by: Peter Maydell --- include/hw/char/serial.h | 3 +++ hw/char/serial-isa.c | 10 +++++----- hw/i386/pc.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/ppc/pnv.c | 2 +- hw/sparc64/sun4u.c | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) -- 2.17.0 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index c4daf11a14..0acfbbc382 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -95,6 +95,9 @@ SerialState *serial_mm_init(MemoryRegion *address_space, Chardev *chr, enum device_endian end); /* serial-isa.c */ + +#define MAX_ISA_SERIAL_PORTS 4 + #define TYPE_ISA_SERIAL "isa-serial" void serial_hds_isa_init(ISABus *bus, int from, int to); diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index eb5996159d..116b7b2e69 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -39,10 +39,10 @@ typedef struct ISASerialState { SerialState state; } ISASerialState; -static const int isa_serial_io[MAX_SERIAL_PORTS] = { +static const int isa_serial_io[MAX_ISA_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; -static const int isa_serial_irq[MAX_SERIAL_PORTS] = { +static const int isa_serial_irq[MAX_ISA_SERIAL_PORTS] = { 4, 3, 4, 3 }; @@ -56,9 +56,9 @@ static void serial_isa_realizefn(DeviceState *dev, Error **errp) if (isa->index == -1) { isa->index = index; } - if (isa->index >= MAX_SERIAL_PORTS) { + if (isa->index >= MAX_ISA_SERIAL_PORTS) { error_setg(errp, "Max. supported number of ISA serial ports is %d.", - MAX_SERIAL_PORTS); + MAX_ISA_SERIAL_PORTS); return; } if (isa->iobase == -1) { @@ -138,7 +138,7 @@ void serial_hds_isa_init(ISABus *bus, int from, int to) int i; assert(from >= 0); - assert(to <= MAX_SERIAL_PORTS); + assert(to <= MAX_ISA_SERIAL_PORTS); for (i = from; i < to; ++i) { if (serial_hd(i)) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d36bac8c89..b297a5d63b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1524,7 +1524,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) qemu_irq *a20_line; ISADevice *i8042, *port92, *vmmouse; - serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS); + serial_hds_isa_init(isa_bus, 0, MAX_ISA_SERIAL_PORTS); parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS); for (i = 0; i < MAX_FD; i++) { diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c index aeadc4a340..e04b49d3c5 100644 --- a/hw/mips/mips_r4k.c +++ b/hw/mips/mips_r4k.c @@ -274,7 +274,7 @@ void mips_r4k_init(MachineState *machine) pit = i8254_pit_init(isa_bus, 0x40, 0, NULL); - serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS); + serial_hds_isa_init(isa_bus, 0, MAX_ISA_SERIAL_PORTS); isa_vga_init(isa_bus); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 98ee3c607a..549cfccdcb 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -648,7 +648,7 @@ static void pnv_init(MachineState *machine) pnv->isa_bus = pnv_isa_create(pnv->chips[0]); /* Create serial port */ - serial_hds_isa_init(pnv->isa_bus, 0, MAX_SERIAL_PORTS); + serial_hds_isa_init(pnv->isa_bus, 0, MAX_ISA_SERIAL_PORTS); /* Create an RTC ISA device too */ mc146818_rtc_init(pnv->isa_bus, 2000, NULL); diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 9b441f704b..1bede85370 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -298,7 +298,7 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp) 0, NULL, 115200, serial_hd(i), DEVICE_BIG_ENDIAN); i++; } - serial_hds_isa_init(s->isa_bus, i, MAX_SERIAL_PORTS); + serial_hds_isa_init(s->isa_bus, i, MAX_ISA_SERIAL_PORTS); /* Parallel ports */ parallel_hds_isa_init(s->isa_bus, MAX_PARALLEL_PORTS);