summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-02-09 15:55:21 +0000
committered <ed@FreeBSD.org>2009-02-09 15:55:21 +0000
commit95eb58b803ea56258e8a3784dd6b04e5b62c4ddb (patch)
treed08212594841b3d669346a5c68d86e38107efd48
parentb47ed35e3f5572770fa8f0e9df71d763cfe85ac9 (diff)
downloadFreeBSD-src-95eb58b803ea56258e8a3784dd6b04e5b62c4ddb.zip
FreeBSD-src-95eb58b803ea56258e8a3784dd6b04e5b62c4ddb.tar.gz
Properly implement GIO_ATTR and CONS_GETINFO.
It seems I didn't implement these two ioctl()'s properly, which meant vidcontrol couldn't properly obtain certain terminal parameters.
-rw-r--r--sys/dev/syscons/scterm-teken.c25
-rw-r--r--sys/dev/syscons/teken/teken.c14
-rw-r--r--sys/dev/syscons/teken/teken.h4
3 files changed, 32 insertions, 11 deletions
diff --git a/sys/dev/syscons/scterm-teken.c b/sys/dev/syscons/scterm-teken.c
index 798a2cd..38caf9a 100644
--- a/sys/dev/syscons/scterm-teken.c
+++ b/sys/dev/syscons/scterm-teken.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <dev/syscons/teken/teken.h>
static void scteken_revattr(unsigned char, teken_attr_t *);
+static unsigned int scteken_attr(const teken_attr_t *);
static sc_term_init_t scteken_init;
static sc_term_term_t scteken_term;
@@ -165,21 +166,25 @@ static int
scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
struct thread *td)
{
+ teken_stat *ts = scp->ts;
vid_info_t *vi;
+ unsigned int attr;
switch (cmd) {
case GIO_ATTR: /* get current attributes */
- *(int*)data = SC_NORM_ATTR;
+ *(int*)data =
+ scteken_attr(teken_get_curattr(&ts->ts_teken));
return (0);
case CONS_GETINFO: /* get current (virtual) console info */
- /* XXX: INCORRECT! */
vi = (vid_info_t *)data;
if (vi->size != sizeof(struct vid_info))
return EINVAL;
- vi->mv_norm.fore = SC_NORM_ATTR & 0x0f;
- vi->mv_norm.back = (SC_NORM_ATTR >> 4) & 0x0f;
- vi->mv_rev.fore = SC_NORM_ATTR & 0x0f;
- vi->mv_rev.back = (SC_NORM_ATTR >> 4) & 0x0f;
+
+ attr = scteken_attr(teken_get_defattr(&ts->ts_teken));
+ vi->mv_norm.fore = attr & 0x0f;
+ vi->mv_norm.back = (attr >> 4) & 0x0f;
+ vi->mv_rev.fore = vi->mv_norm.back;
+ vi->mv_rev.back = vi->mv_norm.fore;
/*
* The other fields are filled by the upper routine. XXX
*/
@@ -280,7 +285,7 @@ scteken_revattr(unsigned char color, teken_attr_t *a)
}
}
-static inline unsigned int
+static unsigned int
scteken_attr(const teken_attr_t *a)
{
unsigned int attr = 0;
@@ -300,7 +305,7 @@ scteken_attr(const teken_attr_t *a)
attr |= FG_BLINK;
#endif /* FG_BLINK */
- return (attr << 8);
+ return (attr);
}
static void
@@ -337,7 +342,7 @@ scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c,
} else
#endif /* TEKEN_UTF8 */
{
- attr = scteken_attr(a);
+ attr = scteken_attr(a) << 8;
ch = c;
}
@@ -373,7 +378,7 @@ scteken_fill(void *arg, const teken_rect_t *r, teken_char_t c,
} else
#endif /* TEKEN_UTF8 */
{
- attr = scteken_attr(a);
+ attr = scteken_attr(a) << 8;
ch = c;
}
diff --git a/sys/dev/syscons/teken/teken.c b/sys/dev/syscons/teken/teken.c
index 3a60255..5720859 100644
--- a/sys/dev/syscons/teken/teken.c
+++ b/sys/dev/syscons/teken/teken.c
@@ -329,6 +329,20 @@ teken_set_cursor(teken_t *t, const teken_pos_t *p)
t->t_cursor = *p;
}
+const teken_attr_t *
+teken_get_curattr(teken_t *t)
+{
+
+ return (&t->t_curattr);
+}
+
+const teken_attr_t *
+teken_get_defattr(teken_t *t)
+{
+
+ return (&t->t_defattr);
+}
+
void
teken_set_defattr(teken_t *t, const teken_attr_t *a)
{
diff --git a/sys/dev/syscons/teken/teken.h b/sys/dev/syscons/teken/teken.h
index ed965d9..dcd43d7 100644
--- a/sys/dev/syscons/teken/teken.h
+++ b/sys/dev/syscons/teken/teken.h
@@ -170,7 +170,9 @@ void teken_init(teken_t *, const teken_funcs_t *, void *);
/* Deliver character input. */
void teken_input(teken_t *, const void *, size_t);
-/* Set teken attributes. */
+/* Get/set teken attributes. */
+const teken_attr_t *teken_get_curattr(teken_t *);
+const teken_attr_t *teken_get_defattr(teken_t *);
void teken_set_cursor(teken_t *, const teken_pos_t *);
void teken_set_defattr(teken_t *, const teken_attr_t *);
void teken_set_winsize(teken_t *, const teken_pos_t *);
OpenPOWER on IntegriCloud