mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] 2.2.18 serial console sysrq backport
@ 2001-02-02 10:22 Michael Stiller
  0 siblings, 0 replies; only message in thread
From: Michael Stiller @ 2001-02-02 10:22 UTC (permalink / raw)
  To: linux-kernel

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

Hi *,

i just backported the 2.4.x serial.c changes to enable MAGIC_SYSRQ via
serial console
on 2.2.18. Patch is working ok so far, i have included it here, maybe it
is useful for
someone. You need to enable CONFIG_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ
to use it.
To trigger MAGIC_SYSRQ send a "break" to the serial console. e.g. 
ALT-a f in minicom. (To trigger the help function try alt-a f h)

Cheers,
-Michael

-- 
Sik an regeln ortografi unt gramatik su halten erhohen 
ferstandlikkeit von gesribene tekste erheblik.

[-- Attachment #2: serial.sysrq.patch --]
[-- Type: text/plain, Size: 3270 bytes --]

--- linux/drivers/char/serial.c.orig	Fri Feb  2 10:13:25 2001
+++ linux/drivers/char/serial.c	Fri Feb  2 10:35:39 2001
@@ -143,6 +143,10 @@
 #include <linux/console.h>
 #endif
 
+#ifdef CONFIG_MAGIC_SYSRQ
+#include <linux/sysrq.h>
+#endif
+
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -178,6 +182,9 @@
 #ifdef CONFIG_SERIAL_CONSOLE
 static struct console sercons;
 #endif
+#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+static unsigned long break_pressed; /* break, really ... */
+#endif
 
 static unsigned detect_uart_irq (struct serial_state * state);
 static void autoconfig(struct serial_state * info);
@@ -376,7 +383,7 @@
 }
 
 static _INLINE_ void receive_chars(struct async_struct *info,
-				 int *status)
+				 int *status, struct pt_regs * regs)
 {
 	struct tty_struct *tty = info->tty;
 	unsigned char ch;
@@ -403,6 +410,21 @@
 			if (*status & UART_LSR_BI) {
 				*status &= ~(UART_LSR_FE | UART_LSR_PE);
 				icount->brk++;
+                        /*
+                         * We do the SysRQ and SAK checking
+                         * here because otherwise the break
+                         * may get masked by ignore_status_mask
+                         * or read_status_mask.
+                         */
+#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+                                if (info->line == sercons.index) {
+                                        if (!break_pressed) {
+                                                break_pressed = jiffies;
+                                                goto ignore_char;
+                                        }
+                                        break_pressed = 0;
+                                }
+#endif
 			} else if (*status & UART_LSR_PE)
 				icount->parity++;
 			else if (*status & UART_LSR_FE)
@@ -447,6 +469,17 @@
 				}
 			}
 		}
+#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+                if (break_pressed && info->line == sercons.index) {
+                        if (ch != 0 &&
+                            time_before(jiffies, break_pressed + HZ*5)) {
+                                handle_sysrq(ch, regs, NULL, NULL);
+                                break_pressed = 0;
+                                goto ignore_char;
+                        }
+                        break_pressed = 0;
+                }
+#endif
 		tty->flip.flag_buf_ptr++;
 		tty->flip.char_buf_ptr++;
 		tty->flip.count++;
@@ -612,7 +645,7 @@
 		printk("status = %x...", status);
 #endif
 		if (status & UART_LSR_DR)
-			receive_chars(info, &status);
+			receive_chars(info, &status, regs);
 		check_modem_status(info);
 		if (status & UART_LSR_THRE)
 			transmit_chars(info, 0);
@@ -676,7 +709,7 @@
 		printk("status = %x...", status);
 #endif
 		if (status & UART_LSR_DR)
-			receive_chars(info, &status);
+			receive_chars(info, &status, regs);
 		check_modem_status(info);
 		if (status & UART_LSR_THRE)
 			transmit_chars(info, 0);
@@ -739,7 +772,7 @@
 		printk("status = %x...", status);
 #endif
 		if (status & UART_LSR_DR)
-			receive_chars(info, &status);
+			receive_chars(info, &status, regs);
 		check_modem_status(info);
 		if (status & UART_LSR_THRE)
 			transmit_chars(info, 0);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-02-02 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-02 10:22 [patch] 2.2.18 serial console sysrq backport Michael Stiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®