0,
 };
 
-struct kbdiacr accent_table[MAX_DIACR] = {
+struct kbdiacruc accent_table[MAX_DIACR] = {
        {'`', 'A', '\300'},     {'`', 'a', '\340'},
        {'\'', 'A', '\301'},    {'\'', 'a', '\341'},
        {'^', 'A', '\302'},     {'^', 'a', '\342'},
 
                p->readonly = rdonly;
 }
 
+/*
+ * Always use USER_MAP. These functions are used by the keyboard,
+ * which shouldn't be affected by G0/G1 switching, etc.
+ * If the user map still contains default values, i.e. the
+ * direct-to-font mapping, then assume user is using Latin1.
+ */
 /* may be called during an interrupt */
 u32 conv_8bit_to_uni(unsigned char c)
 {
-       /*
-        * Always use USER_MAP. This function is used by the keyboard,
-        * which shouldn't be affected by G0/G1 switching, etc.
-        * If the user map still contains default values, i.e. the
-        * direct-to-font mapping, then assume user is using Latin1.
-        */
        unsigned short uni = translations[USER_MAP][c];
        return uni == (0xf000 | c) ? c : uni;
 }
 
+int conv_uni_to_8bit(u32 uni)
+{
+       int c;
+       for (c = 0; c < 0x100; c++)
+               if (translations[USER_MAP][c] == uni ||
+                  (translations[USER_MAP][c] == (c | 0xf000) && uni == c))
+                       return c;
+       return -1;
+}
+
 int
 conv_uni_to_pc(struct vc_data *conp, long ucs) 
 {
 
        NULL,
 };
 
-struct kbdiacr accent_table[MAX_DIACR] = {
+struct kbdiacruc accent_table[MAX_DIACR] = {
        {'`', 'A', '\300'},     {'`', 'a', '\340'},
        {'\'', 'A', '\301'},    {'\'', 'a', '\341'},
        {'^', 'A', '\302'},     {'^', 'a', '\342'},
 
 #include <linux/kbd_kern.h>
 #include <linux/kbd_diacr.h>
 #include <linux/vt_kern.h>
+#include <linux/consolemap.h>
 #include <linux/sysrq.h>
 #include <linux/input.h>
 #include <linux/reboot.h>
                return d;
 
        if (kbd->kbdmode == VC_UNICODE)
-               to_utf8(vc, conv_8bit_to_uni(d));
-       else if (d < 0x100)
-               put_queue(vc, d);
+               to_utf8(vc, d);
+       else {
+               int c = conv_uni_to_8bit(d);
+               if (c != -1)
+                       put_queue(vc, c);
+       }
 
        return ch;
 }
 {
        if (diacr) {
                if (kbd->kbdmode == VC_UNICODE)
-                       to_utf8(vc, conv_8bit_to_uni(diacr));
-               else if (diacr < 0x100)
-                       put_queue(vc, diacr);
+                       to_utf8(vc, diacr);
+               else {
+                       int c = conv_uni_to_8bit(diacr);
+                       if (c != -1)
+                               put_queue(vc, c);
+               }
                diacr = 0;
        }
        put_queue(vc, 13);
                return;
        }
        if (kbd->kbdmode == VC_UNICODE)
-               to_utf8(vc, conv_8bit_to_uni(value));
-       else if (value < 0x100)
-               put_queue(vc, value);
+               to_utf8(vc, value);
+       else {
+               int c = conv_uni_to_8bit(value);
+               if (c != -1)
+                       put_queue(vc, c);
+       }
 }
 
 /*
 
 static void k_self(struct vc_data *vc, unsigned char value, char up_flag)
 {
-       k_unicode(vc, value, up_flag);
+       unsigned int uni;
+       if (kbd->kbdmode == VC_UNICODE)
+               uni = value;
+       else
+               uni = conv_8bit_to_uni(value);
+       k_unicode(vc, uni, up_flag);
 }
 
 static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag)
 
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/console.h>
+#include <linux/consolemap.h>
 #include <linux/signal.h>
 #include <linux/timex.h>
 
        case KDGKBDIACR:
        {
                struct kbdiacrs __user *a = up;
+               struct kbdiacr diacr;
+               int i;
 
                if (put_user(accent_table_size, &a->kb_cnt))
                        return -EFAULT;
-               if (copy_to_user(a->kbdiacr, accent_table, accent_table_size*sizeof(struct kbdiacr)))
+               for (i = 0; i < accent_table_size; i++) {
+                       diacr.diacr = conv_uni_to_8bit(accent_table[i].diacr);
+                       diacr.base = conv_uni_to_8bit(accent_table[i].base);
+                       diacr.result = conv_uni_to_8bit(accent_table[i].result);
+                       if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr)))
+                               return -EFAULT;
+               }
+               return 0;
+       }
+       case KDGKBDIACRUC:
+       {
+               struct kbdiacrsuc __user *a = up;
+
+               if (put_user(accent_table_size, &a->kb_cnt))
+                       return -EFAULT;
+               if (copy_to_user(a->kbdiacruc, accent_table, accent_table_size*sizeof(struct kbdiacruc)))
                        return -EFAULT;
                return 0;
        }
        case KDSKBDIACR:
        {
                struct kbdiacrs __user *a = up;
+               struct kbdiacr diacr;
+               unsigned int ct;
+               int i;
+
+               if (!perm)
+                       return -EPERM;
+               if (get_user(ct,&a->kb_cnt))
+                       return -EFAULT;
+               if (ct >= MAX_DIACR)
+                       return -EINVAL;
+               accent_table_size = ct;
+               for (i = 0; i < ct; i++) {
+                       if (copy_from_user(&diacr, a->kbdiacr + i, sizeof(struct kbdiacr)))
+                               return -EFAULT;
+                       accent_table[i].diacr = conv_8bit_to_uni(diacr.diacr);
+                       accent_table[i].base = conv_8bit_to_uni(diacr.base);
+                       accent_table[i].result = conv_8bit_to_uni(diacr.result);
+               }
+               return 0;
+       }
+
+       case KDSKBDIACRUC:
+       {
+               struct kbdiacrsuc __user *a = up;
                unsigned int ct;
 
                if (!perm)
                if (ct >= MAX_DIACR)
                        return -EINVAL;
                accent_table_size = ct;
-               if (copy_from_user(accent_table, a->kbdiacr, ct*sizeof(struct kbdiacr)))
+               if (copy_from_user(accent_table, a->kbdiacruc, ct*sizeof(struct kbdiacruc)))
                        return -EFAULT;
                return 0;
        }
 
        NULL,
 };
 
-struct kbdiacr accent_table[MAX_DIACR] = {
+struct kbdiacruc accent_table[MAX_DIACR] = {
        {'^', 'c', '\003'},     {'^', 'd', '\004'},
        {'^', 'z', '\032'},     {'^', '\012', '\000'},
 };
 
 #include <linux/sched.h>
 #include <linux/sysrq.h>
 
+#include <linux/consolemap.h>
 #include <linux/kbd_kern.h>
 #include <linux/kbd_diacr.h>
 #include <asm/uaccess.h>
        if (!kbd->fn_handler)
                goto out_func;
        kbd->accent_table =
-               kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL);
+               kmalloc(sizeof(struct kbdiacruc)*MAX_DIACR, GFP_KERNEL);
        if (!kbd->accent_table)
                goto out_fn_handler;
        memcpy(kbd->accent_table, accent_table,
-              sizeof(struct kbdiacr)*MAX_DIACR);
+              sizeof(struct kbdiacruc)*MAX_DIACR);
        kbd->accent_table_size = accent_table_size;
        return kbd;
 
  * Otherwise, conclude that DIACR was not combining after all,
  * queue it and return CH.
  */
-static unsigned char
-handle_diacr(struct kbd_data *kbd, unsigned char ch)
+static unsigned int
+handle_diacr(struct kbd_data *kbd, unsigned int ch)
 {
        int i, d;
 
 kbd_ioctl(struct kbd_data *kbd, struct file *file,
          unsigned int cmd, unsigned long arg)
 {
-       struct kbdiacrs __user *a;
        void __user *argp;
        int ct, perm;
 
        case KDSKBSENT:
                return do_kdgkb_ioctl(kbd, argp, cmd, perm);
        case KDGKBDIACR:
-               a = argp;
+       {
+               struct kbdiacrs __user *a = argp;
+               struct kbdiacr diacr;
+               int i;
 
                if (put_user(kbd->accent_table_size, &a->kb_cnt))
                        return -EFAULT;
+               for (i = 0; i < kbd->accent_table_size; i++) {
+                       diacr.diacr = kbd->accent_table[i].diacr;
+                       diacr.base = kbd->accent_table[i].base;
+                       diacr.result = kbd->accent_table[i].result;
+                       if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr)))
+                       return -EFAULT;
+               }
+               return 0;
+       }
+       case KDGKBDIACRUC:
+       {
+               struct kbdiacrsuc __user *a = argp;
+
                ct = kbd->accent_table_size;
-               if (copy_to_user(a->kbdiacr, kbd->accent_table,
-                                ct * sizeof(struct kbdiacr)))
+               if (put_user(ct, &a->kb_cnt))
+                       return -EFAULT;
+               if (copy_to_user(a->kbdiacruc, kbd->accent_table,
+                                ct * sizeof(struct kbdiacruc)))
                        return -EFAULT;
                return 0;
+       }
        case KDSKBDIACR:
