summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-09-05 13:43:59 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-09-05 13:43:59 +0000
commit7228e7cd652a9274ee9d18d7c4e52b2f5c098ae3 (patch)
tree22bbb42d9f028aa3ab941c232e10c5953c769d3d /sys
parent492552b942809e767e2c035b24d669f0e0936d11 (diff)
Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/wscons/wsemul_sun.c77
-rw-r--r--sys/dev/wscons/wsemul_vt100.c104
-rw-r--r--sys/dev/wscons/wsemul_vt100_subr.c27
3 files changed, 120 insertions, 88 deletions
diff --git a/sys/dev/wscons/wsemul_sun.c b/sys/dev/wscons/wsemul_sun.c
index 923cf8b196d..66f25a5bf9b 100644
--- a/sys/dev/wscons/wsemul_sun.c
+++ b/sys/dev/wscons/wsemul_sun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsemul_sun.c,v 1.24 2009/05/06 20:00:57 miod Exp $ */
+/* $OpenBSD: wsemul_sun.c,v 1.25 2009/09/05 13:43:58 miod Exp $ */
/* $NetBSD: wsemul_sun.c,v 1.11 2000/01/05 11:19:36 drochner Exp $ */
/*
@@ -103,13 +103,13 @@ struct wsemul_sun_emuldata {
void wsemul_sun_init(struct wsemul_sun_emuldata *,
const struct wsscreen_descr *, void *, int, int, long);
-void wsemul_sun_jump_scroll(struct wsemul_sun_emuldata *, const u_char *,
+int wsemul_sun_jump_scroll(struct wsemul_sun_emuldata *, const u_char *,
u_int, int);
void wsemul_sun_reset(struct wsemul_sun_emuldata *);
void wsemul_sun_output_lowchars(struct wsemul_sun_emuldata *, u_char, int);
void wsemul_sun_output_normal(struct wsemul_sun_emuldata *, u_char, int);
-u_int wsemul_sun_output_haveesc(struct wsemul_sun_emuldata *, u_char);
-u_int wsemul_sun_output_control(struct wsemul_sun_emuldata *, u_char);
+void wsemul_sun_output_haveesc(struct wsemul_sun_emuldata *, u_char);
+void wsemul_sun_output_control(struct wsemul_sun_emuldata *, u_char);
void wsemul_sun_control(struct wsemul_sun_emuldata *, u_char);
int wsemul_sun_selectattribute(struct wsemul_sun_emuldata *, int, int, int,
long *, long *);
@@ -279,7 +279,7 @@ wsemul_sun_output_lowchars(struct wsemul_sun_emuldata *edp, u_char c,
break;
case ASCII_LF: /* "Line Feed (LF)" */
- /* if the cur line isn't the last, incr and leave. */
+ /* if the cur line isn't the last, incr and leave. */
if (ROWS_LEFT > 0)
edp->crow++;
else
@@ -296,7 +296,7 @@ wsemul_sun_output_normal(struct wsemul_sun_emuldata *edp, u_char c, int kernel)
c, kernel ? edp->kernattr : edp->curattr);
if (++edp->ccol >= edp->ncols) {
- /* if the cur line isn't the last, incr and leave. */
+ /* if the cur line isn't the last, incr and leave. */
if (ROWS_LEFT > 0)
edp->crow++;
else
@@ -305,27 +305,23 @@ wsemul_sun_output_normal(struct wsemul_sun_emuldata *edp, u_char c, int kernel)
}
}
-u_int
+void
wsemul_sun_output_haveesc(struct wsemul_sun_emuldata *edp, u_char c)
{
- u_int newstate;
-
switch (c) {
case '[': /* continuation of multi-char sequence */
edp->nargs = 0;
bzero(edp->args, sizeof (edp->args));
- newstate = SUN_EMUL_STATE_CONTROL;
+ edp->state = SUN_EMUL_STATE_CONTROL;
break;
default:
#ifdef DEBUG
printf("ESC%c unknown\n", c);
#endif
- newstate = SUN_EMUL_STATE_NORMAL; /* XXX is this wise? */
+ edp->state = SUN_EMUL_STATE_NORMAL; /* XXX is this wise? */
break;
}
-
- return (newstate);
}
void
@@ -503,11 +499,9 @@ setattr:
}
}
-u_int
+void
wsemul_sun_output_control(struct wsemul_sun_emuldata *edp, u_char c)
{
- u_int newstate = SUN_EMUL_STATE_CONTROL;
-
switch (c) {
case '0': case '1': case '2': case '3': case '4': /* argument digit */
case '5': case '6': case '7': case '8': case '9':
@@ -522,7 +516,7 @@ wsemul_sun_output_control(struct wsemul_sun_emuldata *edp, u_char c)
}
edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) +
(c - '0');
- break;
+ break;
case ';': /* argument terminator */
edp->nargs++;
@@ -533,17 +527,19 @@ wsemul_sun_output_control(struct wsemul_sun_emuldata *edp, u_char c)
if (edp->nargs > SUN_EMUL_NARGS)
edp->nargs = SUN_EMUL_NARGS;
wsemul_sun_control(edp, c);
- newstate = SUN_EMUL_STATE_NORMAL;
+ edp->state = SUN_EMUL_STATE_NORMAL;
break;
}
- return (newstate);
}
void
wsemul_sun_output(void *cookie, const u_char *data, u_int count, int kernel)
{
struct wsemul_sun_emuldata *edp = cookie;
- u_int newstate;
+ u_char c;
+#ifdef JUMP_SCROLL
+ int lines;
+#endif
#ifdef DIAGNOSTIC
if (kernel && !edp->console)
@@ -562,47 +558,55 @@ wsemul_sun_output(void *cookie, const u_char *data, u_int count, int kernel)
*/
if ((edp->state == SUN_EMUL_STATE_NORMAL || kernel) &&
ROWS_LEFT == 0 && edp->scrolldist != 0)
- wsemul_sun_jump_scroll(edp, data, count, kernel);
+ lines = wsemul_sun_jump_scroll(edp, data,
+ count, kernel);
+ else
+ lines = 0;
+
+ if (lines > 1) {
+ wsemul_sun_scrollup(edp, lines);
+ edp->crow--;
+ }
#endif
- if (*data < ' ') {
- wsemul_sun_output_lowchars(edp, *data, kernel);
+ c = *data;
+ if (c < ' ') {
+ wsemul_sun_output_lowchars(edp, c, kernel);
continue;
}
if (kernel) {
- wsemul_sun_output_normal(edp, *data, 1);
+ wsemul_sun_output_normal(edp, c, 1);
continue;
}
- switch (newstate = edp->state) {
+ switch (edp->state) {
case SUN_EMUL_STATE_NORMAL:
- wsemul_sun_output_normal(edp, *data, 0);
+ wsemul_sun_output_normal(edp, c, 0);
break;
case SUN_EMUL_STATE_HAVEESC:
- newstate = wsemul_sun_output_haveesc(edp, *data);
+ wsemul_sun_output_haveesc(edp, c);
break;
case SUN_EMUL_STATE_CONTROL:
- newstate = wsemul_sun_output_control(edp, *data);
+ wsemul_sun_output_control(edp, c);
break;
default:
#ifdef DIAGNOSTIC
panic("wsemul_sun: invalid state %d", edp->state);
#else
- /* try to recover, if things get screwed up... */
- newstate = SUN_EMUL_STATE_NORMAL;
- wsemul_sun_output_normal(edp, *data, 0);
+ /* try to recover, if things get screwed up... */
+ edp->state = SUN_EMUL_STATE_NORMAL;
+ wsemul_sun_output_normal(edp, c, 0);
#endif
- break;
+ break;
}
- edp->state = newstate;
}
/* XXX */
(*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol);
}
#ifdef JUMP_SCROLL
-void
+int
wsemul_sun_jump_scroll(struct wsemul_sun_emuldata *edp, const u_char *data,
u_int count, int kernel)
{
@@ -645,10 +649,7 @@ wsemul_sun_jump_scroll(struct wsemul_sun_emuldata *edp, const u_char *data,
}
}
- if (lines > 1) {
- wsemul_sun_scrollup(edp, lines);
- edp->crow--;
- }
+ return lines;
}
#endif
diff --git a/sys/dev/wscons/wsemul_vt100.c b/sys/dev/wscons/wsemul_vt100.c
index 68738aac220..e80b84b2a17 100644
--- a/sys/dev/wscons/wsemul_vt100.c
+++ b/sys/dev/wscons/wsemul_vt100.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsemul_vt100.c,v 1.23 2009/01/12 20:43:53 miod Exp $ */
+/* $OpenBSD: wsemul_vt100.c,v 1.24 2009/09/05 13:43:58 miod Exp $ */
/* $NetBSD: wsemul_vt100.c,v 1.13 2000/04/28 21:56:16 mycroft Exp $ */
/*
@@ -45,11 +45,10 @@
void *wsemul_vt100_cnattach(const struct wsscreen_descr *, void *,
int, int, long);
-void *wsemul_vt100_attach(int console, const struct wsscreen_descr *,
+void *wsemul_vt100_attach(int, const struct wsscreen_descr *,
void *, int, int, void *, long);
-void wsemul_vt100_output(void *cookie, const u_char *data, u_int count,
- int);
-void wsemul_vt100_detach(void *cookie, u_int *crowp, u_int *ccolp);
+void wsemul_vt100_output(void *, const u_char *, u_int, int);
+void wsemul_vt100_detach(void *, u_int *, u_int *);
void wsemul_vt100_resetop(void *, enum wsemul_resetops);
const struct wsemul_ops wsemul_vt100_ops = {
@@ -66,12 +65,12 @@ struct wsemul_vt100_emuldata wsemul_vt100_console_emuldata;
void wsemul_vt100_init(struct wsemul_vt100_emuldata *,
const struct wsscreen_descr *, void *, int, int, long);
-void wsemul_vt100_jump_scroll(struct wsemul_vt100_emuldata *,
+int wsemul_vt100_jump_scroll(struct wsemul_vt100_emuldata *,
const u_char *, u_int, int);
void wsemul_vt100_output_normal(struct wsemul_vt100_emuldata *, u_char, int);
void wsemul_vt100_output_c0c1(struct wsemul_vt100_emuldata *, u_char, int);
void wsemul_vt100_nextline(struct wsemul_vt100_emuldata *);
-typedef u_int vt100_handler(struct wsemul_vt100_emuldata *, u_char);
+typedef void vt100_handler(struct wsemul_vt100_emuldata *, u_char);
vt100_handler
wsemul_vt100_output_esc,
wsemul_vt100_output_csi,
@@ -436,7 +435,7 @@ wsemul_vt100_output_c0c1(struct wsemul_vt100_emuldata *edp, u_char c,
}
}
-u_int
+void
wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_NORMAL;
@@ -562,10 +561,10 @@ wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
break;
}
- return (newstate);
+ edp->state = newstate;
}
-u_int
+void
wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_NORMAL;
@@ -596,10 +595,11 @@ wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (newstate);
+
+ edp->state = newstate;
}
-u_int
+void
wsemul_vt100_output_scs94_percent(struct wsemul_vt100_emuldata *edp, u_char c)
{
switch (c) {
@@ -613,10 +613,11 @@ wsemul_vt100_output_scs94_percent(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (VT100_EMUL_STATE_NORMAL);
+
+ edp->state = VT100_EMUL_STATE_NORMAL;
}
-u_int
+void
wsemul_vt100_output_scs96(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_NORMAL;
@@ -668,10 +669,11 @@ setnrc:
#endif
break;
}
- return (newstate);
+
+ edp->state = newstate;
}
-u_int
+void
wsemul_vt100_output_scs96_percent(struct wsemul_vt100_emuldata *edp, u_char c)
{
switch (c) {
@@ -685,10 +687,11 @@ wsemul_vt100_output_scs96_percent(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (VT100_EMUL_STATE_NORMAL);
+
+ edp->state = VT100_EMUL_STATE_NORMAL;
}
-u_int
+void
wsemul_vt100_output_esc_spc(struct wsemul_vt100_emuldata *edp, u_char c)
{
switch (c) {
@@ -704,28 +707,30 @@ wsemul_vt100_output_esc_spc(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (VT100_EMUL_STATE_NORMAL);
+
+ edp->state = VT100_EMUL_STATE_NORMAL;
}
-u_int
+void
wsemul_vt100_output_string(struct wsemul_vt100_emuldata *edp, u_char c)
{
if (edp->dcstype && edp->dcspos < DCS_MAXLEN)
edp->dcsarg[edp->dcspos++] = c;
- return (VT100_EMUL_STATE_STRING);
+
+ edp->state = VT100_EMUL_STATE_STRING;
}
-u_int
+void
wsemul_vt100_output_string_esc(struct wsemul_vt100_emuldata *edp, u_char c)
{
if (c == '\\') { /* ST complete */
wsemul_vt100_handle_dcs(edp);
- return (VT100_EMUL_STATE_NORMAL);
+ edp->state = VT100_EMUL_STATE_NORMAL;
} else
- return (VT100_EMUL_STATE_STRING);
+ edp->state = VT100_EMUL_STATE_STRING;
}
-u_int
+void
wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_DCS;
@@ -755,7 +760,7 @@ wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
case '$':
newstate = VT100_EMUL_STATE_DCS_DOLLAR;
break;
- case '{': /* DECDLD soft charset */
+ case '{': /* DECDLD soft charset */ /* } */
case '!': /* DECRQUPSS user preferred supplemental set */
/* 'u' must follow - need another state */
case '|': /* DECUDK program F6..F20 */
@@ -771,10 +776,10 @@ wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
}
}
- return (newstate);
+ edp->state = newstate;
}
-u_int
+void
wsemul_vt100_output_dcs_dollar(struct wsemul_vt100_emuldata *edp, u_char c)
{
switch (c) {
@@ -810,10 +815,11 @@ wsemul_vt100_output_dcs_dollar(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (VT100_EMUL_STATE_STRING);
+
+ edp->state = VT100_EMUL_STATE_STRING;
}
-u_int
+void
wsemul_vt100_output_esc_hash(struct wsemul_vt100_emuldata *edp, u_char c)
{
int i;
@@ -862,10 +868,11 @@ wsemul_vt100_output_esc_hash(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
- return (VT100_EMUL_STATE_NORMAL);
+
+ edp->state = VT100_EMUL_STATE_NORMAL;
}
-u_int
+void
wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_CSI;
@@ -904,13 +911,18 @@ wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c)
newstate = VT100_EMUL_STATE_NORMAL;
break;
}
- return (newstate);
+
+ edp->state = newstate;
}
void
wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
{
struct wsemul_vt100_emuldata *edp = cookie;
+ u_char c;
+#ifdef JUMP_SCROLL
+ int lines;
+#endif
#ifdef DIAGNOSTIC
if (kernel && !edp->console)
@@ -929,23 +941,32 @@ wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
*/
if ((edp->state == VT100_EMUL_STATE_NORMAL || kernel) &&
ROWS_BELOW == 0)
- wsemul_vt100_jump_scroll(edp, data, count, kernel);
+ lines = wsemul_vt100_jump_scroll(edp, data,
+ count, kernel);
+ else
+ lines = 0;
+
+ if (lines > 1) {
+ wsemul_vt100_scrollup(edp, lines);
+ edp->crow -= lines;
+ }
#endif
- if ((*data & 0x7f) < 0x20) {
- wsemul_vt100_output_c0c1(edp, *data, kernel);
+ c = *data;
+ if ((c & 0x7f) < 0x20) {
+ wsemul_vt100_output_c0c1(edp, c, kernel);
continue;
}
if (edp->state == VT100_EMUL_STATE_NORMAL || kernel) {
- wsemul_vt100_output_normal(edp, *data, kernel);
+ wsemul_vt100_output_normal(edp, c, kernel);
continue;
}
#ifdef DIAGNOSTIC
if (edp->state > nitems(vt100_output))
panic("wsemul_vt100: invalid state %d", edp->state);
#endif
- edp->state = vt100_output[edp->state - 1](edp, *data);
+ vt100_output[edp->state - 1](edp, c);
}
if (edp->flags & VTFL_CURSORON)
@@ -954,7 +975,7 @@ wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
}
#ifdef JUMP_SCROLL
-void
+int
wsemul_vt100_jump_scroll(struct wsemul_vt100_emuldata *edp, const u_char *data,
u_int count, int kernel)
{
@@ -1012,9 +1033,6 @@ wsemul_vt100_jump_scroll(struct wsemul_vt100_emuldata *edp, const u_char *data,
}
}
- if (lines > 1) {
- wsemul_vt100_scrollup(edp, lines);
- edp->crow -= lines;
- }
+ return lines;
}
#endif
diff --git a/sys/dev/wscons/wsemul_vt100_subr.c b/sys/dev/wscons/wsemul_vt100_subr.c
index c696630c7bb..cdbd558d242 100644
--- a/sys/dev/wscons/wsemul_vt100_subr.c
+++ b/sys/dev/wscons/wsemul_vt100_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsemul_vt100_subr.c,v 1.15 2007/11/27 16:37:27 miod Exp $ */
+/* $OpenBSD: wsemul_vt100_subr.c,v 1.16 2009/09/05 13:43:58 miod Exp $ */
/* $NetBSD: wsemul_vt100_subr.c,v 1.7 2000/04/28 21:56:16 mycroft Exp $ */
/*
@@ -39,7 +39,7 @@
int vt100_selectattribute(struct wsemul_vt100_emuldata *, int, int, int,
long *, long *);
int vt100_ansimode(struct wsemul_vt100_emuldata *, int, int);
-int vt100_decmode(struct wsemul_vt100_emuldata *, int, int);
+void vt100_decmode(struct wsemul_vt100_emuldata *, int, int);
#define VTMODE_SET 33
#define VTMODE_RESET 44
#define VTMODE_REPORT 55
@@ -765,42 +765,53 @@ vt100_ansimode(struct wsemul_vt100_emuldata *edp, int nr, int op)
return (res);
}
-int
+void
vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
{
+#if 0 /* res unused... return it by reference if ever necessary */
int res = 0; /* default: unknown */
- int flags;
+#endif
+ int flags = edp->flags;
- flags = edp->flags;
switch (nr) {
case 1: /* DECCKM application/nomal cursor keys */
if (op == VTMODE_SET)
flags |= VTFL_APPLCURSOR;
else if (op == VTMODE_RESET)
flags &= ~VTFL_APPLCURSOR;
+#if 0
res = ((flags & VTFL_APPLCURSOR) ? 1 : 2);
+#endif
break;
case 2: /* DECANM ANSI vt100/vt52 */
+#if 0
res = 3; /* permanently set ??? */
+#endif
break;
case 3: /* DECCOLM 132/80 cols */
case 4: /* DECSCLM smooth/jump scroll */
case 5: /* DECSCNM light/dark background */
+#if 0
res = 4; /* all permanently reset ??? */
+#endif
break;
case 6: /* DECOM move within/outside margins */
if (op == VTMODE_SET)
flags |= VTFL_DECOM;
else if (op == VTMODE_RESET)
flags &= ~VTFL_DECOM;
+#if 0
res = ((flags & VTFL_DECOM) ? 1 : 2);
+#endif
break;
case 7: /* DECAWM autowrap */
if (op == VTMODE_SET)
flags |= VTFL_DECAWM;
else if (op == VTMODE_RESET)
flags &= ~VTFL_DECAWM;
+#if 0
res = ((flags & VTFL_DECAWM) ? 1 : 2);
+#endif
break;
case 8: /* DECARM keyboard autorepeat */
break;
@@ -816,7 +827,9 @@ vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
if (flags != edp->flags)
(*edp->emulops->cursor)(edp->emulcookie,
flags & VTFL_CURSORON, edp->crow, edp->ccol);
+#if 0
res = ((flags & VTFL_CURSORON) ? 1 : 2);
+#endif
break;
case 42: /* DECNRCM use 7-bit NRC /
7/8 bit from DEC multilingual or ISO-latin-1*/
@@ -824,7 +837,9 @@ vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
flags |= VTFL_NATCHARSET;
else if (op == VTMODE_RESET)
flags &= ~VTFL_NATCHARSET;
+#if 0
res = ((flags & VTFL_NATCHARSET) ? 1 : 2);
+#endif
break;
case 66: /* DECNKM numeric keypad */
break;
@@ -837,6 +852,4 @@ vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
break;
}
edp->flags = flags;
-
- return (res);
}