Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hp300 Pull Apollo Domain keyboard and mouse support...



details:   https://anonhg.NetBSD.org/src/rev/a35aab9f84ce
branches:  trunk
changeset: 761965:a35aab9f84ce
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Feb 12 15:49:01 2011 +0000

description:
Pull Apollo Domain keyboard and mouse support from OpenBSD.
Untested (no hardware), but no bad sideeffect on 425t without Domain keyboard.

This is the last portion of "new hp300 kernel features" submitted in
PR port-hp300/3528 back in 1997, and I think finally we can close it.

diffstat:

 sys/arch/hp300/conf/GENERIC     |    10 +-
 sys/arch/hp300/conf/files.hp300 |    10 +-
 sys/arch/hp300/dev/dnkbd.c      |  1138 +++++++++++++++++++++++++++++++++++++++
 sys/arch/hp300/dev/dnkbdmap.c   |   396 +++++++++++++
 sys/arch/hp300/dev/dnkbdmap.h   |    29 +
 5 files changed, 1573 insertions(+), 10 deletions(-)

diffs (truncated from 1630 to 300 lines):

diff -r a0d09d52b332 -r a35aab9f84ce sys/arch/hp300/conf/GENERIC
--- a/sys/arch/hp300/conf/GENERIC       Sat Feb 12 15:15:56 2011 +0000
+++ b/sys/arch/hp300/conf/GENERIC       Sat Feb 12 15:49:01 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.163 2011/02/12 05:15:39 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.164 2011/02/12 15:49:01 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.163 $"
+#ident                 "GENERIC-$Revision: 1.164 $"
 
 maxusers       32              # estimated number of users
 
@@ -210,9 +210,9 @@
 nhpib*         at intio?               # slow internal HP-IB
 
 # 8250-like serial ports found on Frodo ASIC
-#dnkbd0                at frodo? offset 0x0    # Domain keyboard flavor
-#wskbd*                at dnkbd? mux 1
-#wsmouse*      at dnkbd? mux 0
+dnkbd0         at frodo? offset 0x0    # Domain keyboard flavor
+wskbd*         at dnkbd? mux 1
+wsmouse*       at dnkbd? mux 0
 com*           at frodo? offset ?      # tty flavor
 
 dvbox*         at intio?               # Davinci framebuffer
diff -r a0d09d52b332 -r a35aab9f84ce sys/arch/hp300/conf/files.hp300
--- a/sys/arch/hp300/conf/files.hp300   Sat Feb 12 15:15:56 2011 +0000
+++ b/sys/arch/hp300/conf/files.hp300   Sat Feb 12 15:49:01 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hp300,v 1.81 2011/02/12 05:15:39 tsutsui Exp $
+#      $NetBSD: files.hp300,v 1.82 2011/02/12 15:49:01 tsutsui Exp $
 #
 # hp300-specific configuration info
 
@@ -80,10 +80,10 @@
 file   arch/hp300/dev/com_frodo.c      com_frodo needs-flag
 
 # Apollo Keyboard and mouse
-#device        dnkbd: wskbddev, wsmousedev
-#attach        dnkbd at frodo
-#file  arch/hp300/dev/dnkbd.c                  dnkbd   needs-flag
-#file  arch/hp300/dev/dnkbdmap.c               dnkbd
+device dnkbd: wskbddev, wsmousedev
+attach dnkbd at frodo
+file   arch/hp300/dev/dnkbd.c                  dnkbd   needs-flag
+file   arch/hp300/dev/dnkbdmap.c               dnkbd
 
 #
 # Frame buffer devices on Internal I/O and the DIO bus
