diff options
| author | jmmv <jmmv@NetBSD.org> | 2004-07-28 12:34:02 +0000 |
|---|---|---|
| committer | jmmv <jmmv@NetBSD.org> | 2004-07-28 12:34:02 +0000 |
| commit | 92f81ea7d3230a3390fd962f3788dcdcbc17ddd2 (patch) | |
| tree | a12e9fc1ac5ff154d36f8fd820431df8e485879b /sys/dev/ic | |
| parent | 3f5c400809f99ead824e182465a941b3fcad41c1 (diff) | |
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
Diffstat (limited to 'sys/dev/ic')
| -rw-r--r-- | sys/dev/ic/pcdisplay_subr.c | 43 | ||||
| -rw-r--r-- | sys/dev/ic/pcdisplayvar.h | 3 | ||||
| -rw-r--r-- | sys/dev/ic/vga.c | 23 |
3 files changed, 58 insertions, 11 deletions
diff --git a/sys/dev/ic/pcdisplay_subr.c b/sys/dev/ic/pcdisplay_subr.c index 74213f967bf..86ca0daf48f 100644 --- a/sys/dev/ic/pcdisplay_subr.c +++ b/sys/dev/ic/pcdisplay_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcdisplay_subr.c,v 1.26 2004/05/28 21:42:29 christos Exp $ */ +/* $NetBSD: pcdisplay_subr.c,v 1.27 2004/07/28 12:34:04 jmmv Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -28,7 +28,10 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.26 2004/05/28 21:42:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.27 2004/07/28 12:34:04 jmmv Exp $"); + +#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */ +#include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */ #include <sys/param.h> #include <sys/systm.h> @@ -41,8 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.26 2004/05/28 21:42:29 christos #include <dev/wscons/wsdisplayvar.h> -#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */ - void pcdisplay_cursor_init(scr, existing) struct pcdisplayscreen *scr; @@ -278,6 +279,40 @@ pcdisplay_eraserows(id, startrow, nrows, fillattr) scr->mem[off + i] = val; } +#ifdef WSDISPLAY_CUSTOM_OUTPUT +void +pcdisplay_replaceattr(id, oldattr, newattr) + void *id; + long oldattr, newattr; +{ + struct pcdisplayscreen *scr = id; + bus_space_tag_t memt = scr->hdl->ph_memt; + bus_space_handle_t memh = scr->hdl->ph_memh; + int off; + uint16_t chardata; + + if (scr->active) + for (off = 0; off < scr->type->nrows * scr->type->ncols; + off++) { + chardata = bus_space_read_2(memt, memh, + scr->dispoffset + off * 2); + if ((long)(chardata >> 8) == oldattr) + bus_space_write_2(memt, memh, + scr->dispoffset + off * 2, + ((u_int16_t)(newattr << 8)) | + (chardata & 0x00FF)); + } + else + for (off = 0; off < scr->type->nrows * scr->type->ncols; + off++) { + chardata = scr->mem[off]; + if ((long)(chardata >> 8) == oldattr) + scr->mem[off] = ((u_int16_t)(newattr << 8)) | + (chardata & 0x00FF); + } +} +#endif /* WSDISPLAY_CUSTOM_OUTPUT */ + #ifdef WSDISPLAY_CHARFUNCS int pcdisplay_getwschar(id, wschar) diff --git a/sys/dev/ic/pcdisplayvar.h b/sys/dev/ic/pcdisplayvar.h index 28ac8e6215f..11415421a71 100644 --- a/sys/dev/ic/pcdisplayvar.h +++ b/sys/dev/ic/pcdisplayvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcdisplayvar.h,v 1.13 2004/05/28 21:42:29 christos Exp $ */ +/* $NetBSD: pcdisplayvar.h,v 1.14 2004/07/28 12:34:04 jmmv Exp $ */ /* * Copyright (c) 1998 @@ -88,6 +88,7 @@ void pcdisplay_copycols(void *, int, int, int,int); void pcdisplay_erasecols(void *, int, int, int, long); void pcdisplay_copyrows(void *, int, int, int); void pcdisplay_eraserows(void *, int, int, long); +void pcdisplay_replaceattr(void *, long, long); struct wsdisplay_char; int pcdisplay_getwschar(void *, struct wsdisplay_char *); int pcdisplay_putwschar(void *, struct wsdisplay_char *); diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index f4e3cb87555..9fd61a19a5f 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $NetBSD: vga.c,v 1.74 2004/05/29 02:04:56 christos Exp $ */ +/* $NetBSD: vga.c,v 1.75 2004/07/28 12:34:04 jmmv Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -27,8 +27,13 @@ * rights to redistribute these changes. */ +/* for WSCONS_SUPPORT_PCVTFONTS and WSDISPLAY_CHARFUNCS */ +#include "opt_wsdisplay_compat.h" +/* for WSDISPLAY_CUSTOM_OUTPUT */ +#include "opt_wsmsgattrs.h" + #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.74 2004/05/29 02:04:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.75 2004/07/28 12:34:04 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,9 +56,6 @@ __KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.74 2004/05/29 02:04:56 christos Exp $"); #include <dev/ic/pcdisplay.h> -/* for WSCONS_SUPPORT_PCVTFONTS and WSDISPLAY_CHARFUNCS */ -#include "opt_wsdisplay_compat.h" - int vga_no_builtinfont = 0; static struct wsdisplay_font _vga_builtinfont = { @@ -134,7 +136,12 @@ const struct wsdisplay_emulops vga_emulops = { pcdisplay_erasecols, vga_copyrows, pcdisplay_eraserows, - vga_allocattr + vga_allocattr, +#ifdef WSDISPLAY_CUSTOM_OUTPUT + pcdisplay_replaceattr, +#else + NULL, +#endif }; /* @@ -476,6 +483,10 @@ vga_init_screen(struct vga_config *vc, struct vgascreen *scr, if (!vc->hdl.vh_mono) /* * DEC firmware uses a blue background. + * XXX These should be specified as kernel options for + * XXX alpha only, not hardcoded here (which is wrong + * XXX anyway because the emulation layer will assume + * XXX the default attribute is white on black). */ res = vga_allocattr(scr, WSCOL_WHITE, WSCOL_BLUE, WSATTR_WSCOLORS, attrp); |
