1 /* ----------------------------------------------------------------------- * 2 * 3 * Copyright 2009 Intel Corporation; author: H. Peter Anvin 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 8 * Boston MA 02110-1301, USA; either version 2 of the License, or 9 * (at your option) any later version; incorporated herein by reference. 10 * 11 * ----------------------------------------------------------------------- */ 12 13 #include <stdio.h> 14 #include <string.h> 15 #include <console.h> 16 #include <syslinux/loadfile.h> 17 #include <syslinux/keyboard.h> 18 19 static inline void error(const char *msg) 20 { 21 fputs(msg, stderr); 22 } 23 24 int main(int argc, char *argv[]) 25 { 26 const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map(); 27 size_t map_size; 28 void *kbdmap; 29 30 if (argc != 2) { 31 error("Usage: kbdmap mapfile\n"); 32 return 1; 33 } 34 35 if (kmap->version != 1) { 36 error("Syslinux core version mismatch\n"); 37 return 1; 38 } 39 40 if (loadfile(argv[1], &kbdmap, &map_size)) { 41 error("Keyboard map file load error\n"); 42 return 1; 43 } 44 45 if (map_size != kmap->length) { 46 error("Keyboard map file format error\n"); 47 return 1; 48 } 49 50 memcpy(kmap->map, kbdmap, map_size); 51 return 0; 52 } 53