change log for rtems (2011-03-14)

rtems-vc at rtems.org rtems-vc at rtems.org
Mon Mar 14 15:10:49 UTC 2011


 *joel*:
2011-03-14	Joel Sherrill <joel.sherrill at oarcorp.com>

	PR 1762/cpukit
	* Makefile.am, preinstall.am, libmisc/Makefile.am, wrapup/Makefile.am:
	Add generic serial mouse driver and mouse parser. The parser code was
	in the pc386 BSP but was generic so cleaned up and placed here.
	Serial mouse driver itself is new.
	* libmisc/mouse/README, libmisc/mouse/mouse_parser.c,
	libmisc/mouse/mouse_parser.h, libmisc/mouse/serial_mouse.c,
	libmisc/mouse/serial_mouse.h: New files.

M 1.2771  cpukit/ChangeLog
M  1.105  cpukit/Makefile.am
M   1.89  cpukit/libmisc/Makefile.am
A    1.1  cpukit/libmisc/mouse/README
A    1.1  cpukit/libmisc/mouse/mouse_parser.h
A    1.1  cpukit/libmisc/mouse/mouse_parser.c
A    1.1  cpukit/libmisc/mouse/serial_mouse.h
A    1.1  cpukit/libmisc/mouse/serial_mouse.c
M   1.49  cpukit/preinstall.am
M   1.75  cpukit/wrapup/Makefile.am

diff -u rtems/cpukit/ChangeLog:1.2770 rtems/cpukit/ChangeLog:1.2771
--- rtems/cpukit/ChangeLog:1.2770	Mon Mar 14 08:18:34 2011
+++ rtems/cpukit/ChangeLog	Mon Mar 14 09:56:06 2011
@@ -1,3 +1,14 @@
+2011-03-14	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	PR 1762/cpukit
+	* Makefile.am, preinstall.am, libmisc/Makefile.am, wrapup/Makefile.am:
+	Add generic serial mouse driver and mouse parser. The parser code was
+	in the pc386 BSP but was generic so cleaned up and placed here.
+	Serial mouse driver itself is new.
+	* libmisc/mouse/README, libmisc/mouse/mouse_parser.c,
+	libmisc/mouse/mouse_parser.h, libmisc/mouse/serial_mouse.c,
+	libmisc/mouse/serial_mouse.h: New files.
+
 2011-03-14	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	* score/include/rtems/score/sysstate.h: Spelling.

diff -u rtems/cpukit/Makefile.am:1.104 rtems/cpukit/Makefile.am:1.105
--- rtems/cpukit/Makefile.am:1.104	Wed Feb  9 00:15:53 2011
+++ rtems/cpukit/Makefile.am	Mon Mar 14 09:56:07 2011
@@ -155,6 +155,10 @@
 ## fb
 include_rtems_HEADERS += libmisc/fb/fb.h libmisc/fb/mw_uid.h
 
+## mouse
+include_rtems_HEADERS += libmisc/mouse/mouse_parser.h \
+    libmisc/mouse/serial_mouse.h
+
 ## shell
 if LIBSHELL
 include_rtems_HEADERS += libmisc/shell/shell.h libmisc/shell/shellconfig.h

diff -u rtems/cpukit/libmisc/Makefile.am:1.88 rtems/cpukit/libmisc/Makefile.am:1.89
--- rtems/cpukit/libmisc/Makefile.am:1.88	Thu Feb 17 13:24:20 2011
+++ rtems/cpukit/libmisc/Makefile.am	Mon Mar 14 09:56:07 2011
@@ -64,6 +64,11 @@
 noinst_LIBRARIES += libmw-fb.a
 libmw_fb_a_SOURCES = fb/mw_print.c fb/mw_uid.c fb/fb.h fb/mw_uid.h
 
+## mouse
+noinst_LIBRARIES += libmouse.a
+libmouse_a_SOURCES = mouse/mouse_parser.c mouse/serial_mouse.c
+EXTRA_DIST += mouse/README
+
 ## shell
 if LIBSHELL
 noinst_LIBRARIES += libshell.a

