[OpenBIOS] r350 - openbios-devel/drivers

svn at openbios.org svn at openbios.org
Sun Jan 4 21:39:50 CET 2009


Author: blueswirl
Date: 2009-01-04 21:39:50 +0100 (Sun, 04 Jan 2009)
New Revision: 350

Added:
   openbios-devel/drivers/adb_bus.c
   openbios-devel/drivers/adb_bus.h
   openbios-devel/drivers/adb_kbd.c
   openbios-devel/drivers/adb_kbd.h
   openbios-devel/drivers/adb_mouse.c
   openbios-devel/drivers/adb_mouse.h
Removed:
   openbios-devel/drivers/adb.c
   openbios-devel/drivers/adb.h
Modified:
   openbios-devel/drivers/build.xml
   openbios-devel/drivers/cuda.c
   openbios-devel/drivers/cuda.h
Log:
ADB cleanup (Laurent Vivier)

Split adb.[ch] and part of cuda.c to adb_bus.[ch], adb_kbd.[ch] and
adb_mouse.[ch].


Deleted: openbios-devel/drivers/adb.c
===================================================================
--- openbios-devel/drivers/adb.c	2009-01-04 19:25:41 UTC (rev 349)
+++ openbios-devel/drivers/adb.c	2009-01-04 20:39:50 UTC (rev 350)
@@ -1,631 +0,0 @@
-/*
- * <adbkbd.c>
- *
- * Open Hack'Ware BIOS ADB keyboard support, ported to OpenBIOS
- *
- *  Copyright (c) 2005 Jocelyn Mayer
- *  Copyright (c) 2005 Stefan Reinauer
- *
- *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-
-#include "openbios/config.h"
-#include "openbios/bindings.h"
-#include "asm/types.h"
-#include "adb.h"
-#include "kbd.h"
-#include "cuda.h"
-#include "libc/byteorder.h"
-#include "libc/vsprintf.h"
-
-//#define DEBUG_ADB 1
-
-#ifdef DEBUG_ADB
-#define ADB_DPRINTF(fmt, args...) \
-do { printk("ADB - %s: " fmt, __func__ , ##args); } while (0)
-#else
-#define ADB_DPRINTF(fmt, args...) do { } while (0)
-#endif
-
-DECLARE_UNNAMED_NODE( keyboard, INSTALL_OPEN, sizeof(int));
-
-static void
-keyboard_open(int *idx)
-{
-	RET(-1);
-}
-
-static void
-keyboard_close(int *idx)
-{
-}
-
-static void keyboard_read(void);
-
-NODE_METHODS( keyboard ) = {
-	{ "open",		keyboard_open		},
-	{ "close",		keyboard_close		},
-	{ "read",               keyboard_read		},
-};
-
-/* ADB US keyboard translation map
- * XXX: for now, only shift modifier is defined
- */
-
-
-static const 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 adb_dev_t *my_adb_dev = NULL;
-
-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;
-    /* 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)
-		break;
-            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);
-    }
-
-    return ret;
-}
-
-
-void *adb_kbd_new (char *path, void *private)
-{
-	char buf[64];
-	int props[1];
-	phandle_t ph, aliases;
-    adb_kbd_t *kbd;
-    adb_dev_t *dev = private;
-    kbd = (adb_kbd_t*)malloc(sizeof(adb_kbd_t));
-    if (kbd != NULL) {
-        memset(kbd, 0, sizeof(adb_kbd_t));
-        kbd_set_keymap(&kbd->kbd, sizeof(ADB_kbd_us) / sizeof(keymap_t),
-			ADB_kbd_us);
-        kbd->next_key = -1;
-	dev->state = (int32_t)kbd;
-	my_adb_dev = dev;
-    }
-
-        snprintf(buf, sizeof(buf), "%s/keyboard", path);
-	REGISTER_NAMED_NODE( keyboard, buf);
-
-	ph = find_dev(buf);
-
-	set_property(ph, "device_type", "keyboard", 9);
-	props[0] = __cpu_to_be32(dev->addr);
-	set_property(ph, "reg", (char *)&props, sizeof(props));
-
-	aliases = find_dev("/aliases");
-	set_property(aliases, "adb-keyboard", buf, strlen(buf) + 1);
-
-    return kbd;
-}
-
-/* ( addr len -- actual ) */
-static void keyboard_read(void)
-{
-	char *addr;
-	int len, key, i;
-	len=POP();
-	addr=(char *)POP();
-
-	for (i = 0; i < len; i++) {
-		key = adb_kbd_read(my_adb_dev);
-		if (key == -1 || key == -2)
-			break;
-		*addr++ = (char)key;
-	}
-	PUSH(i);
-}
-
-DECLARE_UNNAMED_NODE( mouse, INSTALL_OPEN, sizeof(int));
-
-static void
-mouse_open(int *idx)
-{
-	RET(-1);
-}
-
-static void
-mouse_close(int *idx)
-{
-}
-
-NODE_METHODS( mouse ) = {
-	{ "open",		mouse_open		},
-	{ "close",		mouse_close		},
-};
-
-void adb_mouse_new (char *path, void *private)
-{
-	char buf[64];
-	int props[1];
-	phandle_t ph, aliases;
-	adb_dev_t *dev = private;
-
-        snprintf(buf, sizeof(buf), "%s/mouse", path);
-	REGISTER_NAMED_NODE( mouse, buf);
-
-	ph = find_dev(buf);
-
-	set_property(ph, "device_type", "mouse", 6);
-	props[0] = __cpu_to_be32(dev->addr);
-	set_property(ph, "reg", (char *)&props, sizeof(props));
-	set_int_property(ph, "#buttons", 3);
-
-	aliases = find_dev("/aliases");
-	set_property(aliases, "adb-mouse", buf, strlen(buf) + 1);
-}
-
-
-int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
-             uint8_t *buf, int len)
-{
-    uint8_t adb_send[ADB_BUF_SIZE], adb_rcv[ADB_BUF_SIZE];
-
-    //ADB_DPRINTF("cmd: %d reg: %d len: %d\n", cmd, reg, len);
-    if (dev->bus == NULL || dev->bus->req == NULL) {
-        ADB_DPRINTF("ERROR: invalid bus !\n");
-	for (;;);
-    }
-    /* Sanity checks */
-    if (cmd != ADB_LISTEN && len != 0) {
-        /* No buffer transmitted but for LISTEN command */
-        ADB_DPRINTF("in buffer for cmd %d\n", cmd);
-        return -1;
-    }
-    if (cmd == ADB_LISTEN && ((len < 2 || len > 8) || buf == NULL)) {
-        /* Need a buffer with a regular register size for LISTEN command */
-        ADB_DPRINTF("no/invalid buffer for ADB_LISTEN (%d)\n", len);
-        return -1;
-    }
-    if ((cmd == ADB_TALK || cmd == ADB_LISTEN) && reg > 3) {
-        /* Need a valid register number for LISTEN and TALK commands */
-        ADB_DPRINTF("invalid reg for TALK/LISTEN command (%d %d)\n", cmd, reg);
-        return -1;
-    }
-    switch (cmd) {
-    case ADB_SEND_RESET:
-        adb_send[0] = ADB_SEND_RESET;
-        break;
-    case ADB_FLUSH:
-        adb_send[0] = (dev->addr << 4) | ADB_FLUSH;
-        break;
-    case ADB_LISTEN:
-        memcpy(adb_send + 1, buf, len);
-        /* No break here */
-    case ADB_TALK:
-        adb_send[0] = (dev->addr << 4) | cmd | reg;
-        break;
-    }
-    memset(adb_rcv, 0, ADB_BUF_SIZE);
-    len = (*dev->bus->req)(dev->bus->host, adb_send, len + 1, adb_rcv);
-#ifdef DEBUG_ADB
-    //printk("%x %x %x %x\n", adb_rcv[0], adb_rcv[1], adb_rcv[2], adb_rcv[3]);
-#endif
-    switch (len) {
-    case 0:
-        /* No data */
-        break;
-    case 2 ... 8:
-        /* Register transmitted */
-        if (buf != NULL)
-            memcpy(buf, adb_rcv, len);
-        break;
-    default:
-        /* Should never happen */
-        //ADB_DPRINTF("Cmd %d returned %d bytes !\n", cmd, len);
-        return -1;
-    }
-    //ADB_DPRINTF("retlen: %d\n", len);
-
-    return len;
-}