-               a = argp;
+       {
+               struct kbdiacrs __user *a = argp;
+               struct kbdiacr diacr;
+               int i;
+
                if (!perm)
                        return -EPERM;
                if (get_user(ct, &a->kb_cnt))
                if (ct >= MAX_DIACR)
                        return -EINVAL;
                kbd->accent_table_size = ct;
-               if (copy_from_user(kbd->accent_table, a->kbdiacr,
-                                  ct * sizeof(struct kbdiacr)))
+               for (i = 0; i < ct; i++) {
+                       if (copy_from_user(&diacr, a->kbdiacr + i, sizeof(struct kbdiacr)))
+                               return -EFAULT;
+                       kbd->accent_table[i].diacr = diacr.diacr;
+                       kbd->accent_table[i].base = diacr.base;
+                       kbd->accent_table[i].result = diacr.result;
+               }
+               return 0;
+       }
+       case KDSKBDIACRUC:
+       {
+               struct kbdiacrsuc __user *a = argp;
+
+               if (!perm)
+                       return -EPERM;
+               if (get_user(ct, &a->kb_cnt))
+                       return -EFAULT;
+               if (ct >= MAX_DIACR)
+                       return -EINVAL;
+               kbd->accent_table_size = ct;
+               if (copy_from_user(kbd->accent_table, a->kbdiacruc,
+                                  ct * sizeof(struct kbdiacruc)))
                        return -EFAULT;
                return 0;
+       }
        default:
                return -ENOIOCTLCMD;
        }
 
        unsigned short **key_maps;
        char **func_table;
        fn_handler_fn **fn_handler;
