From owner-svn-src-head@FreeBSD.ORG Sat Sep 19 17:56:26 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B11BC1065672; Sat, 19 Sep 2009 17:56:26 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F82D8FC1C; Sat, 19 Sep 2009 17:56:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8JHuQk3031724; Sat, 19 Sep 2009 17:56:26 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8JHuQCq031719; Sat, 19 Sep 2009 17:56:26 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200909191756.n8JHuQCq031719@svn.freebsd.org> From: Ed Schouten Date: Sat, 19 Sep 2009 17:56:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197330 - in head: sys/dev/kbd sys/sys usr.sbin/kbdcontrol X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Sep 2009 17:56:26 -0000 Author: ed Date: Sat Sep 19 17:56:26 2009 New Revision: 197330 URL: http://svn.freebsd.org/changeset/base/197330 Log: Make the keyboard layer Unicode aware. Just take keyent_t to use an u_int to store the Unicode codepoints. Unfortunately the keymap is now too big to be loaded using an ioctl argument, so change the ioctl to pick a pointer. This change breaks kbdcontrol ABI. It doesn't break X11, because X11 doesn't do anything with syscons keymaps. It just switches the device out of K_XLATE. Obtained from: //depot/user/ed/newcons/... Modified: head/sys/dev/kbd/kbd.c head/sys/sys/kbio.h head/usr.sbin/kbdcontrol/kbdcontrol.c head/usr.sbin/kbdcontrol/kbdmap.5 Modified: head/sys/dev/kbd/kbd.c ============================================================================== --- head/sys/dev/kbd/kbd.c Sat Sep 19 15:48:59 2009 (r197329) +++ head/sys/dev/kbd/kbd.c Sat Sep 19 17:56:26 2009 (r197330) @@ -837,13 +837,14 @@ static int fkey_change_ok(fkeytab_t *, f int genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) { +#ifndef KBD_DISABLE_KEYMAP_LOAD + keymap_t *mapp; +#endif keyarg_t *keyp; fkeyarg_t *fkeyp; int s; int i; -#ifndef KBD_DISABLE_KEYMAP_LOAD int error; -#endif s = spltty(); switch (cmd) { @@ -869,18 +870,29 @@ genkbd_commonioctl(keyboard_t *kbd, u_lo break; case GIO_KEYMAP: /* get keyboard translation table */ - bcopy(kbd->kb_keymap, arg, sizeof(*kbd->kb_keymap)); - break; + error = copyout(kbd->kb_keymap, *(void **)arg, + sizeof(keymap_t)); + splx(s); + return (error); case PIO_KEYMAP: /* set keyboard translation table */ #ifndef KBD_DISABLE_KEYMAP_LOAD - error = keymap_change_ok(kbd->kb_keymap, (keymap_t *)arg, - curthread); + mapp = malloc(sizeof *mapp, M_TEMP, M_NOWAIT); + error = copyin(*(void **)arg, mapp, sizeof *mapp); + if (error != 0) { + splx(s); + free(mapp, M_TEMP); + return (error); + } + + error = keymap_change_ok(kbd->kb_keymap, mapp, curthread); if (error != 0) { splx(s); + free(mapp, M_TEMP); return (error); } bzero(kbd->kb_accentmap, sizeof(*kbd->kb_accentmap)); - bcopy(arg, kbd->kb_keymap, sizeof(*kbd->kb_keymap)); + bcopy(mapp, kbd->kb_keymap, sizeof(*kbd->kb_keymap)); + free(mapp, M_TEMP); break; #else splx(s); Modified: head/sys/sys/kbio.h ============================================================================== --- head/sys/sys/kbio.h Sat Sep 19 15:48:59 2009 (r197329) +++ head/sys/sys/kbio.h Sat Sep 19 17:56:26 2009 (r197330) @@ -106,7 +106,7 @@ typedef struct keyboard_repeat keyboard_ #define _KEYMAP_DECLARED struct keyent_t { - u_char map[NUM_STATES]; + u_int map[NUM_STATES]; u_char spcl; u_char flgs; #define FLAG_LOCK_O 0 @@ -220,8 +220,9 @@ typedef struct fkeyarg fkeyarg_t; #define GIO_SCRNMAP _IOR('k', 2, scrmap_t) #define PIO_SCRNMAP _IOW('k', 3, scrmap_t) #endif -#define GIO_KEYMAP _IOR('k', 6, keymap_t) -#define PIO_KEYMAP _IOW('k', 7, keymap_t) +/* XXX: Should have keymap_t as an argument, but that's too big for ioctl()! */ +#define GIO_KEYMAP _IO('k', 6) +#define PIO_KEYMAP _IO('k', 7) #define GIO_DEADKEYMAP _IOR('k', 8, accentmap_t) #define PIO_DEADKEYMAP _IOW('k', 9, accentmap_t) #define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t) Modified: head/usr.sbin/kbdcontrol/kbdcontrol.c ============================================================================== --- head/usr.sbin/kbdcontrol/kbdcontrol.c Sat Sep 19 15:48:59 2009 (r197329) +++ head/usr.sbin/kbdcontrol/kbdcontrol.c Sat Sep 19 17:56:26 2009 (r197330) @@ -256,7 +256,7 @@ get_entry(void) case TLET: return (unsigned char)letter; case TNUM: - if (number < 0 || number > 255) + if (number < 0x000000 || number > 0x10FFFF) return -1; return number; default: Modified: head/usr.sbin/kbdcontrol/kbdmap.5 ============================================================================== --- head/usr.sbin/kbdcontrol/kbdmap.5 Sat Sep 19 15:48:59 2009 (r197329) +++ head/usr.sbin/kbdcontrol/kbdmap.5 Sat Sep 19 17:56:26 2009 (r197330) @@ -84,7 +84,7 @@ The symbol the key should produce, in single quotes. .It Ar decnum The -.Tn ASCII +.Tn Unicode value to produce as a decimal number (see @@ -92,7 +92,7 @@ as a decimal number For example, 32 for space. .It 0x Ns Ar hexnum The -.Tn ASCII +.Tn Unicode value to produce as a hexadecimal number. For example, 0x20 for space. @@ -274,7 +274,7 @@ This is followed by the symbol for the accent, given in single quotes or as a decimal or hexadecimal -.Tn ASCII +.Tn Unicode value. This symbol will be produced if the accent key is pressed and @@ -290,7 +290,7 @@ Both symbols in a pair can be given in either single quotes or as decimal or hexadecimal -.Tn ASCII +.Tn Unicode values. .Pp For example,