Module Name:    src
Committed By:   soren
Date:           Wed Jul 31 14:31:01 UTC 2013

Modified Files:
        src/sys/dev/pci: com_puc.c lpt_puc.c

Log Message:
On x86, print the I/O address of lpt_puc as for com_puc so that hacks
using iopl/ioperm can be told where to find the parallel port.

Closes PR kern/43683.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/com_puc.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/lpt_puc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/com_puc.c
diff -u src/sys/dev/pci/com_puc.c:1.20 src/sys/dev/pci/com_puc.c:1.21
--- src/sys/dev/pci/com_puc.c:1.20	Mon Jul 22 13:42:17 2013
+++ src/sys/dev/pci/com_puc.c	Wed Jul 31 14:31:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $	*/
+/*	$NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -90,25 +90,6 @@ com_puc_attach(device_t parent, device_t
 	COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a);
 	sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK;
 
-	/* Enable Cyberserial 8X clock. */
-	if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) {
-		int usrregno;
-
-		if	(aa->flags & PUC_PORT_USR3) usrregno = 3;
-		else if (aa->flags & PUC_PORT_USR2) usrregno = 2;
-		else if (aa->flags & PUC_PORT_USR1) usrregno = 1;
-		else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0;
-
-		if (aa->flags & PUC_COM_SIIG10x)
-			write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1);
-		else
-			write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1);
-	} else {
-		if (!pmf_device_register(self, NULL, com_resume))
-			aprint_error_dev(self,
-			    "couldn't establish power handler\n");
-	}
-
 	intrstr = pci_intr_string(aa->pc, aa->intrhandle);
 	psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL,
 	    comintr, sc);
@@ -131,10 +112,28 @@ com_puc_attach(device_t parent, device_t
 	if (aa->h < 0x10000)
 		aprint_normal("ioaddr 0x%04lx, ", aa->h);
 #endif
-
 	aprint_normal("interrupting at %s\n", intrstr);
-	aprint_normal("%s", device_xname(self));
 
+	/* Enable Cyberserial 8X clock. */
+	if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) {
+		int usrregno;
+
+		if	(aa->flags & PUC_PORT_USR3) usrregno = 3;
+		else if (aa->flags & PUC_PORT_USR2) usrregno = 2;
+		else if (aa->flags & PUC_PORT_USR1) usrregno = 1;
+		else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0;
+
+		if (aa->flags & PUC_COM_SIIG10x)
+			write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1);
+		else
+			write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1);
+	} else {
+		if (!pmf_device_register(self, NULL, com_resume))
+			aprint_error_dev(self,
+			    "couldn't establish power handler\n");
+	}
+
+	aprint_normal("%s", device_xname(self));
 	com_attach_subr(sc);
 }
 

Index: src/sys/dev/pci/lpt_puc.c
diff -u src/sys/dev/pci/lpt_puc.c:1.15 src/sys/dev/pci/lpt_puc.c:1.16
--- src/sys/dev/pci/lpt_puc.c:1.15	Mon Jul 22 13:42:17 2013
+++ src/sys/dev/pci/lpt_puc.c	Wed Jul 31 14:31:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: lpt_puc.c,v 1.15 2013/07/22 13:42:17 soren Exp $	*/
+/*	$NetBSD: lpt_puc.c,v 1.16 2013/07/31 14:31:01 soren Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.15 2013/07/22 13:42:17 soren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.16 2013/07/31 14:31:01 soren Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -75,22 +75,36 @@ lpt_puc_attach(device_t parent, device_t
 	sc->sc_iot = aa->t;
 	sc->sc_ioh = aa->h;
 
+	aprint_naive(": Parallel port");
+	aprint_normal(": ");
+
 	intrstr = pci_intr_string(aa->pc, aa->intrhandle);
 	sc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY,
 	    lptintr, sc);
 	if (sc->sc_ih == NULL) {
-		aprint_error(": couldn't establish interrupt");
+		aprint_error("couldn't establish interrupt");
 		if (intrstr != NULL)
 			aprint_error(" at %s", intrstr);
 		aprint_error("\n");
 		return;
 	}
-	aprint_normal(": interrupting at %s\n", intrstr);
 
-	lpt_attach_subr(sc);
+#if defined(amd64) || defined(i386)
+	/*
+	 * Parallel ports are sometimes used for improvised GPIO by
+	 * userspace programs which need to know the port's I/O address.
+	 * Print the address here so the user doesn't have to dig through
+	 * PCI configuration space to find it.
+	*/
+	if (aa->h < 0x10000)
+		aprint_normal("ioaddr 0x%04lx, ", aa->h);
+#endif
+	aprint_normal("interrupting at %s\n", intrstr);
 
 	if (!pmf_device_register(self, NULL, NULL))
 		aprint_error_dev(self, "couldn't establish power handler\n");
+
+	lpt_attach_subr(sc);
 }
 
 CFATTACH_DECL_NEW(lpt_puc, sizeof(struct lpt_softc),

Reply via email to