113 #include <sys/console.h>
114 #include <sys/promif.h>
115 #include <sys/note.h>
116 #include <sys/polled_io.h>
117 #include <sys/systm.h>
118 #include <sys/ddi.h>
119 #include <sys/sunddi.h>
120 #include <sys/sunndi.h>
121 #include <sys/esunddi.h>
122 #include <sys/sunldi.h>
123 #include <sys/debug.h>
124 #include <sys/console.h>
125 #include <sys/ddi_impldefs.h>
126 #include <sys/policy.h>
127 #include <sys/modctl.h>
128 #include <sys/tem.h>
129 #include <sys/wscons.h>
130 #include <sys/vt_impl.h>
131
132 /* streams stuff */
133 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", copyreq))
134 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", copyresp))
135 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", datab))
136 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", iocblk))
137 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", msgb))
138 _NOTE(SCHEME_PROTECTS_DATA("Unshared data", queue))
139
140 #define MINLINES 10
141 #define MAXLINES 48
142 #define LOSCREENLINES 34
143 #define HISCREENLINES 48
144
145 #define MINCOLS 10
146 #define MAXCOLS 120
147 #define LOSCREENCOLS 80
148 #define HISCREENCOLS 120
149
150 struct wscons_state {
151 dev_t wc_dev; /* major/minor for this device */
152 #ifdef _HAVE_TEM_FIRMWARE
153 int wc_defer_output; /* set if output device is "slow" */
154 #endif /* _HAVE_TEM_FIRMWARE */
155 queue_t *wc_kbdqueue; /* "console keyboard" device queue */
156 /* below us */
157 cons_polledio_t wc_polledio; /* polled I/O function pointers */
158 cons_polledio_t *wc_kb_polledio; /* keyboard's polledio */
159 unsigned int wc_kb_getpolledio_id; /* id for kb CONSOPENPOLLEDIO */
160 queue_t *wc_pending_wq;
161 mblk_t *wc_pending_link; /* I_PLINK pending for kb polledio */
162 } wscons;
163
164 /*
165 * This module has a D_MTPERMOD inner perimeter, so we don't need to protect
166 * the variables only shared within this module
167 */
168 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", wscons))
169 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", wscons_state))
170 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", vt_stat))
171 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", vc_waitactive_msg))
172 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", tty_common))
173 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", vt_mode))
174 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", vt_dispinfo))
175 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", winsize))
176 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data", vc_last_console))
177
178 #ifdef _HAVE_TEM_FIRMWARE
179 ssize_t wc_cons_wrtvec(promif_redir_arg_t arg, uchar_t *s, size_t n);
180 #endif /* _HAVE_TEM_FIRMWARE */
181
182 static int wcopen(queue_t *, dev_t *, int, int, cred_t *);
183 static int wcclose(queue_t *, int, cred_t *);
184 static int wcuwput(queue_t *, mblk_t *);
185 static int wclrput(queue_t *, mblk_t *);
186
187 static struct module_info wcm_info = {
188 0,
189 "wc",
190 0,
191 INFPSZ,
192 2048,
193 128
194 };
195
196 static struct qinit wcurinit = {
197 putq,
383 error = DDI_SUCCESS;
384 break;
385 default:
386 error = DDI_FAILURE;
387 }
388 return (error);
389 }
390
391 #ifdef _HAVE_TEM_FIRMWARE
392 /*
393 * Output buffer. Protected by the per-module inner perimeter.
394 */
395 #define MAXHIWAT 2000
396 static char obuf[MAXHIWAT];
397 #endif /* _HAVE_TEM_FIRMWARE */
398
399 static void
400 wc_init_polledio(void)
401 {
402 static boolean_t polledio_inited = B_FALSE;
403 _NOTE(SCHEME_PROTECTS_DATA("D_MTPERMOD protected data",
404 polledio_inited))
405
406 if (polledio_inited)
407 return;
408
409 polledio_inited = B_TRUE;
410
411 /*
412 * Initialize the parts of the polled I/O struct that
413 * are common to both input and output modes, but which
414 * don't flag to the upper layers, which if any of the
415 * two modes are available. We don't know at this point
416 * if system is configured CONS_KFB, but we will when
417 * consconfig_dacf asks us with CONSOPENPOLLED I/O.
418 */
419 bzero(&(wscons.wc_polledio), sizeof (wscons.wc_polledio));
420 wscons.wc_polledio.cons_polledio_version =
421 CONSPOLLEDIO_V0;
422 wscons.wc_polledio.cons_polledio_argument =
423 (cons_polledio_arg_t)&wscons;
424 wscons.wc_polledio.cons_polledio_enter =
|
113 #include <sys/console.h>
114 #include <sys/promif.h>
115 #include <sys/note.h>
116 #include <sys/polled_io.h>
117 #include <sys/systm.h>
118 #include <sys/ddi.h>
119 #include <sys/sunddi.h>
120 #include <sys/sunndi.h>
121 #include <sys/esunddi.h>
122 #include <sys/sunldi.h>
123 #include <sys/debug.h>
124 #include <sys/console.h>
125 #include <sys/ddi_impldefs.h>
126 #include <sys/policy.h>
127 #include <sys/modctl.h>
128 #include <sys/tem.h>
129 #include <sys/wscons.h>
130 #include <sys/vt_impl.h>
131
132 /* streams stuff */
133 #define MINLINES 10
134 #define MAXLINES 48
135 #define LOSCREENLINES 34
136 #define HISCREENLINES 48
137
138 #define MINCOLS 10
139 #define MAXCOLS 120
140 #define LOSCREENCOLS 80
141 #define HISCREENCOLS 120
142
143 struct wscons_state {
144 dev_t wc_dev; /* major/minor for this device */
145 #ifdef _HAVE_TEM_FIRMWARE
146 int wc_defer_output; /* set if output device is "slow" */
147 #endif /* _HAVE_TEM_FIRMWARE */
148 queue_t *wc_kbdqueue; /* "console keyboard" device queue */
149 /* below us */
150 cons_polledio_t wc_polledio; /* polled I/O function pointers */
151 cons_polledio_t *wc_kb_polledio; /* keyboard's polledio */
152 unsigned int wc_kb_getpolledio_id; /* id for kb CONSOPENPOLLEDIO */
153 queue_t *wc_pending_wq;
154 mblk_t *wc_pending_link; /* I_PLINK pending for kb polledio */
155 } wscons;
156
157 #ifdef _HAVE_TEM_FIRMWARE
158 ssize_t wc_cons_wrtvec(promif_redir_arg_t arg, uchar_t *s, size_t n);
159 #endif /* _HAVE_TEM_FIRMWARE */
160
161 static int wcopen(queue_t *, dev_t *, int, int, cred_t *);
162 static int wcclose(queue_t *, int, cred_t *);
163 static int wcuwput(queue_t *, mblk_t *);
164 static int wclrput(queue_t *, mblk_t *);
165
166 static struct module_info wcm_info = {
167 0,
168 "wc",
169 0,
170 INFPSZ,
171 2048,
172 128
173 };
174
175 static struct qinit wcurinit = {
176 putq,
362 error = DDI_SUCCESS;
363 break;
364 default:
365 error = DDI_FAILURE;
366 }
367 return (error);
368 }
369
370 #ifdef _HAVE_TEM_FIRMWARE
371 /*
372 * Output buffer. Protected by the per-module inner perimeter.
373 */
374 #define MAXHIWAT 2000
375 static char obuf[MAXHIWAT];
376 #endif /* _HAVE_TEM_FIRMWARE */
377
378 static void
379 wc_init_polledio(void)
380 {
381 static boolean_t polledio_inited = B_FALSE;
382
383 if (polledio_inited)
384 return;
385
386 polledio_inited = B_TRUE;
387
388 /*
389 * Initialize the parts of the polled I/O struct that
390 * are common to both input and output modes, but which
391 * don't flag to the upper layers, which if any of the
392 * two modes are available. We don't know at this point
393 * if system is configured CONS_KFB, but we will when
394 * consconfig_dacf asks us with CONSOPENPOLLED I/O.
395 */
396 bzero(&(wscons.wc_polledio), sizeof (wscons.wc_polledio));
397 wscons.wc_polledio.cons_polledio_version =
398 CONSPOLLEDIO_V0;
399 wscons.wc_polledio.cons_polledio_argument =
400 (cons_polledio_arg_t)&wscons;
401 wscons.wc_polledio.cons_polledio_enter =
|