Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci On x86, print the I/O address of lpt_puc as for ...



details:   https://anonhg.NetBSD.org/src/rev/b4440a8e084c
branches:  trunk
changeset: 788963:b4440a8e084c
user:      soren <soren%NetBSD.org@localhost>
date:      Wed Jul 31 14:31:01 2013 +0000

description:
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.

diffstat:

 sys/dev/pci/com_puc.c |  45 ++++++++++++++++++++++-----------------------
 sys/dev/pci/lpt_puc.c |  24 +++++++++++++++++++-----
 2 files changed, 41 insertions(+), 28 deletions(-)

diffs (133 lines):

diff -r bf620759a56e -r b4440a8e084c sys/dev/pci/com_puc.c
--- a/sys/dev/pci/com_puc.c     Wed Jul 31 14:05:33 2013 +0000
+++ b/sys/dev/pci/com_puc.c     Wed Jul 31 14:31:01 2013 +0000
@@ -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_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 @@
        if (aa->h < 0x10000)
                aprint_normal("ioaddr 0x%04lx, ", aa->h);
 #endif
+       aprint_normal("interrupting at %s\n", intrstr);
 
-       aprint_normal("interrupting at %s\n", intrstr);
+       /* 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);
 }
 
diff -r bf620759a56e -r b4440a8e084c sys/dev/pci/lpt_puc.c
--- a/sys/dev/pci/lpt_puc.c     Wed Jul 31 14:05:33 2013 +0000
+++ b/sys/dev/pci/lpt_puc.c     Wed Jul 31 14:31:01 2013 +0000
@@ -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 @@
        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),



Home | Main Index | Thread Index | Old Index