Deleted: openbios-devel/drivers/adb.h
===================================================================
--- openbios-devel/drivers/adb.h	2009-01-04 19:25:41 UTC (rev 349)
+++ openbios-devel/drivers/adb.h	2009-01-04 20:39:50 UTC (rev 350)
@@ -1,106 +0,0 @@
-/*
- * ADB bus definitions for Open Hack'Ware
- *
- * Copyright (c) 2004-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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#if !defined(__OHW_ADB_H__)
-#define __OHW_ADB_H__
-
-typedef struct adb_bus_t adb_bus_t;
-typedef struct adb_dev_t adb_dev_t;
-
-#define ADB_BUF_SIZE 8
-struct adb_bus_t {
-    void *host;
-    int (*req)(void *host, const uint8_t *snd_buf, int len, uint8_t *rcv_buf);
-    adb_dev_t *devices;
-};
-
-struct adb_dev_t {
-    adb_dev_t *next;
-    adb_bus_t *bus;
-    uint8_t addr;
-    uint8_t type;
-    uint32_t state;
-};
-
-#define ADB_BUF_SIZE 8
-
-/* ADB commands */
-enum {
-    ADB_SEND_RESET = 0x00,
-    ADB_FLUSH      = 0x01,
-    ADB_LISTEN     = 0x08,
-    ADB_TALK       = 0x0C,
-};
-/* ADB default IDs before relocation */
-enum {
-    ADB_PROTECT    = 0x01,
-    ADB_KEYBD      = 0x02,
-    ADB_MOUSE      = 0x03,
-    ADB_ABS        = 0x04,
-    ADB_MODEM      = 0x05,
-    ADB_RES        = 0x06,
-    ADB_MISC       = 0x07,
-};
-/* ADB special device handlers IDs */
-enum {
-    ADB_CHADDR        = 0x00,
-    ADB_CHADDR_ACTIV  = 0xFD,
-    ADB_CHADDR_NOCOLL = 0xFE,
-    ADB_SELF_TEST     = 0xFF,
-};
-
-int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
-             uint8_t *buf, int len);
-void adb_bus_reset (adb_bus_t *bus);
-adb_bus_t *adb_bus_new (void *host,
-                        int (*req)(void *host, const uint8_t *snd_buf,
-                                   int len, uint8_t *rcv_buf));
-int adb_bus_init (char *path, adb_bus_t *bus);
-
-static inline int adb_reset (adb_bus_t *bus)
-{
-    adb_dev_t fake_device;
-
-    memset(&fake_device, 0, sizeof(adb_dev_t));
-    fake_device.bus = bus;
-
-    return adb_cmd(&fake_device, ADB_SEND_RESET, 0, NULL, 0);
-}
-
-static inline int adb_flush (adb_dev_t *dev)
-{
-    return adb_cmd(dev, ADB_FLUSH, 0, NULL, 0);
-}
-
-static inline int adb_reg_get (adb_dev_t *dev, uint8_t reg, uint8_t *buf)
-{
-    return adb_cmd(dev, ADB_TALK, reg, buf, 0);
-}
-
-static inline int adb_reg_set (adb_dev_t *dev, uint8_t reg,
-                               uint8_t *buf, int len)
-{
-    return adb_cmd(dev, ADB_LISTEN, reg, buf, len);
-}
-
-void *adb_kbd_new (char *path, void *private);
-
-void adb_mouse_new (char *path, void *private);
-
-#endif /* !defined(__OHW_ADB_H__) */

