Wed Jul 31 14:31:01 2013 UTC ()
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.


(soren)
diff -r1.20 -r1.21 src/sys/dev/pci/com_puc.c
diff -r1.15 -r1.16 src/sys/dev/pci/lpt_puc.c

cvs diff -r1.20 -r1.21 src/sys/dev/pci/com_puc.c (expand / switch to unified diff)

--- src/sys/dev/pci/com_puc.c 2013/07/22 13:42:17 1.20
+++ src/sys/dev/pci/com_puc.c 2013/07/31 14:31:01 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $ */ 1/* $NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. 4 * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Machine-independent ns16x50 serial port ('com') driver attachment to 34 * Machine-independent ns16x50 serial port ('com') driver attachment to
35 * "PCI Universal Communications" controller driver. 35 * "PCI Universal Communications" controller driver.
36 * 36 *
37 * Author: Christopher G. Demetriou, May 17, 1998. 37 * Author: Christopher G. Demetriou, May 17, 1998.
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $");
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/device.h> 45#include <sys/device.h>
46#include <sys/tty.h> 46#include <sys/tty.h>
47 47
48#include <sys/bus.h> 48#include <sys/bus.h>
49 49
50#include <dev/pci/pcivar.h> 50#include <dev/pci/pcivar.h>
51#include <dev/pci/pucvar.h> 51#include <dev/pci/pucvar.h>
52#include <dev/ic/comreg.h> 52#include <dev/ic/comreg.h>
53#include <dev/ic/comvar.h> 53#include <dev/ic/comvar.h>
54#include <dev/pci/cybervar.h> 54#include <dev/pci/cybervar.h>
@@ -80,63 +80,62 @@ com_puc_attach(device_t parent, device_t @@ -80,63 +80,62 @@ com_puc_attach(device_t parent, device_t
80 struct com_puc_softc *psc = device_private(self); 80 struct com_puc_softc *psc = device_private(self);
81 struct com_softc *sc = &psc->sc_com; 81 struct com_softc *sc = &psc->sc_com;
82 struct puc_attach_args *aa = aux; 82 struct puc_attach_args *aa = aux;
83 const char *intrstr; 83 const char *intrstr;
84 84
85 sc->sc_dev = self; 85 sc->sc_dev = self;
86 86
87 aprint_naive(": Serial port"); 87 aprint_naive(": Serial port");
88 aprint_normal(": "); 88 aprint_normal(": ");
89 89
90 COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a); 90 COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a);
91 sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK; 91 sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK;
92 92
93 /* Enable Cyberserial 8X clock. */ 
94 if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) { 
95 int usrregno; 
96 
97 if (aa->flags & PUC_PORT_USR3) usrregno = 3; 
98 else if (aa->flags & PUC_PORT_USR2) usrregno = 2; 
99 else if (aa->flags & PUC_PORT_USR1) usrregno = 1; 
100 else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0; 
101 
102 if (aa->flags & PUC_COM_SIIG10x) 
103 write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1); 
104 else 
105 write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1); 
106 } else { 
107 if (!pmf_device_register(self, NULL, com_resume)) 
108 aprint_error_dev(self, 
109 "couldn't establish power handler\n"); 
110 } 
111 
112 intrstr = pci_intr_string(aa->pc, aa->intrhandle); 93 intrstr = pci_intr_string(aa->pc, aa->intrhandle);
113 psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL, 94 psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL,
114 comintr, sc); 95 comintr, sc);
115 if (psc->sc_ih == NULL) { 96 if (psc->sc_ih == NULL) {
116 aprint_error("couldn't establish interrupt"); 97 aprint_error("couldn't establish interrupt");
117 if (intrstr != NULL) 98 if (intrstr != NULL)
118 aprint_error(" at %s", intrstr); 99 aprint_error(" at %s", intrstr);
119 aprint_error("\n"); 100 aprint_error("\n");
120 return; 101 return;
121 } 102 }
122 103
123#if defined(amd64) || defined(i386) 104#if defined(amd64) || defined(i386)
124 /* 105 /*
125 * Since puc(4) serial ports are typically not identified in the 106 * Since puc(4) serial ports are typically not identified in the
126 * BIOS COM[1234] table, the I/O address must be manually set using 107 * BIOS COM[1234] table, the I/O address must be manually set using
127 * installboot(8) in order to enable a serial console. 108 * installboot(8) in order to enable a serial console.
128 * Print the address here so the user doesn't have to dig through 109 * Print the address here so the user doesn't have to dig through
129 * PCI configuration space to find it. 110 * PCI configuration space to find it.
130 */ 111 */
131 if (aa->h < 0x10000) 112 if (aa->h < 0x10000)
132 aprint_normal("ioaddr 0x%04lx, ", aa->h); 113 aprint_normal("ioaddr 0x%04lx, ", aa->h);
133#endif 114#endif
134 
135 aprint_normal("interrupting at %s\n", intrstr); 115 aprint_normal("interrupting at %s\n", intrstr);
136 aprint_normal("%s", device_xname(self)); 
137 116
 117 /* Enable Cyberserial 8X clock. */
 118 if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) {
 119 int usrregno;
 120
 121 if (aa->flags & PUC_PORT_USR3) usrregno = 3;
 122 else if (aa->flags & PUC_PORT_USR2) usrregno = 2;
 123 else if (aa->flags & PUC_PORT_USR1) usrregno = 1;
 124 else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0;
 125
 126 if (aa->flags & PUC_COM_SIIG10x)
 127 write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1);
 128 else
 129 write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1);
 130 } else {
 131 if (!pmf_device_register(self, NULL, com_resume))
 132 aprint_error_dev(self,
 133 "couldn't establish power handler\n");
 134 }
 135
 136 aprint_normal("%s", device_xname(self));
