2006-06-19 19:44:33 +04:00
|
|
|
/* $NetBSD: util.c,v 1.26 2006/06/19 15:44:36 gdamore Exp $ */
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
/*-
|
2006-02-05 20:38:33 +03:00
|
|
|
* Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
|
1998-12-28 17:01:16 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2006-02-05 20:38:33 +03:00
|
|
|
* by Juergen Hannken-Illjes and Julio M. Merino Vidal.
|
1998-12-28 17:01:16 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
2006-02-05 21:11:46 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wscons/wsksymdef.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
#include <err.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
1998-12-28 17:01:16 +03:00
|
|
|
#include <stdio.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1998-12-28 17:01:16 +03:00
|
|
|
#include <unistd.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
#include "wsconsctl.h"
|
|
|
|
|
|
|
|
#define TABLEN(t) (sizeof(t)/sizeof(t[0]))
|
|
|
|
|
|
|
|
extern struct wskbd_map_data kbmap; /* from keyboard.c */
|
|
|
|
extern struct wskbd_map_data newkbmap; /* from map_parse.y */
|
|
|
|
|
|
|
|
struct nameint {
|
|
|
|
int value;
|
2005-06-27 02:45:50 +04:00
|
|
|
const char *name;
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbtype_tab[] = {
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSKBD_TYPE_LK201, "lk201" },
|
|
|
|
{ WSKBD_TYPE_LK401, "lk401" },
|
|
|
|
{ WSKBD_TYPE_PC_XT, "pc-xt" },
|
|
|
|
{ WSKBD_TYPE_PC_AT, "pc-at" },
|
|
|
|
{ WSKBD_TYPE_USB, "usb" },
|
|
|
|
{ WSKBD_TYPE_HPC_KBD, "hpc-kbd" },
|
|
|
|
{ WSKBD_TYPE_HPC_BTN, "hpc-btn" },
|
|
|
|
{ WSKBD_TYPE_ARCHIMEDES, "archimedes" },
|
|
|
|
{ WSKBD_TYPE_RISCPC, "riscpc" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSKBD_TYPE_ADB, "adb" },
|
|
|
|
{ WSKBD_TYPE_HIL, "hil" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSKBD_TYPE_AMIGA, "amiga" },
|
2002-12-10 16:05:09 +03:00
|
|
|
{ WSKBD_TYPE_MAPLE, "maple" },
|
2003-02-01 02:32:21 +03:00
|
|
|
{ WSKBD_TYPE_ATARI, "atari" },
|
2004-01-21 18:39:34 +03:00
|
|
|
{ WSKBD_TYPE_SUN, "sun" },
|
|
|
|
{ WSKBD_TYPE_SUN5, "sun-type5" },
|
2005-01-31 09:24:08 +03:00
|
|
|
{ WSKBD_TYPE_SGI, "sgi" },
|
|
|
|
{ WSKBD_TYPE_MATRIXKP, "matrix-keypad" },
|
2006-06-19 19:44:33 +04:00
|
|
|
{ WSKBD_TYPE_BLUETOOTH, "bluetooth" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint mstype_tab[] = {
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSMOUSE_TYPE_VSXXX, "dec-tc" },
|
|
|
|
{ WSMOUSE_TYPE_PS2, "ps2" },
|
|
|
|
{ WSMOUSE_TYPE_USB, "usb" },
|
|
|
|
{ WSMOUSE_TYPE_LMS, "logitech-bus" },
|
|
|
|
{ WSMOUSE_TYPE_MMS, "ms-inport" },
|
|
|
|
{ WSMOUSE_TYPE_TPANEL, "touch-panel" },
|
|
|
|
{ WSMOUSE_TYPE_NEXT, "next" },
|
|
|
|
{ WSMOUSE_TYPE_ARCHIMEDES, "archimedes" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSMOUSE_TYPE_HIL, "hil" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSMOUSE_TYPE_AMIGA, "amiga" },
|
2002-02-24 05:01:40 +03:00
|
|
|
{ WSMOUSE_TYPE_MAXINE, "dec-maxine" },
|
2002-12-10 16:05:09 +03:00
|
|
|
{ WSMOUSE_TYPE_MAPLE, "maple" },
|
2006-06-19 19:44:33 +04:00
|
|
|
{ WSMOUSE_TYPE_BLUETOOTH, "bluetooth" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint dpytype_tab[] = {
|
1998-12-30 16:54:03 +03:00
|
|
|
{ WSDISPLAY_TYPE_UNKNOWN, "unknown" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_PM_MONO, "dec-pm-mono" },
|
|
|
|
{ WSDISPLAY_TYPE_PM_COLOR, "dec-pm-color" },
|
1998-12-28 17:01:16 +03:00
|
|
|
{ WSDISPLAY_TYPE_CFB, "dec-cfb" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_XCFB, "dec-xcfb" },
|
1998-12-28 17:01:16 +03:00
|
|
|
{ WSDISPLAY_TYPE_MFB, "dec-mfb" },
|
|
|
|
{ WSDISPLAY_TYPE_SFB, "dec-sfb" },
|
|
|
|
{ WSDISPLAY_TYPE_ISAVGA, "vga-isa" },
|
|
|
|
{ WSDISPLAY_TYPE_PCIVGA, "vga-pci" },
|
|
|
|
{ WSDISPLAY_TYPE_TGA, "dec-tga-pci" },
|
|
|
|
{ WSDISPLAY_TYPE_SFBP, "dec-sfb+" },
|
|
|
|
{ WSDISPLAY_TYPE_PCIMISC, "generic-pci" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_NEXTMONO, "next-mono" },
|
2001-12-04 12:56:31 +03:00
|
|
|
{ WSDISPLAY_TYPE_PX, "dec-px" },
|
|
|
|
{ WSDISPLAY_TYPE_PXG, "dec-pxg" },
|
|
|
|
{ WSDISPLAY_TYPE_TX, "dec-tx" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_HPCFB, "generic-hpc" },
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSDISPLAY_TYPE_VIDC, "arm-vidc" },
|
|
|
|
{ WSDISPLAY_TYPE_SPX, "dec-spx" },
|
|
|
|
{ WSDISPLAY_TYPE_GPX, "dec-gpx" },
|
|
|
|
{ WSDISPLAY_TYPE_LCG, "dec-lcg" },
|
|
|
|
{ WSDISPLAY_TYPE_VAX_MONO, "dec-vax-mono" },
|
|
|
|
{ WSDISPLAY_TYPE_SB_P9100, "sparcbook-p9100" },
|
|
|
|
{ WSDISPLAY_TYPE_EGA, "ega" },
|
|
|
|
{ WSDISPLAY_TYPE_DCPVR, "dreamcast-pvr" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSDISPLAY_TYPE_GATOR, "hp-gator" },
|
|
|
|
{ WSDISPLAY_TYPE_TOPCAT, "hp-topcat" },
|
|
|
|
{ WSDISPLAY_TYPE_RENAISSANCE, "hp-renaissance" },
|
|
|
|
{ WSDISPLAY_TYPE_CATSEYE, "hp-catseye" },
|
|
|
|
{ WSDISPLAY_TYPE_DAVINCI, "hp-davinci" },
|
|
|
|
{ WSDISPLAY_TYPE_TIGER, "hp-tiger" },
|
|
|
|
{ WSDISPLAY_TYPE_HYPERION, "hp-hyperion" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSDISPLAY_TYPE_AMIGACC, "amiga-cc" },
|
2004-04-03 02:16:52 +04:00
|
|
|
{ WSDISPLAY_TYPE_SUN24, "sun24" },
|
|
|
|
{ WSDISPLAY_TYPE_NEWPORT, "sgi-newport" },
|
|
|
|
{ WSDISPLAY_TYPE_GR2, "sgi-gr2" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNCG12, "suncg12" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNCG14, "suncg14" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNTCX, "suntcx" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNFFB, "sunffb" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbdenc_tab[] = {
|
1999-11-10 19:49:38 +03:00
|
|
|
KB_ENCTAB
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbdvar_tab[] = {
|
|
|
|
KB_VARTAB
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
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" },
|
|
|
|
};
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
static struct field *field_tab;
|
|
|
|
static int field_tab_len;
|
|
|
|
|
2005-06-27 02:45:50 +04:00
|
|
|
static const char *int2name(int, int, struct nameint *, int);
|
2005-01-19 23:37:52 +03:00
|
|
|
static int name2int(char *, struct nameint *, int);
|
|
|
|
static void print_kmap(struct wskbd_map_data *);
|
2006-02-05 20:38:33 +03:00
|
|
|
static unsigned int rd_bitfield(const char *);
|
|
|
|
static void pr_bitfield(unsigned int);
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
void
|
2005-01-19 23:37:52 +03:00
|
|
|
field_setup(struct field *ftab, int len)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
2006-02-05 21:11:46 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
field_tab = ftab;
|
|
|
|
field_tab_len = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct field *
|
2005-01-19 23:37:52 +03:00
|
|
|
field_by_name(char *name)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < field_tab_len; i++)
|
|
|
|
if (strcmp(field_tab[i].name, name) == 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
return field_tab + i;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not found", name);
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct field *
|
2005-01-19 23:37:52 +03:00
|
|
|
field_by_value(void *addr)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < field_tab_len; i++)
|
|
|
|
if (field_tab[i].valp == addr)
|
2006-02-05 21:11:46 +03:00
|
|
|
return field_tab + i;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "internal error: field_by_value: not found");
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
2004-07-30 15:08:03 +04:00
|
|
|
void
|
2005-01-19 23:37:52 +03:00
|
|
|
field_disable_by_value(void *addr)
|
2004-07-30 15:08:03 +04:00
|
|
|
{
|
|
|
|
struct field *f;
|
|
|
|
|
|
|
|
f = field_by_value(addr);
|
|
|
|
f->flags |= FLG_DISABLED;
|
|
|
|
}
|
|
|
|
|
2005-06-27 02:45:50 +04:00
|
|
|
static const char *
|
2005-01-19 23:37:52 +03:00
|
|
|
int2name(int val, int uflag, struct nameint *tab, int len)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
static char tmp[20];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
if (tab[i].value == val)
|
2006-02-05 21:11:46 +03:00
|
|
|
return tab[i].name;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
if (uflag) {
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)snprintf(tmp, sizeof(tmp), "unknown_%d", val);
|
|
|
|
return tmp;
|
1998-12-28 17:01:16 +03:00
|
|
|
} else
|
2006-02-05 21:11:46 +03:00
|
|
|
return NULL;
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-01-19 23:37:52 +03:00
|
|
|
name2int(char *val, struct nameint *tab, int len)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
if (strcmp(tab[i].name, val) == 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
return tab[i].value;
|
|
|
|
return -1;
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-06-27 02:45:50 +04:00
|
|
|
pr_field(struct field *f, const char *sep)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
2005-06-27 02:45:50 +04:00
|
|
|
const char *p;
|
2006-02-05 21:11:46 +03:00
|
|
|
unsigned int flags;
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
int first, i, mask;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
if (sep)
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("%s%s", f->name, sep);
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
switch (f->format) {
|
|
|
|
case FMT_UINT:
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("%u", *((unsigned int *) f->valp));
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
2002-04-07 14:40:04 +04:00
|
|
|
case FMT_STRING:
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("\"%s\"", *((char **) f->valp));
|
2002-04-07 14:40:04 +04:00
|
|
|
break;
|
2006-02-05 20:38:33 +03:00
|
|
|
case FMT_BITFIELD:
|
|
|
|
pr_bitfield(*((unsigned int *) f->valp));
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
case FMT_KBDTYPE:
|
2006-02-05 21:11:46 +03:00
|
|
|
p = int2name(*((unsigned int *) f->valp), 1,
|
|
|
|
kbtype_tab, TABLEN(kbtype_tab));
|
|
|
|
(void)printf("%s", p);
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_MSTYPE:
|
2006-02-05 21:11:46 +03:00
|
|
|
p = int2name(*((unsigned int *) f->valp), 1,
|
|
|
|
mstype_tab, TABLEN(mstype_tab));
|
|
|
|
(void)printf("%s", p);
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_DPYTYPE:
|
2006-02-05 21:11:46 +03:00
|
|
|
p = int2name(*((unsigned int *) f->valp), 1,
|
|
|
|
dpytype_tab, TABLEN(dpytype_tab));
|
|
|
|
(void)printf("%s", p);
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_KBDENC:
|
2006-02-05 21:11:46 +03:00
|
|
|
p = int2name(KB_ENCODING(*((unsigned int *) f->valp)), 1,
|
|
|
|
kbdenc_tab, TABLEN(kbdenc_tab));
|
|
|
|
(void)printf("%s", p);
|
1998-12-28 17:01:16 +03:00
|
|
|
|
2006-02-05 21:11:46 +03:00
|
|
|
flags = KB_VARIANT(*((unsigned int *) f->valp));
|
1999-11-10 19:49:38 +03:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (!(flags & (1 << i)))
|
|
|
|
continue;
|
|
|
|
p = int2name(flags & (1 << i), 1,
|
2006-02-05 21:11:46 +03:00
|
|
|
kbdvar_tab, TABLEN(kbdvar_tab));
|
|
|
|
(void)printf(".%s", p);
|
1999-11-10 19:49:38 +03:00
|
|
|
}
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_KBMAP:
|
|
|
|
print_kmap((struct wskbd_map_data *) f->valp);
|
|
|
|
break;
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
case FMT_COLOR:
|
2006-02-05 21:11:46 +03:00
|
|
|
p = int2name(*((unsigned int *) f->valp), 1,
|
|
|
|
color_tab, TABLEN(color_tab));
|
|
|
|
(void)printf("%s", p);
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
break;
|
|
|
|
case FMT_ATTRS:
|
|
|
|
mask = 0x10;
|
|
|
|
first = 1;
|
|
|
|
while (mask > 0) {
|
2006-02-05 21:11:46 +03:00
|
|
|
if (*((unsigned int *) f->valp) & mask) {
|
|
|
|
p = int2name(*((unsigned int *) f->valp) & mask,
|
|
|
|
1, attr_tab, TABLEN(attr_tab));
|
|
|
|
(void)printf("%s%s", first ? "" : ",", p);
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
if (first)
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("none");
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
default:
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "internal error: pr_field: no format %d",
|
|
|
|
f->format);
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("\n");
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
static void
|
|
|
|
pr_bitfield(unsigned int f)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (f == 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("none");
|
2006-02-05 20:38:33 +03:00
|
|
|
else {
|
|
|
|
int i, first, mask;
|
|
|
|
|
|
|
|
for (i = 0, first = 1, mask = 1; i < sizeof(f) * 8; i++) {
|
|
|
|
if (f & mask) {
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("%s%d", first ? "" : " ", i);
|
2006-02-05 20:38:33 +03:00
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
mask = mask << 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
void
|
2005-01-19 23:37:52 +03:00
|
|
|
rd_field(struct field *f, char *val, int merge)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
int i;
|
2006-02-05 21:11:46 +03:00
|
|
|
unsigned int u;
|
1998-12-28 17:01:16 +03:00
|
|
|
char *p;
|
|
|
|
struct wscons_keymap *mp;
|
|
|
|
|
|
|
|
switch (f->format) {
|
|
|
|
case FMT_UINT:
|
|
|
|
if (sscanf(val, "%u", &u) != 1)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a number", val);
|
1998-12-28 17:01:16 +03:00
|
|
|
if (merge)
|
2006-02-05 21:11:46 +03:00
|
|
|
*((unsigned int *) f->valp) += u;
|
1998-12-28 17:01:16 +03:00
|
|
|
else
|
2006-02-05 21:11:46 +03:00
|
|
|
*((unsigned int *) f->valp) = u;
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
2002-04-07 14:40:04 +04:00
|
|
|
case FMT_STRING:
|
|
|
|
if ((*((char **) f->valp) = strdup(val)) == NULL)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "strdup");
|
2002-04-07 14:40:04 +04:00
|
|
|
break;
|
2006-02-05 20:38:33 +03:00
|
|
|
case FMT_BITFIELD:
|
|
|
|
*((unsigned int *) f->valp) = rd_bitfield(val);
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
case FMT_KBDENC:
|
|
|
|
p = strchr(val, '.');
|
|
|
|
if (p != NULL)
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
i = name2int(val, kbdenc_tab, TABLEN(kbdenc_tab));
|
|
|
|
if (i == -1)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid encoding", val);
|
|
|
|
*((unsigned int *) f->valp) = i;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
1999-11-10 19:49:38 +03:00
|
|
|
while (p) {
|
|
|
|
val = p;
|
|
|
|
p = strchr(p, '.');
|
|
|
|
if (p != NULL)
|
|
|
|
*p++ = '\0';
|
|
|
|
i = name2int(val, kbdvar_tab, TABLEN(kbdvar_tab));
|
|
|
|
if (i == -1)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid variant",
|
|
|
|
val);
|
|
|
|
*((unsigned int *) f->valp) |= i;
|
1999-11-10 19:49:38 +03:00
|
|
|
}
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_KBMAP:
|
|
|
|
if (! merge)
|
|
|
|
kbmap.maplen = 0;
|
|
|
|
map_scan_setinput(val);
|
|
|
|
yyparse();
|
|
|
|
if (merge) {
|
|
|
|
if (newkbmap.maplen < kbmap.maplen)
|
|
|
|
newkbmap.maplen = kbmap.maplen;
|
|
|
|
for (i = 0; i < kbmap.maplen; i++) {
|
|
|
|
mp = newkbmap.map + i;
|
|
|
|
if (mp->command == KS_voidSymbol &&
|
|
|
|
mp->group1[0] == KS_voidSymbol &&
|
|
|
|
mp->group1[1] == KS_voidSymbol &&
|
|
|
|
mp->group2[0] == KS_voidSymbol &&
|
|
|
|
mp->group2[1] == KS_voidSymbol)
|
|
|
|
*mp = kbmap.map[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kbmap.maplen = newkbmap.maplen;
|
|
|
|
bcopy(newkbmap.map, kbmap.map,
|
2006-02-05 21:11:46 +03:00
|
|
|
kbmap.maplen * sizeof(struct wscons_keymap));
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
case FMT_COLOR:
|
|
|
|
i = name2int(val, color_tab, TABLEN(color_tab));
|
|
|
|
if (i == -1)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid color", val);
|
|
|
|
*((unsigned int *) f->valp) = i;
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
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)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid attribute",
|
|
|
|
val);
|
|
|
|
*((unsigned int *) f->valp) |= i;
|
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@.
2004-07-28 16:34:02 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
default:
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "internal error: rd_field: no format %d",
|
|
|
|
f->format);
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
static unsigned int
|
|
|
|
rd_bitfield(const char *str)
|
|
|
|
{
|
|
|
|
const char *ptr;
|
|
|
|
char *ep;
|
|
|
|
long lval;
|
|
|
|
unsigned int result;
|
|
|
|
|
|
|
|
ep = NULL;
|
|
|
|
ptr = str;
|
|
|
|
result = 0;
|
|
|
|
while (*ptr != '\0') {
|
|
|
|
errno = 0;
|
|
|
|
lval = strtol(ptr, &ep, 10);
|
|
|
|
if (*ep != '\0' && *ep != ' ')
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid number list", str);
|
2006-02-05 20:38:33 +03:00
|
|
|
if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%s: not a valid number list", str);
|
2006-02-05 20:38:33 +03:00
|
|
|
if (lval >= sizeof(result) * 8)
|
2006-02-05 21:11:46 +03:00
|
|
|
errx(EXIT_FAILURE, "%ld: number out of range", lval);
|
2006-02-05 20:38:33 +03:00
|
|
|
result |= (1 << lval);
|
|
|
|
|
|
|
|
ptr = ep;
|
|
|
|
while (*ptr == ' ')
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
static void
|
2005-01-19 23:37:52 +03:00
|
|
|
print_kmap(struct wskbd_map_data *map)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct wscons_keymap *mp;
|
|
|
|
|
|
|
|
for (i = 0; i < map->maplen; i++) {
|
|
|
|
mp = map->map + i;
|
|
|
|
|
|
|
|
if (mp->command == KS_voidSymbol &&
|
|
|
|
mp->group1[0] == KS_voidSymbol &&
|
|
|
|
mp->group1[1] == KS_voidSymbol &&
|
|
|
|
mp->group2[0] == KS_voidSymbol &&
|
|
|
|
mp->group2[1] == KS_voidSymbol)
|
|
|
|
continue;
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf("\n");
|
|
|
|
(void)printf("keycode %u =", i);
|
1998-12-28 17:01:16 +03:00
|
|
|
if (mp->command != KS_voidSymbol)
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf(" %s", ksym2name(mp->command));
|
|
|
|
(void)printf(" %s", ksym2name(mp->group1[0]));
|
1998-12-28 17:01:16 +03:00
|
|
|
if (mp->group1[0] != mp->group1[1] ||
|
|
|
|
mp->group1[0] != mp->group2[0] ||
|
|
|
|
mp->group1[0] != mp->group2[1]) {
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf(" %s", ksym2name(mp->group1[1]));
|
1998-12-28 17:01:16 +03:00
|
|
|
if (mp->group1[0] != mp->group2[0] ||
|
|
|
|
mp->group1[1] != mp->group2[1]) {
|
2006-02-05 21:11:46 +03:00
|
|
|
(void)printf(" %s", ksym2name(mp->group2[0]));
|
|
|
|
(void)printf(" %s", ksym2name(mp->group2[1]));
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|