diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-02-03 22:09:45 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-02-03 22:09:45 -0800 |
commit | 2b02abdaa91f41235f40f846d08bb09d8841baa6 (patch) | |
tree | f19f6cabf0f1a2b6e4227bbb2c9901f30991ef57 /com32 | |
parent | fd3b1f970c6385d178762fb5cfe922a2930d0cad (diff) | |
download | syslinux-2b02abdaa91f41235f40f846d08bb09d8841baa6.tar.gz |
kbdmap.c32: new module to load a keyboard map dynamically
Load a new keyboard map dynamically
Diffstat (limited to 'com32')
-rw-r--r-- | com32/modules/Makefile | 2 | ||||
-rw-r--r-- | com32/modules/kbdmap.c | 56 |
2 files changed, 57 insertions, 1 deletions
diff --git a/com32/modules/Makefile b/com32/modules/Makefile index 1bce20b4..2739a39b 100644 --- a/com32/modules/Makefile +++ b/com32/modules/Makefile @@ -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 index 00000000..39d7301c --- /dev/null +++ b/com32/modules/kbdmap.c @@ -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; +} + + |