View | Details | Raw Unified | Return to bug 175425 | Differences between
and this patch

Collapse All | Expand All

(-)sys/dev/kbdmux/kbdmux.c (+32 lines)
Lines 943-948 Link Here
943
	kbdmux_state_t	*state = (kbdmux_state_t *) kbd->kb_data;
943
	kbdmux_state_t	*state = (kbdmux_state_t *) kbd->kb_data;
944
	kbdmux_kbd_t	*k;
944
	kbdmux_kbd_t	*k;
945
	keyboard_info_t	*ki;
945
	keyboard_info_t	*ki;
946
	keyboard_info_array_t	*kia;
947
	keyboard_info_t	*kia_limit;
948
	int		 ki_count;
946
	int		 error = 0, mode;
949
	int		 error = 0, mode;
947
#ifdef COMPAT_FREEBSD6
950
#ifdef COMPAT_FREEBSD6
948
	int		 ival;
951
	int		 ival;
Lines 1049-1054 Link Here
1049
		KBDMUX_UNLOCK(state);
1052
		KBDMUX_UNLOCK(state);
1050
		break;
1053
		break;
1051
1054
1055
	case KBLSTKBD: /* list mux contents */
1056
		kia = (keyboard_info_array_t *) arg;
1057
1058
		if (kia == NULL || kia->len <= 0)
1059
			return (EINVAL); /* bad input */
1060
1061
		KBDMUX_LOCK(state);
1062
1063
		kia_limit = (keyboard_info_t *) ((char*)arg+kia->len);
1064
		ki = kia->kbs;
1065
		ki_count = 0;
1066
		SLIST_FOREACH(k, &state->ks_kbds, next) {
1067
			if (ki+1 > kia_limit)
1068
				break;
1069
			ki->kb_index  = k->kbd->kb_index;
1070
			(void) strcpy(ki->kb_name, k->kbd->kb_name);
1071
			ki->kb_unit   = k->kbd->kb_unit;
1072
			ki->kb_type   = k->kbd->kb_type;
1073
			ki->kb_config = k->kbd->kb_config;
1074
			ki->kb_flags  = k->kbd->kb_flags;
1075
1076
			ki++;
1077
			ki_count++;
1078
		}
1079
		kia->len = ki_count;
1080
1081
		KBDMUX_UNLOCK(state);
1082
		break;
1083
1052
	case KDGKBMODE: /* get kyboard mode */
1084
	case KDGKBMODE: /* get kyboard mode */
1053
		KBDMUX_LOCK(state);
1085
		KBDMUX_LOCK(state);
1054
		*(int *)arg = state->ks_mode;
1086
		*(int *)arg = state->ks_mode;
(-)sys/dev/syscons/syscons.c (+1 lines)
Lines 1349-1354 Link Here
1349
1349
1350
    case KBADDKBD:		/* add/remove keyboard to/from mux */
1350
    case KBADDKBD:		/* add/remove keyboard to/from mux */
1351
    case KBRELKBD:
1351
    case KBRELKBD:
1352
    case KBLSTKBD:
1352
	error = kbdd_ioctl(sc->kbd, cmd, data);
1353
	error = kbdd_ioctl(sc->kbd, cmd, data);
1353
	if (error == ENOIOCTL)
1354
	if (error == ENOIOCTL)
1354
	    error = ENODEV;
1355
	    error = ENODEV;
(-)sys/sys/kbio.h (+7 lines)
Lines 70-78 Link Here
70
};
70
};
71
typedef struct keyboard_info keyboard_info_t;
71
typedef struct keyboard_info keyboard_info_t;
72
72
73
struct keyboard_info_array {
74
	int		len;		/* array kbs[] length		*/
75
	keyboard_info_t	kbs[1];		/* variable size array		*/
76
} __packed;
77
typedef struct keyboard_info_array keyboard_info_array_t;
78
73
/* add/remove keyboard to/from mux */
79
/* add/remove keyboard to/from mux */
74
#define KBADDKBD	_IOW('K', 68, keyboard_info_t)	/* add keyboard */
80
#define KBADDKBD	_IOW('K', 68, keyboard_info_t)	/* add keyboard */
75
#define KBRELKBD	_IOW('K', 69, keyboard_info_t)	/* release keyboard */
81
#define KBRELKBD	_IOW('K', 69, keyboard_info_t)	/* release keyboard */
82
#define KBLSTKBD	_IOWRE('K', 70)			/* list mux */
76
83
77
/* see console.h for the definition of the following ioctl */
84
/* see console.h for the definition of the following ioctl */
78
#ifdef notdef
85
#ifdef notdef
(-)usr.sbin/kbdcontrol/kbdcontrol.1 (+2 lines)
Lines 146-151 Link Here
146
Use hexadecimal numbers in keyboard map dump.
146
Use hexadecimal numbers in keyboard map dump.
147
.It Fl i
147
.It Fl i
148
Print brief information about the keyboard.
148
Print brief information about the keyboard.
149
.It Fl I
150
Print contents of the keyboard multiplexer.
149
.It Fl K
151
.It Fl K
150
Disconnect the keyboard from the console.
152
Disconnect the keyboard from the console.
151
You need to use the
153
You need to use the
(-)usr.sbin/kbdcontrol/kbdcontrol.c (-17 / +56 lines)
Lines 138-143 Link Here
138
void		set_keyboard(char *device);
138
void		set_keyboard(char *device);
139
void		set_keyrates(char *opt);
139
void		set_keyrates(char *opt);
140
void		show_kbd_info(void);
140
void		show_kbd_info(void);
141
void		show_mux_info(void);
141
void		usage(void) __dead2;
142
void		usage(void) __dead2;
142
143
143
char *
144
char *
Lines 1011-1016 Link Here
1011
	return "unknown";
