lkml.org 
[lkml]   [1997]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectEmergency keyboard combinations - patch
    Hi!

    This patch allows you to recover system from very strange situations
    (crashed X, keyboard in raw mode, crashed kernel etc.) with hard-coded
    combinations. These are life-savers, not recommended for normal use,
    but when something crashes next time, you'll probably like them.

    Do not enable this for 'safe' machines - anyone who can access
    keyboard may to really strange things...
    Pavel


    diff -ur linux.backup/drivers/char/Makefile linux/drivers/char/Makefile
    --- linux.backup/drivers/char/Makefile Fri Jan 3 19:04:02 1997
    +++ linux/drivers/char/Makefile Mon Mar 31 20:32:54 1997
    @@ -22,7 +22,7 @@
    M_OBJS :=
    L_OBJS := tty_io.o n_tty.o console.o \
    tty_ioctl.o pty.o vt.o mem.o vc_screen.o random.o \
    - consolemap.o selection.o
    + consolemap.o selection.o keyboard.o

    ifeq ($(CONFIG_SERIAL),y)
    ifndef CONFIG_SUN_SERIAL
    diff -ur linux.backup/drivers/char/keyboard.c linux/drivers/char/keyboard.c
    --- linux.backup/drivers/char/keyboard.c Tue Mar 11 21:03:12 1997
    +++ linux/drivers/char/keyboard.c Mon Mar 31 21:22:44 1997
    @@ -14,8 +14,12 @@
    * dynamic function/string keys, led setting, Sept 1994
    * `Sticky' modifier keys, 951006.
    * 11-11-96: SAK should now work in the raw mode (Martin Mares)
    + * 3-31-97: Emergency keyboard combinations (Pavel Machek)
    + * mj's stuff for SAK in raw mode deleted
    + * Activate by SysRq + letter, SysRq + h for help
    */

    +#define CONFIG_EMG_KEYS
    #define KEYBOARD_IRQ 1
    #define DISABLE_KBD_DURING_INTERRUPTS 0

    @@ -127,10 +130,6 @@
    do_ignore, do_ignore, do_ignore
    };

    -/* Key types processed even in raw modes */
    -
    -#define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1 << KT_SHIFT))
    -
    typedef void (*void_fnp)(void);
    typedef void (void_fn)(void);

    @@ -146,8 +145,6 @@
    decr_console, incr_console, spawn_console, bare_num
    };

    -#define SPECIALS_ALLOWED_IN_RAW_MODE (1 << KVAL(K_SAK))
    -
    /* maximum values each key_handler can handle */
    const int max_vals[] = {
    255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1,
    @@ -161,6 +158,10 @@
    static void put_queue(int);
    static unsigned char handle_diacr(unsigned char);

    +#ifdef CONFIG_EMG_KEYS
    +static void emergency_key(int);
    +#endif
    +
    /* pt_regs - set by keyboard_interrupt(), used by show_ptregs() */
    static struct pt_regs * pt_regs;

    @@ -506,6 +507,11 @@
    } else
    rep = set_bit(keycode, key_down);

    +#ifdef CONFIG_EMG_KEYS
    + if (!up_flag && test_bit( E0_PRSCR, key_down ) && (keycode != E0_PRSCR))
    + emergency_key( keycode );
    +#endif
    +
    if (kbd->kbdmode == VC_MEDIUMRAW) {
    /* soon keycodes will require more than one byte */
    put_queue(keycode + up_flag);
    @@ -541,8 +547,8 @@

    if (type >= 0xf0) {
    type -= 0xf0;
    - if (raw_mode && ! (TYPES_ALLOWED_IN_RAW_MODE & (1 << type)))
    - return;
    + if (raw_mode)
    + return;
    if (type == KT_LETTER) {
    type = KT_LATIN;
    if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
    @@ -550,7 +556,7 @@
    if (key_map)
    keysym = key_map[keycode];
    }
    - }
    + }
    (*key_handler[type])(keysym & 0xff, up_flag);
    if (type != KT_SLOCK)
    kbd->slockstate = 0;
    @@ -792,8 +798,7 @@
    return;
    if (value >= SIZE(spec_fn_table))
    return;
    - if ((kbd->kbdmode == VC_RAW || kbd->kbdmode == VC_MEDIUMRAW) &&
    - !(SPECIALS_ALLOWED_IN_RAW_MODE & (1 << value)))
    + if (kbd->kbdmode == VC_RAW || kbd->kbdmode == VC_MEDIUMRAW)
    return;
    spec_fn_table[value]();
    }
    @@ -1397,3 +1402,90 @@
    return (1);
    }
    #endif /* INIT_KBD */
    +
    +#ifdef CONFIG_EMG_KEYS
    +
    +extern union bdflush_param{
    + struct {
    + int nfract; /* Percentage of buffer cache dirty to
    + activate bdflush */
    + int ndirty; /* Maximum number of dirty blocks to write out per
    + wake-cycle */
    + int nrefill; /* Number of clean buffers to try to obtain
    + each time we call refill */
    + int nref_dirt; /* Dirty buffer threshold for activating bdflush
    + when trying to refill buffers. */
    + int dummy1; /* unused */
    + int age_buffer; /* Time for normal buffer to age before
    + we flush it */
    + int age_super; /* Time for superblock to age before we
    + flush it */
    + int dummy2; /* unused */
    + int dummy3; /* unused */
    + } b_un;
    + unsigned int data[9];
    + } bdf_prm;
    +
    +extern int console_loglevel;
    +
    +static void
    +emergency_key( int keycode )
    +{
    + /* 1..9 */
    +if ( (keycode >= 59) && (keycode <= 68) ) { set_console( keycode - 59 ); return; }
    +printk( KERN_INFO "Emergency " );
    +switch( keycode ) {
    + case 25: /* P: Ptregs */
    + printk( "ptregs\n" );
    + show_ptregs();
    + break;
    + case 50: /* M: Mem */
    + printk( "mem\n" );
    + show_mem();
    + break;
    + case 20: /* T: sTate */
    + printk( "state\n" );
    + show_state();
    + break;
    + case 16: /* U: unraw */
    + kbd->kbdmode = VC_XLATE;
    + printk( "unraw\n" );
    + break;
    + case 30: /* A: Security Attetion Key */
    + SAK();
    + printk( "SAK\n" );
    + break;
    + case 31: /* S: sync */
    + bdf_prm.b_un.nfract = 0;
    + bdf_prm.b_un.ndirty = 5000;
    + bdf_prm.b_un.age_buffer = 100;
    + bdf_prm.b_un.age_super = 100;
    + printk( "sync\n" );
    + printk( KERN_INFO "Strange values had been set for bdflush to emulate SYNC.\n" );
    + break;
    + case 32: /* D: ctrl-alt-Del */
    + printk( "ctrl-alt-del emulation\n" );
    + boot_it();
    + break;
    + case 17: /* W: poWer off */
    + printk( "power off\n" );
    + machine_power_off( NULL );
    + break;
    + case 19: /* R: Reset */
    + printk( "reset\n" );
    + machine_restart( NULL );
    + break;
    + case 47: /* V: make console verbose */
    + printk( "verbose\n" );
    + console_loglevel = 8;
    + printk( KERN_INFO "Console is now verbose :-)\n" );
    + break;
    + case 35: /* H: help */
    + case 53: /* ? */
    + printk( "combinations: Help, F1-F10 set console, Unraw, sAk, Verbose\n" );
    + printk( KERN_INFO " Sync, ctrl-alt-Del, poWer off, Reset, Ptregs, Mem, sTate\n" );
    + break;
    + default:
    + }
    +}
    +#endif
    \
     
     \ /
      Last update: 2005-03-22 13:39    [W:0.029 / U:30.140 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site