All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Katz <katzj@redhat.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] Hook up sysrq for xencons
Date: Wed, 31 Aug 2005 18:20:32 -0400	[thread overview]
Message-ID: <1125526832.2569.80.camel@bree.local.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 195 bytes --]

Having sysrq is regularly handy.  Following in the tradition set by the
various consoles for virtual ppc stuff, I've made the sysrq key ^O.

Signed-off-by: Jeremy Katz <katzj@redhat.com>

Jeremy

[-- Attachment #2: xen-sysrq.patch --]
[-- Type: text/x-patch, Size: 3244 bytes --]

diff -r 8af8ddf91078 linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Aug 31 14:53:43 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Aug 31 18:19:48 2005
@@ -45,6 +45,7 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/bootmem.h>
+#include <linux/sysrq.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -66,6 +67,11 @@
 static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
 static int xc_num = -1;
 
+#ifdef CONFIG_MAGIC_SYSRQ
+static unsigned long sysrq_requested;
+extern int sysrq_enabled;
+#endif
+
 static int __init xencons_setup(char *str)
 {
     char *q;
@@ -296,7 +302,7 @@
 static char x_char;
 
 /* Non-privileged receive callback. */
-static void xencons_rx(char *buf, unsigned len)
+static void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
 {
     int           i;
     unsigned long flags;
@@ -304,8 +310,27 @@
     spin_lock_irqsave(&xencons_lock, flags);
     if ( xencons_tty != NULL )
     {
-        for ( i = 0; i < len; i++ )
+        for ( i = 0; i < len; i++ ) {
+#ifdef CONFIG_MAGIC_SYSRQ
+            if (sysrq_enabled) {
+                if (buf[i] == '\x0f') { /* ^O */
+                    sysrq_requested = jiffies;
+                    continue; /* don't print the sysrq key */
+                } else if (sysrq_requested) {
+                    unsigned long sysrq_timeout = sysrq_requested + HZ*2;
+                    sysrq_requested = 0;
+                    /* if it's been less than a timeout, do the sysrq */
+                    if (time_before(jiffies, sysrq_timeout)) {
+                        spin_unlock_irqrestore(&xencons_lock, flags);
+                        handle_sysrq(buf[i], regs, xencons_tty);
+                        spin_lock_irqsave(&xencons_lock, flags);
+                        continue;
+                    }
+                }
+            }
+#endif
             tty_insert_flip_char(xencons_tty, buf[i], 0);
+        }
         tty_flip_buffer_push(xencons_tty);
     }
     spin_unlock_irqrestore(&xencons_lock, flags);
diff -r 8af8ddf91078 linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Aug 31 14:53:43 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Aug 31 18:19:48 2005
@@ -82,7 +82,7 @@
 	while (ring->cons < ring->prod) {
 		if (xencons_receiver != NULL) {
 			xencons_receiver(ring->buf + XENCONS_IDX(ring->cons),
-					 1);
+					 1, regs);
 		}
 		ring->cons++;
 	}
diff -r 8af8ddf91078 linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h	Wed Aug 31 14:53:43 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h	Wed Aug 31 18:19:48 2005
@@ -7,7 +7,8 @@
 int xencons_ring_init(void);
 int xencons_ring_send(const char *data, unsigned len);
 
-typedef void (xencons_receiver_func)(char *buf, unsigned len);
+typedef void (xencons_receiver_func)(char *buf, unsigned len, 
+                                     struct pt_regs *regs);
 void xencons_ring_register_receiver(xencons_receiver_func *f);
 
 #endif /* _XENCONS_RING_H */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2005-08-31 22:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-31 22:20 Jeremy Katz [this message]
2005-09-01 10:46 ` [PATCH] Hook up sysrq for xencons Christian Limpach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1125526832.2569.80.camel@bree.local.net \
    --to=katzj@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.