summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openhackware/src/dev/char
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/openhackware/src/dev/char')
-rw-r--r--qemu/roms/openhackware/src/dev/char/char.h29
-rw-r--r--qemu/roms/openhackware/src/dev/char/kbd.c122
-rw-r--r--qemu/roms/openhackware/src/dev/char/kbd.h104
-rw-r--r--qemu/roms/openhackware/src/dev/char/kbdadb.c482
-rw-r--r--qemu/roms/openhackware/src/dev/char/pckbd.c214
5 files changed, 951 insertions, 0 deletions
diff --git a/qemu/roms/openhackware/src/dev/char/char.h b/qemu/roms/openhackware/src/dev/char/char.h
new file mode 100644
index 000000000..14f17e773
--- /dev/null
+++ b/qemu/roms/openhackware/src/dev/char/char.h
@@ -0,0 +1,29 @@
+/*
+ * <char.h>
+ *
+ * Open Hack'Ware BIOS misc char devices definitions.
+ *
+ * Copyright (c) 2005 Jocelyn Mayer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if !defined (__OHW_DEV_CHAR_H__)
+#define __OHW_DEV_CHAR_H__
+
+/* Keyboard devices registration */
+int pckbd_register (void);
+void *adb_kbd_new (void *private);
+
+#endif /* !defined (__OHW_DEV_CHAR_H__) */
diff --git a/qemu/roms/openhackware/src/dev/char/kbd.c b/qemu/roms/openhackware/src/dev/char/kbd.c
new file mode 100644
index 000000000..78f520404
--- /dev/null
+++ b/qemu/roms/openhackware/src/dev/char/kbd.c
@@ -0,0 +1,122 @@
+/*
+ * <kbd.c>
+ *
+ * Open Hack'Ware BIOS generic keyboard input translation.
+ *
+ * Copyright (c) 2005 Jocelyn Mayer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "bios.h"
+#include "kbd.h"
+
+//#define DEBUG_KBD
+#ifdef DEBUG_KBD
+#define KBD_DPRINTF(fmt, args...) \
+do { dprintf("KBD - %s: " fmt, __func__ , ##args); } while (0)
+#else
+#define KBD_DPRINTF(fmt, args...) do { } while (0)
+#endif
+
+void *kbd_new (int len)
+{
+ kbd_t *kbd;
+
+ if (len < (int)sizeof(kbd_t)) {
+ kbd = NULL;
+ } else {
+ kbd = malloc(len);
+ if (kbd != NULL)
+ memset(kbd, 0, len);
+ }
+
+ return kbd;
+}
+
+int kbd_set_keymap (kbd_t *kbd, int nb_keys, keymap_t *keymap)
+{
+ kbd->nb_keys = nb_keys;
+ kbd->keymap = keymap;
+
+ return 0;
+}
+
+int kbd_translate_key (kbd_t *kbd, int keycode, int up_down)
+{
+ keymap_t *keyt;
+ int mod_state, key, type;
+ int ret;
+
+ ret = -1;
+ /* Get key table */
+ if (keycode < kbd->nb_keys) {
+ keyt = &kbd->keymap[keycode];
+ /* Get modifier state */
+ mod_state = (kbd->mod_state | (kbd->mod_state >> 8)) & 0xFF;
+ /* Adjust with lock */
+ if (keyt->lck_shift >= 0) {
+ if ((kbd->mod_state >> (16 + keyt->lck_shift)) & 0x01) {
+ KBD_DPRINTF("adjust with lock %02x => %02x (%d %08x)\n",
+ mod_state,
+ mod_state ^ ((kbd->mod_state >>
+ (16 + keyt->lck_shift)) &
+ 0x01),
+ keyt->lck_shift, kbd->mod_state);
+ }
+ mod_state ^= (kbd->mod_state >> (16 + keyt->lck_shift)) & 0x01;
+ }
+ key = keyt->trans[mod_state];
+ type = key & 0xFF000000;
+ key &= ~0xFF000000;
+ switch (type) {
+ case KBD_TYPE_REGULAR:
+ if (!up_down) {
+ /* We don't care about up events on "normal" keys */
+ ret = key;
+ }
+ break;
+ case KBD_TYPE_LOCK:
+ if (!up_down) {
+ kbd->mod_state ^= key;
+ ret = -2;
+ KBD_DPRINTF("Change modifier type %d key %04x %s => %08x\n",
+ type, key, up_down ? "up" : "down",
+ kbd->mod_state);
+ }
+ break;
+ case KBD_TYPE_LMOD:
+ case KBD_TYPE_RMOD:
+ if (up_down)
+ kbd->mod_state &= ~key;
+ else
+ kbd->mod_state |= key;
+ KBD_DPRINTF("Change modifier type %d key %04x %s => %08x\n",
+ type, key, up_down ? "up" : "down", kbd->mod_state);
+ ret = -2; /* The caller may know the key was a modifier */
+ break;
+ default:
+ KBD_DPRINTF("Unknown key: keycode=%02x mod_state=%02x (%08x)\n",
+ keycode, mod_state, kbd->mod_state);
+ break;
+ }
+ } else {
+ KBD_DPRINTF("Unmanaged key: keycode=%02x mod_state %08x\n",
+ keycode, kbd->mod_state);
+ }
+
+ return ret;
+}
diff --git a/qemu/roms/openhackware/src/dev/char/kbd.h b/qemu/roms/openhackware/src/dev/char/kbd.h
new file mode 100644
index 000000000..3a56609fd
--- /dev/null
+++ b/qemu/roms/openhackware/src/dev/char/kbd.h
@@ -0,0 +1,104 @@
+/*
+ * <kbd.h>
+ *
+ * Open Hack'Ware BIOS generic keyboard management definitions.
+ *
+ * Copyright (c) 2005 Jocelyn Mayer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if !defined (__OHW_KBD_H__)
+#define __OHW_KBD_H__
+
+typedef struct kbd_t kbd_t;
+typedef struct keymap_t keymap_t;
+struct kbd_t {
+ uint32_t mod_state;
+ /* Modifier state
+ * 0x00 kk ll rr
+ * | | | |
+ * Not used for now -+ | | |
+ * Locks ---------------+ | |
+ * Left modifiers ---------+ |
+ * Right modifiers -----------+
+ */
+ int nb_keys;
+ keymap_t *keymap;
+};
+
+/* Modifiers */
+typedef enum {
+ KBD_MOD_SHIFT = 0x01,
+ KBD_MOD_CTRL = 0x02,
+ KBD_MOD_ALT = 0x04,
+ KBD_MOD_CMD = 0x08,
+ KBD_MOD_OPT = 0x10,
+} kbd_modifiers;
+
+/* Locks */
+typedef enum {
+ KBD_LCK_CAPS = 0x01,
+ KBD_LCK_NUM = 0x02,
+ KBD_LCK_SCROLL = 0x04,
+} kbd_locks;
+
+/* Lock shifts */
+typedef enum {
+ KBD_SH_NONE = -1,
+ KBD_SH_CAPS = 0,
+ KBD_SH_NUML = 1,
+ KBD_SH_SCRL = 2,
+} kbd_lck_shifts;
+
+enum {
+ KBD_TYPE_REGULAR = 0 << 24,
+ KBD_TYPE_LMOD = 1 << 24,
+ KBD_TYPE_RMOD = 2 << 24,
+ KBD_TYPE_LOCK = 3 << 24,
+};
+
+#define KBD_MOD_MAP(mod) \
+KBD_SH_NONE, { (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
+ (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
+ (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
+ (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), }
+#define KBD_MOD_MAP_LSHIFT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_SHIFT)
+#define KBD_MOD_MAP_RSHIFT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_SHIFT << 8))
+#define KBD_MOD_MAP_LCTRL KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CTRL)
+#define KBD_MOD_MAP_RCTRL KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CTRL << 8))
+#define KBD_MOD_MAP_LALT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_ALT)
+#define KBD_MOD_MAP_RALT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_ALT << 8))
+#define KBD_MOD_MAP_LCMD KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CMD)
+#define KBD_MOD_MAP_RCMD KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CMD << 8))
+#define KBD_MOD_MAP_LOPT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_OPT)
+#define KBD_MOD_MAP_ROPT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_OPT << 8))
+#define KBD_MOD_MAP_CAPS KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_CAPS << 16))
+#define KBD_MOD_MAP_NUML KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_NUML << 16))
+#define KBD_MOD_MAP_SCROLL KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_SCRL << 16))
+#define KBD_MAP_NONE KBD_MOD_MAP(-1)
+
+/* Keymap definition */
+struct keymap_t {
+ /* Set the lock which applies to this key (if any) */
+ int lck_shift;
+ /* Key translations */
+ uint32_t trans[32];
+};
+
+void *kbd_new (int len);
+int kbd_set_keymap (kbd_t *kbd, int nb_keys, keymap_t *keymap);
+int kbd_translate_key (kbd_t *kbd, int keycode, int up_down);
+
+#endif /* !defined (__OHW_KBD_H__) */
diff --git a/qemu/roms/openhackware/src/dev/char/kbdadb.c b/qemu/roms/openhackware/src/dev/char/kbdadb.c
new file mode 100644
index 000000000..4f7dd374b
--- /dev/null
+++ b/qemu/roms/openhackware/src/dev/char/kbdadb.c
@@ -0,0 +1,482 @@
+/*
+ * <adbkbd.c>
+ *
+ * Open Hack'Ware BIOS ADB keyboard support.
+ *
+ * Copyright (c) 2005 Jocelyn Mayer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "bios.h"
+#include "adb.h"
+#include "kbd.h"
+
+#ifdef DEBUG_ADB
+#define ADB_DPRINTF(fmt, args...) \
+do { dprintf("ADB - %s: " fmt, __func__ , ##args); } while (0)
+#else
+#define ADB_DPRINTF(fmt, args...) do { } while (0)
+#endif
+
+/* ADB US keyboard translation map
+ * XXX: for now, only shift modifier is defined
+ */
+static keymap_t ADB_kbd_us[] = {
+ /* 0x00 */
+ { KBD_SH_CAPS, { 0x61, 0x41, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x73, 0x53, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x64, 0x44, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x66, 0x46, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x68, 0x48, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x67, 0x47, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x7A, 0x5A, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x78, 0x58, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x08 */
+ { KBD_SH_CAPS, { 0x63, 0x43, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x76, 0x56, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x60, 0x40, -1, -1, -1, -1, -1, -1, /* ? */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x62, 0x42, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x71, 0x51, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x77, 0x57, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x65, 0x45, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x72, 0x52, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x10 */
+ { KBD_SH_CAPS, { 0x79, 0x59, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x74, 0x54, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x31, 0x21, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x32, 0x40, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x33, 0x23, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x34, 0x24, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x36, 0x5E, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x35, 0x25, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x18 */
+ { KBD_SH_CAPS, { 0x3D, 0x2B, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x39, 0x28, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x37, 0x26, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x2D, 0x5F, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x38, 0x2A, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x30, 0x29, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x5D, 0x7D, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x6F, 0x4F, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x20 */
+ { KBD_SH_CAPS, { 0x75, 0x55, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x5B, 0x7B, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x69, 0x49, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x70, 0x50, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MOD_MAP(0x0D), },
+ { KBD_SH_CAPS, { 0x6C, 0x4C, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x6A, 0x4A, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x27, 0x22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x28 */
+ { KBD_SH_CAPS, { 0x6B, 0x4B, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x3B, 0x3A, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x5C, 0x7C, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x2C, 0x3C, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x2F, 0x3F, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x6E, 0x4E, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x6D, 0x4D, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_CAPS, { 0x2E, 0x3E, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x30 : tab */
+ { KBD_MOD_MAP(0x09), },
+ /* 0x31 : space */
+ { KBD_MOD_MAP(0x20), },
+ /* 0x32 : '<' '>' */
+ { KBD_SH_CAPS, { 0x3C, 0x3E, -1, -1, -1, -1, -1, -1, /* ? */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x33 : backspace */
+ { KBD_MOD_MAP(0x08), },
+ { KBD_MAP_NONE, },
+ /* 0x35 : ESC */
+ { KBD_MOD_MAP(0x1B), },
+ /* 0x36 : control */
+ { KBD_MOD_MAP_LCTRL, },
+ /* 0x37 : command */
+ { KBD_MOD_MAP_LCMD, },
+ /* 0x38 : left shift */
+ { KBD_MOD_MAP_LSHIFT, },
+ /* 0x39 : caps-lock */
+ { KBD_MOD_MAP_CAPS, },
+ /* 0x3A : option */
+ { KBD_MOD_MAP_LOPT, },
+ /* 0x3B : left */
+ { KBD_MAP_NONE, },
+ /* 0x3C : right */
+ { KBD_MAP_NONE, },
+ /* 0x3D : down */
+ { KBD_MAP_NONE, },
+ /* 0x3E : up */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ /* 0x40 */
+ { KBD_MAP_NONE, },
+ { KBD_SH_NUML, { 0x7F, 0x2E, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ { KBD_SH_NONE, { 0x2A, 0x2A, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ { KBD_SH_NONE, { 0x2B, 0x2B, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ { KBD_MOD_MAP(0x7F), },
+ /* 0x48 */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ { KBD_SH_NONE, { 0x2F, 0x2F, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MOD_MAP(0x0D), },
+ { KBD_MAP_NONE, },
+ { KBD_SH_NONE, { 0x2D, 0x2D, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ /* 0x50 */
+ { KBD_MAP_NONE, },
+ { KBD_SH_NONE, { 0x3D, 0x3D, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x30, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x31, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x32, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x33, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x34, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x35, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ /* 0x58 */
+ { KBD_SH_NUML, { -1, 0x36, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x37, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ { KBD_SH_NUML, { -1, 0x38, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_SH_NUML, { -1, 0x39, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { KBD_MAP_NONE, },
+ { KBD_MOD_MAP(0x2F), },
+ { KBD_MAP_NONE, },
+ /* 0x60 : F5 */
+ { KBD_MAP_NONE, },
+ /* 0x61 : F6 */
+ { KBD_MAP_NONE, },
+ /* 0x62 : F7 */
+ { KBD_MAP_NONE, },
+ /* 0x63 : F3 */
+ { KBD_MAP_NONE, },
+ /* 0x64 : F8 */
+ { KBD_MAP_NONE, },
+ /* 0x65 : F9 */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ /* 0x67 : F11 */
+ { KBD_MAP_NONE, },
+ /* 0x68 */
+ { KBD_MAP_NONE, },
+ /* 0x69 : F13 */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ /* 0x6B : F14 */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ /* 0x6D : F10 */
+ { KBD_MAP_NONE, },
+ { KBD_MAP_NONE, },
+ /* 0x6F : F12 */
+ { KBD_MAP_NONE, },
+ /* 0x70 */
+ { KBD_MAP_NONE, },
+ /* 0x71 : F15 */
+ { KBD_MAP_NONE, },
+ /* 0x72 : help */
+ { KBD_MAP_NONE, },
+ /* 0x73 : home */
+ { KBD_MAP_NONE, },
+ /* 0x74 : page up */
+ { KBD_MAP_NONE, },
+ /* 0x75 : del */
+ { KBD_MAP_NONE, },
+ /* 0x76 : F4 */
+ { KBD_MAP_NONE, },
+ /* 0x77 : end */
+ { KBD_MAP_NONE, },
+ /* 0x78 : F2 */
+ { KBD_MAP_NONE, },
+ /* 0x79 : page down */
+ { KBD_MAP_NONE, },
+ /* 0x7A : F1 */
+ { KBD_MAP_NONE, },
+ /* 0x7B : right shift */
+ { KBD_MOD_MAP_RSHIFT, },
+ /* 0x7C : right option */
+ { KBD_MOD_MAP_ROPT, },
+ /* 0x7D : right control */
+ { KBD_MOD_MAP_RCTRL, },
+ { KBD_MAP_NONE, },
+ /* 0x7F : power */
+ { KBD_MAP_NONE, },
+};
+
+typedef struct adb_kbd_t adb_kbd_t;
+struct adb_kbd_t {
+ kbd_t kbd;
+ int next_key;
+};
+
+static int adb_kbd_open (unused void *private)
+{
+ return 0;
+}
+
+static int adb_kbd_close (unused void *private)
+{
+ return 0;
+}
+
+static int adb_kbd_read (void *private)
+{
+ uint8_t buffer[ADB_BUF_SIZE];
+ adb_dev_t *dev = private;
+ adb_kbd_t *kbd;
+ int key;
+ int ret;
+
+ kbd = (void *)dev->state;
+ ADB_DPRINTF("enter\n");
+ /* Get saved state */
+ ret = -1;
+ for (key = -1; key == -1; ) {
+ if (kbd->next_key != -1) {
+ key = kbd->next_key;
+ kbd->next_key = -1;
+ } else {
+ if (adb_reg_get(dev, 0, buffer) != 2) {
+ goto out;
+ }
+ kbd->next_key = buffer[1] == 0xFF ? -1 : buffer[1];
+ key = buffer[0];
+ }
+ ret = kbd_translate_key(&kbd->kbd, key & 0x7F, key >> 7);
+ ADB_DPRINTF("Translated %d (%02x) into %d (%02x)\n",
+ key, key, ret, ret);
+ }
+ out:
+
+ return ret;
+}
+
+static cops_t adb_kbd_ops = {
+ &adb_kbd_open,
+ &adb_kbd_close,
+ &adb_kbd_read,
+ NULL,
+};
+
+void *adb_kbd_new (void *private)
+{
+ adb_kbd_t *kbd;
+ adb_dev_t *dev = private;
+
+ kbd = kbd_new(sizeof(adb_kbd_t));
+ if (kbd != NULL) {
+ kbd_set_keymap(&kbd->kbd,
+ sizeof(ADB_kbd_us) / sizeof(keymap_t), ADB_kbd_us);
+ kbd->next_key = -1;
+ dev->state = (int32_t)kbd;
+ chardev_register(CHARDEV_KBD, &adb_kbd_ops, private);
+ }
+
+ return kbd;
+}
diff --git a/qemu/roms/openhackware/src/dev/char/pckbd.c b/qemu/roms/openhackware/src/dev/char/pckbd.c
new file mode 100644
index 000000000..45b5a67d8
--- /dev/null
+++ b/qemu/roms/openhackware/src/dev/char/pckbd.c
@@ -0,0 +1,214 @@
+/*
+ * <pckbd.c>
+ *
+ * Open Hack'Ware BIOS PC keyboard driver.
+ *
+ * Copyright (c) 2005 Jocelyn Mayer
+ *
+ * This code is a rework (mostly simplification) from code
+ * proposed by Matthew Wood <mwood@realmsys.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License V2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "bios.h"
+
+/* IO definitions */
+#define PCKBD_IO_BASE 0x60
+#define PCKBD_COMMAND_OFFSET 0x4
+#define PCKBD_STATUS_OFFSET 0x4
+
+/* Indexes for keyboard state */
+#define SHIFT 0x1
+#define CTRL 0x2
+#define ALT 0x4
+
+/* Scan codes */
+#define L_SHIFT 0x2a
+#define R_SHIFT 0x36
+#define L_CTRL 0x1d
+/* XXX: R_CTRL ? */
+#define L_ALT 0x38
+/* XXX: missing capslock */
+/* XXX: TODO: add keypad/numlock ... (pc105 kbd) */
+
+typedef struct kbdmap_t kbdmap_t;
+struct kbdmap_t {
+ char translate[8];
+};
+
+typedef struct pckbd_t pckbd_t;
+struct pckbd_t {
+ int modifiers;
+ kbdmap_t *map;
+ int maplen;
+ int io_base;
+};
+
+/* XXX: should not be here cause it's locale dependent */
+static kbdmap_t pc_map_us[] = {
+ /* 0x00 */
+ { { -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { { 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, }, },
+ { { '1', '!', -1, -1, '1', '!', -1, -1, }, },
+ { { '2', '\'', '\'', -1, -1, '2', '\'', '\'', }, },
+ { { '3', '#', -1, -1, '3', '#', -1, -1, }, },
+ { { '4', '$', -1, -1, '4', '$', -1, -1, }, },
+ { { '5', '%', -1, -1, '5', '%', -1, -1, }, },
+ { { '6', '^', -1, -1, '6', '^', -1, -1, }, },
+ /* 0x08 */
+ { { '7', '&', -1, -1, '7', '&', -1, -1, }, },
+ { { '8', '*', -1, -1, '8', '*', -1, -1, }, },
+ { { '9', '(', -1, -1, '9', '(', -1, -1, }, },
+ { { '0', ')', -1, -1, '0', ')', -1, -1, }, },
+ { { '-', '_', -1, -1, '-', '_', -1, -1, }, },
+ { { '=', '+', -1, -1, '=', '+', -1, -1, }, },
+ { { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, }, },
+ { { 0x2a, -1, -1, -1, 0x2a, -1, -1, -1, }, },
+ /* 0x10 */
+ { { 'q', 'Q', -1, -1, 'q', 'Q', -1, -1, }, },
+ { { 'w', 'W', -1, -1, 'w', 'W', -1, -1, }, },
+ { { 'e', 'E', -1, -1, 'e', 'E', -1, -1, }, },
+ { { 'r', 'R', -1, -1, 'r', 'R', -1, -1, }, },
+ { { 't', 'T', -1, -1, 't', 'T', -1, -1, }, },
+ { { 'y', 'Y', -1, -1, 'y', 'Y', -1, -1, }, },
+ { { 'u', 'U', -1, -1, 'u', 'U', -1, -1, }, },
+ { { 'i', 'I', -1, -1, 'i', 'I', -1, -1, }, },
+ /* 0x18 */
+ { { 'o', 'O', -1, -1, 'o', 'O', -1, -1, }, },
+ { { 'p', 'P', -1, -1, 'p', 'P', -1, -1, }, },
+ { { '[', '{', 0x1b, 0x1b, '[', '{', 0x1b, 0x1b, }, },
+ { { ']', '}', -1, -1, ']', '}', -1, -1, }, },
+ { { 0x0d, 0x0d, '\r', '\r', 0x0d, 0x0d, '\r', '\r', }, },
+ { { -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { { 'a', 'A', -1, -1, 'a', 'A', -1, -1, }, },
+ { { 's', 'S', -1, -1, 's', 'S', -1, -1, }, },
+ /* 0x20 */
+ { { 'd', 'D', -1, -1, 'd', 'D', -1, -1, }, },
+ { { 'f', 'F', -1, -1, 'f', 'F', -1, -1, }, },
+ { { 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, }, },
+ { { 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, }, },
+ { { 'j', 'J', '\r', '\r', 'j', 'J', '\r', '\r', }, },
+ { { 'k', 'K', -1, -1, 'k', 'K', -1, -1, }, },
+ { { 'l', 'L', -1, -1, 'l', 'L', -1, -1, }, },
+ { { ';', ':', -1, -1, ';', ':', -1, -1, }, },
+ /* 0x28 */
+ { { '\'', '"', -1, -1, '\'', '"', -1, -1, }, },
+ { { '`', '~', -1, -1, '`', '~', -1, -1, }, },
+ { { 0x02, -1, -1, -1, -1, -1, -1, -1, }, },
+ { { '\\', '|', -1, -1, '\\', '|', -1, -1, }, },
+ { { 'z', 'Z', -1, -1, 'z', 'Z', -1, -1, }, },
+ { { 'x', 'X', -1, -1, 'x', 'X', -1, -1, }, },
+ { { 'c', 'C', -1, -1, 'c', 'C', -1, -1, }, },
+ { { 'v', 'V', 0x16, 0x16, 'v', 'V', -1, -1, }, },
+ /* 0x30 */
+ { { 'b', 'B', -1, -1, 'b', 'B', -1, -1, }, },
+ { { 'n', 'N', -1, -1, 'n', 'N', -1, -1, }, },
+ { { 'm', 'M', 0x0d, 0x0d, 'm', 'M', 0x0d, 0x0d, }, },
+ { { ',', '<', -1, -1, ',', '<', -1, -1, }, },
+ { { '.', '>', -1, -1, '.', '>', -1, -1, }, },
+ { { '/', '?', -1, -1, '/', '?', -1, -1, }, },
+ { { -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { { '*', '*', -1, -1, '*', '*', -1, -1, }, },
+ /* 0x38 */
+ { { -1, -1, -1, -1, -1, -1, -1, -1, }, },
+ { { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', }, },
+};
+
+static int pckbd_open (unused void *private)
+{
+ return 0;
+}
+
+static int pckbd_close (unused void *private)
+{
+ return 0;
+}
+
+static int pckbd_readb (void *private)
+{
+ pckbd_t *kbd = private;
+ int status, key, up, mod;
+ int ret;
+
+ for (ret = -1; ret < 0; ) {
+ status = inb(kbd->io_base + PCKBD_STATUS_OFFSET);
+ if (!(status & 1)) {
+ /* No more data available */
+ break;
+ }
+ key = inb(kbd->io_base);
+ up = (key & 0x80) != 0;
+ key &= ~0x80;
+ switch (key) {
+ case 0:
+ break;
+ case L_ALT:
+ mod = ALT;
+ goto set_modifiers;
+ case L_SHIFT:
+ case R_SHIFT:
+ mod = SHIFT;
+ goto set_modifiers;
+ case L_CTRL:
+#if 0 /* XXX: missing definition */
+ case R_CTRL:
+#endif
+ mod = CTRL;
+ set_modifiers:
+ if (up)
+ kbd->modifiers &= ~mod;
+ else
+ kbd->modifiers |= mod;
+ break;
+ default:
+ /* We don't care about up events or unknown keys */
+ if (!up && key < kbd->maplen)
+ ret = kbd->map[key].translate[kbd->modifiers];
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static cops_t pckbd_ops = {
+ &pckbd_open,
+ &pckbd_close,
+ &pckbd_readb,
+ NULL,
+};
+
+int pckbd_register (void)
+{
+ pckbd_t *kbd;
+
+ kbd = malloc(sizeof(pckbd_t));
+ if (kbd == NULL)
+ return -1;
+ memset(kbd, 0, sizeof(pckbd_t));
+ /* Set IO base */
+ /* XXX: should be a parameter... */
+ kbd->io_base = PCKBD_IO_BASE;
+ /* Set default keymap */
+ kbd->map = pc_map_us;
+ kbd->maplen = sizeof(pc_map_us) / sizeof(kbdmap_t);
+ /* Reset modifiers state */
+ kbd->modifiers = 0x00;
+ chardev_register(CHARDEV_KBD, &pckbd_ops, kbd);
+
+ return 0;
+}