home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!stanford.edu!rock!cole
- From: cole@concert.net (Derrick C. Cole)
- Subject: Microsoft Bus Mouse patch 2a
- Message-ID: <1992Aug30.021148.21070@rock.concert.net>
- Sender: news@rock.concert.net
- Organization: MCNC Data Operations
- Date: Sun, 30 Aug 1992 02:11:48 GMT
- Lines: 363
-
- Greetings!
-
- This patch is to be made against pristine linux-0.97 patchlevel 1. The default
- choice in linux/Makefile is for the Microsoft mouse. You can of course choose
- the Logitech driver, or comment out both choices for no bus mouse driver.
-
- Any questions, problems can be directed to me at cole@concert.net, or to the
- newsgroup.
-
- Thanks again Frank, Teemu, Andrew and the original Logitech driver writers!
-
- Good luck!
- Derrick
-
- --- cut here ---
-
- *** linux/Makefile.orig Fri Aug 28 21:24:31 1992
- --- linux/Makefile Fri Aug 28 21:48:31 1992
- *************** KEYBOARD = -DKBD_US -DKBDFLAGS=0
- *** 46,51 ****
- --- 46,57 ----
- # KEYBOARD = -DKDB_NO
-
- #
- + # if you want a bus mouse driver, uncomment your choice
- + #
- + # BUSMOUSE = -DBUSMOUSE=LOGITECH
- + BUSMOUSE = -DBUSMOUSE=MICROSOFT
- +
- + #
- # comment this line if you don't want the emulation-code
- #
-
- *** linux/kernel/chr_drv/Makefile.orig Fri Aug 28 21:21:07 1992
- --- linux/kernel/chr_drv/Makefile Fri Aug 28 21:51:03 1992
- *************** chr_drv.a: $(OBJS)
- *** 26,31 ****
- --- 26,37 ----
- keyboard.o: keyboard.c
- $(CC) $(CFLAGS) $(KEYBOARD) -c -o keyboard.o keyboard.c
-
- + mouse.o: mouse.c
- + $(CC) $(CFLAGS) $(BUSMOUSE) -c -o mouse.o mouse.c
- +
- + mem.o: mem.c
- + $(CC) $(CFLAGS) $(BUSMOUSE) -c -o mem.o mem.c
- +
- clean:
- rm -f core *.o *.a tmp_make keyboard.s
- for i in *.c;do rm -f `basename $$i .c`.s;done
- *** linux/kernel/chr_drv/mem.c.orig Fri Aug 28 21:50:00 1992
- --- linux/kernel/chr_drv/mem.c Fri Aug 28 21:50:00 1992
- *************** long chr_dev_init(long mem_start, long m
- *** 256,261 ****
- --- 256,263 ----
- chrdev_fops[1] = &mem_fops;
- mem_start = tty_init(mem_start);
- mem_start = lp_init(mem_start);
- + #ifdef BUSMOUSE
- mem_start = mouse_init(mem_start);
- + #endif
- return mem_start;
- }
- *** linux/kernel/chr_drv/mouse.c.orig Fri Aug 28 16:34:44 1992
- --- linux/kernel/chr_drv/mouse.c Sat Aug 29 20:27:39 1992
- ***************
- *** 13,21 ****
- * Modified the select() code blindly to conform to the VFS
- * requirements. 92.07.14 - Linus. Somebody should test it out.
- *
- ! * version 0.1
- */
-
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/mouse.h>
- --- 13,40 ----
- * Modified the select() code blindly to conform to the VFS
- * requirements. 92.07.14 - Linus. Somebody should test it out.
- *
- ! * Added MicroSoft busmouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92)
- ! *
- ! * Modified by Derrick Cole (cole@concert.net) 8/28/92
- ! * modified the read_mouse() code to handle a Microsoft mouse with the
- ! * following settings:
- ! *
- ! * J2=NORMAL
- ! * J3=PRIMARY INPORT
- ! * J4=5
- ! *
- ! * Works for me. Changes to Teemu's code inspired by code received from
- ! * Frank ten Wolde (franky@duteca.et.tudelft.nl.) Please check this code
- ! * out. We may be dealing with different types of Microsoft Mice, or
- ! * different settings bring about drastic code changes.
- ! * mouse_init() should check for a bus mouse generically, too. Anyone know
- ! * how to do this?
- ! *
- ! * version 0.2a
- */
-
- + #ifdef BUSMOUSE
- +
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/mouse.h>
- *************** static void mouse_interrupt(int unused)
- *** 34,39 ****
- --- 53,59 ----
- {
- char dx, dy, buttons;
-
- + #if (BUSMOUSE == LOGITECH)
- MSE_INT_OFF();
-
- outb(MSE_READ_X_LOW, MSE_CONTROL_PORT);
- *************** static void mouse_interrupt(int unused)
- *** 50,55 ****
- --- 70,93 ----
-
- dy |= (buttons & 0xf) << 4;
- buttons = ((buttons >> 5) & 0x07);
- + #endif
- +
- + #if (BUSMOUSE == MICROSOFT)
- + outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT);
- + outb(inb(MSE_DATA_PORT) | 0x20, MSE_DATA_PORT);
- +
- + outb(MSE_READ_X, MSE_CONTROL_PORT);
- + dx = inb(MSE_DATA_PORT);
- +
- + outb(MSE_READ_Y, MSE_CONTROL_PORT);
- + dy = inb(MSE_DATA_PORT);
- +
- + outb(MSE_READ_BUTTONS, MSE_CONTROL_PORT);
- + buttons = ~(inb(MSE_DATA_PORT)) & 0x07;
- +
- + outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT);
- + outb(inb(MSE_DATA_PORT) & 0xdf, MSE_DATA_PORT);
- + #endif
-
- mouse.buttons = buttons;
- mouse.latch_buttons |= buttons;
- *************** static void mouse_interrupt(int unused)
- *** 58,65 ****
- mouse.ready = 1;
- if (mouse.inode && mouse.inode->i_wait)
- wake_up(&mouse.inode->i_wait);
- !
- MSE_INT_ON();
- }
-
- static void release_mouse(struct inode * inode, struct file * file)
- --- 96,105 ----
- mouse.ready = 1;
- if (mouse.inode && mouse.inode->i_wait)
- wake_up(&mouse.inode->i_wait);
- !
- ! #if (BUSMOUSE == LOGITECH)
- MSE_INT_ON();
- + #endif
- }
-
- static void release_mouse(struct inode * inode, struct file * file)
- *************** static int open_mouse(struct inode * ino
- *** 88,93 ****
- --- 128,137 ----
- mouse.active = 0; /* it's not active, fix it */
- return -EBUSY; /* IRQ is busy, so we're BUSY */
- } /* if we can't get the IRQ and mouse not active */
- + #if (BUSMOUSE == MICROSOFT)
- + outb(MSE_START, MSE_CONTROL_PORT);
- + #endif
- +
- MSE_INT_ON();
- return 0;
- }
- *************** static int read_mouse(struct inode * ino
- *** 103,110 ****
-
- if (count < 3) return -EINVAL;
- if (!mouse.ready) return -EAGAIN;
- !
- MSE_INT_OFF();
-
- put_fs_byte(mouse.latch_buttons | 0x80, buffer);
-
- --- 147,156 ----
-
- if (count < 3) return -EINVAL;
- if (!mouse.ready) return -EAGAIN;
- !
- ! #if (BUSMOUSE == LOGITECH)
- MSE_INT_OFF();
- + #endif
-
- put_fs_byte(mouse.latch_buttons | 0x80, buffer);
-
- *************** static int read_mouse(struct inode * ino
- *** 121,132 ****
- for (i = 3; i < count; i++)
- put_fs_byte(0x00, buffer + i);
-
- ! mouse.dx = 0;
- ! mouse.dy = 0;
- mouse.latch_buttons = mouse.buttons;
- mouse.ready = 0;
- !
- MSE_INT_ON();
- return i;
- }
-
- --- 167,179 ----
- for (i = 3; i < count; i++)
- put_fs_byte(0x00, buffer + i);
-
- ! mouse.dx = mouse.dy = 0;
- mouse.latch_buttons = mouse.buttons;
- mouse.ready = 0;
- !
- ! #if (BUSMOUSE == LOGITECH)
- MSE_INT_ON();
- + #endif
- return i;
- }
-
- *************** static struct file_operations mouse_fops
- *** 153,160 ****
-
- long mouse_init(long kmem_start)
- {
- int i;
- !
- outb(MSE_CONFIG_BYTE, MSE_CONFIG_PORT);
- outb(MSE_SIGNATURE_BYTE, MSE_SIGNATURE_PORT);
-
- --- 200,208 ----
-
- long mouse_init(long kmem_start)
- {
- + #if (BUSMOUSE == LOGITECH)
- int i;
- !
- outb(MSE_CONFIG_BYTE, MSE_CONFIG_PORT);
- outb(MSE_SIGNATURE_BYTE, MSE_SIGNATURE_PORT);
-
- *************** long mouse_init(long kmem_start)
- *** 164,180 ****
- mouse.present = 0;
- return kmem_start;
- }
- chrdev_fops[10] = &mouse_fops;
- outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
-
- MSE_INT_OFF();
-
- mouse.present = 1;
- ! mouse.active = 0;
- ! mouse.ready = 0;
- mouse.buttons = mouse.latch_buttons = 0x80;
- ! mouse.dx = 0;
- ! mouse.dy = 0;
- ! printk("Bus mouse detected and installed.\n");
- return kmem_start;
- }
- --- 212,237 ----
- mouse.present = 0;
- return kmem_start;
- }
- + #endif
- +
- chrdev_fops[10] = &mouse_fops;
- +
- + #if (BUSMOUSE == LOGITECH)
- outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
- + #endif
-
- MSE_INT_OFF();
-
- mouse.present = 1;
- ! mouse.active = mouse.ready = 0;
- mouse.buttons = mouse.latch_buttons = 0x80;
- ! mouse.dx = mouse.dy = 0;
- ! #if (BUSMOUSE == LOGITECH)
- ! printk("Logitech Bus Mouse detected and installed.\n");
- ! #elif (BUSMOUSE == MICROSOFT)
- ! printk("Microsoft Bus Mouse detected and installed.\n");
- ! #endif
- return kmem_start;
- }
- +
- + #endif
- *** linux/include/linux/mouse.h.orig Thu Aug 27 20:37:13 1992
- --- linux/include/linux/mouse.h Sat Aug 29 00:03:35 1992
- ***************
- *** 12,21 ****
- --- 12,32 ----
- * Minor modifications for Linux 0.96c-pl1 by Nathan Laredo
- * gt7080a@prism.gatech.edu (13JUL92)
- *
- + * Microsoft BusMouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92)
- + *
- + * Microsoft Bus Mouse support modified by Derrick Cole (cole@concert.net)
- + * 8/28/92
- */
-
- + #if defined (BUSMOUSE)
- +
- + #define LOGITECH 1
- + #define MICROSOFT 2
- +
- #define MOUSE_IRQ 5
-
- + #if (BUSMOUSE == LOGITECH)
- +
- #define MSE_DATA_PORT 0x23c
- #define MSE_SIGNATURE_PORT 0x23d
- #define MSE_CONTROL_PORT 0x23e
- ***************
- *** 40,45 ****
- --- 51,81 ----
- #define MSE_INT_OFF() outb(MSE_DISABLE_INTERRUPTS, MSE_CONTROL_PORT)
- #define MSE_INT_ON() outb(MSE_ENABLE_INTERRUPTS, MSE_CONTROL_PORT)
-
- + #endif
- +
- + #if (BUSMOUSE == MICROSOFT)
- +
- + #define MSE_CONTROL_PORT 0x23c
- + #define MSE_DATA_PORT 0x23d
- + #define MSE_SIGNATURE_PORT 0x23d
- + #define MSE_CONFIG_PORT 0x23f
- +
- + #define MSE_ENABLE_INTERRUPTS 0x11
- + #define MSE_DISABLE_INTERRUPTS 0x10
- +
- + #define MSE_READ_BUTTONS 0x00
- + #define MSE_READ_X 0x01
- + #define MSE_READ_Y 0x02
- +
- + #define MSE_START 0x80
- + #define MSE_COMMAND_MODE 0x07
- +
- + /* useful macros */
- + #define MSE_INT_OFF() {outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT); outb(MSE_DISABLE_INTERRUPTS, MSE_DATA_PORT);}
- + #define MSE_INT_ON() {outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT); outb(MSE_ENABLE_INTERRUPTS, MSE_DATA_PORT);}
- +
- + #endif
- +
- struct mouse_status
- {
- char buttons;
- *************** struct mouse_status
- *** 57,61 ****
- --- 93,98 ----
- /* Function Prototypes */
- extern long mouse_init(long);
-
- + #endif
- #endif
-
- --
- ---
- Derrick Cole MCNC Center for Communications
-