122 #ifdef DEBUG
123 int pts_debug = 0;
124 #define DBG(a) if (pts_debug) cmn_err(CE_NOTE, a)
125 #else
126 #define DBG(a)
127 #endif
128
129 static int ptsopen(queue_t *, dev_t *, int, int, cred_t *);
130 static int ptsclose(queue_t *, int, cred_t *);
131 static void ptswput(queue_t *, mblk_t *);
132 static void ptsrsrv(queue_t *);
133 static void ptswsrv(queue_t *);
134
135 /*
136 * Slave Stream Pseudo Terminal Module: stream data structure definitions
137 */
138 static struct module_info pts_info = {
139 0xface,
140 "pts",
141 0,
142 512,
143 512,
144 128
145 };
146
147 static struct qinit ptsrint = {
148 NULL,
149 (int (*)()) ptsrsrv,
150 ptsopen,
151 ptsclose,
152 NULL,
153 &pts_info,
154 NULL
155 };
156
157 static struct qinit ptswint = {
158 (int (*)()) ptswput,
159 (int (*)()) ptswsrv,
160 NULL,
161 NULL,
162 NULL,
163 &pts_info,
392 * After qprocson pts driver is fully plumbed into the stream and can
393 * send/receive messages. Setting pts_rdq will allow master side to send
394 * messages to the slave. This setting can't occur before qprocson() is
395 * finished because slave is not ready to process them.
396 */
397 PT_ENTER_WRITE(ptsp);
398 ptsp->pts_rdq = rqp;
399 ASSERT(ptsp->pt_nullmsg == NULL);
400 ptsp->pt_nullmsg = mp;
401 PT_EXIT_WRITE(ptsp);
402
403 /*
404 * set up hi/lo water marks on stream head read queue
405 * and add controlling tty if not set
406 */
407
408 mop->b_datap->db_type = M_SETOPTS;
409 mop->b_wptr += sizeof (struct stroptions);
410 sop = (struct stroptions *)mop->b_rptr;
411 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
412 sop->so_hiwat = 512;
413 sop->so_lowat = 256;
414 putnext(rqp, mop);
415
416 return (0);
417 }
418
419
420
421 /*
422 * Find the address to private data identifying the slave's write
423 * queue. Send a 0-length msg up the slave's read queue to designate
424 * the master is closing. Uattach the master from the slave by nulling
425 * out master's write queue field in private data.
426 */
427 /*ARGSUSED1*/
428 static int
429 ptsclose(queue_t *rqp, int flag, cred_t *credp)
430 {
431 struct pt_ttys *ptsp;
432 queue_t *wqp;
|
122 #ifdef DEBUG
123 int pts_debug = 0;
124 #define DBG(a) if (pts_debug) cmn_err(CE_NOTE, a)
125 #else
126 #define DBG(a)
127 #endif
128
129 static int ptsopen(queue_t *, dev_t *, int, int, cred_t *);
130 static int ptsclose(queue_t *, int, cred_t *);
131 static void ptswput(queue_t *, mblk_t *);
132 static void ptsrsrv(queue_t *);
133 static void ptswsrv(queue_t *);
134
135 /*
136 * Slave Stream Pseudo Terminal Module: stream data structure definitions
137 */
138 static struct module_info pts_info = {
139 0xface,
140 "pts",
141 0,
142 _TTY_BUFSIZ,
143 _TTY_BUFSIZ,
144 128
145 };
146
147 static struct qinit ptsrint = {
148 NULL,
149 (int (*)()) ptsrsrv,
150 ptsopen,
151 ptsclose,
152 NULL,
153 &pts_info,
154 NULL
155 };
156
157 static struct qinit ptswint = {
158 (int (*)()) ptswput,
159 (int (*)()) ptswsrv,
160 NULL,
161 NULL,
162 NULL,
163 &pts_info,
392 * After qprocson pts driver is fully plumbed into the stream and can
393 * send/receive messages. Setting pts_rdq will allow master side to send
394 * messages to the slave. This setting can't occur before qprocson() is
395 * finished because slave is not ready to process them.
396 */
397 PT_ENTER_WRITE(ptsp);
398 ptsp->pts_rdq = rqp;
399 ASSERT(ptsp->pt_nullmsg == NULL);
400 ptsp->pt_nullmsg = mp;
401 PT_EXIT_WRITE(ptsp);
402
403 /*
404 * set up hi/lo water marks on stream head read queue
405 * and add controlling tty if not set
406 */
407
408 mop->b_datap->db_type = M_SETOPTS;
409 mop->b_wptr += sizeof (struct stroptions);
410 sop = (struct stroptions *)mop->b_rptr;
411 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
412 sop->so_hiwat = _TTY_BUFSIZ;
413 sop->so_lowat = 256;
414 putnext(rqp, mop);
415
416 return (0);
417 }
418
419
420
421 /*
422 * Find the address to private data identifying the slave's write
423 * queue. Send a 0-length msg up the slave's read queue to designate
424 * the master is closing. Uattach the master from the slave by nulling
425 * out master's write queue field in private data.
426 */
427 /*ARGSUSED1*/
428 static int
429 ptsclose(queue_t *rqp, int flag, cred_t *credp)
430 {
431 struct pt_ttys *ptsp;
432 queue_t *wqp;
|