-       struct kbdiacr *accent_table;
+       struct kbdiacruc *accent_table;
        unsigned int accent_table_size;
-       unsigned char diacr;
+       unsigned int diacr;
        unsigned short sysrq;
 };
 
 
        0,
 };
 
-struct kbdiacr accent_table[MAX_DIACR] = {
+struct kbdiacruc accent_table[MAX_DIACR] = {
        {'`', 'A', 'À'},        {'`', 'a', 'à'},
        {'\'', 'A', 'Á'},       {'\'', 'a', 'á'},
        {'^', 'A', 'Â'},        {'^', 'a', 'â'},
 
 extern unsigned short *set_translate(int m, struct vc_data *vc);
 extern int conv_uni_to_pc(struct vc_data *conp, long ucs);
 extern u32 conv_8bit_to_uni(unsigned char c);
+extern int conv_uni_to_8bit(u32 uni);
 void console_map_init(void);
 
 #define _DIACR_H
 #include <linux/kd.h>
 
-extern struct kbdiacr accent_table[];
+extern struct kbdiacruc accent_table[];
 extern unsigned int accent_table_size;
 
 #endif /* _DIACR_H */
 
 #define KDGKBDIACR      0x4B4A  /* read kernel accent table */
 #define KDSKBDIACR      0x4B4B  /* write kernel accent table */
 
+struct kbdiacruc {
+        __u32 diacr, base, result;
+};
+struct kbdiacrsuc {
+        unsigned int kb_cnt;    /* number of entries in following array */
+       struct kbdiacruc kbdiacruc[256];    /* MAX_DIACR from keyboard.h */
+};
+#define KDGKBDIACRUC    0x4BFA  /* read kernel accent table - UCS */
+#define KDSKBDIACRUC    0x4BFB  /* write kernel accent table - UCS */
+
 struct kbkeycode {
        unsigned int scancode, keycode;
 };