mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-06 13:09:50 +00:00
The first stage of console driver reorganization: activate new
keyboard and video card drivers.
This commit is contained in:
parent
2ad872c579
commit
c67e8bd332
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42505
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: kbdcontrol.c,v 1.18 1998/09/04 10:15:48 yokota Exp $";
|
||||
"$Id: kbdcontrol.c,v 1.19 1998/09/10 12:20:09 yokota Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
@ -37,6 +37,7 @@ static const char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <machine/console.h>
|
||||
#include "path.h"
|
||||
#include "lex.h"
|
||||
@ -417,7 +418,7 @@ print_entry(FILE *fp, int value)
|
||||
|
||||
|
||||
void
|
||||
print_key_definition_line(FILE *fp, int scancode, struct key_t *key)
|
||||
print_key_definition_line(FILE *fp, int scancode, struct keyent_t *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -865,14 +866,108 @@ set_history(char *opt)
|
||||
warn("setting history buffer size");
|
||||
}
|
||||
|
||||
static char
|
||||
*get_kbd_type_name(int type)
|
||||
{
|
||||
static struct {
|
||||
int type;
|
||||
char *name;
|
||||
} name_table[] = {
|
||||
{ KB_84, "AT 84" },
|
||||
{ KB_101, "AT 101/102" },
|
||||
{ KB_OTHER, "generic" },
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(name_table)/sizeof(name_table[0]); ++i) {
|
||||
if (type == name_table[i].type)
|
||||
return name_table[i].name;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void
|
||||
show_kbd_info(void)
|
||||
{
|
||||
keyboard_info_t info;
|
||||
|
||||
if (ioctl(0, KDGKBINFO, &info) == -1) {
|
||||
warn("unable to obtain keyboard information");
|
||||
return;
|
||||
}
|
||||
printf("kbd%d:\n", info.kb_index);
|
||||
printf(" %.*s%d, type:%s (%d)\n",
|
||||
sizeof(info.kb_name), info.kb_name, info.kb_unit,
|
||||
get_kbd_type_name(info.kb_type), info.kb_type);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_keyboard(char *device)
|
||||
{
|
||||
keyboard_info_t info;
|
||||
int fd;
|
||||
|
||||
fd = open(device, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
warn("cannot open %s", device);
|
||||
return;
|
||||
}
|
||||
if (ioctl(fd, KDGKBINFO, &info) == -1) {
|
||||
warn("unable to obtain keyboard information");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* The keyboard device driver won't release the keyboard by
|
||||
* the following ioctl, but it automatically will, when the device
|
||||
* is closed. So, we don't check error here.
|
||||
*/
|
||||
ioctl(fd, CONS_RELKBD, 0);
|
||||
close(fd);
|
||||
#if 1
|
||||
printf("kbd%d\n", info.kb_index);
|
||||
printf(" %.*s%d, type:%s (%d)\n",
|
||||
sizeof(info.kb_name), info.kb_name, info.kb_unit,
|
||||
get_kbd_type_name(info.kb_type), info.kb_type);
|
||||
#endif
|
||||
|
||||
if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
|
||||
warn("unable to set keyboard");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
release_keyboard(void)
|
||||
{
|
||||
keyboard_info_t info;
|
||||
|
||||
/*
|
||||
* If stdin is not associated with a keyboard, the following ioctl
|
||||
* will fail.
|
||||
*/
|
||||
if (ioctl(0, KDGKBINFO, &info) == -1) {
|
||||
warn("unable to obtain keyboard information");
|
||||
return;
|
||||
}
|
||||
#if 1
|
||||
printf("kbd%d\n", info.kb_index);
|
||||
printf(" %.*s%d, type:%s (%d)\n",
|
||||
sizeof(info.kb_name), info.kb_name, info.kb_unit,
|
||||
get_kbd_type_name(info.kb_type), info.kb_type);
|
||||
#endif
|
||||
if (ioctl(0, CONS_RELKBD, 0) == -1)
|
||||
warn("unable to release the keyboard");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: kbdcontrol [-dFx] [-b duration.pitch | [quiet.]belltype]",
|
||||
"usage: kbdcontrol [-dFKix] [-b duration.pitch | [quiet.]belltype]",
|
||||
" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
|
||||
" [-h size] [-L mapfile]");
|
||||
" [-h size] [-k device] [-L mapfile]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -882,7 +977,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
while((opt = getopt(argc, argv, "b:df:h:Fl:L:r:x")) != -1)
|
||||
while((opt = getopt(argc, argv, "b:df:h:iKk:Fl:L:r:x")) != -1)
|
||||
switch(opt) {
|
||||
case 'b':
|
||||
set_bell_values(optarg);
|
||||
@ -906,6 +1001,15 @@ main(int argc, char **argv)
|
||||
case 'h':
|
||||
set_history(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
show_kbd_info();
|
||||
break;
|
||||
case 'K':
|
||||
release_keyboard();
|
||||
break;
|
||||
case 'k':
|
||||
set_keyboard(optarg);
|
||||
break;
|
||||
case 'r':
|
||||
set_keyrates(optarg);
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: vidcontrol.c,v 1.23 1998/09/24 01:36:36 gpalmer Exp $";
|
||||
"$Id: vidcontrol.c,v 1.24 1998/10/01 11:40:22 yokota Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
@ -431,7 +431,7 @@ static char
|
||||
void
|
||||
show_adapter_info(void)
|
||||
{
|
||||
struct video_adapter ad;
|
||||
struct video_adapter_info ad;
|
||||
|
||||
ad.va_index = 0;
|
||||
if (ioctl(0, CONS_ADPINFO, &ad)) {
|
||||
@ -439,11 +439,11 @@ show_adapter_info(void)
|
||||
return;
|
||||
}
|
||||
|
||||
printf("adapter %d:\n", ad.va_index);
|
||||
printf(" type:%s%s (%d), flags:0x%08x, CRTC:0x%x\n",
|
||||
printf("fb%d:\n", ad.va_index);
|
||||
printf(" %.*s%d, type:%s%s (%d), flags:0x%x\n",
|
||||
(int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
|
||||
(ad.va_flags & V_ADP_VESA) ? "VESA " : "",
|
||||
adapter_name(ad.va_type), ad.va_type,
|
||||
ad.va_flags, ad.va_crtc_addr);
|
||||
adapter_name(ad.va_type), ad.va_type, ad.va_flags);
|
||||
printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
|
||||
ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user