On Friday 23 June 2006 14:44, M. Warner Losh wrote: > : I think a better option would be to remove the test in sio.c for the > : AMD64 case since isa_irq_pending() won't do anything. > > I hate #ifdef __amd64__ code. It is evil and should be avoided. > Maybe the right answer is to have a separate ACPI probe routine that > does something similar to the pccard case where we pass 'noprobe = 1' > to the sioprobe routine. If ACPI says there's a sio there, we don't > need to probe for it...
That sounds like a good solution! Better than an ifdef for sure :) How's this diff? Note that I just mangled the uart ACPI attachment and the sio PCCARD one.. -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
Index: sys/conf/files
===================================================================
RCS file: /usr/CVS-Repository/src/sys/conf/files,v
retrieving revision 1.1104
diff -u -r1.1104 files
--- sys/conf/files 23 Mar 2006 23:06:14 -0000 1.1104
+++ sys/conf/files 23 Jun 2006 05:46:57 -0000
@@ -828,6 +828,7 @@
dev/si/si_eisa.c optional si eisa
dev/si/si_isa.c optional si isa
dev/si/si_pci.c optional si pci
+dev/sio/sio_acpi.c optional sio acpi
dev/sio/sio_pccard.c optional sio pccard
dev/sio/sio_pci.c optional sio pci
dev/sio/sio_puc.c optional sio puc pci
Index: sys/modules/sio/Makefile
===================================================================
RCS file: /usr/CVS-Repository/src/sys/modules/sio/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- sys/modules/sio/Makefile 14 Oct 2005 23:30:15 -0000 1.9
+++ sys/modules/sio/Makefile 23 Jun 2006 05:46:32 -0000
@@ -8,7 +8,7 @@
KMOD= sio
SRCS= bus_if.h card_if.h device_if.h isa_if.h pci_if.h \
opt_comconsole.h opt_compat.h opt_gdb.h opt_kdb.h opt_sio.h \
- sio.c sio_pccard.c sio_pci.c sio_puc.c pccarddevs.h
+ sio.c sio_acpi.c sio_pccard.c sio_pci.c sio_puc.c pccarddevs.h
.if ${MACHINE} == "pc98"
SRCS+= sio_cbus.c
.else
Index: sys/dev/sio/sio_acpi.c
===================================================================
RCS file: sys/dev/sio/sio_acpi.c
diff -N sys/dev/sio/sio_acpi.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sys/dev/sio/sio_acpi.c 23 Jun 2006 05:57:03 -0000
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2006 Daniel O'Connor. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/module.h>
+#include <sys/tty.h>
+#include <machine/bus.h>
+#include <sys/timepps.h>
+
+#include <dev/sio/siovar.h>
+
+#include <isa/isareg.h>
+#include <isa/isavar.h>
+
+static int sio_acpi_attach(device_t dev);
+static int sio_acpi_probe(device_t dev);
+
+static device_method_t sio_acpi_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, sio_acpi_probe),
+ DEVMETHOD(device_attach, sio_acpi_attach),
+ DEVMETHOD(device_detach, siodetach),
+
+ { 0, 0 }
+};
+
+static driver_t sio_acpi_driver = {
+ sio_driver_name,
+ sio_acpi_methods,
+ 0,
+};
+
+static struct isa_pnp_id sio_acpi_ids[] = {
+ {0x0005d041, "Standard PC COM port"}, /* PNP0500 */
+ {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */
+ {0}
+};
+
+static int
+sio_acpi_probe(dev)
+ device_t dev;
+{
+ device_t parent;
+
+ parent = device_get_parent(dev);
+
+ if (!ISA_PNP_PROBE(parent, dev, sio_acpi_ids))
+ return (sioprobe(dev, 0, 0UL, 2));
+
+ /* Add checks for non-ns8250 IDs here. */
+ return (ENXIO);
+
+}
+
+static int
+sio_acpi_attach(dev)
+ device_t dev;
+{
+ int err;
+
+ /* Do not probe IRQ - if ACPI says it's there, it is */
+ if ((err = sioprobe(dev, 0, 0UL, 1)) != 0)
+ return (err);
+ return (sioattach(dev, 0, 0UL));
+}
+
+DRIVER_MODULE(sio, acpi, sio_acpi_driver, sio_devclass, 0, 0);
Index: sys/dev/sio/sio_isa.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/dev/sio/sio_isa.c,v
retrieving revision 1.16
diff -u -r1.16 sio_isa.c
--- sys/dev/sio/sio_isa.c 29 May 2005 04:42:25 -0000 1.16
+++ sys/dev/sio/sio_isa.c 23 Jun 2006 05:46:11 -0000
@@ -167,4 +167,3 @@
}
DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
-DRIVER_MODULE(sio, acpi, sio_isa_driver, sio_devclass, 0, 0);
Index: sys/dev/sio/sio.c
===================================================================
RCS file: /usr/CVS-Repository/src/sys/dev/sio/sio.c,v
retrieving revision 1.464
diff -u -r1.464 sio.c
--- sys/dev/sio/sio.c 22 Feb 2006 18:16:25 -0000 1.464
+++ sys/dev/sio/sio.c 23 Jun 2006 06:03:59 -0000
@@ -716,10 +716,12 @@
failures[1] = sio_getreg(com, com_ier) - IER_ETXRDY;
failures[2] = sio_getreg(com, com_mcr) - mcr_image;
DELAY(10000); /* Some internal modems need this time */
- irqmap[1] = isa_irq_pending();
+ if (noprobe < 2)
+ irqmap[1] = isa_irq_pending();
failures[4] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_TXRDY;
DELAY(1000); /* XXX */
- irqmap[2] = isa_irq_pending();
+ if (noprobe < 2)
+ irqmap[2] = isa_irq_pending();
failures[6] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_NOPEND;
/*
@@ -735,26 +737,30 @@
sio_setreg(com, com_cfcr, CFCR_8BITS); /* dummy to avoid bus echo */
failures[7] = sio_getreg(com, com_ier);
DELAY(1000); /* XXX */
- irqmap[3] = isa_irq_pending();
+ if (noprobe < 2)
+ irqmap[3] = isa_irq_pending();
failures[9] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_NOPEND;
mtx_unlock_spin(&sio_lock);
- irqs = irqmap[1] & ~irqmap[0];
- if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
- ((1 << xirq) & irqs) == 0) {
+ if (noprobe < 2) {
+ irqs = irqmap[1] & ~irqmap[0];
+ if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
+ ((1 << xirq) & irqs) == 0) {
printf(
- "sio%d: configured irq %ld not in bitmap of probed irqs %#x\n",
+ "sio%d: configured irq %ld not in bitmap of probed irqs %#x\n",
device_get_unit(dev), xirq, irqs);
printf(
- "sio%d: port may not be enabled\n",
+ "sio%d: port may not be enabled\n",
device_get_unit(dev));
- }
- if (bootverbose)
+ }
+
+ if (bootverbose)
printf("sio%d: irq maps: %#x %#x %#x %#x\n",
- device_get_unit(dev),
- irqmap[0], irqmap[1], irqmap[2], irqmap[3]);
+ device_get_unit(dev),
+ irqmap[0], irqmap[1], irqmap[2], irqmap[3]);
+ }
result = 0;
for (fn = 0; fn < sizeof failures; ++fn)
if (failures[fn]) {
pgpk0UDFeSWJK.pgp
Description: PGP signature
