ia64/xen-unstable

changeset 6589:6bb68b092976

Hook up sysrq for xencons.
Having sysrq is regularly handy. Following in the tradition set by the
various consoles for virtual ppc stuff, the sysrq key is ^O.
Signed-off-by: Jeremy Katz <katzj@redhat.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Sep 01 10:38:57 2005 +0000 (2005-09-01)
parents f25a9797419e
children af78c9d526e0
files linux-2.6-xen-sparse/drivers/xen/console/console.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu Sep 01 10:26:17 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu Sep 01 10:38:57 2005 +0000
     1.3 @@ -45,6 +45,7 @@
     1.4  #include <linux/init.h>
     1.5  #include <linux/console.h>
     1.6  #include <linux/bootmem.h>
     1.7 +#include <linux/sysrq.h>
     1.8  #include <asm/io.h>
     1.9  #include <asm/irq.h>
    1.10  #include <asm/uaccess.h>
    1.11 @@ -66,6 +67,11 @@
    1.12  static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
    1.13  static int xc_num = -1;
    1.14  
    1.15 +#ifdef CONFIG_MAGIC_SYSRQ
    1.16 +static unsigned long sysrq_requested;
    1.17 +extern int sysrq_enabled;
    1.18 +#endif
    1.19 +
    1.20  static int __init xencons_setup(char *str)
    1.21  {
    1.22      char *q;
    1.23 @@ -296,7 +302,7 @@ static int xencons_priv_irq;
    1.24  static char x_char;
    1.25  
    1.26  /* Non-privileged receive callback. */
    1.27 -static void xencons_rx(char *buf, unsigned len)
    1.28 +static void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
    1.29  {
    1.30      int           i;
    1.31      unsigned long flags;
    1.32 @@ -304,8 +310,27 @@ static void xencons_rx(char *buf, unsign
    1.33      spin_lock_irqsave(&xencons_lock, flags);
    1.34      if ( xencons_tty != NULL )
    1.35      {
    1.36 -        for ( i = 0; i < len; i++ )
    1.37 +        for ( i = 0; i < len; i++ ) {
    1.38 +#ifdef CONFIG_MAGIC_SYSRQ
    1.39 +            if (sysrq_enabled) {
    1.40 +                if (buf[i] == '\x0f') { /* ^O */
    1.41 +                    sysrq_requested = jiffies;
    1.42 +                    continue; /* don't print the sysrq key */
    1.43 +                } else if (sysrq_requested) {
    1.44 +                    unsigned long sysrq_timeout = sysrq_requested + HZ*2;
    1.45 +                    sysrq_requested = 0;
    1.46 +                    /* if it's been less than a timeout, do the sysrq */
    1.47 +                    if (time_before(jiffies, sysrq_timeout)) {
    1.48 +                        spin_unlock_irqrestore(&xencons_lock, flags);
    1.49 +                        handle_sysrq(buf[i], regs, xencons_tty);
    1.50 +                        spin_lock_irqsave(&xencons_lock, flags);
    1.51 +                        continue;
    1.52 +                    }
    1.53 +                }
    1.54 +            }
    1.55 +#endif
    1.56              tty_insert_flip_char(xencons_tty, buf[i], 0);
    1.57 +        }
    1.58          tty_flip_buffer_push(xencons_tty);
    1.59      }
    1.60      spin_unlock_irqrestore(&xencons_lock, flags);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Thu Sep 01 10:26:17 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Thu Sep 01 10:38:57 2005 +0000
     2.3 @@ -82,7 +82,7 @@ static irqreturn_t handle_input(int irq,
     2.4  	while (ring->cons < ring->prod) {
     2.5  		if (xencons_receiver != NULL) {
     2.6  			xencons_receiver(ring->buf + XENCONS_IDX(ring->cons),
     2.7 -					 1);
     2.8 +					 1, regs);
     2.9  		}
    2.10  		ring->cons++;
    2.11  	}
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h	Thu Sep 01 10:26:17 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h	Thu Sep 01 10:38:57 2005 +0000
     3.3 @@ -7,7 +7,8 @@ asmlinkage int xprintk(const char *fmt, 
     3.4  int xencons_ring_init(void);
     3.5  int xencons_ring_send(const char *data, unsigned len);
     3.6  
     3.7 -typedef void (xencons_receiver_func)(char *buf, unsigned len);
     3.8 +typedef void (xencons_receiver_func)(char *buf, unsigned len, 
     3.9 +                                     struct pt_regs *regs);
    3.10  void xencons_ring_register_receiver(xencons_receiver_func *f);
    3.11  
    3.12  #endif /* _XENCONS_RING_H */