198 /*
199 * This macro converts a zc_state_t pointer to the associated slave minor node's
200 * dev_t.
201 */
202 #define ZC_STATE_TO_SLAVEDEV(x) (makedevice(ddi_driver_major((x)->zc_devinfo), \
203 (minor_t)(ddi_get_instance((x)->zc_devinfo) << 1 | ZC_SLAVE_MINOR)))
204
205 int zcons_debug = 0;
206 #define DBG(a) if (zcons_debug) cmn_err(CE_NOTE, a)
207 #define DBG1(a, b) if (zcons_debug) cmn_err(CE_NOTE, a, b)
208
209
210 /*
211 * Zone Console Pseudo Terminal Module: stream data structure definitions
212 */
213 static struct module_info zc_info = {
214 31337, /* c0z we r hAx0rs */
215 "zcons",
216 0,
217 INFPSZ,
218 2048,
219 128
220 };
221
222 static struct qinit zc_rinit = {
223 NULL,
224 (int (*)()) zc_rsrv,
225 zc_open,
226 zc_close,
227 NULL,
228 &zc_info,
229 NULL
230 };
231
232 static struct qinit zc_winit = {
233 (int (*)()) zc_wput,
234 (int (*)()) zc_wsrv,
235 NULL,
236 NULL,
237 NULL,
238 &zc_info,
484 /*
485 * Following qprocson(), the master side is fully plumbed into the
486 * STREAM and may send/receive messages. Setting zcs->zc_master_rdq
487 * will allow the slave to send messages to us (the master).
488 * This cannot occur before qprocson() because the master is not
489 * ready to process them until that point.
490 */
491 zcs->zc_master_rdq = rqp;
492
493 /*
494 * set up hi/lo water marks on stream head read queue and add
495 * controlling tty as needed.
496 */
497 mop->b_datap->db_type = M_SETOPTS;
498 mop->b_wptr += sizeof (struct stroptions);
499 sop = (struct stroptions *)(void *)mop->b_rptr;
500 if (oflag & FNOCTTY)
501 sop->so_flags = SO_HIWAT | SO_LOWAT;
502 else
503 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
504 sop->so_hiwat = 512;
505 sop->so_lowat = 256;
506 putnext(rqp, mop);
507
508 return (0);
509 }
510
511 /*ARGSUSED*/
512 static int
513 zc_slave_open(zc_state_t *zcs,
514 queue_t *rqp, /* pointer to the read side queue */
515 dev_t *devp, /* pointer to stream tail's dev */
516 int oflag, /* the user open(2) supplied flags */
517 int sflag, /* open state flag */
518 cred_t *credp) /* credentials */
519 {
520 mblk_t *mop;
521 struct stroptions *sop;
522 major_t major;
523 minor_t minor;
524 minor_t lastminor;
559 * q_ptr stores driver private data; stash the soft state data on both
560 * read and write sides of the queue.
561 */
562 WR(rqp)->q_ptr = rqp->q_ptr = zcs;
563
564 qprocson(rqp);
565
566 /*
567 * Must follow qprocson(), since we aren't ready to process until then.
568 */
569 zcs->zc_slave_rdq = rqp;
570
571 /*
572 * set up hi/lo water marks on stream head read queue and add
573 * controlling tty as needed.
574 */
575 mop->b_datap->db_type = M_SETOPTS;
576 mop->b_wptr += sizeof (struct stroptions);
577 sop = (struct stroptions *)(void *)mop->b_rptr;
578 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
579 sop->so_hiwat = 512;
580 sop->so_lowat = 256;
581 putnext(rqp, mop);
582
583 return (0);
584 }
585
586 /*
587 * open(9e) entrypoint; checks sflag, and rejects anything unordinary.
588 */
589 static int
590 zc_open(queue_t *rqp, /* pointer to the read side queue */
591 dev_t *devp, /* pointer to stream tail's dev */
592 int oflag, /* the user open(2) supplied flags */
593 int sflag, /* open state flag */
594 cred_t *credp) /* credentials */
595 {
596 int instance = ZC_INSTANCE(*devp);
597 int ret;
598 zc_state_t *zcs;
599
|
198 /*
199 * This macro converts a zc_state_t pointer to the associated slave minor node's
200 * dev_t.
201 */
202 #define ZC_STATE_TO_SLAVEDEV(x) (makedevice(ddi_driver_major((x)->zc_devinfo), \
203 (minor_t)(ddi_get_instance((x)->zc_devinfo) << 1 | ZC_SLAVE_MINOR)))
204
205 int zcons_debug = 0;
206 #define DBG(a) if (zcons_debug) cmn_err(CE_NOTE, a)
207 #define DBG1(a, b) if (zcons_debug) cmn_err(CE_NOTE, a, b)
208
209
210 /*
211 * Zone Console Pseudo Terminal Module: stream data structure definitions
212 */
213 static struct module_info zc_info = {
214 31337, /* c0z we r hAx0rs */
215 "zcons",
216 0,
217 INFPSZ,
218 _TTY_BUFSIZ,
219 128
220 };
221
222 static struct qinit zc_rinit = {
223 NULL,
224 (int (*)()) zc_rsrv,
225 zc_open,
226 zc_close,
227 NULL,
228 &zc_info,
229 NULL
230 };
231
232 static struct qinit zc_winit = {
233 (int (*)()) zc_wput,
234 (int (*)()) zc_wsrv,
235 NULL,
236 NULL,
237 NULL,
238 &zc_info,
484 /*
485 * Following qprocson(), the master side is fully plumbed into the
486 * STREAM and may send/receive messages. Setting zcs->zc_master_rdq
487 * will allow the slave to send messages to us (the master).
488 * This cannot occur before qprocson() because the master is not
489 * ready to process them until that point.
490 */
491 zcs->zc_master_rdq = rqp;
492
493 /*
494 * set up hi/lo water marks on stream head read queue and add
495 * controlling tty as needed.
496 */
497 mop->b_datap->db_type = M_SETOPTS;
498 mop->b_wptr += sizeof (struct stroptions);
499 sop = (struct stroptions *)(void *)mop->b_rptr;
500 if (oflag & FNOCTTY)
501 sop->so_flags = SO_HIWAT | SO_LOWAT;
502 else
503 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
504 sop->so_hiwat = _TTY_BUFSIZ;
505 sop->so_lowat = 256;
506 putnext(rqp, mop);
507
508 return (0);
509 }
510
511 /*ARGSUSED*/
512 static int
513 zc_slave_open(zc_state_t *zcs,
514 queue_t *rqp, /* pointer to the read side queue */
515 dev_t *devp, /* pointer to stream tail's dev */
516 int oflag, /* the user open(2) supplied flags */
517 int sflag, /* open state flag */
518 cred_t *credp) /* credentials */
519 {
520 mblk_t *mop;
521 struct stroptions *sop;
522 major_t major;
523 minor_t minor;
524 minor_t lastminor;
559 * q_ptr stores driver private data; stash the soft state data on both
560 * read and write sides of the queue.
561 */
562 WR(rqp)->q_ptr = rqp->q_ptr = zcs;
563
564 qprocson(rqp);
565
566 /*
567 * Must follow qprocson(), since we aren't ready to process until then.
568 */
569 zcs->zc_slave_rdq = rqp;
570
571 /*
572 * set up hi/lo water marks on stream head read queue and add
573 * controlling tty as needed.
574 */
575 mop->b_datap->db_type = M_SETOPTS;
576 mop->b_wptr += sizeof (struct stroptions);
577 sop = (struct stroptions *)(void *)mop->b_rptr;
578 sop->so_flags = SO_HIWAT | SO_LOWAT | SO_ISTTY;
579 sop->so_hiwat = _TTY_BUFSIZ;
580 sop->so_lowat = 256;
581 putnext(rqp, mop);
582
583 return (0);
584 }
585
586 /*
587 * open(9e) entrypoint; checks sflag, and rejects anything unordinary.
588 */
589 static int
590 zc_open(queue_t *rqp, /* pointer to the read side queue */
591 dev_t *devp, /* pointer to stream tail's dev */
592 int oflag, /* the user open(2) supplied flags */
593 int sflag, /* open state flag */
594 cred_t *credp) /* credentials */
595 {
596 int instance = ZC_INSTANCE(*devp);
597 int ret;
598 zc_state_t *zcs;
599
|