Added: openbios-devel/drivers/adb_bus.c
===================================================================
--- openbios-devel/drivers/adb_bus.c	                        (rev 0)
+++ openbios-devel/drivers/adb_bus.c	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,257 @@
+/*
+ *
+ * Open Hack'Ware BIOS ADB bus support, ported to OpenBIOS
+ *
+ *  Copyright (c) 2005 Jocelyn Mayer
+ *  Copyright (c) 2005 Stefan Reinauer
+ *
+ *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/vsprintf.h"
+
+#include "adb_bus.h"
+#include "adb_kbd.h"
+#include "adb_mouse.h"
+
+DECLARE_UNNAMED_NODE( adb, INSTALL_OPEN, sizeof(int));
+
+static void
+adb_initialize (int *idx)
+{
+	phandle_t ph=get_cur_dev();
+
+	push_str("adb");
+	fword("device-type");
+
+	set_property(ph, "compatible", "adb", 4);
+	set_int_property(ph, "#address-cells", 1);
+	set_int_property(ph, "#size-cells", 0);
+}
+
+static void
+adb_open(int *idx)
+{
+	RET(-1);
+}
+
+static void
+adb_close(int *idx)
+{
+}
+
+NODE_METHODS( adb ) = {
+	{ NULL,			adb_initialize		},
+	{ "open",		adb_open		},
+	{ "close",		adb_close		},
+};
+
+adb_bus_t *adb_bus_new (void *host,
+                        int (*req)(void *host, const uint8_t *snd_buf,
+                                   int len, uint8_t *rcv_buf))
+{
+    adb_bus_t *new;
+
+    new = malloc(sizeof(adb_bus_t));
+    if (new == NULL)
+        return NULL;
+    new->host = host;
+    new->req = req;
+
+    return new;
+}
+
+/* Check and relocate all ADB devices as suggested in
+ * ADB_manager Apple documentation
+ */
+
+int adb_bus_init (char *path, adb_bus_t *bus)
+{
+    char buf[64];
+    uint8_t buffer[ADB_BUF_SIZE];
+    uint8_t adb_addresses[16] =
+        { 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, 0, };
+    adb_dev_t tmp_device, **cur;
+    int address;
+    int reloc = 0, next_free = 7;
+    int keep;
+
+    snprintf(buf, sizeof(buf), "%s/adb", path);
+    REGISTER_NAMED_NODE( adb, buf);
+    /* Reset the bus */
+    // ADB_DPRINTF("\n");
+    adb_reset(bus);
+    cur = &bus->devices;
+    memset(&tmp_device, 0, sizeof(adb_dev_t));
+    tmp_device.bus = bus;
+    for (address = 1; address < 8 && adb_addresses[reloc] > 0;) {
+        if (address == ADB_RES) {
+            /* Reserved */
+            address++;
+            continue;
+        }
+        //ADB_DPRINTF("Check device on ADB address %d\n", address);
+        tmp_device.addr = address;
+        switch (adb_reg_get(&tmp_device, 3, buffer)) {
+        case 0:
+            //ADB_DPRINTF("No device on ADB address %d\n", address);
+            /* Register this address as free */
+            if (adb_addresses[next_free] != 0)
+                adb_addresses[next_free++] = address;
+            /* Check next ADB address */
+            address++;
+            break;
+        case 2:
+           /* One device answered :
+            * make it available and relocate it to a free address
+            */
+            if (buffer[0] == ADB_CHADDR) {
+                /* device self test failed */
+                ADB_DPRINTF("device on ADB address %d self-test failed "
+                            "%02x %02x %02x\n", address,
+                            buffer[0], buffer[1], buffer[2]);
+                keep = 0;
+            } else {
+                //ADB_DPRINTF("device on ADB address %d self-test OK\n",
+                //            address);
+                keep = 1;
+            }
+            ADB_DPRINTF("Relocate device on ADB address %d to %d (%d)\n",
+                        address, adb_addresses[reloc], reloc);
+            buffer[0] = ((buffer[0] & 0x40) & ~0x90) | adb_addresses[reloc];
+            if (keep == 1)
+                buffer[0] |= 0x20;
+            buffer[1] = ADB_CHADDR_NOCOLL;
+            if (adb_reg_set(&tmp_device, 3, buffer, 2) < 0) {
+                ADB_DPRINTF("ADB device relocation failed\n");
+                return -1;
+            }
+            if (keep == 1) {
+                *cur = malloc(sizeof(adb_dev_t));
+                if (*cur == NULL) {
+                    return -1;
+                }
+                (*cur)->type = address;
+                (*cur)->bus = bus;
+                (*cur)->addr = adb_addresses[reloc++];
+                /* Flush buffers */
+                adb_flush(*cur);
+                switch ((*cur)->type) {
+                case ADB_PROTECT:
+                    ADB_DPRINTF("Found one protected device\n");
+                    break;
+                case ADB_KEYBD:
+                    ADB_DPRINTF("Found one keyboard on address %d\n", address);
+                    adb_kbd_new(buf, *cur);
+                    break;
+                case ADB_MOUSE:
+                    ADB_DPRINTF("Found one mouse on address %d\n", address);
+                    adb_mouse_new(buf, *cur);
+                    break;
+                case ADB_ABS:
+                    ADB_DPRINTF("Found one absolute positioning device\n");
+                    break;
+                case ADB_MODEM:
+                    ADB_DPRINTF("Found one modem\n");
+                    break;
+                case ADB_RES:
+                    ADB_DPRINTF("Found one ADB res device\n");
+                    break;
+                case ADB_MISC:
+                    ADB_DPRINTF("Found one ADB misc device\n");
+                    break;
+                }
+                cur = &((*cur)->next);
+            }
+            break;
+        case 1:
+        case 3 ... 7:
+            /* SHOULD NOT HAPPEN : register 3 is always two bytes long */
+            ADB_DPRINTF("Invalid returned len for ADB register 3\n");
+            return -1;
+        case -1:
+            /* ADB ERROR */
+            ADB_DPRINTF("error gettting ADB register 3\n");
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
+             uint8_t *buf, int len)
+{
+    uint8_t adb_send[ADB_BUF_SIZE], adb_rcv[ADB_BUF_SIZE];
+
+    //ADB_DPRINTF("cmd: %d reg: %d len: %d\n", cmd, reg, len);
+    if (dev->bus == NULL || dev->bus->req == NULL) {
+        ADB_DPRINTF("ERROR: invalid bus !\n");
+	for (;;);
+    }
+    /* Sanity checks */
+    if (cmd != ADB_LISTEN && len != 0) {
+        /* No buffer transmitted but for LISTEN command */
+        ADB_DPRINTF("in buffer for cmd %d\n", cmd);
+        return -1;
+    }
+    if (cmd == ADB_LISTEN && ((len < 2 || len > 8) || buf == NULL)) {
+        /* Need a buffer with a regular register size for LISTEN command */
+        ADB_DPRINTF("no/invalid buffer for ADB_LISTEN (%d)\n", len);
+        return -1;
+    }
+    if ((cmd == ADB_TALK || cmd == ADB_LISTEN) && reg > 3) {
+        /* Need a valid register number for LISTEN and TALK commands */
+        ADB_DPRINTF("invalid reg for TALK/LISTEN command (%d %d)\n", cmd, reg);
+        return -1;
+    }
+    switch (cmd) {
+    case ADB_SEND_RESET:
+        adb_send[0] = ADB_SEND_RESET;
+        break;
+    case ADB_FLUSH:
+        adb_send[0] = (dev->addr << 4) | ADB_FLUSH;
+        break;
+    case ADB_LISTEN:
+        memcpy(adb_send + 1, buf, len);
+        /* No break here */
+    case ADB_TALK:
+        adb_send[0] = (dev->addr << 4) | cmd | reg;
+        break;
+    }
+    memset(adb_rcv, 0, ADB_BUF_SIZE);
+    len = (*dev->bus->req)(dev->bus->host, adb_send, len + 1, adb_rcv);
+#ifdef DEBUG_ADB
+    //printk("%x %x %x %x\n", adb_rcv[0], adb_rcv[1], adb_rcv[2], adb_rcv[3]);
+#endif
+    switch (len) {
+    case 0:
+        /* No data */
+        break;
+    case 2 ... 8:
+        /* Register transmitted */
+        if (buf != NULL)
+            memcpy(buf, adb_rcv, len);
+        break;
+    default:
+        /* Should never happen */
+        //ADB_DPRINTF("Cmd %d returned %d bytes !\n", cmd, len);
+        return -1;
+    }
+    //ADB_DPRINTF("retlen: %d\n", len);
+
+    return len;
+}

Added: openbios-devel/drivers/adb_bus.h
===================================================================
--- openbios-devel/drivers/adb_bus.h	                        (rev 0)
+++ openbios-devel/drivers/adb_bus.h	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,104 @@
+/*
+ * ADB bus definitions for Open Hack'Ware
+ *
+ * Copyright (c) 2004-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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+typedef struct adb_bus_t adb_bus_t;
+typedef struct adb_dev_t adb_dev_t;
+
+#define ADB_BUF_SIZE 8
+struct adb_bus_t {
+    void *host;
+    int (*req)(void *host, const uint8_t *snd_buf, int len, uint8_t *rcv_buf);
+    adb_dev_t *devices;
+};
+
+struct adb_dev_t {
+    adb_dev_t *next;
+    adb_bus_t *bus;
+    uint8_t addr;
+    uint8_t type;
+    uint32_t state;
+};
+
+#define ADB_BUF_SIZE 8
+
+/* ADB commands */
+enum {
+    ADB_SEND_RESET = 0x00,
+    ADB_FLUSH      = 0x01,
+    ADB_LISTEN     = 0x08,
+    ADB_TALK       = 0x0C,
+};
+/* ADB default IDs before relocation */
+enum {
+    ADB_PROTECT    = 0x01,
+    ADB_KEYBD      = 0x02,
+    ADB_MOUSE      = 0x03,
+    ADB_ABS        = 0x04,
+    ADB_MODEM      = 0x05,
+    ADB_RES        = 0x06,
+    ADB_MISC       = 0x07,
+};
+/* ADB special device handlers IDs */
+enum {
+    ADB_CHADDR        = 0x00,
+    ADB_CHADDR_ACTIV  = 0xFD,
+    ADB_CHADDR_NOCOLL = 0xFE,
+    ADB_SELF_TEST     = 0xFF,
+};
+
+int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
+             uint8_t *buf, int len);
+void adb_bus_reset (adb_bus_t *bus);
+adb_bus_t *adb_bus_new (void *host,
+                        int (*req)(void *host, const uint8_t *snd_buf,
+                                   int len, uint8_t *rcv_buf));
+int adb_bus_init (char *path, adb_bus_t *bus);
+
+static inline int adb_reset (adb_bus_t *bus)
+{
+    adb_dev_t fake_device;
+
+    memset(&fake_device, 0, sizeof(adb_dev_t));
+    fake_device.bus = bus;
+
+    return adb_cmd(&fake_device, ADB_SEND_RESET, 0, NULL, 0);
+}
+
+static inline int adb_flush (adb_dev_t *dev)
+{
+    return adb_cmd(dev, ADB_FLUSH, 0, NULL, 0);
+}
+
+static inline int adb_reg_get (adb_dev_t *dev, uint8_t reg, uint8_t *buf)
+{
+    return adb_cmd(dev, ADB_TALK, reg, buf, 0);
+}
+
+static inline int adb_reg_set (adb_dev_t *dev, uint8_t reg,
+                               uint8_t *buf, int len)
+{
+    return adb_cmd(dev, ADB_LISTEN, reg, buf, len);
+}
+
+#ifdef DEBUG_ADB
+#define ADB_DPRINTF(fmt, args...) \
+do { printk("ADB - %s: " fmt, __func__ , ##args); } while (0)
+#else
+#define ADB_DPRINTF(fmt, args...) do { } while (0)
+#endif

Added: openbios-devel/drivers/adb_kbd.c
===================================================================
--- openbios-devel/drivers/adb_kbd.c	                        (rev 0)
+++ openbios-devel/drivers/adb_kbd.c	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,516 @@
+/*
+ *
+ * Open Hack'Ware BIOS ADB keyboard support, ported to OpenBIOS
+ *
+ *  Copyright (c) 2005 Jocelyn Mayer
+ *  Copyright (c) 2005 Stefan Reinauer
+ *
+ *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/byteorder.h"
+#include "libc/vsprintf.h"
+#include "kbd.h"
+
+#include "adb_bus.h"
+#include "adb_kbd.h"
+
+DECLARE_UNNAMED_NODE( keyboard, INSTALL_OPEN, sizeof(int));
+
+static void
+keyboard_open(int *idx)
+{
+	RET(-1);
+}
+
+static void
+keyboard_close(int *idx)
+{
+}
+
+static void keyboard_read(void);
+
+NODE_METHODS( keyboard ) = {
+	{ "open",		keyboard_open		},
+	{ "close",		keyboard_close		},
+	{ "read",               keyboard_read		},
+};
+
+/* ADB US keyboard translation map
+ * XXX: for now, only shift modifier is defined
+ */
+
+
+static const 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 adb_dev_t *my_adb_dev = NULL;
+
+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;
+    /* 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)
+		break;
+            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);
+    }
+
+    return ret;
+}
+
+
+void *adb_kbd_new (char *path, void *private)
+{
+	char buf[64];
+	int props[1];
+	phandle_t ph, aliases;
+    adb_kbd_t *kbd;
+    adb_dev_t *dev = private;
+    kbd = (adb_kbd_t*)malloc(sizeof(adb_kbd_t));
+    if (kbd != NULL) {
+        memset(kbd, 0, sizeof(adb_kbd_t));
+        kbd_set_keymap(&kbd->kbd, sizeof(ADB_kbd_us) / sizeof(keymap_t),
+			ADB_kbd_us);
+        kbd->next_key = -1;
+	dev->state = (int32_t)kbd;
+	my_adb_dev = dev;
+    }
+
+        snprintf(buf, sizeof(buf), "%s/keyboard", path);
+	REGISTER_NAMED_NODE( keyboard, buf);
+
+	ph = find_dev(buf);
+
+	set_property(ph, "device_type", "keyboard", 9);
+	props[0] = __cpu_to_be32(dev->addr);
+	set_property(ph, "reg", (char *)&props, sizeof(props));
+
+	aliases = find_dev("/aliases");
+	set_property(aliases, "adb-keyboard", buf, strlen(buf) + 1);
+
+    return kbd;
+}
+
+/* ( addr len -- actual ) */
+static void keyboard_read(void)
+{
+	char *addr;
+	int len, key, i;
+	len=POP();
+	addr=(char *)POP();
+
+	for (i = 0; i < len; i++) {
+		key = adb_kbd_read(my_adb_dev);
+		if (key == -1 || key == -2)
+			break;
+		*addr++ = (char)key;
+	}
+	PUSH(i);
+}

Added: openbios-devel/drivers/adb_kbd.h
===================================================================
--- openbios-devel/drivers/adb_kbd.h	                        (rev 0)
+++ openbios-devel/drivers/adb_kbd.h	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,22 @@
+/*
+ *
+ * Open Hack'Ware BIOS ADB keyboard support, ported to OpenBIOS
+ *
+ *  Copyright (c) 2005 Jocelyn Mayer
+ *  Copyright (c) 2005 Stefan Reinauer
+ *
+ *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+void *adb_kbd_new (char *path, void *private);

Added: openbios-devel/drivers/adb_mouse.c
===================================================================
--- openbios-devel/drivers/adb_mouse.c	                        (rev 0)
+++ openbios-devel/drivers/adb_mouse.c	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,67 @@
+/*
+ *
+ * Open Hack'Ware BIOS ADB mouse support, ported to OpenBIOS
+ *
+ *  Copyright (c) 2005 Jocelyn Mayer
+ *  Copyright (c) 2005 Stefan Reinauer
+ *
+ *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include "openbios/config.h"
+#include "openbios/bindings.h"
+#include "libc/byteorder.h"
+#include "libc/vsprintf.h"
+
+#include "adb_bus.h"
+#include "adb_mouse.h"
+
+DECLARE_UNNAMED_NODE( mouse, INSTALL_OPEN, sizeof(int));
+
+static void
+mouse_open(int *idx)
+{
+	RET(-1);
+}
+
+static void
+mouse_close(int *idx)
+{
+}
+
+NODE_METHODS( mouse ) = {
+	{ "open",		mouse_open		},
+	{ "close",		mouse_close		},
+};
+
+void adb_mouse_new (char *path, void *private)
+{
+	char buf[64];
+	int props[1];
+	phandle_t ph, aliases;
+	adb_dev_t *dev = private;
+
+        snprintf(buf, sizeof(buf), "%s/mouse", path);
+	REGISTER_NAMED_NODE( mouse, buf);
+
+	ph = find_dev(buf);
+
+	set_property(ph, "device_type", "mouse", 6);
+	props[0] = __cpu_to_be32(dev->addr);
+	set_property(ph, "reg", (char *)&props, sizeof(props));
+	set_int_property(ph, "#buttons", 3);
+
+	aliases = find_dev("/aliases");
+	set_property(aliases, "adb-mouse", buf, strlen(buf) + 1);
+}

Added: openbios-devel/drivers/adb_mouse.h
===================================================================
--- openbios-devel/drivers/adb_mouse.h	                        (rev 0)
+++ openbios-devel/drivers/adb_mouse.h	2009-01-04 20:39:50 UTC (rev 350)
@@ -0,0 +1,22 @@
+/*
+ *
+ * Open Hack'Ware BIOS ADB mouse support, ported to OpenBIOS
+ *
+ *  Copyright (c) 2005 Jocelyn Mayer
+ *  Copyright (c) 2005 Stefan Reinauer
+ *
+ *   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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+void adb_mouse_new (char *path, void *private);

Modified: openbios-devel/drivers/build.xml
===================================================================
--- openbios-devel/drivers/build.xml	2009-01-04 19:25:41 UTC (rev 349)
+++ openbios-devel/drivers/build.xml	2009-01-04 20:39:50 UTC (rev 350)
@@ -6,7 +6,9 @@
   <object source="ide.c"   condition="DRIVER_IDE"/>
   <object source="timer.c" condition="DRIVER_IDE"/>
   <object source="kbd.c"   condition="DRIVER_ADB"/>
-  <object source="adb.c"   condition="DRIVER_ADB"/>
+  <object source="adb_bus.c" condition="DRIVER_ADB"/>
+  <object source="adb_kbd.c" condition="DRIVER_ADB"/>
+  <object source="adb_mouse.c" condition="DRIVER_ADB"/>
   <object source="cuda.c"  condition="DRIVER_ADB"/>
   <object source="floppy.c" condition="DRIVER_FLOPPY"/>
   <object source="iommu.c" condition="DRIVER_SBUS"/>

Modified: openbios-devel/drivers/cuda.c
===================================================================
--- openbios-devel/drivers/cuda.c	2009-01-04 19:25:41 UTC (rev 349)
+++ openbios-devel/drivers/cuda.c	2009-01-04 20:39:50 UTC (rev 350)
@@ -3,9 +3,6 @@
 #include "libc/byteorder.h"
 #include "libc/vsprintf.h"
 
-#include "adb.h"
-
-
 #include "cuda.h"
 //#define DEBUG_CUDA
 #ifdef DEBUG_CUDA
@@ -14,7 +11,6 @@
 #else
 #define CUDA_DPRINTF(fmt, args...) do { } while (0)
 #endif
-#define ADB_DPRINTF CUDA_DPRINTF
 
 #define IO_CUDA_OFFSET	0x00016000
 #define IO_CUDA_SIZE	0x00002000
@@ -305,170 +301,3 @@
 
 	return cuda;
 }
-
-#ifdef CONFIG_DRIVER_ADB
-
-DECLARE_UNNAMED_NODE( adb, INSTALL_OPEN, sizeof(int));
-
-static void
-adb_initialize (int *idx)
-{
-	phandle_t ph=get_cur_dev();
-
-	push_str("adb");
-	fword("device-type");
-
-	set_property(ph, "compatible", "adb", 4);
-	set_int_property(ph, "#address-cells", 1);
-	set_int_property(ph, "#size-cells", 0);
-}
-
-static void
-adb_open(int *idx)
-{
-	RET(-1);
-}
-
-static void
-adb_close(int *idx)
-{
-}
-
-NODE_METHODS( adb ) = {
-	{ NULL,			adb_initialize		},
-	{ "open",		adb_open		},
-	{ "close",		adb_close		},
-};
-
-adb_bus_t *adb_bus_new (void *host,
-                        int (*req)(void *host, const uint8_t *snd_buf,
-                                   int len, uint8_t *rcv_buf))
-{
-    adb_bus_t *new;
-
-    new = malloc(sizeof(adb_bus_t));
-    if (new == NULL)
-        return NULL;
-    new->host = host;
-    new->req = req;
-
-    return new;
-}
-
-/* Check and relocate all ADB devices as suggested in
- *  * ADB_manager Apple documentation
- *   */
-int adb_bus_init (char *path, adb_bus_t *bus)
-{
-    char buf[64];
-    uint8_t buffer[ADB_BUF_SIZE];
-    uint8_t adb_addresses[16] =
-        { 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, 0, };
-    adb_dev_t tmp_device, **cur;
-    int address;
-    int reloc = 0, next_free = 7;
-    int keep;
-
-    snprintf(buf, sizeof(buf), "%s/adb", path);
-    REGISTER_NAMED_NODE( adb, buf);
-    /* Reset the bus */
-    // ADB_DPRINTF("\n");
-    adb_reset(bus);
-    cur = &bus->devices;
-    memset(&tmp_device, 0, sizeof(adb_dev_t));
-    tmp_device.bus = bus;
-    for (address = 1; address < 8 && adb_addresses[reloc] > 0;) {
-        if (address == ADB_RES) {
-            /* Reserved */
-            address++;
-            continue;
-        }
-        //ADB_DPRINTF("Check device on ADB address %d\n", address);
-        tmp_device.addr = address;
-        switch (adb_reg_get(&tmp_device, 3, buffer)) {
-        case 0:
-            //ADB_DPRINTF("No device on ADB address %d\n", address);
-            /* Register this address as free */
-            if (adb_addresses[next_free] != 0)
-                adb_addresses[next_free++] = address;
-            /* Check next ADB address */
-            address++;
-            break;
-        case 2:
-           /* One device answered :
-            * make it available and relocate it to a free address
-            */
-            if (buffer[0] == ADB_CHADDR) {
-                /* device self test failed */
-                ADB_DPRINTF("device on ADB address %d self-test failed "
-                            "%02x %02x %02x\n", address,
-                            buffer[0], buffer[1], buffer[2]);
-                keep = 0;
-            } else {
-                //ADB_DPRINTF("device on ADB address %d self-test OK\n",
-                //            address);
-                keep = 1;
-            }
-            ADB_DPRINTF("Relocate device on ADB address %d to %d (%d)\n",
-                        address, adb_addresses[reloc], reloc);
-            buffer[0] = ((buffer[0] & 0x40) & ~0x90) | adb_addresses[reloc];
-            if (keep == 1)
-                buffer[0] |= 0x20;
-            buffer[1] = ADB_CHADDR_NOCOLL;
-            if (adb_reg_set(&tmp_device, 3, buffer, 2) < 0) {
-                ADB_DPRINTF("ADB device relocation failed\n");
-                return -1;
-            }
-            if (keep == 1) {
-                *cur = malloc(sizeof(adb_dev_t));
-                if (*cur == NULL) {
-                    return -1;
-                }
-                (*cur)->type = address;
-                (*cur)->bus = bus;
-                (*cur)->addr = adb_addresses[reloc++];
-                /* Flush buffers */
-                adb_flush(*cur);
-                switch ((*cur)->type) {
-                case ADB_PROTECT:
-                    ADB_DPRINTF("Found one protected device\n");
-                    break;
-                case ADB_KEYBD:
-                    ADB_DPRINTF("Found one keyboard on address %d\n", address);
-                    adb_kbd_new(buf, *cur);
-                    break;
-                case ADB_MOUSE:
-                    ADB_DPRINTF("Found one mouse on address %d\n", address);
-                    adb_mouse_new(buf, *cur);
-                    break;
-                case ADB_ABS:
-                    ADB_DPRINTF("Found one absolute positioning device\n");
-                    break;
-                case ADB_MODEM:
-                    ADB_DPRINTF("Found one modem\n");
-                    break;
-                case ADB_RES:
-                    ADB_DPRINTF("Found one ADB res device\n");
-                    break;
-                case ADB_MISC:
-                    ADB_DPRINTF("Found one ADB misc device\n");
-                    break;
-                }
-                cur = &((*cur)->next);
-            }
-            break;
-        case 1:
-        case 3 ... 7:
-            /* SHOULD NOT HAPPEN : register 3 is always two bytes long */
-            ADB_DPRINTF("Invalid returned len for ADB register 3\n");
-            return -1;
-        case -1:
-            /* ADB ERROR */
-            ADB_DPRINTF("error gettting ADB register 3\n");
-            return -1;
-        }
-    }
-
-    return 0;
-}
-#endif

Modified: openbios-devel/drivers/cuda.h
===================================================================
--- openbios-devel/drivers/cuda.h	2009-01-04 19:25:41 UTC (rev 349)
+++ openbios-devel/drivers/cuda.h	2009-01-04 20:39:50 UTC (rev 350)
@@ -1,4 +1,4 @@
-#include "adb.h"
+#include "adb_bus.h"
 
 struct cuda_t {
 	uint32_t base;




More information about the OpenBIOS mailing list