diff -r a0d09d52b332 -r a35aab9f84ce sys/arch/hp300/dev/dnkbd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/dnkbd.c        Sat Feb 12 15:49:01 2011 +0000
@@ -0,0 +1,1138 @@
+/*     $NetBSD: dnkbd.c,v 1.1 2011/02/12 15:49:01 tsutsui Exp $        */
+/*     $OpenBSD: dnkbd.c,v 1.17 2009/07/23 21:05:56 blambert Exp $     */
+
+/*
+ * Copyright (c) 2005, Miodrag Vallat
+ * Copyright (c) 1997 Michael Smith.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Driver for the Apollo Domain keyboard and mouse.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/callout.h>
+#include <sys/conf.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+
+#include <machine/autoconf.h>
+
+#include <dev/cons.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wskbdvar.h>
+#include <dev/wscons/wsksymdef.h>
+#include <dev/wscons/wsksymvar.h>
+#include "wsmouse.h"
+#if NWSMOUSE > 0
+#include <dev/wscons/wsmousevar.h>
+#endif
+
+#include <dev/ic/ns16550reg.h>
+#include <dev/ic/comreg.h>
+
+#include <hp300/dev/dnkbdmap.h>
+#include <hp300/dev/frodoreg.h>
+#include <hp300/dev/frodovar.h>
+
+#include "hilkbd.h"
+#include "ioconf.h"
+
+/*
+ * Keyboard key codes
+ */
+
+#define        DNKEY_CAPSLOCK  0x7e
+#define        DNKEY_REPEAT    0x7f
+#define        DNKEY_RELEASE   0x80
+#define        DNKEY_CHANNEL   0xff
+
+/*
+ * Channels
+ */
+
+#define        DNCHANNEL_RESET 0x00
+#define        DNCHANNEL_KBD   0x01
+#define        DNCHANNEL_MOUSE 0x02
+
+/*
+ * Keyboard modes
+ */
+
+#define        DNMODE_COOKED   0x00
+#define        DNMODE_RAW      0x01
+
+/*
+ * Keyboard commands
+ */
+
+#define        DNCMD_PREFIX    0xff
+#define        DNCMD_COOKED    DNMODE_COOKED
+#define        DNCMD_RAW       DNMODE_RAW
+#define        DNCMD_IDENT_1   0x12
+#define        DNCMD_IDENT_2   0x21
+
+/*
+ * Bell commands
+ */
+
+#define        DNCMD_BELL      0x21
+#define        DNCMD_BELL_ON   0x81
+#define        DNCMD_BELL_OFF  0x82
+
+/*
+ * Mouse status
+ */
+
+#define        DNBUTTON_L      0x10
+#define        DNBUTTON_R      0x20
+#define        DNBUTTON_M      0x40
+
+struct dnkbd_softc {
+       device_t        sc_dev;
+       bus_space_tag_t sc_bst;
+       bus_space_handle_t sc_bsh;
+
+       int             sc_flags;
+#define        SF_ENABLED      0x01            /* keyboard enabled */
+#define        SF_CONSOLE      0x02            /* keyboard is console */
+#define        SF_POLLING      0x04            /* polling mode */
+#define        SF_PLUGGED      0x08            /* keyboard has been seen plugged */
+#define        SF_ATTACHED     0x10            /* subdevices have been attached */
+#define        SF_MOUSE        0x20            /* mouse enabled */
+#define        SF_BELL         0x40            /* bell is active */
+#define        SF_BELL_TMO     0x80            /* bell stop timeout is scheduled */
+
+       u_int           sc_identlen;
+#define        MAX_IDENTLEN    32
+       char            sc_ident[MAX_IDENTLEN];
+       kbd_t           sc_layout;
+
+       enum { STATE_KEYBOARD, STATE_MOUSE, STATE_CHANNEL, STATE_ECHO }
+                       sc_state, sc_prevstate;
+       u_int           sc_echolen;
+
+       u_int8_t        sc_mousepkt[3]; /* mouse packet being constructed */
+       u_int           sc_mousepos;    /* index in above */
+
+       struct callout  sc_bellstop_tmo;
+
+       device_t        sc_wskbddev;
+#if NWSMOUSE > 0
+       device_t        sc_wsmousedev;
+#endif
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+       int             sc_rawkbd;
+       int             sc_nrep;
+       char            sc_rep[2];      /* at most, one key */
+       struct callout  sc_rawrepeat_ch;
+#define        REP_DELAY1      400
+#define        REP_DELAYN      100
+#endif
+};
+
+int    dnkbd_match(device_t, cfdata_t, void *);
+void   dnkbd_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(dnkbd, sizeof(struct dnkbd_softc),
+    dnkbd_match, dnkbd_attach, NULL, NULL);
+
+void   dnkbd_init(struct dnkbd_softc *, uint16_t, uint16_t);
+int    dnkbd_enable(void *, int);
+void   dnkbd_set_leds(void *, int);
+int    dnkbd_ioctl(void *, u_long, void *, int, struct lwp *);
+
+const struct wskbd_accessops dnkbd_accessops = {
+       dnkbd_enable,
+       dnkbd_set_leds,
+       dnkbd_ioctl
+};
+
+#if NWSMOUSE > 0
+int    dnmouse_enable(void *);
+int    dnmouse_ioctl(void *, u_long, void *, int, struct lwp *);
+void   dnmouse_disable(void *);
+
+const struct wsmouse_accessops dnmouse_accessops = {
+       dnmouse_enable,
+       dnmouse_ioctl,
+       dnmouse_disable
+};
+#endif
+
+void   dnkbd_bell(void *, u_int, u_int, u_int);
+void   dnkbd_cngetc(void *, u_int *, int *);
+void   dnkbd_cnpollc(void *, int);
+
+const struct wskbd_consops dnkbd_consops = {
+       dnkbd_cngetc,
+       dnkbd_cnpollc,
+       dnkbd_bell
+};
+
+struct wskbd_mapdata dnkbd_keymapdata = {
+       dnkbd_keydesctab,
+#ifdef DNKBD_LAYOUT
+       DNKBD_LAYOUT
+#else
+       KB_US
+#endif
+};
+
+typedef enum { EVENT_NONE, EVENT_KEYBOARD, EVENT_MOUSE } dnevent;
+
+void   dnevent_kbd(struct dnkbd_softc *, int);
+void   dnevent_kbd_internal(struct dnkbd_softc *, int);
+void   dnevent_mouse(struct dnkbd_softc *, u_int8_t *);
+void   dnkbd_attach_subdevices(struct dnkbd_softc *);
+void   dnkbd_bellstop(void *);
+void   dnkbd_decode(int, u_int *, int *);
+dnevent        dnkbd_input(struct dnkbd_softc *, int);
+int    dnkbd_intr(void *);
+int    dnkbd_pollin(struct dnkbd_softc *, u_int);
+int    dnkbd_pollout(struct dnkbd_softc *, int);
+int    dnkbd_probe(struct dnkbd_softc *);
+void   dnkbd_rawrepeat(void *);
+int    dnkbd_send(struct dnkbd_softc *, const u_int8_t *, size_t);
+int    dnsubmatch_kbd(device_t, cfdata_t, const int *, void *);
+int    dnsubmatch_mouse(device_t, cfdata_t, const int *, void *);
+
+int
+dnkbd_match(device_t parent, cfdata_t cf, void *aux)
+{
+       struct frodo_attach_args *fa = aux;
+
+       if (strcmp(fa->fa_name, dnkbd_cd.cd_name) != 0)
+               return (0);
+
+       if (machineid == HP_382) {
+               /* 382 has frodo but no Domain keyboard connector. */
+               return 0;
+       }
+
+       /* only attach to the first frodo port */
+       return (fa->fa_offset == FRODO_APCI_OFFSET(0));



Home | Main Index | Thread Index | Old Index