wscons.c revision fea9cb91bd8e12d84069b4dab1268363668b4bff
d75e6a5d480f559280524b60d52730c76a25524ftn * CDDL HEADER START
d75e6a5d480f559280524b60d52730c76a25524ftn * The contents of this file are subject to the terms of the
d75e6a5d480f559280524b60d52730c76a25524ftn * Common Development and Distribution License (the "License").
d75e6a5d480f559280524b60d52730c76a25524ftn * You may not use this file except in compliance with the License.
d75e6a5d480f559280524b60d52730c76a25524ftn * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d75e6a5d480f559280524b60d52730c76a25524ftn * See the License for the specific language governing permissions
d75e6a5d480f559280524b60d52730c76a25524ftn * and limitations under the License.
d75e6a5d480f559280524b60d52730c76a25524ftn * When distributing Covered Code, include this CDDL HEADER in each
d75e6a5d480f559280524b60d52730c76a25524ftn * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d75e6a5d480f559280524b60d52730c76a25524ftn * If applicable, add the following below this CDDL HEADER, with the
d75e6a5d480f559280524b60d52730c76a25524ftn * fields enclosed by brackets "[]" replaced with your own identifying
d75e6a5d480f559280524b60d52730c76a25524ftn * information: Portions Copyright [yyyy] [name of copyright owner]
d75e6a5d480f559280524b60d52730c76a25524ftn * CDDL HEADER END
d75e6a5d480f559280524b60d52730c76a25524ftn * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
d75e6a5d480f559280524b60d52730c76a25524ftn * Use is subject to license terms.
d75e6a5d480f559280524b60d52730c76a25524ftn#pragma ident "%Z%%M% %I% %E% SMI"
d75e6a5d480f559280524b60d52730c76a25524ftn * "Workstation console" multiplexor driver for Sun.
d75e6a5d480f559280524b60d52730c76a25524ftn * Sends output to the primary frame buffer using the PROM monitor;
d75e6a5d480f559280524b60d52730c76a25524ftn * gets input from a stream linked below us that is the "keyboard
d75e6a5d480f559280524b60d52730c76a25524ftn * driver", below which is linked the primary keyboard.
d75e6a5d480f559280524b60d52730c76a25524ftn /* write-side exclusion lock */
d75e6a5d480f559280524b60d52730c76a25524ftn tty_common_t wc_ttycommon; /* data common to all tty drivers */
d75e6a5d480f559280524b60d52730c76a25524ftn int wc_defer_output; /* set if output device is "slow" */
d75e6a5d480f559280524b60d52730c76a25524ftn#endif /* _HAVE_TEM_FIRMWARE */
d75e6a5d480f559280524b60d52730c76a25524ftn queue_t *wc_kbdqueue; /* "console keyboard" device queue */
d75e6a5d480f559280524b60d52730c76a25524ftn /* below us */
d75e6a5d480f559280524b60d52730c76a25524ftn cons_polledio_t wc_polledio; /* polled I/O function pointers */
d75e6a5d480f559280524b60d52730c76a25524ftn cons_polledio_t *wc_kb_polledio; /* keyboard's polledio */
d75e6a5d480f559280524b60d52730c76a25524ftn unsigned int wc_kb_getpolledio_id; /* id for kb CONSOPENPOLLEDIO */
d75e6a5d480f559280524b60d52730c76a25524ftn mblk_t *wc_pending_link; /* I_PLINK pending for kb polledio */
d75e6a5d480f559280524b60d52730c76a25524ftn#define WCS_DELAY 0x00000004 /* waiting for delay to finish */
d75e6a5d480f559280524b60d52730c76a25524ftn#define WCS_BUSY 0x00000008 /* waiting for transmission to finish */
d75e6a5d480f559280524b60d52730c76a25524ftnstatic int wcopen(queue_t *, dev_t *, int, int, cred_t *);
d75e6a5d480f559280524b60d52730c76a25524ftn * We always putnext directly to the underlying queue.
d75e6a5d480f559280524b60d52730c76a25524ftnstatic int wc_info(dev_info_t *, ddi_info_cmd_t, void *, void **result);
d75e6a5d480f559280524b60d52730c76a25524ftnDDI_DEFINE_STREAM_OPS(wc_ops, nulldev, nulldev, wc_attach, nodev, nodev,
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wcreioctl(void *);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wcopoll(void *);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wconsout(void *);
d75e6a5d480f559280524b60d52730c76a25524ftn#endif /* _HAVE_TEM_FIRMWARE */
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wcrstrt(void *);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wcstart(void);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_open_kb_polledio(struct wscons *wc, queue_t *q, mblk_t *mp);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_close_kb_polledio(struct wscons *wc, queue_t *q, mblk_t *mp);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_polled_putchar(struct cons_polledio_arg *arg,
d75e6a5d480f559280524b60d52730c76a25524ftn unsigned char c);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic boolean_t wc_polled_ischar(struct cons_polledio_arg *arg);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic int wc_polled_getchar(struct cons_polledio_arg *arg);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_polled_enter(struct cons_polledio_arg *arg);
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_polled_exit(struct cons_polledio_arg *arg);
d75e6a5d480f559280524b60d52730c76a25524ftn * Debug printing
d75e6a5d480f559280524b60d52730c76a25524ftn/*PRINTFLIKE1*/
d75e6a5d480f559280524b60d52730c76a25524ftnstatic void wc_dprintf(const char *fmt, ...) __KPRINTFLIKE(1);
d75e6a5d480f559280524b60d52730c76a25524ftn * Severity levels for printing
d75e6a5d480f559280524b60d52730c76a25524ftn * Module linkage information for the kernel.
d75e6a5d480f559280524b60d52730c76a25524ftn &mod_driverops, /* Type of module. This one is a pseudo driver */
d75e6a5d480f559280524b60d52730c76a25524ftn "Workstation multiplexer Driver 'wc' %I%",
&modldrv,
_init(void)
_fini(void)
return (DDI_SUCCESS);
void **result)
int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
return (error);
#ifdef _HAVE_TEM_FIRMWARE
int len;
NULL);
if (!polledio_inited) {
#ifdef _HAVE_TEM_FIRMWARE
return (EBUSY);
qprocson(q);
qprocsoff(q);
case M_STOP:
case M_START:
wcstart();
case M_IOCTL: {
case I_PLINK:
case I_PUNLINK:
case TCSETSW:
case TCSETSF:
case TCSETAW:
case TCSETAF:
case TCSBRK:
wcstart();
case CONSSETABORTENABLE:
case CONSGETABORTENABLE:
case KIOCSDIRECT:
case M_FLUSH:
case M_BREAK:
case M_DELAY:
case M_DATA:
wcstart();
queue_t *q;
char *term;
return (EFAULT);
return (EOVERFLOW);
return (EFAULT);
int error;
long len;
case TIOCSWINSZ:
case CONSOPENPOLLEDIO:
if (error != 0) {
case CONS_GETTERM:
case WC_OPEN_FB:
goto open_fail;
goto open_fail;
goto open_fail;
goto open_fail;
goto open_fail;
case WC_CLOSE_FB:
goto close_fail;
if (datasize != 0) {
if (error < 0) {
error = 0;
if (error != 0) {
goto nomem;
goto nomem;
sizeof (struct cons_polledio *);
goto nomem;
goto nomem;
#ifdef _HAVE_TEM_FIRMWARE
queue_t *q;
wcstart();
wcstart();
wcstart(void)
#ifdef _HAVE_TEM_FIRMWARE
queue_t *q;
case M_DELAY:
case M_IOCTL:
#ifdef _HAVE_TEM_FIRMWARE
kcred);
#ifdef _HAVE_TEM_FIRMWARE
(void) quntimeout(q,
cc--;
if (prom_mayput((char)c) != 0) {
(void) quntimeout(q,
while (cc <= 0) {
#ifdef _HAVE_TEM_FIRMWARE
queue_t *q;
char *current_position;
goto transmit;
while (cc != 0) {
if (bytes_left == 0) {
goto transmit;
cc--;
bytes_left--;
wcstart();
case M_FLUSH:
case M_DATA:
wcstart();
case M_IOCACK:
case M_IOCNAK:
case M_IOCACK:
case CONSOPENPOLLEDIO:
*(struct cons_polledio **)
case CONSCLOSEPOLLEDIO:
case M_IOCNAK:
case CONSCLOSEPOLLEDIO:
return (ENXIO);
* moved to space.c to allow "wc" to become a loadable module.
static boolean_t
return (B_FALSE);
#ifdef DEBUG
#ifdef _HAVE_TEM_FIRMWARE
console_get_size(&r, &c, &x, &y);