summaryrefslogtreecommitdiffstats
path: root/drivers/char/pc_keyb.c
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@nuclecu.unam.mx>1997-08-06 19:14:48 +0000
committerMiguel de Icaza <miguel@nuclecu.unam.mx>1997-08-06 19:14:48 +0000
commite2819e52a162873ff5061de81bb749831bdb5de9 (patch)
tree6067ea700202750ba335a423696f2972700e5f76 /drivers/char/pc_keyb.c
parent17a005074429bbf143e40401f405ae4363e56828 (diff)
Merge to 2.1.38.
IMPORTANT NOTE: I could not figure out what information is the one that should be used for the following files (ie, those that were in our tree, or those that came from Linus' patch), please, check these: include/asm-mips/jazz.h include/asm-mips/jazzdma.h include/asm-mips/ioctls.h
Diffstat (limited to 'drivers/char/pc_keyb.c')
-rw-r--r--drivers/char/pc_keyb.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/drivers/char/pc_keyb.c b/drivers/char/pc_keyb.c
index fd1c8e862..866a4170f 100644
--- a/drivers/char/pc_keyb.c
+++ b/drivers/char/pc_keyb.c
@@ -7,6 +7,8 @@
* Major cleanup by Martin Mares, May 1997
*/
+#include <linux/config.h>
+
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
@@ -25,21 +27,38 @@
#include "pc_keyb.h"
+/* Simple translation table for the SysRq keys */
+
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char pckbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
/*
* In case we run on a non-x86 hardware we need to initialize both the keyboard
* controller and the keyboard. On a x86, the BIOS will already have initialized
* them.
*/
+#ifndef __i386__
+#define INIT_KBD
+#endif
+
#ifdef INIT_KBD
__initfunc(static int kbd_wait_for_input(void))
{
- int n;
- int status, data;
+ int n;
+ int status, data;
+ unsigned long start = jiffies;
- n = KBD_TIMEOUT;
- do {
+ do {
status = kbd_read_status();
/*
* Wait for input data to become available. This bit will
@@ -62,7 +81,7 @@ __initfunc(static int kbd_wait_for_input(void))
continue;
}
return (data & 0xff);
- } while (--n);
+ } while (jiffies - start < KBD_INIT_TIMEOUT);
return -1; /* timed-out if fell through to here... */
}
@@ -165,12 +184,11 @@ __initfunc(static char *initialize_kbd2(void))
__initfunc(void initialize_kbd(void))
{
- unsigned long flags;
char *msg;
- save_flags(flags); cli();
+ disable_irq(KEYBOARD_IRQ);
msg = initialize_kbd2();
- restore_flags(flags);
+ enable_irq(KEYBOARD_IRQ);
if (msg)
printk(KERN_WARNING "initialize_kbd: %s\n", msg);
@@ -191,12 +209,15 @@ static volatile unsigned char resend = 0;
static inline void kb_wait(void)
{
- int i;
+ unsigned long start = jiffies;
- for (i=0; i<KBD_TIMEOUT; i++)
+ do {
if (! (kbd_read_status() & KBD_STAT_IBF))
return;
+ } while (jiffies - start < KBC_TIMEOUT);
+#ifdef KBD_REPORT_TIMEOUTS
printk(KERN_WARNING "Keyboard timed out\n");
+#endif
}
/*
@@ -374,7 +395,7 @@ static int do_acknowledge(unsigned char scancode)
}
if (scancode == 0) {
#ifdef KBD_REPORT_ERR
- printk(KERN_INFO "keyboard buffer overflow\n");
+ printk(KERN_INFO "Keyboard buffer overflow\n");
#endif
prev_scancode = 0;
return 0;
@@ -390,7 +411,7 @@ int pckbd_pretranslate(unsigned char scancode, char raw_mode)
#ifndef KBD_IS_FOCUS_9000
#ifdef KBD_REPORT_ERR
if (!raw_mode)
- printk(KERN_DEBUG "keyboard error\n");
+ printk(KERN_DEBUG "Keyboard error\n");
#endif
#endif
prev_scancode = 0;
@@ -505,15 +526,17 @@ static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
unsigned char scancode;
/* mouse data? */
- if (status & kbd_read_mask & KBD_STAT_MOUSE_OBF)
+ if (status & kbd_read_mask & KBD_STAT_MOUSE_OBF){
+ printk ("MOUSE!\n");
break;
+ }
scancode = kbd_read_input();
if ((status & KBD_STAT_OBF) && do_acknowledge(scancode))
handle_scancode(scancode);
status = kbd_read_status();
- } while (status & (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF));
+ } while (status & KBD_STAT_OBF);
mark_bh(KEYBOARD_BH);
enable_keyboard();
@@ -527,7 +550,7 @@ static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
static int send_data(unsigned char data)
{
int retries = 3;
- int i;
+ unsigned long start;
do {
kb_wait();
@@ -536,16 +559,21 @@ static int send_data(unsigned char data)
reply_expected = 1;
kbd_write_output(data);
kbd_pause();
- for(i=0; i<0x200000; i++) {
- kbd_read_status(); /* just as a delay */
+ start = jiffies;
+ do {
if (acknowledge)
return 1;
- if (resend)
- break;
- }
- if (!resend)
- return 0;
+ if (jiffies - start >= KBD_TIMEOUT) {
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING "Keyboard timeout\n");
+#endif
+ return 0;
+ }
+ } while (!resend);
} while (retries-- > 0);
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n");
+#endif
return 0;
}
@@ -557,7 +585,7 @@ void pckbd_leds(unsigned char leds)
__initfunc(void pckbd_init_hw(void))
{
- request_irq(KEYBOARD_IRQ, keyboard_interrupt, 0, "keyboard", NULL);
+ request_irq(KEYBOARD_IRQ, keyboard_interrupt, 0, "keyboard-aaa", NULL);
keyboard_setup();
#ifdef INIT_KBD
initialize_kbd();