? sbin/wsconsctl/.gdbinit ? sbin/wsconsctl/keysym.h ? sbin/wsconsctl/map_parse.c ? sbin/wsconsctl/map_parse.h ? sbin/wsconsctl/map_scan.c ? sbin/wsconsctl/wsconsctl ? sbin/wsconsctl/wsconsctl.cat8 Index: sys/arch/i386/conf/DELPHI =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/DELPHI,v retrieving revision 1.37 diff -u -r1.37 DELPHI --- sys/arch/i386/conf/DELPHI 15 Jul 2004 03:53:47 -0000 1.37 +++ sys/arch/i386/conf/DELPHI 28 Jul 2004 12:14:37 -0000 @@ -160,9 +160,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.623 diff -u -r1.623 GENERIC --- sys/arch/i386/conf/GENERIC 19 Jul 2004 14:23:59 -0000 1.623 +++ sys/arch/i386/conf/GENERIC 28 Jul 2004 12:14:38 -0000 @@ -226,9 +226,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/GENERIC_LAPTOP =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC_LAPTOP,v retrieving revision 1.107 diff -u -r1.107 GENERIC_LAPTOP --- sys/arch/i386/conf/GENERIC_LAPTOP 19 Jul 2004 14:23:59 -0000 1.107 +++ sys/arch/i386/conf/GENERIC_LAPTOP 28 Jul 2004 12:14:51 -0000 @@ -190,9 +190,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/GENERIC_TINY =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC_TINY,v retrieving revision 1.69 diff -u -r1.69 GENERIC_TINY --- sys/arch/i386/conf/GENERIC_TINY 15 Jul 2004 03:53:47 -0000 1.69 +++ sys/arch/i386/conf/GENERIC_TINY 28 Jul 2004 12:14:51 -0000 @@ -170,9 +170,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/INSTALL =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/INSTALL,v retrieving revision 1.245 diff -u -r1.245 INSTALL --- sys/arch/i386/conf/INSTALL 19 Jul 2004 14:24:00 -0000 1.245 +++ sys/arch/i386/conf/INSTALL 28 Jul 2004 12:14:52 -0000 @@ -158,9 +158,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h -options WS_KERNEL_FG=WSCOL_WHITE +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" +#options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers #options WSDISPLAY_COMPAT_PCVT # emulate some ioctls #options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/INSTALL_LAPTOP =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/INSTALL_LAPTOP,v retrieving revision 1.64 diff -u -r1.64 INSTALL_LAPTOP --- sys/arch/i386/conf/INSTALL_LAPTOP 23 Jul 2004 15:36:00 -0000 1.64 +++ sys/arch/i386/conf/INSTALL_LAPTOP 28 Jul 2004 12:14:54 -0000 @@ -156,9 +156,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h -options WS_KERNEL_FG=WSCOL_WHITE +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" +#options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers #options WSDISPLAY_COMPAT_PCVT # emulate some ioctls #options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/IOPENER =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/IOPENER,v retrieving revision 1.46 diff -u -r1.46 IOPENER --- sys/arch/i386/conf/IOPENER 15 Jul 2004 03:53:49 -0000 1.46 +++ sys/arch/i386/conf/IOPENER 28 Jul 2004 12:14:57 -0000 @@ -143,9 +143,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/LAMB =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/LAMB,v retrieving revision 1.37 diff -u -r1.37 LAMB --- sys/arch/i386/conf/LAMB 15 Jul 2004 03:53:49 -0000 1.37 +++ sys/arch/i386/conf/LAMB 28 Jul 2004 12:14:58 -0000 @@ -164,9 +164,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/SWINGER =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/SWINGER,v retrieving revision 1.50 diff -u -r1.50 SWINGER --- sys/arch/i386/conf/SWINGER 15 Jul 2004 03:53:49 -0000 1.50 +++ sys/arch/i386/conf/SWINGER 28 Jul 2004 12:14:58 -0000 @@ -156,9 +156,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +#options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/arch/i386/conf/VIRTUALPC =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/VIRTUALPC,v retrieving revision 1.7 diff -u -r1.7 VIRTUALPC --- sys/arch/i386/conf/VIRTUALPC 15 Jul 2004 03:53:49 -0000 1.7 +++ sys/arch/i386/conf/VIRTUALPC 28 Jul 2004 12:14:59 -0000 @@ -198,9 +198,16 @@ # builtin terminal emulations #options WSEMUL_SUN # sun terminal emulation options WSEMUL_VT100 # VT100 / VT220 emulation -# different kernel output - see dev/wscons/wsdisplayvar.h +# customization of console and kernel output - see dev/wscons/wsdisplayvar.h +options WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8) +#options WS_DEFAULT_FG=WSCOL_WHITE +#options WS_DEFAULT_BG=WSCOL_BLACK +#options WS_DEFAULT_COLATTR="" +#options WS_DEFAULT_MONOATTR="" options WS_KERNEL_FG=WSCOL_GREEN #options WS_KERNEL_BG=WSCOL_BLACK +#options WS_KERNEL_COLATTR="" +#options WS_KERNEL_MONOATTR="" # compatibility to other console drivers options WSDISPLAY_COMPAT_PCVT # emulate some ioctls options WSDISPLAY_COMPAT_SYSCONS # emulate some ioctls Index: sys/dev/ic/pcdisplay_subr.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/pcdisplay_subr.c,v retrieving revision 1.26 diff -u -r1.26 pcdisplay_subr.c --- sys/dev/ic/pcdisplay_subr.c 28 May 2004 21:42:29 -0000 1.26 +++ sys/dev/ic/pcdisplay_subr.c 28 Jul 2004 12:15:03 -0000 @@ -30,6 +30,9 @@ #include __KERNEL_RCSID(0, "$NetBSD: pcdisplay_subr.c,v 1.26 2004/05/28 21:42:29 christos Exp $"); +#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */ +#include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */ + #include #include #include @@ -41,8 +44,6 @@ #include -#include "opt_wsdisplay_compat.h" /* for WSDISPLAY_CHARFUNCS */ - void pcdisplay_cursor_init(scr, existing) struct pcdisplayscreen *scr; @@ -278,6 +279,40 @@ 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) Index: sys/dev/ic/pcdisplayvar.h =================================================================== RCS file: /cvsroot/src/sys/dev/ic/pcdisplayvar.h,v retrieving revision 1.13 diff -u -r1.13 pcdisplayvar.h --- sys/dev/ic/pcdisplayvar.h 28 May 2004 21:42:29 -0000 1.13 +++ sys/dev/ic/pcdisplayvar.h 28 Jul 2004 12:15:03 -0000 @@ -88,6 +88,7 @@ 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 *); Index: sys/dev/ic/vga.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/vga.c,v retrieving revision 1.74 diff -u -r1.74 vga.c --- sys/dev/ic/vga.c 29 May 2004 02:04:56 -0000 1.74 +++ sys/dev/ic/vga.c 28 Jul 2004 12:15:05 -0000 @@ -27,6 +27,11 @@ * 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 __KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.74 2004/05/29 02:04:56 christos Exp $"); @@ -51,9 +56,6 @@ #include -/* 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 @@ pcdisplay_erasecols, vga_copyrows, pcdisplay_eraserows, - vga_allocattr + vga_allocattr, +#ifdef WSDISPLAY_CUSTOM_OUTPUT + pcdisplay_replaceattr, +#else + NULL, +#endif }; /* @@ -476,6 +483,10 @@ 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); Index: sys/dev/wscons/files.wscons =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/files.wscons,v retrieving revision 1.30 diff -u -r1.30 files.wscons --- sys/dev/wscons/files.wscons 28 May 2004 21:42:29 -0000 1.30 +++ sys/dev/wscons/files.wscons 28 Jul 2004 12:15:06 -0000 @@ -14,8 +14,10 @@ defparam opt_wsemul.h WSEMUL_DEFAULT defflag opt_wsemul.h WSEMUL_NO_DUMB WSEMUL_SUN WSEMUL_VT100 -defparam opt_wskernattr.h WS_KERNEL_FG WS_KERNEL_BG +defparam opt_wsmsgattrs.h WS_DEFAULT_COLATTR WS_DEFAULT_MONOATTR + WS_DEFAULT_BG WS_DEFAULT_FG WS_KERNEL_COLATTR WS_KERNEL_MONOATTR + WS_KERNEL_BG WS_KERNEL_FG WSDISPLAY_SCROLLCOMBO defparam opt_wsemul.h WSEMUL_VT100_HILIT_FG WSEMUL_VT100_UNDERLINE_FG WSEMUL_VT100_HILIT_BG WSEMUL_VT100_UNDERLINE_BG Index: sys/dev/wscons/wsconsio.h =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsconsio.h,v retrieving revision 1.67 diff -u -r1.67 wsconsio.h --- sys/dev/wscons/wsconsio.h 20 Jul 2004 20:28:20 -0000 1.67 +++ sys/dev/wscons/wsconsio.h 28 Jul 2004 12:15:11 -0000 @@ -443,6 +443,14 @@ #define WSDISPLAYIO_DGSCROLL _IOR('W', 87, struct wsdisplay_scroll_data) #define WSDISPLAYIO_DSSCROLL _IOW('W', 88, struct wsdisplay_scroll_data) +struct wsdisplay_msgattrs { + int default_attrs, default_bg, default_fg; + int kernel_attrs, kernel_bg, kernel_fg; +}; + +#define WSDISPLAYIO_GMSGATTRS _IOR('W', 89, struct wsdisplay_msgattrs) +#define WSDISPLAYIO_SMSGATTRS _IOW('W', 90, struct wsdisplay_msgattrs) + /* XXX NOT YET DEFINED */ /* Mapping information retrieval. */ Index: sys/dev/wscons/wsdisplay.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsdisplay.c,v retrieving revision 1.79 diff -u -r1.79 wsdisplay.c --- sys/dev/wscons/wsdisplay.c 20 Jul 2004 20:28:20 -0000 1.79 +++ sys/dev/wscons/wsdisplay.c 28 Jul 2004 12:15:15 -0000 @@ -34,6 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.79 2004/07/20 20:28:20 heas Exp $"); #include "opt_wsdisplay_compat.h" +#include "opt_wsmsgattrs.h" #include "opt_compat_netbsd.h" #include "wskbd.h" #include "wsmux.h" @@ -1151,6 +1152,32 @@ return ENODEV; #endif /* WSDISPLAY_CHARFUNCS */ +#ifdef WSDISPLAY_CUSTOM_OUTPUT + case WSDISPLAYIO_GMSGATTRS: +#define d ((struct wsdisplay_msgattrs *)data) + (*scr->scr_dconf->wsemul->getmsgattrs) + (scr->scr_dconf->wsemulcookie, d); + return (0); +#undef d + + case WSDISPLAYIO_SMSGATTRS: { +#define d ((struct wsdisplay_msgattrs *)data) + int i; + for (i = 0; i < WSDISPLAY_MAXSCREEN; i++) + if (sc->sc_scr[i] != NULL) + (*sc->sc_scr[i]->scr_dconf->wsemul->setmsgattrs) + (sc->sc_scr[i]->scr_dconf->wsemulcookie, + sc->sc_scr[i]->scr_dconf->scrdata, + d); + } + return (0); +#undef d +#else + case WSDISPLAYIO_GMSGATTRS: + case WSDISPLAYIO_SMSGATTRS: + return (ENODEV); +#endif + } /* check ioctls for display */ Index: sys/dev/wscons/wsdisplayvar.h =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsdisplayvar.h,v retrieving revision 1.27 diff -u -r1.27 wsdisplayvar.h --- sys/dev/wscons/wsdisplayvar.h 28 May 2004 22:38:28 -0000 1.27 +++ sys/dev/wscons/wsdisplayvar.h 28 Jul 2004 12:15:16 -0000 @@ -73,6 +73,7 @@ #define WSATTR_UNDERLINE 8 #define WSATTR_WSCOLORS 16 /* XXX need a free_attr() ??? */ + void (*replaceattr)(void *c, long oldattr, long newattr); }; struct wsscreen_descr { @@ -215,3 +216,39 @@ void wsdisplay_switchtoconsole(void); const struct wsscreen_descr * wsdisplay_screentype_pick(const struct wsscreen_list *, const char *); + +#if defined(_KERNEL) +# if defined(_KERNEL_OPT) +# include "opt_wsmsgattrs.h" +# endif +# if !defined(WS_DEFAULT_FG) +# define WS_DEFAULT_FG WSCOL_WHITE +# endif +# if !defined(WS_DEFAULT_BG) +# define WS_DEFAULT_BG WSCOL_BLACK +# endif +# if !defined(WS_DEFAULT_COLATTR) +# define WS_DEFAULT_COLATTR 0 +# endif +# if !defined(WS_DEFAULT_MONOATTR) +# define WS_DEFAULT_MONOATTR 0 +# endif +# if defined(WS_KERNEL_FG) || defined(WS_KERNEL_BG) || \ + defined(WS_KERNEL_COLATTR) || defined(WS_KERNEL_MONOATTR) +# define WS_KERNEL_CUSTOMIZED +# else +# undef WS_KERNEL_CUSTOMIZED +# endif +# if !defined(WS_KERNEL_FG) +# define WS_KERNEL_FG WS_DEFAULT_FG +# endif +# if !defined(WS_KERNEL_BG) +# define WS_KERNEL_BG WS_DEFAULT_BG +# endif +# if !defined(WS_KERNEL_COLATTR) +# define WS_KERNEL_COLATTR WS_DEFAULT_COLATTR +# endif +# if !defined(WS_KERNEL_MONOATTR) +# define WS_KERNEL_MONOATTR WS_DEFAULT_MONOATTR +# endif +#endif /* _KERNEL */ Index: sys/dev/wscons/wsemul_sun.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_sun.c,v retrieving revision 1.17 diff -u -r1.17 wsemul_sun.c --- sys/dev/wscons/wsemul_sun.c 27 Sep 2002 15:37:40 -0000 1.17 +++ sys/dev/wscons/wsemul_sun.c 28 Jul 2004 12:15:16 -0000 @@ -47,7 +47,7 @@ #include #include -#include "opt_wskernattr.h" +#include "opt_wsmsgattrs.h" void *wsemul_sun_cnattach(const struct wsscreen_descr *, void *, int, int, long); Index: sys/dev/wscons/wsemul_vt100.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_vt100.c,v retrieving revision 1.25 diff -u -r1.25 wsemul_vt100.c --- sys/dev/wscons/wsemul_vt100.c 24 Mar 2004 17:26:53 -0000 1.25 +++ sys/dev/wscons/wsemul_vt100.c 28 Jul 2004 12:15:17 -0000 @@ -29,6 +29,8 @@ #include __KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.25 2004/03/24 17:26:53 drochner Exp $"); +#include "opt_wsmsgattrs.h" + #include #include #include @@ -41,8 +43,6 @@ #include #include -#include "opt_wskernattr.h" - void *wsemul_vt100_cnattach(const struct wsscreen_descr *, void *, int, int, long); void *wsemul_vt100_attach(int console, const struct wsscreen_descr *, @@ -50,6 +50,11 @@ 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_resetop(void *, enum wsemul_resetops); +#ifdef WSDISPLAY_CUSTOM_OUTPUT +static void wsemul_vt100_getmsgattrs(void *, struct wsdisplay_msgattrs *); +static void wsemul_vt100_setmsgattrs(void *, const struct wsscreen_descr *, + const struct wsdisplay_msgattrs *); +#endif /* WSDISPLAY_CUSTOM_OUTPUT */ const struct wsemul_ops wsemul_vt100_ops = { "vt100", @@ -58,7 +63,14 @@ wsemul_vt100_output, wsemul_vt100_translate, wsemul_vt100_detach, - wsemul_vt100_resetop + wsemul_vt100_resetop, +#ifdef WSDISPLAY_CUSTOM_OUTPUT + wsemul_vt100_getmsgattrs, + wsemul_vt100_setmsgattrs, +#else + NULL, + NULL, +#endif }; struct wsemul_vt100_emuldata wsemul_vt100_console_emuldata; @@ -122,6 +134,8 @@ const struct wsscreen_descr *type, void *cookie, int ccol, int crow, long defattr) { + int error; + edp->emulops = type->textops; edp->emulcookie = cookie; edp->scrcapabilities = type->capabilities; @@ -129,7 +143,64 @@ edp->ncols = type->ncols; edp->crow = crow; edp->ccol = ccol; - edp->defattr = defattr; + + /* The underlying driver has already allocated a default and simple + * attribute for us, which is stored in defattr. We try to set the + * values specified by the kernel options below, but in case of + * failure we fallback to the value given by the driver. */ + + if (type->capabilities & WSSCREEN_WSCOLORS) { + edp->msgattrs.default_attrs = WS_DEFAULT_COLATTR | + WSATTR_WSCOLORS; + edp->msgattrs.default_bg = WS_DEFAULT_BG; + edp->msgattrs.default_fg = WS_DEFAULT_FG; + + edp->msgattrs.kernel_attrs = WS_KERNEL_COLATTR | + WSATTR_WSCOLORS; + edp->msgattrs.kernel_bg = WS_KERNEL_BG; + edp->msgattrs.kernel_fg = WS_KERNEL_FG; + } else { + edp->msgattrs.default_attrs = WS_DEFAULT_MONOATTR; + edp->msgattrs.default_bg = edp->msgattrs.default_fg = 0; + + edp->msgattrs.kernel_attrs = WS_KERNEL_MONOATTR; + edp->msgattrs.kernel_bg = edp->msgattrs.kernel_fg = 0; + } + + error = (*edp->emulops->allocattr)(cookie, + edp->msgattrs.default_fg, + edp->msgattrs.default_bg, + edp->msgattrs.default_attrs, + &edp->defattr); + if (error) { + edp->defattr = defattr; + /* XXX This assumes the driver has allocated white on black + * XXX as the default attribute, which is not always true. + * XXX Maybe we need an emulop that, given an attribute, + * XXX (defattr) returns its flags and colors? */ + edp->msgattrs.default_attrs = 0; + edp->msgattrs.default_bg = WSCOL_BLACK; + edp->msgattrs.default_fg = WSCOL_WHITE; + } else { + if (edp->emulops->replaceattr != NULL) + (*edp->emulops->replaceattr)(cookie, defattr, + edp->defattr); + } + +#if defined(WS_KERNEL_CUSTOMIZED) + /* Set up kernel colors, in case they were customized by the user; + * otherwise default to the colors specified for the console. + * In case of failure, we use console colors too; we can assume + * they are good as they have been previously allocated and + * verified. */ + error = (*edp->emulops->allocattr)(cookie, + edp->msgattrs.kernel_fg, + edp->msgattrs.kernel_bg, + edp->msgattrs.kernel_attrs, + &edp->kernattr); + if (error) +#endif + edp->kernattr = edp->defattr; } void * @@ -137,10 +208,6 @@ int ccol, int crow, long defattr) { struct wsemul_vt100_emuldata *edp; -#if defined(WS_KERNEL_FG) || defined(WS_KERNEL_BG) || \ - defined(WS_KERNEL_COLATTR) || defined(WS_KERNEL_MONOATTR) - int res; -#endif edp = &wsemul_vt100_console_emuldata; wsemul_vt100_init(edp, type, cookie, ccol, crow, defattr); @@ -149,33 +216,6 @@ #endif edp->cbcookie = NULL; -#if defined(WS_KERNEL_FG) || defined(WS_KERNEL_BG) || \ - defined(WS_KERNEL_COLATTR) || defined(WS_KERNEL_MONOATTR) -#ifndef WS_KERNEL_FG -#define WS_KERNEL_FG WSCOL_WHITE -#endif -#ifndef WS_KERNEL_BG -#define WS_KERNEL_BG WSCOL_BLACK -#endif -#ifndef WS_KERNEL_COLATTR -#define WS_KERNEL_COLATTR 0 -#endif -#ifndef WS_KERNEL_MONOATTR -#define WS_KERNEL_MONOATTR 0 -#endif - if (type->capabilities & WSSCREEN_WSCOLORS) - res = (*edp->emulops->allocattr)(cookie, - WS_KERNEL_FG, WS_KERNEL_BG, - WS_KERNEL_COLATTR | WSATTR_WSCOLORS, - &edp->kernattr); - else - res = (*edp->emulops->allocattr)(cookie, 0, 0, - WS_KERNEL_MONOATTR, - &edp->kernattr); - if (res) -#endif - edp->kernattr = defattr; - edp->tabs = 0; edp->dblwid = 0; edp->dw = 0; @@ -270,9 +310,9 @@ edp->state = VT100_EMUL_STATE_NORMAL; edp->flags = VTFL_DECAWM | VTFL_CURSORON; edp->bkgdattr = edp->curattr = edp->defattr; - edp->attrflags = 0; - edp->fgcol = WSCOL_WHITE; - edp->bgcol = WSCOL_BLACK; + edp->attrflags = edp->msgattrs.default_attrs; + edp->fgcol = edp->msgattrs.default_fg; + edp->bgcol = edp->msgattrs.default_bg; edp->scrreg_startrow = 0; edp->scrreg_nrows = edp->nrows; if (edp->tabs) { @@ -939,3 +979,78 @@ (*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol << edp->dw); } + +#ifdef WSDISPLAY_CUSTOM_OUTPUT +static void +wsemul_vt100_getmsgattrs(void *cookie, struct wsdisplay_msgattrs *ma) +{ + struct wsemul_vt100_emuldata *edp = cookie; + + *ma = edp->msgattrs; +} + +static void +wsemul_vt100_setmsgattrs(void *cookie, const struct wsscreen_descr *type, + const struct wsdisplay_msgattrs *ma) +{ + int error; + long tmp; + struct wsemul_vt100_emuldata *edp = cookie; + + edp->msgattrs = *ma; + if (type->capabilities & WSSCREEN_WSCOLORS) { + edp->msgattrs.default_attrs |= WSATTR_WSCOLORS; + edp->msgattrs.kernel_attrs |= WSATTR_WSCOLORS; + } else { + edp->msgattrs.default_bg = edp->msgattrs.kernel_bg = 0; + edp->msgattrs.default_fg = edp->msgattrs.kernel_fg = 0; + } + + error = (*edp->emulops->allocattr)(edp->emulcookie, + edp->msgattrs.default_fg, + edp->msgattrs.default_bg, + edp->msgattrs.default_attrs, + &tmp); +#ifdef VT100_DEBUG + if (error) + printf("vt100: failed to allocate attribute for default " + "messages\n"); + else +#endif + { + if (edp->curattr == edp->defattr) { + edp->bkgdattr = edp->curattr = tmp; + edp->attrflags = edp->msgattrs.default_attrs; + edp->bgcol = edp->msgattrs.default_bg; + edp->fgcol = edp->msgattrs.default_fg; + } else { + edp->savedbkgdattr = edp->savedattr = tmp; + edp->savedattrflags = edp->msgattrs.default_attrs; + edp->savedbgcol = edp->msgattrs.default_bg; + edp->savedfgcol = edp->msgattrs.default_fg; + } + if (edp->emulops->replaceattr != NULL) + (*edp->emulops->replaceattr)(edp->emulcookie, + edp->defattr, tmp); + edp->defattr = tmp; + } + + error = (*edp->emulops->allocattr)(edp->emulcookie, + edp->msgattrs.kernel_fg, + edp->msgattrs.kernel_bg, + edp->msgattrs.kernel_attrs, + &tmp); +#ifdef VT100_DEBUG + if (error) + printf("vt100: failed to allocate attribute for kernel " + "messages\n"); + else +#endif + { + if (edp->emulops->replaceattr != NULL) + (*edp->emulops->replaceattr)(edp->emulcookie, + edp->kernattr, tmp); + edp->kernattr = tmp; + } +} +#endif /* WSDISPLAY_CUSTOM_OUTPUT */ Index: sys/dev/wscons/wsemul_vt100_chars.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_vt100_chars.c,v retrieving revision 1.9 diff -u -r1.9 wsemul_vt100_chars.c --- sys/dev/wscons/wsemul_vt100_chars.c 24 Mar 2004 17:26:53 -0000 1.9 +++ sys/dev/wscons/wsemul_vt100_chars.c 28 Jul 2004 12:15:22 -0000 @@ -31,6 +31,7 @@ #include #include +#include #include #include #include Index: sys/dev/wscons/wsemul_vt100_keys.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_vt100_keys.c,v retrieving revision 1.6 diff -u -r1.6 wsemul_vt100_keys.c --- sys/dev/wscons/wsemul_vt100_keys.c 24 Mar 2004 17:26:53 -0000 1.6 +++ sys/dev/wscons/wsemul_vt100_keys.c 28 Jul 2004 12:15:22 -0000 @@ -32,6 +32,7 @@ #include #include +#include #include #include #include Index: sys/dev/wscons/wsemul_vt100_subr.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_vt100_subr.c,v retrieving revision 1.16 diff -u -r1.16 wsemul_vt100_subr.c --- sys/dev/wscons/wsemul_vt100_subr.c 23 Apr 2004 21:29:16 -0000 1.16 +++ sys/dev/wscons/wsemul_vt100_subr.c 28 Jul 2004 12:15:22 -0000 @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -474,14 +475,14 @@ case 0: /* reset */ if (n == edp->nargs - 1) { edp->bkgdattr = edp->curattr = edp->defattr; - edp->attrflags = 0; - edp->fgcol = WSCOL_WHITE; - edp->bgcol = WSCOL_BLACK; + edp->attrflags = edp->msgattrs.default_attrs; + edp->fgcol = edp->msgattrs.default_fg; + edp->bgcol = edp->msgattrs.default_bg; return; } - flags = 0; - fgcol = WSCOL_WHITE; - bgcol = WSCOL_BLACK; + flags = edp->msgattrs.default_attrs; + fgcol = edp->msgattrs.default_fg; + bgcol = edp->msgattrs.default_bg; break; case 1: /* bold */ flags |= WSATTR_HILIT; @@ -622,13 +623,13 @@ { int error; - if ((flags & WSATTR_WSCOLORS) && - !(edp->scrcapabilities & WSSCREEN_WSCOLORS)) { + if (!(edp->scrcapabilities & WSSCREEN_WSCOLORS)) { flags &= ~WSATTR_WSCOLORS; #ifdef VT100_DEBUG printf("colors ignored (impossible)\n"); #endif - } + } else + flags |= WSATTR_WSCOLORS; error = (*edp->emulops->allocattr)(edp->emulcookie, fgcol, bgcol, flags & WSATTR_WSCOLORS, bkgdattr); if (error) Index: sys/dev/wscons/wsemul_vt100var.h =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemul_vt100var.h,v retrieving revision 1.8 diff -u -r1.8 wsemul_vt100var.h --- sys/dev/wscons/wsemul_vt100var.h 24 Mar 2004 17:26:53 -0000 1.8 +++ sys/dev/wscons/wsemul_vt100var.h 28 Jul 2004 12:15:22 -0000 @@ -33,6 +33,7 @@ void *emulcookie; int scrcapabilities; u_int nrows, ncols, crow, ccol; + struct wsdisplay_msgattrs msgattrs; long defattr; /* default attribute */ long kernattr; /* attribute for kernel output */ Index: sys/dev/wscons/wsemulconf.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemulconf.c,v retrieving revision 1.5 diff -u -r1.5 wsemulconf.c --- sys/dev/wscons/wsemulconf.c 13 Oct 2001 15:56:16 -0000 1.5 +++ sys/dev/wscons/wsemulconf.c 28 Jul 2004 12:15:22 -0000 @@ -36,6 +36,7 @@ #include #include +#include #include #include #include /* pulls in opt_wsemul.h */ Index: sys/dev/wscons/wsemulvar.h =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsemulvar.h,v retrieving revision 1.8 diff -u -r1.8 wsemulvar.h --- sys/dev/wscons/wsemulvar.h 13 Oct 2001 15:56:16 -0000 1.8 +++ sys/dev/wscons/wsemulvar.h 28 Jul 2004 12:15:22 -0000 @@ -50,6 +50,9 @@ int (*translate)(void *, keysym_t, char **); void (*detach)(void *cookie, u_int *crow, u_int *ccol); void (*reset)(void *, enum wsemul_resetops); + void (*getmsgattrs)(void *, struct wsdisplay_msgattrs *); + void (*setmsgattrs)(void *, const struct wsscreen_descr *, + const struct wsdisplay_msgattrs *); }; #if defined(_KERNEL_OPT) Index: sbin/wsconsctl/display.c =================================================================== RCS file: /cvsroot/src/sbin/wsconsctl/display.c,v retrieving revision 1.4 diff -u -r1.4 display.c --- sbin/wsconsctl/display.c 3 Jun 2004 19:18:41 -0000 1.4 +++ sbin/wsconsctl/display.c 28 Jul 2004 12:15:22 -0000 @@ -52,12 +52,20 @@ static struct wsdisplay_usefontdata font; static struct wsdisplay_scroll_data scroll_l; static int havescroll = 1; +static int msg_default_attrs, msg_default_bg, msg_default_fg; +static int msg_kernel_attrs, msg_kernel_bg, msg_kernel_fg; struct field display_field_tab[] = { { "type", &dpytype, FMT_DPYTYPE, FLG_RDONLY }, { "font", &font.name, FMT_STRING, FLG_WRONLY }, { "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY }, { "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY }, + { "msg.default.attrs", &msg_default_attrs, FMT_ATTRS, FLG_MODIFY }, + { "msg.default.bg", &msg_default_bg, FMT_COLOR, FLG_MODIFY }, + { "msg.default.fg", &msg_default_fg, FMT_COLOR, FLG_MODIFY }, + { "msg.kernel.attrs", &msg_kernel_attrs, FMT_ATTRS, FLG_MODIFY }, + { "msg.kernel.bg", &msg_kernel_bg, FMT_COLOR, FLG_MODIFY }, + { "msg.kernel.fg", &msg_kernel_fg, FMT_COLOR, FLG_MODIFY }, }; int display_field_tab_len = sizeof(display_field_tab)/ @@ -84,6 +92,41 @@ if (ioctl(fd, WSDISPLAYIO_GTYPE, &dpytype) < 0) err(1, "WSDISPLAYIO_GTYPE"); + if (field_by_value(&msg_default_attrs)->flags & FLG_GET || + field_by_value(&msg_default_bg)->flags & FLG_GET || + field_by_value(&msg_default_fg)->flags & FLG_GET || + field_by_value(&msg_kernel_attrs)->flags & FLG_GET || + field_by_value(&msg_kernel_bg)->flags & FLG_GET || + field_by_value(&msg_kernel_fg)->flags & FLG_GET) { + struct wsdisplay_msgattrs ma; + + if (ioctl(fd, WSDISPLAYIO_GMSGATTRS, &ma) < 0) { + warnx("no support to change console/kernel colors"); + + ma.default_attrs = -1; + ma.default_bg = -1; + ma.default_fg = -1; + + ma.kernel_attrs = -1; + ma.kernel_bg = -1; + ma.kernel_fg = -1; + } + + msg_default_attrs = ma.default_attrs; + if (ma.default_attrs & WSATTR_WSCOLORS) { + msg_default_bg = ma.default_bg; + msg_default_fg = ma.default_fg; + } else + msg_default_bg = msg_default_fg = -1; + + msg_kernel_attrs = ma.kernel_attrs; + if (ma.kernel_attrs & WSATTR_WSCOLORS) { + msg_kernel_bg = ma.kernel_bg; + msg_kernel_fg = ma.kernel_fg; + } else + msg_kernel_bg = msg_kernel_fg = -1; + } + if (init_values() == 0 || havescroll == 0) return; @@ -104,7 +147,56 @@ err(1, "WSDISPLAYIO_SFONT"); pr_field(field_by_value(&font.name), " -> "); } - + + if (field_by_value(&msg_default_attrs)->flags & FLG_SET || + field_by_value(&msg_default_bg)->flags & FLG_SET || + field_by_value(&msg_default_fg)->flags & FLG_SET || + field_by_value(&msg_kernel_attrs)->flags & FLG_SET || + field_by_value(&msg_kernel_bg)->flags & FLG_SET || + field_by_value(&msg_kernel_fg)->flags & FLG_SET) { + struct wsdisplay_msgattrs ma; + + if (ioctl(fd, WSDISPLAYIO_GMSGATTRS, &ma) < 0) + err(1, "WSDISPLAYIO_GMSGATTRS"); + + if (field_by_value(&msg_default_attrs)->flags & FLG_SET) { + ma.default_attrs = msg_default_attrs; + pr_field(field_by_value(&msg_default_attrs), " -> "); + } + if (ma.default_attrs & WSATTR_WSCOLORS) { + if (field_by_value(&msg_default_bg)->flags & FLG_SET) { + ma.default_bg = msg_default_bg; + pr_field(field_by_value(&msg_default_bg), + " -> "); + } + if (field_by_value(&msg_default_fg)->flags & FLG_SET) { + ma.default_fg = msg_default_fg; + pr_field(field_by_value(&msg_default_fg), + " -> "); + } + } + + if (field_by_value(&msg_kernel_attrs)->flags & FLG_SET) { + ma.kernel_attrs = msg_kernel_attrs; + pr_field(field_by_value(&msg_kernel_attrs), " -> "); + } + if (ma.default_attrs & WSATTR_WSCOLORS) { + if (field_by_value(&msg_kernel_bg)->flags & FLG_SET) { + ma.kernel_bg = msg_kernel_bg; + pr_field(field_by_value(&msg_kernel_bg), + " -> "); + } + if (field_by_value(&msg_kernel_fg)->flags & FLG_SET) { + ma.kernel_fg = msg_kernel_fg; + pr_field(field_by_value(&msg_kernel_fg), + " -> "); + } + } + + if (ioctl(fd, WSDISPLAYIO_SMSGATTRS, &ma) < 0) + err(1, "WSDISPLAYIO_SMSGATTRS"); + } + if (init_values() == 0 || havescroll == 0) return; Index: sbin/wsconsctl/util.c =================================================================== RCS file: /cvsroot/src/sbin/wsconsctl/util.c,v retrieving revision 1.18 diff -u -r1.18 util.c --- sbin/wsconsctl/util.c 2 Apr 2004 22:16:52 -0000 1.18 +++ sbin/wsconsctl/util.c 28 Jul 2004 12:15:22 -0000 @@ -140,6 +140,27 @@ KB_VARTAB }; +static struct nameint color_tab[] = { + { WSCOL_UNSUPPORTED, "unsupported" }, + { WSCOL_BLACK, "black" }, + { WSCOL_RED, "red" }, + { WSCOL_GREEN, "green" }, + { WSCOL_BROWN, "brown" }, + { WSCOL_BLUE, "blue" }, + { WSCOL_MAGENTA, "magenta" }, + { WSCOL_CYAN, "cyan" }, + { WSCOL_WHITE, "white" }, +}; + +static struct nameint attr_tab[] = { + { WSATTR_NONE, "none" }, + { WSATTR_REVERSE, "reverse" }, + { WSATTR_HILIT, "hilit" }, + { WSATTR_BLINK, "blink" }, + { WSATTR_UNDERLINE, "underline" }, + { WSATTR_WSCOLORS, "color" }, +}; + static struct field *field_tab; static int field_tab_len; @@ -224,7 +245,7 @@ { char *p; u_int flags; - int i; + int first, i, mask; if (sep) printf("%s%s", f->name, sep); @@ -268,6 +289,26 @@ case FMT_KBMAP: print_kmap((struct wskbd_map_data *) f->valp); break; + case FMT_COLOR: + p = int2name(*((u_int *) f->valp), 1, + color_tab, TABLEN(color_tab)); + printf("%s", p); + break; + case FMT_ATTRS: + mask = 0x10; + first = 1; + while (mask > 0) { + if (*((u_int *) f->valp) & mask) { + p = int2name(*((u_int *) f->valp) & mask, 1, + attr_tab, TABLEN(attr_tab)); + printf("%s%s", first ? "" : ",", p); + first = 0; + } + mask >>= 1; + } + if (first) + printf("none"); + break; default: errx(1, "internal error: pr_field: no format %d", f->format); break; @@ -343,6 +384,25 @@ bcopy(newkbmap.map, kbmap.map, kbmap.maplen*sizeof(struct wscons_keymap)); break; + case FMT_COLOR: + i = name2int(val, color_tab, TABLEN(color_tab)); + if (i == -1) + errx(1, "%s: not a valid color", val); + *((u_int *) f->valp) = i; + break; + case FMT_ATTRS: + p = val; + while (p) { + val = p; + p = strchr(p, ','); + if (p != NULL) + *p++ = '\0'; + i = name2int(val, attr_tab, TABLEN(attr_tab)); + if (i == -1) + errx(1, "%s: not a valid attribute", val); + *((u_int *) f->valp) |= i; + } + break; default: errx(1, "internal error: rd_field: no format %d", f->format); break; Index: sbin/wsconsctl/wsconsctl.h =================================================================== RCS file: /cvsroot/src/sbin/wsconsctl/wsconsctl.h,v retrieving revision 1.3 diff -u -r1.3 wsconsctl.h --- sbin/wsconsctl/wsconsctl.h 7 Apr 2002 10:40:04 -0000 1.3 +++ sbin/wsconsctl/wsconsctl.h 28 Jul 2004 12:15:35 -0000 @@ -38,6 +38,24 @@ #include +/* fg / bg values. Made identical to ANSI terminal color codes. */ +#define WSCOL_UNSUPPORTED -1 +#define WSCOL_BLACK 0 +#define WSCOL_RED 1 +#define WSCOL_GREEN 2 +#define WSCOL_BROWN 3 +#define WSCOL_BLUE 4 +#define WSCOL_MAGENTA 5 +#define WSCOL_CYAN 6 +#define WSCOL_WHITE 7 +/* flag values: */ +#define WSATTR_NONE 0 +#define WSATTR_REVERSE 1 +#define WSATTR_HILIT 2 +#define WSATTR_BLINK 4 +#define WSATTR_UNDERLINE 8 +#define WSATTR_WSCOLORS 16 + struct field { char *name; void *valp; @@ -48,6 +66,8 @@ #define FMT_DPYTYPE 103 /* display type */ #define FMT_KBDENC 104 /* keyboard encoding */ #define FMT_KBMAP 105 /* keyboard map */ +#define FMT_COLOR 201 /* display color */ +#define FMT_ATTRS 202 /* display attributes */ int format; #define FLG_RDONLY 0x0001 /* variable cannot be modified */ #define FLG_WRONLY 0x0002 /* variable cannot be displayed */ Index: share/man/man4/wscons.4 =================================================================== RCS file: /cvsroot/src/share/man/man4/wscons.4,v retrieving revision 1.22 diff -u -r1.22 wscons.4 --- share/man/man4/wscons.4 26 Feb 2004 23:03:58 -0000 1.22 +++ share/man/man4/wscons.4 28 Jul 2004 12:15:35 -0000 @@ -31,7 +31,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 27, 2004 +.Dd July 28, 2004 .Dt WSCONS 4 .Os .Sh NAME @@ -42,6 +42,10 @@ .Cd options WSEMUL_VT100 .Cd options WSEMUL_NO_DUMB .Cd options WSEMUL_DEFAULT=\&"xxx\&" +.Cd options WS_DEFAULT_FG=WSCOL_XXX +.Cd options WS_DEFAULT_BG=WSCOL_XXX +.Cd options WS_DEFAULT_COLATTR=\&"(WSATTR_XXX | WSATTR_YYY)" +.Cd options WS_DEFAULT_MONOATTR=\&"(WSATTR_XXX | WSATTR_YYY)" .Cd options WS_KERNEL_FG=WSCOL_XXX .Cd options WS_KERNEL_BG=WSCOL_XXX .Cd options WS_KERNEL_COLATTR=\&"(WSATTR_XXX | WSATTR_YYY)" @@ -216,34 +220,45 @@ driver entry points, symlinks are a helpful measure.) .Ss Other options .Bl -tag -width xxxxxxxx -.It Cd options WS_KERNEL_FG=WSCOL_XXX , -.It Cd options WS_KERNEL_BG=WSCOL_XXX , -.It Cd options \&WS_KERNEL_COLATTR="(WSATTR_XXX | WSATTR_YYY)" +.It Cd options WS_DEFAULT_FG=WSCOL_XXX , +.It Cd options WS_DEFAULT_BG=WSCOL_XXX , +.It Cd options \&WS_DEFAULT_COLATTR="(WSATTR_XXX | WSATTR_YYY)" and -.It Cd options \&WS_KERNEL_MONOATTR="(WSATTR_XXX | WSATTR_YYY)" -allow to make console output originating from the kernel appear differently -than output from user level programs (via -.Pa /dev/console -or the specific tty -device like -.Pa /dev/ttyE0 ) . -.Dq WS_KERNEL_FG +.It Cd options \&WS_DEFAULT_MONOATTR="(WSATTR_XXX | WSATTR_YYY)" +allow to make default console output appear in specific colors and +attributes. +.Dq WS_DEFAULT_FG and -.Dq WS_KERNEL_BG +.Dq WS_DEFAULT_BG set the foreground / background used on color displays. The .Dq WSCOL_XXX arguments are colors as defined in .Pa src/sys/dev/wscons/wsdisplayvar.h . -.Dq WS_KERNEL_COLATTR +.Dq WS_DEFAULT_COLATTR and -.Dq WS_KERNEL_MONOATTR +.Dq WS_DEFAULT_MONOATTR are additional attribute flags used on color or monochrome displays, respectively. -The arguments are defined in the same header file. Whether the attributes +The arguments are defined in the same header file. +Whether the attributes are supported or not depends on the actually used graphics adapter. These options are ignored by the .Dq dumb terminal emulation. +.It Cd options WS_KERNEL_FG=WSCOL_XXX , +.It Cd options WS_KERNEL_BG=WSCOL_XXX , +.It Cd options \&WS_KERNEL_COLATTR="(WSATTR_XXX | WSATTR_YYY)" +and +.It Cd options \&WS_KERNEL_MONOATTR="(WSATTR_XXX | WSATTR_YYY)" +allow to make console output originating from the kernel appear differently +than output from user level programs (via +.Pa /dev/console +or the specific tty +device like +.Pa /dev/ttyE0 ) . +Their meaning is the same as their +.Sq WS_DEFAULT_* +counterparts. .It Cd options WSCOMPAT_USL_SYNCTIMEOUT=nnn The virtual screen switching protocol enabled by .Dq WSDISPLAY_COMPAT_USL Index: share/man/man4/wsdisplay.4 =================================================================== RCS file: /cvsroot/src/share/man/man4/wsdisplay.4,v retrieving revision 1.22 diff -u -r1.22 wsdisplay.4 --- share/man/man4/wsdisplay.4 21 Jul 2004 00:14:28 -0000 1.22 +++ share/man/man4/wsdisplay.4 28 Jul 2004 12:15:35 -0000 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 20, 2004 +.Dd July 28, 2004 .Os .Dt WSDISPLAY 4 .Sh NAME @@ -401,6 +401,42 @@ .Pp .It Dv WSDISPLAYIO_LINEBYTES Pq Li u_int Get the number of bytes per row, which may be the same as the number of pixels. +.It Dv WSDISPLAYIO_GMSGATTRS Pq Li struct wsdisplay_msgattrs +Get the attributes (colors and flags) used to print console messages, including +separate fields for default output and kernel output. +The returned structure is as follows: +.Bd -literal -offset indent +struct wsdisplay_msgattrs { + int default_attrs, default_bg, default_fg; + int kernel_attrs, kernel_bg, kernel_fg; +}; +.Ed +.Pp +The +.Va default_attrs +and +.Va kernel_attrs +variables are a combination of +.Va WSATTR_* +bits, and specify the attribues used to draw messages. +The +.Va default_bg , +.Va default_fg , +.Va kernel_bg +and +.Va kernel_fg +variables specify the colors used to print messages, being +.Sq _bg +for the background and +.Sq _fg +for the foreground; their values are one of all the +.Va WSCOL_* +macros available. +.It Dv WSDISPLAYIO_SMSGATTRS Pq Li struct wsdisplay_msgattrs +Set the attributes (colors and flags) used to print console messages, including +separate fields for default output and kernel output. +The argument structure is the same as for +.Dv WSDISPLAYIO_GMSGATTRS . .El .Sh FILES .Bl -item