11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
24
25
26 /*
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 #pragma ident "%Z%%M% %I% %E% SMI" /* from S5R4 1.13 */
32
33 /*
34 * Description:
35 *
36 * The PTEM streams module is used as a pseudo driver emulator. Its purpose
37 * is to emulate the ioctl() functions of a terminal device driver.
38 */
39
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/stream.h>
43 #include <sys/stropts.h>
44 #include <sys/strsun.h>
45 #include <sys/termio.h>
46 #include <sys/pcb.h>
47 #include <sys/signal.h>
48 #include <sys/cred.h>
49 #include <sys/strtty.h>
50 #include <sys/errno.h>
51 #include <sys/cmn_err.h>
52 #include <sys/jioctl.h>
89
90 int
91 _info(struct modinfo *modinfop)
92 {
93 return (mod_info(&modlinkage, modinfop));
94 }
95
96 /*
97 * stream data structure definitions
98 */
99 static int ptemopen(queue_t *, dev_t *, int, int, cred_t *);
100 static int ptemclose(queue_t *, int, cred_t *);
101 static void ptemrput(queue_t *, mblk_t *);
102 static void ptemwput(queue_t *, mblk_t *);
103 static void ptemwsrv(queue_t *);
104
105 static struct module_info ptem_info = {
106 0xabcd,
107 "ptem",
108 0,
109 512,
110 512,
111 128
112 };
113
114 static struct qinit ptemrinit = {
115 (int (*)()) ptemrput,
116 NULL,
117 ptemopen,
118 ptemclose,
119 NULL,
120 &ptem_info,
121 NULL
122 };
123
124 static struct qinit ptemwinit = {
125 (int (*)()) ptemwput,
126 (int (*)()) ptemwsrv,
127 ptemopen,
128 ptemclose,
129 nulldev,
130 &ptem_info,
184 */
185 if ((ntp->dack_ptr = allocb(4, BPRI_MED)) == NULL) {
186 kmem_free(ntp, sizeof (*ntp));
187 return (EAGAIN);
188 }
189
190 /*
191 * Initialize an M_SETOPTS message to set up hi/lo water marks on
192 * stream head read queue and add controlling tty if not set.
193 */
194 mop = allocb(sizeof (struct stroptions), BPRI_MED);
195 if (mop == NULL) {
196 freemsg(ntp->dack_ptr);
197 kmem_free(ntp, sizeof (*ntp));
198 return (EAGAIN);
199 }
200 mop->b_datap->db_type = M_SETOPTS;
201 mop->b_wptr += sizeof (struct stroptions);
202 sop = (struct stroptions *)mop->b_rptr;
203 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
204 sop->so_hiwat = 512;
205 sop->so_lowat = 256;
206
207 /*
208 * Cross-link.
209 */
210 ntp->q_ptr = q;
211 q->q_ptr = ntp;
212 WR(q)->q_ptr = ntp;
213
214 /*
215 * Get termios defaults. These are stored as
216 * a property in the "options" node.
217 */
218 if (ddi_getlongprop(DDI_DEV_T_ANY, ddi_root_node(), 0, "ttymodes",
219 (caddr_t)&termiosp, &len) == DDI_PROP_SUCCESS &&
220 len == sizeof (struct termios)) {
221
222 ntp->cflags = termiosp->c_cflag;
223 kmem_free(termiosp, len);
224 } else {
465
466 case TIOCSWINSZ:
467 ptioc(q, mp, WRSIDE);
468 break;
469
470 case JWINSIZE:
471 case TIOCGWINSZ:
472 mioc2ack(mp, NULL, 0, 0);
473 qreply(q, mp);
474 break;
475
476 default:
477 freemsg(mp);
478 }
479 break;
480
481 case M_FLUSH:
482 if (*mp->b_rptr & FLUSHW) {
483 if ((ntp->state & IS_PTSTTY) &&
484 (*mp->b_rptr & FLUSHBAND))
485 flushband(q, *(mp->b_rptr + 1), FLUSHDATA);
486 else
487 flushq(q, FLUSHDATA);
488 }
489 putnext(q, mp);
490 break;
491
492 case M_READ:
493 freemsg(mp);
494 break;
495
496 case M_STOP:
497 /*
498 * Set the output flow control state.
499 */
500 ntp->state |= OFLOW_CTL;
501 putnext(q, mp);
502 break;
503
504 case M_START:
505 /*
|
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
24
25
26 /*
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 /*
32 * Description:
33 *
34 * The PTEM streams module is used as a pseudo driver emulator. Its purpose
35 * is to emulate the ioctl() functions of a terminal device driver.
36 */
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/stream.h>
41 #include <sys/stropts.h>
42 #include <sys/strsun.h>
43 #include <sys/termio.h>
44 #include <sys/pcb.h>
45 #include <sys/signal.h>
46 #include <sys/cred.h>
47 #include <sys/strtty.h>
48 #include <sys/errno.h>
49 #include <sys/cmn_err.h>
50 #include <sys/jioctl.h>
87
88 int
89 _info(struct modinfo *modinfop)
90 {
91 return (mod_info(&modlinkage, modinfop));
92 }
93
94 /*
95 * stream data structure definitions
96 */
97 static int ptemopen(queue_t *, dev_t *, int, int, cred_t *);
98 static int ptemclose(queue_t *, int, cred_t *);
99 static void ptemrput(queue_t *, mblk_t *);
100 static void ptemwput(queue_t *, mblk_t *);
101 static void ptemwsrv(queue_t *);
102
103 static struct module_info ptem_info = {
104 0xabcd,
105 "ptem",
106 0,
107 _TTY_BUFSIZ,
108 _TTY_BUFSIZ,
109 128
110 };
111
112 static struct qinit ptemrinit = {
113 (int (*)()) ptemrput,
114 NULL,
115 ptemopen,
116 ptemclose,
117 NULL,
118 &ptem_info,
119 NULL
120 };
121
122 static struct qinit ptemwinit = {
123 (int (*)()) ptemwput,
124 (int (*)()) ptemwsrv,
125 ptemopen,
126 ptemclose,
127 nulldev,
128 &ptem_info,
182 */
183 if ((ntp->dack_ptr = allocb(4, BPRI_MED)) == NULL) {
184 kmem_free(ntp, sizeof (*ntp));
185 return (EAGAIN);
186 }
187
188 /*
189 * Initialize an M_SETOPTS message to set up hi/lo water marks on
190 * stream head read queue and add controlling tty if not set.
191 */
192 mop = allocb(sizeof (struct stroptions), BPRI_MED);
193 if (mop == NULL) {
194 freemsg(ntp->dack_ptr);
195 kmem_free(ntp, sizeof (*ntp));
196 return (EAGAIN);
197 }
198 mop->b_datap->db_type = M_SETOPTS;
199 mop->b_wptr += sizeof (struct stroptions);
200 sop = (struct stroptions *)mop->b_rptr;
201 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
202 sop->so_hiwat = _TTY_BUFSIZ;
203 sop->so_lowat = 256;
204
205 /*
206 * Cross-link.
207 */
208 ntp->q_ptr = q;
209 q->q_ptr = ntp;
210 WR(q)->q_ptr = ntp;
211
212 /*
213 * Get termios defaults. These are stored as
214 * a property in the "options" node.
215 */
216 if (ddi_getlongprop(DDI_DEV_T_ANY, ddi_root_node(), 0, "ttymodes",
217 (caddr_t)&termiosp, &len) == DDI_PROP_SUCCESS &&
218 len == sizeof (struct termios)) {
219
220 ntp->cflags = termiosp->c_cflag;
221 kmem_free(termiosp, len);
222 } else {
463
464 case TIOCSWINSZ:
465 ptioc(q, mp, WRSIDE);
466 break;
467
468 case JWINSIZE:
469 case TIOCGWINSZ:
470 mioc2ack(mp, NULL, 0, 0);
471 qreply(q, mp);
472 break;
473
474 default:
475 freemsg(mp);
476 }
477 break;
478
479 case M_FLUSH:
480 if (*mp->b_rptr & FLUSHW) {
481 if ((ntp->state & IS_PTSTTY) &&
482 (*mp->b_rptr & FLUSHBAND))
483 flushband(q, *(mp->b_rptr + 1),
484 FLUSHDATA);
485 else
486 flushq(q, FLUSHDATA);
487 }
488 putnext(q, mp);
489 break;
490
491 case M_READ:
492 freemsg(mp);
493 break;
494
495 case M_STOP:
496 /*
497 * Set the output flow control state.
498 */
499 ntp->state |= OFLOW_CTL;
500 putnext(q, mp);
501 break;
502
503 case M_START:
504 /*
|