sunkbd.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:38k
- /* keyboard.c: Sun keyboard driver.
- *
- * Copyright (C) 1995, 1996, 1997 David S. Miller (davem@caip.rutgers.edu)
- *
- * Added vuid event generation and /dev/kbd device for SunOS
- * compatibility - Miguel (miguel@nuclecu.unam.mx)
- *
- * Added PCI 8042 controller support -DaveM
- * Added Magic SysRq support -MJ
- */
- #include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/tty.h>
- #include <linux/tty_flip.h>
- #include <linux/mm.h>
- #include <linux/ptrace.h>
- #include <linux/signal.h>
- #include <linux/string.h>
- #include <linux/fcntl.h>
- #include <linux/poll.h>
- #include <linux/random.h>
- #include <linux/delay.h>
- #include <linux/init.h>
- #include <linux/sysrq.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
- #include <linux/devfs_fs_kernel.h>
- #include <asm/kbio.h>
- #include <asm/vuid_event.h>
- #include <asm/bitops.h>
- #include <asm/oplib.h>
- #include <asm/uaccess.h>
- #include <linux/kbd_kern.h>
- #include <linux/kbd_diacr.h>
- #include <linux/vt_kern.h>
- #ifdef CONFIG_PCI
- #include <linux/pci.h>
- #include <asm/pbm.h>
- #include <asm/ebus.h>
- #endif
- #include "sunkbd.h"
- #define SIZE(x) (sizeof(x)/sizeof((x)[0]))
- /* Define this one if you are making a new frame buffer driver */
- /* it will not block the keyboard */
- /* #define CODING_NEW_DRIVER */
- /* KBD device number, temporal */
- #define KBD_MAJOR 11
- #define KBD_REPORT_ERR
- #define KBD_REPORT_UNKN
- #ifndef KBD_DEFMODE
- #define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
- #endif
- #ifndef KBD_DEFLEDS
- /*
- * Some laptops take the 789uiojklm,. keys as number pad when NumLock
- * is on. This seems a good reason to start with NumLock off.
- */
- #define KBD_DEFLEDS 0
- #endif
- #ifndef KBD_DEFLOCK
- #define KBD_DEFLOCK 0
- #endif
- extern void poke_blanked_console(void);
- extern void ctrl_alt_del(void);
- extern void reset_vc(unsigned int new_console);
- extern void scrollback(int);
- extern void scrollfront(int);
- struct l1a_kbd_state l1a_state;
- static spinlock_t sunkbd_lock = SPIN_LOCK_UNLOCKED;
- /*
- * global state includes the following, and various static variables
- * in this module: prev_scancode, shift_state, diacr, npadch, dead_key_next.
- * (last_console is now a global variable)
- */
- /* shift state counters.. */
- static unsigned char k_down[NR_SHIFT];
- /* keyboard key bitmap */
- static unsigned long key_down[256/BITS_PER_LONG];
- void push_kbd (int scan);
- int kbd_redirected;
- static int dead_key_next;
- /*
- * In order to retrieve the shift_state (for the mouse server), either
- * the variable must be global, or a new procedure must be created to
- * return the value. I chose the former way.
- */
- #ifndef CONFIG_PCI
- int shift_state;
- struct kbd_struct kbd_table[MAX_NR_CONSOLES];
- #endif
- static int npadch = -1; /* -1 or number assembled on pad */
- static unsigned char diacr;
- static char rep; /* flag telling character repeat */
- static struct tty_struct **ttytab;
- static struct kbd_struct * kbd = kbd_table;
- static struct tty_struct * tty;
- static int compose_led_on;
- static int kbd_delay_ticks = HZ / 5;
- static int kbd_rate_ticks = HZ / 20;
- void sun_compute_shiftstate(void);
- typedef void (*k_hand)(unsigned char value, char up_flag);
- typedef void (k_handfn)(unsigned char value, char up_flag);
- static k_handfn
- do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
- do_meta, do_ascii, do_lock, do_lowercase, do_ignore;
- static k_hand key_handler[16] = {
- do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
- do_meta, do_ascii, do_lock, do_lowercase,
- do_ignore, do_ignore, do_ignore, do_ignore
- };
- typedef void (*void_fnp)(void);
- typedef void (void_fn)(void);
- static void_fn do_null, enter, show_ptregs, send_intr, lastcons, caps_toggle,
- num, hold, scroll_forw, scroll_back, boot_it, caps_on, compose,
- SAK, decr_console, incr_console, spawn_console, bare_num;
- static void_fnp spec_fn_table[] = {
- do_null, enter, show_ptregs, show_mem,
- show_state, send_intr, lastcons, caps_toggle,
- num, hold, scroll_forw, scroll_back,
- boot_it, caps_on, compose, SAK,
- decr_console, incr_console, spawn_console, bare_num
- };
- /* maximum values each key_handler can handle */
- #ifndef CONFIG_PCI
- const int max_vals[] = {
- 255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1,
- NR_DEAD - 1, 255, 3, NR_SHIFT - 1,
- 255, NR_ASCII - 1, NR_LOCK - 1, 255,
- NR_LOCK - 1
- };
- const int NR_TYPES = SIZE(max_vals);
- #endif
- static void put_queue(int);
- static unsigned char handle_diacr(unsigned char);
- /* pt_regs - set by keyboard_interrupt(), used by show_ptregs() */
- static struct pt_regs * pt_regs;
- #ifdef CONFIG_MAGIC_SYSRQ
- unsigned char sun_sysrq_xlate[128] =
- "