kbdmap.c32: new module to load a keyboard map dynamically
authorH. Peter Anvin <hpa@zytor.com>
Wed, 4 Feb 2009 06:09:45 +0000 (22:09 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 4 Feb 2009 06:09:45 +0000 (22:09 -0800)
Load a new keyboard map dynamically

NEWS
com32/modules/Makefile
com32/modules/kbdmap.c [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7334de4..33147d6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Changes in 3.74:
          a menu system (or not.)  With the UI directive specifying
          the menu system, the DEFAULT directive can be used to select
          the default entry inside the menus.
+       * kbdmap.c32: new module to load a new keyboard map dynamically.
 
 Changes in 3.73:
        * Upgrade gPXE to release version 0.9.5.
index 1bce20b..2739a39 100644 (file)
@@ -20,7 +20,7 @@ include ../MCONFIG
 MODULES          = chain.c32 config.c32 ethersel.c32 mboot.c32 dmitest.c32 \
            cpuidtest.c32 \
            pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 meminfo.c32 \
-           sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32
+           sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 kbdmap.c32
 
 TESTFILES =
 
diff --git a/com32/modules/kbdmap.c b/com32/modules/kbdmap.c
new file mode 100644 (file)
index 0000000..39d7301
--- /dev/null
@@ -0,0 +1,56 @@
+/* ----------------------------------------------------------------------- *
+ *   
+ *   Copyright 2009 H. Peter Anvin - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ *   Boston MA 02110-1301, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <string.h>
+#include <console.h>
+#include <syslinux/loadfile.h>
+#include <syslinux/keyboard.h>
+
+static inline void error(const char *msg)
+{
+  fputs(msg, stderr);
+}
+
+int main(int argc, char *argv[])
+{
+  const struct syslinux_keyboard_map * const kmap = syslinux_keyboard_map();
+  size_t map_size;
+  void *kbdmap;
+
+  openconsole(&dev_null_r, &dev_stdcon_w);
+
+  if (argc != 2) {
+    error("Usage: kbdmap mapfile\n");
+    return 1;
+  }
+
+  if (kmap->version != 1) {
+    error("Syslinux core version mismatch\n");
+    return 1;
+  }
+  
+  if (loadfile(argv[1], &kbdmap, &map_size)) {
+    error("Keyboard map file load error\n");
+    return 1;
+  }
+
+  if (map_size != kmap->length) {
+    error("Keyboard map file format error\n");
+    return 1;
+  }
+
+  memcpy(kmap->map, kbdmap, map_size);
+  return 0;
+}
+
+