1012
	return "unknown";
1012
}
1013
}
1013
1014
1015
static void
1016
print_kbd_info(keyboard_info_t *info)
1017
{
1018
	printf("%.*s%d, type:%s (%d)\n",
1019
		(int)sizeof(info->kb_name), info->kb_name, info->kb_unit,
1020
		get_kbd_type_name(info->kb_type), info->kb_type);
1021
}
1022
1023
static void
1024
print_kbd_info_extended(keyboard_info_t *info)
1025
{
1026
	printf("kbd%d:\n", info->kb_index);
1027
	printf("    ");
1028
	print_kbd_info(info);
1029
}
1030
1014
void
1031
void
1015
show_kbd_info(void)
1032
show_kbd_info(void)
1016
{
1033
{
Lines 1020-1032 Link Here
1020
		warn("unable to obtain keyboard information");
1037
		warn("unable to obtain keyboard information");
1021
		return;
1038
		return;
1022
	}
1039
	}
1023
	printf("kbd%d:\n", info.kb_index);
1040
        print_kbd_info_extended(&info);
1024
	printf("    %.*s%d, type:%s (%d)\n",
1025
		(int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1026
		get_kbd_type_name(info.kb_type), info.kb_type);
1027
}
1041
}
1028
1042
1029
void
1043
void
1044
show_mux_info(void)
1045
{
1046
	int i;
1047
	keyboard_info_t info_mux;
1048
1049
	keyboard_info_array_t *info_arr = (keyboard_info_array_t*)
1050
          malloc(IOCPARM_MAX);
1051
	info_arr->len = IOCPARM_MAX;
1052
1053
	if (ioctl(0, KDGKBINFO, &info_mux) == -1) {
1054
		warn("unable to obtain keyboard information");
1055
		free(info_arr);
1056
		return;
1057
	}
1058
	if (ioctl(0, KBLSTKBD, info_arr) == -1) {
1059
		warn("unable to obtain keyboard multiplexer information");
1060
		free(info_arr);
1061
		return;
1062
	}
1063
1064
	printf("Keyboard multiplexor kbd%d: ", info_mux.kb_index);
1065
	print_kbd_info(&info_mux);
1066
	for (i=0; i<info_arr->len; i++) {
1067
		printf("    part[%i]: kbd%d: ", i, info_arr->kbs[i].kb_index);
1068
		print_kbd_info(&info_arr->kbs[i]);
1069
	}
1070
1071
	free(info_arr);
1072
}
1073
1074
void
1030
set_keyboard(char *device)
1075
set_keyboard(char *device)
1031
{
1076
{
1032
	keyboard_info_t info;
1077
	keyboard_info_t info;
Lines 1050-1059 Link Here
1050
	ioctl(fd, CONS_RELKBD, 0);
1095
	ioctl(fd, CONS_RELKBD, 0);
1051
	close(fd);
1096
	close(fd);
1052
#if 1
1097
#if 1
1053
	printf("kbd%d\n", info.kb_index);
1098
        print_kbd_info_extended(&info);
1054
	printf("    %.*s%d, type:%s (%d)\n",
1055
		(int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1056
		get_kbd_type_name(info.kb_type), info.kb_type);
1057
#endif
1099
#endif
1058
1100
1059
	if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
1101
	if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
Lines 1074-1083 Link Here
1074
		return;
1116
		return;
1075
	}
1117
	}
1076
#if 1
1118
#if 1
1077
	printf("kbd%d\n", info.kb_index);
1119
        print_kbd_info_extended(&info);
1078
	printf("    %.*s%d, type:%s (%d)\n",
1079
		(int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1080
		get_kbd_type_name(info.kb_type), info.kb_type);
1081
#endif
1120
#endif
1082
	if (ioctl(0, CONS_RELKBD, 0) == -1)
1121
	if (ioctl(0, CONS_RELKBD, 0) == -1)
1083
		warn("unable to release the keyboard");
1122
		warn("unable to release the keyboard");
Lines 1098-1107 Link Here
1098
		return;
1137
		return;
1099
	}
1138
	}
1100
#if 1
1139
#if 1
1101
	printf("kbd%d\n", info.kb_index);
1140
        print_kbd_info_extended(&info);
1102
	printf("    %.*s%d, type:%s (%d)\n",
1103
		(int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1104
		get_kbd_type_name(info.kb_type), info.kb_type);
1105
#endif
1141
#endif
1106
	/*
1142
	/*
1107
	 * split kbd into name and unit. find the right most part of the
1143
	 * split kbd into name and unit. find the right most part of the
Lines 1163-1169 Link Here
1163
{
1199
{
1164
	int		opt;
1200
	int		opt;
1165
1201
1166
	while((opt = getopt(argc, argv, "A:a:b:df:iKk:Fl:L:r:x")) != -1)
1202
	while((opt = getopt(argc, argv, "A:a:b:df:iIKk:Fl:L:r:x")) != -1)
1167
		switch(opt) {
1203
		switch(opt) {
1168
		case 'A':
1204
		case 'A':
1169
		case 'a':
1205
		case 'a':
Lines 1191-1196 Link Here
1191
		case 'i':
1227
		case 'i':
1192
			show_kbd_info();
1228
			show_kbd_info();
1193
			break;
1229
			break;
1230
		case 'I':
1231
			show_mux_info();
1232
			break;
1194
		case 'K':
1233
		case 'K':
1195
			release_keyboard();
1234
			release_keyboard();
1196
			break;
1235
			break;

Return to bug 175425