138 com_attach_subr(sc); 137 com_attach_subr(sc);
139} 138}
140 139
141CFATTACH_DECL_NEW(com_puc, sizeof(struct com_puc_softc), 140CFATTACH_DECL_NEW(com_puc, sizeof(struct com_puc_softc),
142 com_puc_probe, com_puc_attach, NULL, NULL); 141 com_puc_probe, com_puc_attach, NULL, NULL);

cvs diff -r1.15 -r1.16 src/sys/dev/pci/lpt_puc.c (expand / switch to unified diff)

--- src/sys/dev/pci/lpt_puc.c 2013/07/22 13:42:17 1.15
+++ src/sys/dev/pci/lpt_puc.c 2013/07/31 14:31:01 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lpt_puc.c,v 1.15 2013/07/22 13:42:17 soren Exp $ */ 1/* $NetBSD: lpt_puc.c,v 1.16 2013/07/31 14:31:01 soren Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. 4 * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Machine-independent parallel port ('lpt') driver attachment to "PCI 34 * Machine-independent parallel port ('lpt') driver attachment to "PCI
35 * Universal Communications" controller driver. 35 * Universal Communications" controller driver.
36 * 36 *
37 * Author: Christopher G. Demetriou, May 17, 1998. 37 * Author: Christopher G. Demetriou, May 17, 1998.
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.15 2013/07/22 13:42:17 soren Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.16 2013/07/31 14:31:01 soren Exp $");
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/device.h> 45#include <sys/device.h>
46 46
47#include <sys/bus.h> 47#include <sys/bus.h>
48 48
49#include <dev/pci/pcivar.h> 49#include <dev/pci/pcivar.h>
50#include <dev/pci/pucvar.h> 50#include <dev/pci/pucvar.h>
51#include <dev/ic/lptvar.h> 51#include <dev/ic/lptvar.h>
52 52
53static int 53static int
54lpt_puc_probe(device_t parent, cfdata_t match, void *aux) 54lpt_puc_probe(device_t parent, cfdata_t match, void *aux)
@@ -65,33 +65,47 @@ lpt_puc_probe(device_t parent, cfdata_t  @@ -65,33 +65,47 @@ lpt_puc_probe(device_t parent, cfdata_t
65} 65}
66 66
67static void 67static void
68lpt_puc_attach(device_t parent, device_t self, void *aux) 68lpt_puc_attach(device_t parent, device_t self, void *aux)
69{ 69{
70 struct lpt_softc *sc = device_private(self); 70 struct lpt_softc *sc = device_private(self);
71 struct puc_attach_args *aa = aux; 71 struct puc_attach_args *aa = aux;
72 const char *intrstr; 72 const char *intrstr;
73 73
74 sc->sc_dev = self; 74 sc->sc_dev = self;
75 sc->sc_iot = aa->t; 75 sc->sc_iot = aa->t;
76 sc->sc_ioh = aa->h; 76 sc->sc_ioh = aa->h;
77 77
 78 aprint_naive(": Parallel port");
 79 aprint_normal(": ");
 80
78 intrstr = pci_intr_string(aa->pc, aa->intrhandle); 81 intrstr = pci_intr_string(aa->pc, aa->intrhandle);
79 sc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY, 82 sc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY,
80 lptintr, sc); 83 lptintr, sc);
81 if (sc->sc_ih == NULL) { 84 if (sc->sc_ih == NULL) {
82 aprint_error(": couldn't establish interrupt"); 85 aprint_error("couldn't establish interrupt");
83 if (intrstr != NULL) 86 if (intrstr != NULL)
84 aprint_error(" at %s", intrstr); 87 aprint_error(" at %s", intrstr);
85 aprint_error("\n"); 88 aprint_error("\n");
86 return; 89 return;
87 } 90 }
88 aprint_normal(": interrupting at %s\n", intrstr); 
89 91
90 lpt_attach_subr(sc); 92#if defined(amd64) || defined(i386)
 93 /*
 94 * Parallel ports are sometimes used for improvised GPIO by
 95 * userspace programs which need to know the port's I/O address.
 96 * Print the address here so the user doesn't have to dig through
 97 * PCI configuration space to find it.
 98 */
 99 if (aa->h < 0x10000)
 100 aprint_normal("ioaddr 0x%04lx, ", aa->h);
 101#endif
 102 aprint_normal("interrupting at %s\n", intrstr);
91 103
92 if (!pmf_device_register(self, NULL, NULL)) 104 if (!pmf_device_register(self, NULL, NULL))
93 aprint_error_dev(self, "couldn't establish power handler\n"); 105 aprint_error_dev(self, "couldn't establish power handler\n");
 106
 107 lpt_attach_subr(sc);
94} 108}
95 109
96CFATTACH_DECL_NEW(lpt_puc, sizeof(struct lpt_softc), 110CFATTACH_DECL_NEW(lpt_puc, sizeof(struct lpt_softc),
97 lpt_puc_probe, lpt_puc_attach, NULL, NULL); 111 lpt_puc_probe, lpt_puc_attach, NULL, NULL);