5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Toomas Soome <tsoome@me.com>
25 */
26
27 /*
28 * "Workstation console" multiplexor driver for Sun.
29 *
30 * Sends output to the primary frame buffer using the PROM monitor;
31 * gets input from a stream linked below us that is the "keyboard
32 * driver", below which is linked the primary keyboard.
33 */
34
35 /*
36 * Locking Policy:
37 * This module has a D_MTPERMOD inner perimeter which means STREAMS
38 * only allows one thread to enter this module through STREAMS entry
39 * points each time -- open() close() put() srv() qtimeout().
40 * So for the most time we do not need locking in this module, but with
41 * the following exceptions:
42 *
43 * - wc shares three global variables (wc_dip, vc_active_console,
44 * vc_cons_user, vc_avl_root) with virtual console devname part
494 * We need to have service procedure to make sure the keyboard events
495 * are queued up for screen output and are not dependant on the screen
496 * updates.
497 */
498 static int
499 wcuwsrv(queue_t *q)
500 {
501 vc_state_t *pvc = (vc_state_t *)q->q_ptr;
502 tem_vt_state_t ptem = NULL;
503 mblk_t *mp;
504 ssize_t cc;
505
506 while ((mp = getq(q)) != NULL) {
507 /*
508 * If we're waiting for something to happen (delay timeout to
509 * expire, current transmission to finish, output to be
510 * restarted, output to finish draining), don't grab anything
511 * new.
512 */
513 if (pvc->vc_flags & (WCS_DELAY|WCS_BUSY|WCS_STOPPED)) {
514 putbq(q, mp);
515 return (0);
516 }
517
518 switch (mp->b_datap->db_type) {
519 default: /* drop unknown type */
520 freemsg(mp);
521 continue;
522
523 case M_IOCTL:
524 wcioctl(q, mp);
525 continue;
526
527 case M_DELAY:
528 /*
529 * Arrange for "wcrstrt" to be called when the
530 * delay expires; it will turn WCS_DELAY off.
531 */
532 if (pvc->vc_timeoutid != 0)
533 (void) quntimeout(q, pvc->vc_timeoutid);
534 pvc->vc_timeoutid = qtimeout(q, wcrstrt, pvc,
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Toomas Soome <tsoome@me.com>
25 * Copyright 2019 Joyent, Inc.
26 */
27
28 /*
29 * "Workstation console" multiplexor driver for Sun.
30 *
31 * Sends output to the primary frame buffer using the PROM monitor;
32 * gets input from a stream linked below us that is the "keyboard
33 * driver", below which is linked the primary keyboard.
34 */
35
36 /*
37 * Locking Policy:
38 * This module has a D_MTPERMOD inner perimeter which means STREAMS
39 * only allows one thread to enter this module through STREAMS entry
40 * points each time -- open() close() put() srv() qtimeout().
41 * So for the most time we do not need locking in this module, but with
42 * the following exceptions:
43 *
44 * - wc shares three global variables (wc_dip, vc_active_console,
45 * vc_cons_user, vc_avl_root) with virtual console devname part
495 * We need to have service procedure to make sure the keyboard events
496 * are queued up for screen output and are not dependant on the screen
497 * updates.
498 */
499 static int
500 wcuwsrv(queue_t *q)
501 {
502 vc_state_t *pvc = (vc_state_t *)q->q_ptr;
503 tem_vt_state_t ptem = NULL;
504 mblk_t *mp;
505 ssize_t cc;
506
507 while ((mp = getq(q)) != NULL) {
508 /*
509 * If we're waiting for something to happen (delay timeout to
510 * expire, current transmission to finish, output to be
511 * restarted, output to finish draining), don't grab anything
512 * new.
513 */
514 if (pvc->vc_flags & (WCS_DELAY|WCS_BUSY|WCS_STOPPED)) {
515 (void) putbq(q, mp);
516 return (0);
517 }
518
519 switch (mp->b_datap->db_type) {
520 default: /* drop unknown type */
521 freemsg(mp);
522 continue;
523
524 case M_IOCTL:
525 wcioctl(q, mp);
526 continue;
527
528 case M_DELAY:
529 /*
530 * Arrange for "wcrstrt" to be called when the
531 * delay expires; it will turn WCS_DELAY off.
532 */
533 if (pvc->vc_timeoutid != 0)
534 (void) quntimeout(q, pvc->vc_timeoutid);
535 pvc->vc_timeoutid = qtimeout(q, wcrstrt, pvc,
|