diff -u /dev/null rtems/cpukit/libmisc/mouse/README:1.1
--- /dev/null	Mon Mar 14 10:10:48 2011
+++ rtems/cpukit/libmisc/mouse/README	Mon Mar 14 09:56:07 2011
@@ -0,0 +1,214 @@
+#
+#  $Id$
+#
+
+SOURCE: http://www.kryslix.com/nsfaq/Q.12.html
+
+Subject: What protocol do mice use?
+Date: 09/16/97
+Updated: 11/16/00 This document was adapated from a web page produced by
+Tomi Engdahl <then at delta.hut.fi>
+Microsoft serial mouse
+Description
+
+The Microsoft serial mouse is the most popular 2 button mouse. It is
+supported by all major operating systems. The maximum tracking rate for
+a Microsoft mouse is 40 reports/second * 127 counts per report, in other
+words, 5080 counts per second. The most common range for mice is is 100
+to 400 CPI (counts per inch) but can be up to 1000 CPI. A 100CPI mouse
+can discriminate motion up to 50.8 inches/second while a 400 CPI mouse
+can only discriminate motion up to 12.7 inches/second.
+Pinout
+
+9 pin  25 pin    Line    Comments
+shell  1         GND
+3      2         TD      Serial data from host to mouse (only for power)
+2      3         RD      Serial data from mouse to host
+7      4         RTS     Positive voltage to mouse
+8      5         CTS
+6      6         DSR
+5      7         SGND
+4      20        DTR     Positive voltage to mouse and reset/detection
+
+RTS = Request to Send   CTS  = Clear to Send
+DSR = Data Set Ready    DTR  = Data Terminal Ready
+GND = Protective Ground SGND = Signal Ground
+
+To function correctly, both the RTS and DTR lines must be
+positive. DTR/DSR and RTS/CTS must NOT be shorted. RTS may be toggled
+negative for at least 100ms to reset the mouse. (After a cold boot, the
+RTS line is usually negative. This provides an automatic toggle when
+RTS is brought positive). When DTR is toggled the mouse should send a
+single byte 0x45 (ASCII 'M').
+
+Serial data parameters:
+1200bps, 7 databits, 1 stop-bit
+
+Data packet format:
+
+Data is sent in 3 byte packets for each event (a button is pressed or
+released or the mouse moves):
+
+        D7      D6      D5      D4      D3      D2      D1      D0
+ 
+Byte 1  X       1       LB      RB      Y7      Y6      X7      X6
+Byte 2  X       0       X5      X4      X3      X2      X1      X0      
+Byte 3  X       0       Y5      Y4      Y3      Y2      Y1      Y0
+
+LB is the state of the left button (1 means down)
+RB is the state of the right button (1 means down)
+X7-X0 movement in X direction since last packet (signed byte)
+Y7-Y0 movement in Y direction since last packet (signed byte)
+
+The high order bit of each byte (D7) is ignored. Bit D6 indicates the start of an event, which allows the software to synchronize with the mouse.
+
+Graphical representation of a packet
+
+              1st byte        2nd byte         3rd byte
+          ================  ===============  ================
+           - 1 ? ? Y Y X X  - 0 X X X X X X  - 0 Y Y Y Y Y Y
+          ================  ===============  ================
+               | | \ / \ /      \---------/      \---------/
+               | |  |   |            |                |
+               | |  |   \----\       |                |
+               | |  \--------|-------|--------\       |
+               | |          / \ /---------\  / \ /---------\
+               | |         ================ =================
+               | |          0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0
+ Left Button --/ |         ================ =================
+Right Button ----/            X increment      Y increment
+
+3 Button Logitech extension
+
+Logitech extended the 2 button mouse protocol to support 3 button mice
+by adding a 4th byte when the middle button is pressed (and the first
+packet after it is released). If a 4th byte is encountered (i.e., an
+extra byte with D6 set to 0) then D5 of that byte (0x20) indicates the
+status of the middle mouse button.
+
+Mouse systems mouse
+
+Serial data parameters:
+
+1200bps, 8 databits, 1 stop-bit
+
+5 byte Mouse Systems packet
+
+        D7      D6      D5      D4      D3      D2      D1      D0
+
+Byte 1  1       0       0       0       0       LB      CB      RB
+Byte 2  X7      X6      X5      X4      X3      X2      X1      X0
+Byte 3  Y7      Y6      Y5      Y4      Y3      Y4      Y1      Y0
+Byte 4  X7'     X6'     X5'     X4'     X3'     X2'     X1'     X0'
+Byte 5  Y7'     Y6'     Y5'     Y4'     Y3'     Y4'     Y1'     Y0'
+
+LB is left button state (0=pressed, 1=released)
+CB is center button state (0=pressed, 1=released)
+RB is right button state (0=pressed, 1=released)
+X7-X0 movement in X direction since last packet in signed byte 
+      format (-128..+127), positive direction right
+Y7-Y0 movement in Y direction since last packet in signed byte 
+      format (-128..+127), positive direction up
+X7'-X0' movement in X direction since sending of X7-X0 packet in signed byte 
+      format (-128..+127), positive direction right
+Y7'-Y0' movement in Y direction since sending of Y7-Y0 in signed byte 
+      format (-128..+127), positive direction up
+
+The last two bytes in the packet (bytes 4 and 5) contain information
+about movement data changes which have occured after data bytes 2 and
+3 have been sent.
+
+PS/2 mouse
+
+The standard PS/2 mouse (such as the Logitech mouse) defaults to 160 CPI
+and can be switched to 40, 80, 160 or 320 CPI via software. The Microsoft
+mouse driver for Windows 3.x and Windows 95 defaults to 160 counts per
+inch. The maximum tracking rate for PS/2 mouse is 40 reports/second *
+255 counts per report, or 10200 counts per second. A 100 CPI mouse could
+discriminate motion up to 102 inches per second while a 400 CPI mouse
+could discriminate motion up to 25.2 inches per second.
+
+Connector pinout
+
+Pin     Wire Name
+1       DATA
+2       Reserved
+3       Ground
+4       +5V Supply
+5       CLK
+6       Reserved
+Shield  Chassis
+
+Packet Format
+
+        D7      D6      D5      D4      D3      D2      D1      D0
+Byte 1  XV      XV      YS      XS       1       M       R       L
+Byte 2  X7      X6      X5      X4      X3      X2      X1      X0
+Byte 3  Y7      Y6      Y5      Y4      Y3      Y2      Y1      Y0
+
+L       Left button state (1 = pressed down)
+M	Middle button state (1 = pressed down)
+R       Right button state (1 = pressed down)
+X0-X7   Movement in X direction
+Y0-Y7   Movement in Y direction
+XS,YS   Movement data sign bits (1 = negative)
+XV,YV   Movement data overflow bits (1 = overflow has occured)
+
+Physical connector
+
+The PS/2 mouse connector has the following pinout when looking at the
+connector on the back of the computer:
+
+        4 u 6
+       1  .  2
+        3   5
+
+1.      GND
+2.      +5V
+3.      DATA
+4.      CLOCK
+5.      Not used
+6.      Not used
+
+Bi-directional transmission is controlled by the CLK and DATA lines. Both
+are fed by an open collector device which lets either host or mouse force
+the line to "0". During non-transmission, CLK is at "1" and DATA can be at
+"0" or "1".
+
+The host can inhibit mouse transmission by forcing CLK to "0". If the
+host inhibits the mouse while it is transmitting, the byte must be
+retransmitted (if the inhibit state arrived before the 11th clock).
+
+Receiving data: Check 'clock'. If inactive, there is a bit on the 'data'
+line. Each transmission unit is one start bit, eight data bits, odd
+parity and one stop bit. Start bits are low, stop bits high. Each clock
+active or inactive period is 30 to 50 microseconds. Data transition to
+falling edge of clock is 5 to 25 microseconds.
+
+Sending: Check that both clock and data are high. Pull down data for
+start bit, and start clocking.
+
+NOTE: Logitech has made the extension to this protocol to allow three
+buttons (the M bit is always 0 on 2 button mice).
+
+References
+
+* Original PC mouse info page by Tomi Engdahl
+  http://www.hut.fi/~then/mytexts/mouse.html
+
+* PC Magazine May 28, 1991
+
+* Programmer's Reference to Genius Mouse
+  ftp://x2ftp.oulu.fi/pub/msdos/programming/docs/gmouse.doc
+
+* Logitech Pointing Device Hardware Information Product Support Document # 1410
+  ftp://ftp.logitech.com/pub/TechSupport/MOUSE/HELP/1410.txt
+
+* Mice: How do they work? by Richard Torrens
+  http://box.argonet.co.uk/users/4qd/meece.html
+
+* In Pursuit Of The Perfect Portable Pointer by Intelink Electronics
+from EDN Products Edition April 16, 1977 pages 43-45
+
+* Programming the Microsoft Mouse 
+  http://www.geocities.com/SiliconValley/2151/mouse.html

diff -u /dev/null rtems/cpukit/libmisc/mouse/mouse_parser.h:1.1
--- /dev/null	Mon Mar 14 10:10:48 2011
+++ rtems/cpukit/libmisc/mouse/mouse_parser.h	Mon Mar 14 09:56:07 2011
@@ -0,0 +1,108 @@
+/*
+ * This file is the header file for the Mouse Parser Engine which
+ * is derived from a UNIX Serial Port Mouse Driver with the following
+ * notice:
+ *
+ * ==================================================================
+ * Copyright (c) 1999 Greg Haerr <greg at censoft.com>
+ * Portions Copyright (c) 1991 David I. Bell
+ * Permission is granted to use, distribute, or modify this source,
+ * provided that this copyright notice remains intact.
+ *
+ * UNIX Serial Port Mouse Driver
+ *
+ * This driver opens a serial port directly, and interprets serial data.
+ * Microsoft, PC, Logitech and PS/2 mice are supported.  The PS/2 mouse
+ * is only supported if the OS runs the mouse byte codes through the
+ * serial port.
+ *
+ * Mouse Types Supported: pc  ms, logi, ps2
+ * ==================================================================
+ *
+ * It has been modified to support the concept of being just a parser
+ * fed data from an arbitrary source.  It is independent of either 
+ * a PS/2 driver or a serial port.
+ *
+ * It was moved to cpukit/libmisc/mouse by Joel Sherrill.
+ *
+ * $Id$
+ */
+
+#ifndef __MOUSE_PARSER_h__
+#define __MOUSE_PARSER_h__
+
+#include <rtems/mw_uid.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ *  This is the mask for the right button.
+ *
+ *  @note Use the same definitions as the user interface.
+ */
+#define RBUTTON      MV_BUTTON_RIGHT
+
+/**
+ * This is the mask for the center button.
+ *
+ *  @note Use the same definitions as the user interface.
+ */
+#define MBUTTON      MV_BUTTON_CENTER
+
+/**
+ *  This is the mask for the left button.
+ *
+ *  @note Use the same definitions as the user interface.
+ */
+#define LBUTTON      MV_BUTTON_LEFT
+
+/**
+ *  This type is the device coordinates.
+ */
+typedef int           COORD;
+
+/**
+ *  This type is the mouse button mask.
+ */
+typedef unsigned int  BUTTON;
+
+/**
+ *  This type defines a pointer to the enqueue method.  It is
+ *  available since some device drivers keep pointers to the method
+ *  to know when to enqueue or not.
+ */
+typedef void (*mouse_parser_enqueue_handler)(unsigned char *, size_t);
+
+/**
+ *  @brief Initialize the Mouse Parser Engine
+ *
+ *  This method initializes the Mouse Parser Engine for the mouse
+ *  of @a type. The @a type should be one of the following strings:
+ *  pc  ms, logi, ps2.
+ *
+ *  @a param[in] type indicates the type of mouse.
+ *
+ *  @return This method returns 0 on success and -1 on error.
+ */
+int mouse_parser_initialize(const char *type);
+
+/**
+ *  @brief Enqueue Input to the Mouse Parser Engine
+ *
+ *  This method is used to pass mouse input to the Mouse Parser Engine.
+ *
+ *  @a param[in] buffer is the data to enqueue
+ *  @a param[in] size is the amount of data to enqueue
+ */
+void mouse_parser_enqueue(
+  unsigned char *buffer,
+  size_t         size
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

diff -u /dev/null rtems/cpukit/libmisc/mouse/mouse_parser.c:1.1
--- /dev/null	Mon Mar 14 10:10:48 2011
+++ rtems/cpukit/libmisc/mouse/mouse_parser.c	Mon Mar 14 09:56:07 2011
@@ -0,0 +1,312 @@
+/*
+ * This code is derived from a UNIX Serial Port Mouse Driver with
+ * the following notice:
+ *
+ * ==================================================================
+ * Copyright (c) 1999 Greg Haerr <greg at censoft.com>
+ * Portions Copyright (c) 1991 David I. Bell
+ * Permission is granted to use, distribute, or modify this source,
+ * provided that this copyright notice remains intact.
+ *
+ * UNIX Serial Port Mouse Driver
+ *
+ * This driver opens a serial port directly, and interprets serial data.
+ * Microsoft, PC, Logitech and PS/2 mice are supported.  The PS/2 mouse
+ * is only supported if the OS runs the mouse byte codes through the
+ * serial port.
+ *
+ * Mouse Types Supported: pc  ms, logi, ps2
+ * ==================================================================
+ *
+ * It has been modified to support the concept of being just a parser
+ * fed data from an arbitrary source.  It is independent of either 
+ * a PS/2 driver or a serial port.
+ *
+ * It was moved to cpukit/libmisc/mouse by Joel Sherrill.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>  /* strcmp */
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <rtems.h>
+#include <bsp.h>
+#include <rtems/mouse_parser.h>
+#include <rtems/mw_uid.h>
+
+/* states for the mouse */
+#define IDLE   0  /* start of byte sequence */
+#define XSET   1  /* setting x delta */
+#define YSET   2  /* setting y delta */
+#define XADD   3  /* adjusting x delta */
+#define YADD   4  /* adjusting y delta */
+
+/* values in the bytes returned by the mouse for the buttons*/
+#define PC_LEFT_BUTTON   4
+#define PC_MIDDLE_BUTTON 2
+#define PC_RIGHT_BUTTON  1
+
+#define MS_LEFT_BUTTON   2
+#define MS_RIGHT_BUTTON  1
+
+#define PS2_CTRL_BYTE    0x08
+#define PS2_LEFT_BUTTON    1
+#define PS2_RIGHT_BUTTON  2
+
+/* Bit fields in the bytes sent by the mouse.*/
+#define TOP_FIVE_BITS      0xf8
+#define BOTTOM_THREE_BITS  0x07
+#define TOP_BIT            0x80
+#define SIXTH_BIT          0x40
+#define BOTTOM_TWO_BITS    0x03
+#define THIRD_FOURTH_BITS  0x0c
+#define BOTTOM_SIX_BITS    0x3f
+
+/* local data */
+static int     state;            /* IDLE, XSET, ... */
+static BUTTON  buttons;          /* current mouse buttons pressed*/
+static BUTTON  availbuttons;     /* which buttons are available */
+static COORD   xd;               /* change in x */
+static COORD   yd;               /* change in y */
+
+static int     left;             /* because the button values change */
+static int     middle;           /* between mice, the buttons are */
+static int     right;            /* redefined */
+
+static int     (*parse)( int );  /* parse routine */
+
+/* local routines*/
+static int ParsePC(int);    /* routine to interpret PC mouse */
+static int ParseMS(int);    /* routine to interpret MS mouse */
+static int ParsePS2(int);    /* routine to interpret PS/2 mouse */
+
+/*
+ * Open up the mouse device.
+ * Returns the fd if successful, or negative if unsuccessful.
+ */
+int mouse_parser_initialize(const char *type)
+{
+  /* set button bits and parse procedure*/
+  if (!strcmp(type, "pc") || !strcmp(type, "logi")) {
+    /* pc or logitech mouse*/
+    left = PC_LEFT_BUTTON;
+    middle = PC_MIDDLE_BUTTON;
+    right = PC_RIGHT_BUTTON;
+    parse = ParsePC;
+  } else if (strcmp(type, "ms") == 0) {
+    /* microsoft mouse*/
+    left = MS_LEFT_BUTTON;
+    right = MS_RIGHT_BUTTON;
+    middle = 0;
+    parse = ParseMS;
+  } else if (strcmp(type, "ps2") == 0) {
+    /* PS/2 mouse*/
+    left = PS2_LEFT_BUTTON;
+    right = PS2_RIGHT_BUTTON;
+    middle = 0;
+    parse = ParsePS2;
+  } else
+    return -1;
+
+  printk("Device: /dev/mouse -- mouse type is: %s\n", type );
+
+  /* initialize data*/
+  availbuttons = left | middle | right;
+  state = IDLE;
+  buttons = 0;
+  xd = 0;
+  yd = 0;
+  return 0;
+}
+
+/*
+ * Attempt to read bytes from the mouse and interpret them.
+ * Returns -1 on error, 0 if either no bytes were read or not enough
+ * was read for a complete state, or 1 if the new state was read.
+ * When a new state is read, the current buttons and x and y deltas
+ * are returned.  This routine does not block.
+ */
+int MOU_Data( int ch, COORD *dx, COORD *dy, COORD *dz, BUTTON *bptr)
+{
+  int b;
+
+  if ( !parse ) {
+    printk( "Mouse parser is not initialized!\n" );
+    return -1;
+  } 
+
+  /*
+   * Loop over all the bytes read in the buffer, parsing them.
+   * When a complete state has been read, return the results,
+   * leaving further bytes in the buffer for later calls.
+   */
+  if ( (*parse)( ch ) ) {
+    *dx = xd;
+    *dy = yd;
+    *dz = 0;
+    b = 0;
+    if (buttons & left)
+      b |= LBUTTON;
+    if (buttons & right)
+      b |= RBUTTON;
+    if (buttons & middle)
+      b |= MBUTTON;
+    *bptr = b;
+    return 1;
+  }
+  return 0;
+}
+
+/*
+ * Input routine for PC mouse.
+ * Returns nonzero when a new mouse state has been completed.
+ */
+static int ParsePC(int byte)
+{
+  int  sign;      /* sign of movement */
+
+  switch (state) {
+    case IDLE:
+      if ((byte & TOP_FIVE_BITS) == TOP_BIT) {
+        buttons = ~byte & BOTTOM_THREE_BITS;
+        state = XSET;
+      }
+      break;
+
+    case XSET:
+      sign = 1;
+      if (byte > 127) {
+        byte = 256 - byte;
+        sign = -1;
+      }
+      xd = byte * sign;
+      state = YSET;
+      break;
+
+    case YSET:
+      sign = 1;
+      if (byte > 127) {
+        byte = 256 - byte;
+        sign = -1;
+      }
+      yd = -byte * sign;
+      state = XADD;
+      break;
+
+    case XADD:
+      sign = 1;
+      if (byte > 127) {
+        byte = 256 - byte;
+        sign = -1;
+      }
+      xd += byte * sign;
+      state = YADD;
+      break;
+
+    case YADD:
+      sign = 1;
+      if (byte > 127) {
+        byte = 256 - byte;
+        sign = -1;
+      }
+      yd -= byte * sign;
+      state = IDLE;
+      return 1;
+  }
+  return 0;
+}
+
+/*
+ * Input routine for Microsoft mouse.
+ * Returns nonzero when a new mouse state has been completed.
+ */
+static int ParseMS(int byte)
+{
+  switch (state) {
+    case IDLE:
+      if (byte & SIXTH_BIT) {
+        buttons = (byte >> 4) & BOTTOM_TWO_BITS;
+        yd = ((byte & THIRD_FOURTH_BITS) << 4);
+        xd = ((byte & BOTTOM_TWO_BITS) << 6);
+        state = XADD;
+      }
+      break;
+
+    case XADD:
+      xd |= (byte & BOTTOM_SIX_BITS);
+      state = YADD;
+      break;
+
+    case YADD:
+      yd |= (byte & BOTTOM_SIX_BITS);
+      state = IDLE;
+      if (xd > 127)
+        xd -= 256;
+      if (yd > 127)
+        yd -= 256;
+      return 1;
+  }
+  return 0;
+}
+
+/*
+ * Input routine for PS/2 mouse.
+ * Returns nonzero when a new mouse state has been completed.
+ */
+static int ParsePS2(int byte)
+{
+  switch (state) {
+    case IDLE:
+      if (byte & PS2_CTRL_BYTE) {
+        buttons = byte &
+          (PS2_LEFT_BUTTON|PS2_RIGHT_BUTTON);
+        state = XSET;
+      }
+      break;
+
+    case XSET:
+      if(byte > 127)
+        byte -= 256;
+      xd = byte;
+      state = YSET;
+      break;
+
+    case YSET:
+      if(byte > 127)
+        byte -= 256;
+      yd = -byte;
+      state = IDLE;
+      return 1;
+  }
+  return 0;
+}
+
+/* generic mouse parser */
+void mouse_parser_enqueue( unsigned char *buffer, size_t size )
+{
+  COORD dx;
+  COORD dy;
+  COORD dz;
+  BUTTON bptr;
+
+  while( size-- ) {
+    if ( MOU_Data( *buffer++, &dx, &dy, &dz, &bptr ) ) {
+       struct MW_UID_MESSAGE m;
+
+        m.type = MV_UID_REL_POS;
+        /* buttons definitons have been selected to match */
+        m.m.pos.btns = bptr;
+        m.m.pos.x  = dx;
+        m.m.pos.y  = dy;
+        m.m.pos.z  = dz;
+        /* printk( "Mouse: msg: dx=%d, dy=%d, btn=%X\n", dx, dy, bptr ); */
+        uid_send_message( &m );
+    }
+  }
+}
+

diff -u /dev/null rtems/cpukit/libmisc/mouse/serial_mouse.h:1.1
--- /dev/null	Mon Mar 14 10:10:48 2011
+++ rtems/cpukit/libmisc/mouse/serial_mouse.h	Mon Mar 14 09:56:07 2011
@@ -0,0 +1,156 @@
+/**
+ * @file rtems/serial_mouse.h
+ *
+ *  This file describes the Serial Mouse Driver for all boards.
+ *  This driver assumes that the BSP or application will provide
+ *  an implementation of the method bsp_get_serial_mouse_device()
+ *  which tells the driver what serial port device to open() and
+ *  what type of mouse is connected.
+ *
+ *  This driver relies on the Mouse Parser Engine.
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#ifndef __SERIAL_MOUSE_h__
+#define __SERIAL_MOUSE_h__
+
+/* functions */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ *  This macro defines the serial mouse device driver entry points.
+ */
+#define SERIAL_MOUSE_DRIVER_TABLE_ENTRY \
+  { serial_mouse_initialize, serial_mouse_open, serial_mouse_close, \
+    serial_mouse_read, serial_mouse_write, serial_mouse_control }
+
+/**
+ *  @brief Serial Mouse Driver Initialization
+ *
+ *  This method initializes the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_initialize(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Serial Mouse Driver Open
+ *
+ *  This method implements the Open device driver entry
+ *  point for the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_open(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Serial Mouse Driver Close
+ *
+ *  This method implements the Close device driver entry
+ *  point for the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_close(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Serial Mouse Driver Read
+ *
+ *  This method implements the Read device driver entry
+ *  point for the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_read(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Serial Mouse Driver Write
+ *
+ *  This method implements the Write device driver entry
+ *  point for the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_write(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Serial Mouse Driver IO Control
+ *
+ *  This method implements the IO Control device driver entry
+ *  point for the serial mouse driver.
+ *
+ *  @param[in] major is the mouse device major number
+ *  @param[in] minor is the mouse device minor number
+ *  @param[in] arguments points to device driver arguments
+ */
+rtems_device_driver serial_mouse_control(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+);
+
+/**
+ *  @brief Obtain Serial Mouse Configuration Information
+ *
+ *  This method is implemented by the BSP or application and
+ *  tells the driver what device to open() and what type of
+ *  mouse is connected.
+ *
+ *  @param[in] name will point to a string with the device name
+ *             of the serial port with the mouse connected.
+ *  @param[in] type will point to a string with the type of mouse connected.
+ *
+ *  @return This method returns true on success and false on error.
+ */
+bool bsp_get_serial_mouse_device(
+  const char **name,
+  const char **type
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* __tty_drv__  */

diff -u /dev/null rtems/cpukit/libmisc/mouse/serial_mouse.c:1.1
--- /dev/null	Mon Mar 14 10:10:48 2011
+++ rtems/cpukit/libmisc/mouse/serial_mouse.c	Mon Mar 14 09:56:07 2011
@@ -0,0 +1,185 @@
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <bsp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <rtems/libio.h>
+#include <termios.h>
+#include <rtems/termiostypes.h>
+#include <rtems/mouse_parser.h>
+#include <rtems/serial_mouse.h>
+
+int         serial_mouse_fd = -1;
+const char *serial_mouse_device;
+const char *serial_mouse_type;
+
+int serial_mouse_l_rint(int c, struct rtems_termios_tty *tp)
+{
+  unsigned char buf = c;
+  
+  /* call mouse_parser( void *ptr, char *buffer, int size ) */
+  mouse_parser_enqueue( &buf, 1 );
+  return 0;
+}
+
+static struct rtems_termios_linesw serial_mouse_linesw = {
+  .l_open = NULL,
+  .l_close = NULL,
+  .l_read  = NULL,
+  .l_write = NULL,
+  .l_rint  = serial_mouse_l_rint,
+  .l_start = NULL,
+  .l_ioctl = NULL,
+  .l_modem = NULL
+};
+
+
+/*
+ *  Serial Mouse - device driver INITIALIZE entry point.
+ */
+rtems_device_driver serial_mouse_initialize(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  bool status;
+
+  status = bsp_get_serial_mouse_device(
+    &serial_mouse_device,
+    &serial_mouse_type
+  );
+
+  (void) rtems_io_register_name( "/dev/mouse", major, 0 );
+
+  rtems_termios_linesw[ 6 ] = serial_mouse_linesw;
+
+  return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * serial_mouse - device driver OPEN entry point
+ */
+rtems_device_driver serial_mouse_open(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *args
+)
+{
+  struct termios  termios_attr;
+  int             status;
+  int             disc = 6;
+
+  /* XXX open(2) the configured /dev/comX */
+  /* XXX save the file descriptor */
+  serial_mouse_fd = open( serial_mouse_device, O_RDONLY );
+  if ( serial_mouse_fd == -1 ) {
+   printk(
+     "Error opening serial_mouse device on %s\n",
+     serial_mouse_device
+   );
+   return RTEMS_IO_ERROR;
+  }
+
+  /* 1200-8-N-1, without hardware flow control */
+  /* BSP_uart_init( BSP_UART_PORT, 1200, CHR_8_BITS, 0, 0, 0 ); */
+  status = tcgetattr(serial_mouse_fd, &termios_attr );
+  if (status != 0) {
+    printk("Error getting mouse attributes\n");
+    return RTEMS_IO_ERROR;
+  }
+  termios_attr.c_lflag &= ~(ICANON|ECHO|ECHONL|ECHOK|ECHOE|ECHOPRT|ECHOCTL);
+  termios_attr.c_iflag &= ~(IXON|IXANY|IXOFF);
+  /*
+  termios_attr.c_cc[VMIN] = itask_VMIN;
+  termios_attr.c_cc[VTIME] = itask_VTIME;
+  */
+  termios_attr.c_cflag |= B1200;
+  termios_attr.c_cflag |= CS8;
+  status = tcsetattr( serial_mouse_fd, TCSANOW, &termios_attr );
+  if (status != 0) {
+    printk("Error setting mouse attributes\n");
+    return RTEMS_IO_ERROR;
+  }
+
+  status = ioctl(serial_mouse_fd, TIOCSETD, &disc);
+  if (status != 0) {
+    printk("Error setting mouse attributes\n");
+    return RTEMS_IO_ERROR;
+  }
+
+  sleep(5);
+  return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver serial_mouse_close(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  close( serial_mouse_fd );
+
+  return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver serial_mouse_read(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  return RTEMS_SUCCESSFUL;
+}
+
+
+rtems_device_driver serial_mouse_write(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  return RTEMS_SUCCESSFUL;
+}
+
+
+rtems_device_driver serial_mouse_control(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  rtems_libio_ioctl_args_t *args = (rtems_libio_ioctl_args_t *)arg;
+
+  switch( args->command ) {
+
+    case MW_UID_REGISTER_DEVICE:
+      printk( "SerialMouse: reg=%s\n", args->buffer );
+      mouse_parser_initialize( serial_mouse_type );
+      break;
+
+    case MW_UID_UNREGISTER_DEVICE:
+      break;
+
+    default:
+      args->ioctl_return = ioctl(serial_mouse_fd, args->command, args->buffer );
+      if ( !args->ioctl_return )
+        return RTEMS_SUCCESSFUL;
+      return RTEMS_IO_ERROR;
+  }
+  args->ioctl_return = 0;
+  return RTEMS_SUCCESSFUL;
+}

diff -u rtems/cpukit/preinstall.am:1.48 rtems/cpukit/preinstall.am:1.49
--- rtems/cpukit/preinstall.am:1.48	Wed Feb  9 00:16:10 2011
+++ rtems/cpukit/preinstall.am	Mon Mar 14 09:56:07 2011
@@ -338,6 +338,14 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mw_uid.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mw_uid.h
 
+$(PROJECT_INCLUDE)/rtems/mouse_parser.h: libmisc/mouse/mouse_parser.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mouse_parser.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mouse_parser.h
+
+$(PROJECT_INCLUDE)/rtems/serial_mouse.h: libmisc/mouse/serial_mouse.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/serial_mouse.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/serial_mouse.h
+
 if LIBSHELL
 $(PROJECT_INCLUDE)/rtems/shell.h: libmisc/shell/shell.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/shell.h

diff -u rtems/cpukit/wrapup/Makefile.am:1.74 rtems/cpukit/wrapup/Makefile.am:1.75
--- rtems/cpukit/wrapup/Makefile.am:1.74	Wed Jul 14 10:44:44 2010
+++ rtems/cpukit/wrapup/Makefile.am	Mon Mar 14 09:56:08 2011
@@ -53,6 +53,7 @@
 TMP_LIBS += ../libmisc/libdevnull.a
 TMP_LIBS += ../libmisc/libdummy.a
 TMP_LIBS += ../libmisc/libfsmount.a
+TMP_LIBS += ../libmisc/libmouse.a
 TMP_LIBS += ../libmisc/libmw-fb.a
 TMP_LIBS += ../libmisc/libstringto.a
 TMP_LIBS += ../libmisc/libuuid.a


 *joel*:
2011-03-14	Joel Sherrill <joel.sherrill at oarcorp.com>

	PR 1762/cpukit
	* Makefile.am, preinstall.am, console/console.c, console/keyboard.c,
	console/keyboard.h, console/pc_keyb.c, console/ps2_mouse.c,
	console/vgainit.c: Made mouse parser engine generic. Now use generic
	serial mouse driver. Moved many externs from C to .h.
	* console/kbd_parser.c, console/serial_mouse_config.c: New files.
	* console/mouse_parser.c, console/mouse_parser.h,
	console/serial_mouse.c, console/serial_mouse.h: Removed.

M  1.270  c/src/lib/libbsp/i386/pc386/ChangeLog
M   1.57  c/src/lib/libbsp/i386/pc386/Makefile.am
M   1.52  c/src/lib/libbsp/i386/pc386/console/console.c
A    1.1  c/src/lib/libbsp/i386/pc386/console/kbd_parser.c
M    1.6  c/src/lib/libbsp/i386/pc386/console/keyboard.h
M   1.11  c/src/lib/libbsp/i386/pc386/console/keyboard.c
R    1.5  c/src/lib/libbsp/i386/pc386/console/mouse_parser.h
R    1.5  c/src/lib/libbsp/i386/pc386/console/mouse_parser.c
M    1.6  c/src/lib/libbsp/i386/pc386/console/pc_keyb.c
M   1.16  c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c
R    1.7  c/src/lib/libbsp/i386/pc386/console/serial_mouse.h
R   1.15  c/src/lib/libbsp/i386/pc386/console/serial_mouse.c
A    1.1  c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c
M    1.6  c/src/lib/libbsp/i386/pc386/console/vgainit.c
M   1.10  c/src/lib/libbsp/i386/pc386/preinstall.am

diff -u rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.269 rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.270
--- rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.269	Fri Mar  4 15:56:44 2011
+++ rtems/c/src/lib/libbsp/i386/pc386/ChangeLog	Mon Mar 14 09:57:00 2011
@@ -1,3 +1,14 @@
+2011-03-14	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	PR 1762/cpukit
+	* Makefile.am, preinstall.am, console/console.c, console/keyboard.c,
+	console/keyboard.h, console/pc_keyb.c, console/ps2_mouse.c,
+	console/vgainit.c: Made mouse parser engine generic. Now use generic
+	serial mouse driver. Moved many externs from C to .h.
+	* console/kbd_parser.c, console/serial_mouse_config.c: New files.
+	* console/mouse_parser.c, console/mouse_parser.h,
+	console/serial_mouse.c, console/serial_mouse.h: Removed.
+
 2011-03-04	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	* timer/timer.c: Retry up to 5 times when the calibration loop fails.

diff -u rtems/c/src/lib/libbsp/i386/pc386/Makefile.am:1.56 rtems/c/src/lib/libbsp/i386/pc386/Makefile.am:1.57
--- rtems/c/src/lib/libbsp/i386/pc386/Makefile.am:1.56	Fri Apr 30 06:43:01 2010
+++ rtems/c/src/lib/libbsp/i386/pc386/Makefile.am	Mon Mar 14 09:57:00 2011
@@ -63,15 +63,15 @@
     ../../../shared/clockdrv_shell.h
 
 include_rtemsdir = $(includedir)/rtems
-include_rtems_HEADERS = console/keyboard.h console/kd.h \
-    console/serial_mouse.h console/ps2_drv.h
+include_rtems_HEADERS = console/keyboard.h console/kd.h console/ps2_drv.h
 
 include_HEADERS += ../../i386/shared/comm/i386_io.h
 # console
 libbsp_a_SOURCES += console/console.c console/inch.c console/outch.c \
     console/defkeymap.c console/fb_vga.c console/keyboard.c \
-    console/mouse_parser.c console/pc_keyb.c console/ps2_mouse.c \
-    console/serial_mouse.c console/vgainit.c console/vt.c console/videoAsm.S \
+    console/pc_keyb.c console/ps2_mouse.c \
+    console/vgainit.c console/vt.c console/videoAsm.S \
+    console/kbd_parser.c console/serial_mouse_config.c \
     ../../i386/shared/comm/uart.c ../../i386/shared/comm/tty_drv.c
 
 # gdb

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/console.c:1.51 rtems/c/src/lib/libbsp/i386/pc386/console/console.c:1.52
--- rtems/c/src/lib/libbsp/i386/pc386/console/console.c:1.51	Fri Jan 28 14:35:34 2011
+++ rtems/c/src/lib/libbsp/i386/pc386/console/console.c	Mon Mar 14 09:57:00 2011
@@ -1,6 +1,4 @@
 /*-------------------------------------------------------------------------+
-| console.c v1.1 - PC386 BSP - 1997/08/07
-+--------------------------------------------------------------------------+
 | This file contains the PC386 console I/O package.
 +--------------------------------------------------------------------------+
 | (C) Copyright 1997 -
@@ -15,17 +13,16 @@
 | This file is provided "AS IS" without warranty of any kind, either
 | expressed or implied.
 +--------------------------------------------------------------------------+
-| This code is based on:
-|   console.c,v 1.4 1995/12/19 20:07:23 joel Exp - go32 BSP
-| With the following copyright notice:
-| **************************************************************************
-| *  COPYRIGHT (c) 1989-1999.
-| *  On-Line Applications Research Corporation (OAR).
-| *
-| *  The license and distribution terms for this file may be
-| *  found in the file LICENSE in this distribution or at
-| *  http://www.rtems.com/license/LICENSE.
-| **************************************************************************
+| This code was based on code from the go32 BSP and was copyright by OAR.
+| Subsequent modifications are also copyright OAR.
+|
+|  COPYRIGHT (c) 1989-2011.
+|  On-Line Applications Research Corporation (OAR).
+|
+|  The license and distribution terms for this file may be
+|  found in the file LICENSE in this distribution or at
+|  http://www.rtems.com/license/LICENSE.
+|
 |
 |  $Id$
 +--------------------------------------------------------------------------*/
@@ -44,7 +41,8 @@
 #include <libcpu/cpuModel.h>
 
 #include <rtems/mw_uid.h>
-#include "mouse_parser.h"
+#include <rtems/mouse_parser.h>
+#include <rtems/keyboard.h>
 
 /*
  * Possible value for console input/output :
@@ -71,32 +69,21 @@
 int BSPBaseBaud    = 115200;
 int BSPCmdBaud     = 9600;
 
-extern BSP_polling_getchar_function_type BSP_poll_char;
-extern int getch( void );
-extern void kbd_init( void );
+
+/* printk support */
+BSP_output_char_function_type BSP_output_char =
+                       (BSP_output_char_function_type) _IBMPC_outch;
+
+BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input;
 
 /*-------------------------------------------------------------------------+
 | External Prototypes
 +--------------------------------------------------------------------------*/
-extern void keyboard_interrupt(void );
-extern void keyboard_interrupt_wrapper(void *);
-extern int BSP_wait_polled_input(void);
-extern void _IBMPC_initVideo(void);
-
 static int  conSetAttr(int minor, const struct termios *);
-static void isr_on(const rtems_irq_connect_data *);
-static void isr_off(const rtems_irq_connect_data *);
-static int  isr_is_on(const rtems_irq_connect_data *);
-
-extern int rtems_kbpoll( void );
-
-static rtems_irq_connect_data console_isr_data = {BSP_KEYBOARD,
-                                                  keyboard_interrupt_wrapper,
-                                                  0,
-                                                  isr_on,
-                                                  isr_off,
-                                                  isr_is_on};
 
+/*
+ *  Keyboard Interrupt Configuration
+ */
 static void
 isr_on(const rtems_irq_connect_data *unused)
 {
@@ -115,7 +102,13 @@
   return BSP_irq_enabled_at_i8259s(irq->name);
 }
 
-extern int  rtems_kbpoll( void );
+static rtems_irq_connect_data console_isr_data =
+  {BSP_KEYBOARD,
+   keyboard_interrupt,
+   0,
+   isr_on,
+   isr_off,
+   isr_is_on};
 
 static ssize_t
 ibmpc_console_write(int minor, const char *buf, size_t len)
@@ -472,8 +465,6 @@
   return RTEMS_SUCCESSFUL;
 } /* console_write */
 
-extern int vt_ioctl( unsigned int cmd, unsigned long arg);
-
 /*
  * Handle ioctl request.
  */
@@ -550,16 +541,3 @@
   
   return 0;
 }
-
-void keyboard_interrupt_wrapper(void *unused){
-  keyboard_interrupt();
-}
-
-/*
- * BSP initialization
- */
-
-BSP_output_char_function_type BSP_output_char =
-                       (BSP_output_char_function_type) _IBMPC_outch;
-
-BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input;

diff -u /dev/null rtems/c/src/lib/libbsp/i386/pc386/console/kbd_parser.c:1.1
--- /dev/null	Mon Mar 14 10:10:49 2011
+++ rtems/c/src/lib/libbsp/i386/pc386/console/kbd_parser.c	Mon Mar 14 09:57:00 2011
@@ -0,0 +1,49 @@
+/*
+ *  The contents of this file were formerly in console.c which
+ *  had the following copyright notice:
+ *
+ *  (C) Copyright 1997
+ *  NavIST Group - Real-Time Distributed Systems and Industrial Automation
+ *  http://pandora.ist.utl.pt
+ *  Instituto Superior Tecnico * Lisboa * PORTUGAL
+ *
+ *  The original code and subsequent modifications are:
+ *
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <rtems.h>
+#include <rtems/keyboard.h>
+#include <rtems/mw_uid.h>
+
+/* adds a kbd message to the queue */
+static void kbd_parser( void *ptr, unsigned short keycode, unsigned long mods )
+{
+  struct MW_UID_MESSAGE m;
+  struct kbd_struct * kbd = (struct kbd_struct *)ptr;
+
+  m.type = MV_UID_KBD;
+  m.m.kbd.code       = keycode;
+  m.m.kbd.modifiers  = kbd->ledflagstate;
+  m.m.kbd.mode       = kbd->kbdmode;
+  /*  printk( "kbd: msg: keycode=%X, mod=%X\n", keycode, mods );  */
+
+  uid_send_message( &m );
+}
+
+void register_kbd_msg_queue( char *q_name, int port )
+{
+  kbd_set_driver_handler( kbd_parser );
+}
+
+void unregister_kbd_msg_queue( int port )
+{
+   kbd_set_driver_handler( NULL );
+}

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.h:1.5 rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.h:1.6
--- rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.h:1.5	Fri Feb 18 15:05:49 2005
+++ rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.h	Mon Mar 14 09:57:00 2011
@@ -1,8 +1,7 @@
 /*
- * $Id$
- *
  *  Submitted by: Rosimildo da Silva:  rdasilva at connecttel.com
  *
+ *  $Id$
  */
 
 #ifndef __RTEMS_KEYBOARD_H
@@ -497,10 +496,10 @@
 
 extern struct kbd_struct kbd_table[];
 
-extern int kbd_init(void);
 
-extern unsigned char getledstate(void);
-extern void setledstate(struct kbd_struct *kbd, unsigned int led);
+void kbd_set_driver_handler(
+  void ( *handler )( void *, unsigned short, unsigned long )
+);
 
 static inline void show_console(void)
 {
@@ -510,69 +509,90 @@
 {
 }
 
-extern void set_leds(void);
+void set_leds(void);
 
 static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
 {
-	return ((kbd->modeflags >> flag) & 1);
+  return ((kbd->modeflags >> flag) & 1);
 }
 
 static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
 {
-	return ((kbd->ledflagstate >> flag) & 1);
+  return ((kbd->ledflagstate >> flag) & 1);
 }
 
 static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
 {
-	kbd->modeflags |= 1 << flag;
+  kbd->modeflags |= 1 << flag;
 }
 
 static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
 {
-	kbd->ledflagstate |= 1 << flag;
+  kbd->ledflagstate |= 1 << flag;
 }
 
 static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
 {
-	kbd->modeflags &= ~(1 << flag);
+  kbd->modeflags &= ~(1 << flag);
 }
 
 static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
 {
-	kbd->ledflagstate &= ~(1 << flag);
+  kbd->ledflagstate &= ~(1 << flag);
 }
 
 static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
 {
-	kbd->lockstate ^= 1 << flag;
+  kbd->lockstate ^= 1 << flag;
 }
 
 static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
 {
-	kbd->slockstate ^= 1 << flag;
+  kbd->slockstate ^= 1 << flag;
 }
 
 static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
 {
-	kbd->modeflags ^= 1 << flag;
+  kbd->modeflags ^= 1 << flag;
 }
 
 static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
 {
-	kbd->ledflagstate ^= 1 << flag;
-   set_leds();
+  kbd->ledflagstate ^= 1 << flag;
+  set_leds();
 }
 
 #define U(x) ((x) ^ 0xf000)
 
 /* keyboard.c */
-
+int kbd_init(void);
 int getkeycode(unsigned int scancode);
 int setkeycode(unsigned int scancode, unsigned int keycode);
 void compute_shiftstate(void);
+unsigned char getledstate(void);
+void setledstate(struct kbd_struct *kbd, unsigned int led);
+void handle_scancode(unsigned char scancode, int down);
+
+/* kbd_parser.c */
+void register_kbd_msg_queue( char *qname, int port );
+void unregister_kbd_msg_queue( int port );
 
 /* defkeymap.c */
-
 extern unsigned int keymap_count;
 
+/* inch.c */
+void add_to_queue( unsigned short );
+int getch( void );
+int BSP_wait_polled_input(void);
+int rtems_kbpoll( void );
+
+/* outch.c */
+void _IBMPC_initVideo(void);
+
+/* pc_keyb.c */
+void keyboard_interrupt(void *unused);
+
+/* vt.c */
+int vt_ioctl( unsigned int cmd, unsigned long arg);
+
 #endif

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.c:1.10 rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.c:1.11
--- rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.c:1.10	Mon Sep 22 16:49:43 2008
+++ rtems/c/src/lib/libbsp/i386/pc386/console/keyboard.c	Mon Mar 14 09:57:00 2011
@@ -30,8 +30,6 @@
 #define KBD_DEFLOCK 0
 #endif
 
-extern void add_to_queue( unsigned short );
-
 int set_bit(int nr, unsigned long * addr)
 {
   int                   mask;

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/pc_keyb.c:1.5 rtems/c/src/lib/libbsp/i386/pc386/console/pc_keyb.c:1.6
--- rtems/c/src/lib/libbsp/i386/pc386/console/pc_keyb.c:1.5	Wed Sep 12 10:16:00 2007
+++ rtems/c/src/lib/libbsp/i386/pc386/console/pc_keyb.c	Mon Mar 14 09:57:00 2011
@@ -21,11 +21,9 @@
 #include <errno.h>
 
 #include <bsp.h>
+#include <rtems/keyboard.h>
 #include "i386kbd.h"
 
-/* keyboard.c */
-extern void handle_scancode(unsigned char scancode, int down);
-
 static unsigned char handle_kbd_event(void);
 static void kbd_write_command_w(int data);
 static void kbd_write_output_w(int data);
@@ -384,7 +382,7 @@
 	return status;
 }
 
-void keyboard_interrupt( void )
+void keyboard_interrupt(void *unused)
 {
 	handle_kbd_event();
 }
@@ -627,17 +625,3 @@
 #endif
 
 }
-
-/*
-char BSP_wait_polled_input( void )
-{
-  int                   c;
-  rtems_interrupt_level level;
-
-  rtems_interrupt_disable(level);
-  while ( ( c= kbd_wait_for_input() ) < 0 )
-      continue;
-  rtems_interrupt_enable(level);
-  return c;
-}
-*/

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c:1.15 rtems/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c:1.16
--- rtems/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c:1.15	Wed Feb  9 09:57:29 2011
+++ rtems/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c	Mon Mar 14 09:57:00 2011
@@ -9,9 +9,9 @@
  * Code fixes to handle mouse ACKs properly.
  * C. Scott Ananian <cananian at alumni.princeton.edu> 1999-01-29.
  *
- * RTEMS port: by Rosimildo da Silva.
- * This module was ported from Linux.
+ *  RTEMS port: by Rosimildo da Silva.
  *
+ *  $Id$
  */
 
 #include <stdlib.h>
@@ -26,11 +26,11 @@
 #include <termios.h>
 #include <i386_io.h>
 #include <rtems/mw_uid.h>
+#include <rtems/mouse_parser.h>
 
 #define  INITIALIZE_MOUSE
 /* Some configuration switches are present in the include file... */
 #include "ps2_mouse.h"
-#include "mouse_parser.h"
 
 static void kbd_write_command_w(int data);
 #if 0
@@ -59,14 +59,16 @@
 #define MAX_RETRIES	60		/* some aux operations take long time*/
 
 static void ps2_mouse_interrupt(rtems_irq_hdl_param);
-
-static void ( *driver_input_handler_ps2 )( void *,  unsigned char *, int ) = 0;
+static mouse_parser_enqueue_handler driver_input_handler_ps2 = NULL;
 
 /*
  * This routine sets the handler to handle the characters received
  * from the serial port.
  */
-void ps2_set_driver_handler( int port, void ( *handler )( void *,  unsigned char *, int ) )
+void ps2_set_driver_handler(
+  int                          port,
+  mouse_parser_enqueue_handler handler
+)
 {
   driver_input_handler_ps2 = handler;
 }
@@ -185,7 +187,7 @@
 
     /* if the input queue is active, add to it */
     if( driver_input_handler_ps2 ) {
-      driver_input_handler_ps2( NULL,  &scancode, 1 );
+      driver_input_handler_ps2( &scancode, 1 );
     } else {
       /* post this byte to termios */
       rtems_termios_enqueue_raw_characters( termios_ttyp_paux, (char *)&scancode, 1 );
@@ -557,12 +559,16 @@
       break;
 
     case MW_UID_REGISTER_DEVICE:
-      printk( "PS2 Mouse: reg=%s\n", args->buffer );
-      register_mou_msg_queue( args->buffer, -1 );
+      printk( "PS2 Mouse: registering\n" );
+      mouse_parser_initialize( "ps2" );
+      ps2_set_driver_handler( minor, mouse_parser_enqueue );
       break;
 
     case MW_UID_UNREGISTER_DEVICE:
+/*
       unregister_mou_msg_queue( -1 );
+*/
+      ps2_set_driver_handler( minor, NULL );
       break;
   }
   args->ioctl_return = 0;

diff -u /dev/null rtems/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c:1.1
--- /dev/null	Mon Mar 14 10:10:49 2011
+++ rtems/c/src/lib/libbsp/i386/pc386/console/serial_mouse_config.c	Mon Mar 14 09:57:00 2011
@@ -0,0 +1,54 @@
+/*
+ *  COPYRIGHT (c) 1989-2007.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <bsp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* select which serial port the mouse is connected to */
+/* XXX - Hook these somewhere */
+#ifdef   SERIAL_MOUSE_COM1
+  #define SERIAL_MOUSE_COM  1
+#elif defined(SERIAL_MOUSE_COM2)
+  #define SERIAL_MOUSE_COM  2
+#else
+  /* Select Default to be COM1  */
+  #define SERIAL_MOUSE_COM  1
+#endif
+
+extern int BSPConsolePort;
+
+bool bsp_get_serial_mouse_device(
+  const char **name,
+  const char **type
+)
+{
+  #ifdef SERIAL_MOUSE_COM2
+    *name = "/dev/ttyS2";
+  #else
+    *name = "/dev/ttyS1";
+  #endif
+  
+  *type = "ms";
+
+  /* Check if this port is not been used as console */
+  /* XXX configure the serial port, take boot args additionally */
+  if ( BSPConsolePort == SERIAL_MOUSE_COM ) {
+    printk( "SERIAL MOUSE: port selected as console.(%s)\n", *name );
+    rtems_fatal_error_occurred( -1 );
+  }
+
+  printk("Mouse Device: %s\n", *name );
+  return name;
+}

diff -u rtems/c/src/lib/libbsp/i386/pc386/console/vgainit.c:1.5 rtems/c/src/lib/libbsp/i386/pc386/console/vgainit.c:1.6
--- rtems/c/src/lib/libbsp/i386/pc386/console/vgainit.c:1.5	Wed Jan 19 15:27:39 2005
+++ rtems/c/src/lib/libbsp/i386/pc386/console/vgainit.c	Mon Mar 14 09:57:00 2011
@@ -58,7 +58,6 @@
   int data2;
 } REGIO;
 
-/* extern data*/
 #if ROMFONT
 extern FARADDR 		rom_char_addr;		/* address of ROM font*/
 extern int		ROM_CHAR_HEIGHT;	/* ROM character height*/

diff -u rtems/c/src/lib/libbsp/i386/pc386/preinstall.am:1.9 rtems/c/src/lib/libbsp/i386/pc386/preinstall.am:1.10
--- rtems/c/src/lib/libbsp/i386/pc386/preinstall.am:1.9	Fri Apr 30 06:43:01 2010
+++ rtems/c/src/lib/libbsp/i386/pc386/preinstall.am	Mon Mar 14 09:57:00 2011
@@ -106,10 +106,6 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/kd.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/kd.h
 
-$(PROJECT_INCLUDE)/rtems/serial_mouse.h: console/serial_mouse.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/serial_mouse.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/serial_mouse.h
-
 $(PROJECT_INCLUDE)/rtems/ps2_drv.h: console/ps2_drv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ps2_drv.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ps2_drv.h



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20110314/2a9d443b/attachment.html>


More information about the vc mailing list