lkml.org 
[lkml]   [1999]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: PATCH: magic sysrq for serial console
> Hopefully this is useful for someone. I made the sysrq stuff work
> on a serial console, since we have some trouble with a machine which
> is on a remote location and has a serial console (see my other message
> about the oopsen on that machine).
>
> You just send a BREAK and then within 5 seconds a command key. You need
> to enable both serial console support and magic sysrq support in the
> kernel to use this.
>
> You do need a getty or anything else running on the serial device, since
> the serial driver only sees interrupts and BREAKs if the port is
> actually opened!
>
> Patch is against 2.2.12-pre7, I think it will patch against the
> real 2.2.12 as well when it gets released.

This would be great for people like me who have sparc's with nothing but a
serial terminal on the thing.

<joke>
I wonder if anyone is working on a sysrq for the network.
</joke>

> diff -ruN linux-2.2.12-pre7.orig/Documentation/Configure.help linux-2.2.12-pre7.new/Documentation/Configure.help
> --- linux-2.2.12-pre7.orig/Documentation/Configure.help Tue Aug 17 22:39:01 1999
> +++ linux-2.2.12-pre7.new/Documentation/Configure.help Tue Aug 17 22:16:07 1999
> @@ -9975,9 +9975,11 @@
> if the system crashes for example during kernel debugging (e.g., you
> will be able to flush the buffer cache to disk, reboot the system
> immediately or dump some status information). This is accomplished
> - by pressing various keys while holding SysRq (Alt+PrintScreen). The
> - keys are documented in Documentation/sysrq.txt. Don't say Y unless
> - you really know what this hack does.
> + by pressing various keys while holding SysRq (Alt+PrintScreen). It
> + also works on a serial console, if you send a BREAK and then within 5
> + seconds a command keypress. The keys are documented in
> + Documentation/sysrq.txt. Don't say Y unless you really know what
> + this hack does.
>
> ISDN subsystem
> CONFIG_ISDN
> diff -ruN linux-2.2.12-pre7.orig/Documentation/sysrq.txt linux-2.2.12-pre7.new/Documentation/sysrq.txt
> --- linux-2.2.12-pre7.orig/Documentation/sysrq.txt Tue Aug 17 22:39:01 1999
> +++ linux-2.2.12-pre7.new/Documentation/sysrq.txt Tue Aug 17 22:18:05 1999
> @@ -23,6 +23,10 @@
>
> On PowerPC - You press 'ALT-Print Screen-<command key>'.
>
> +On the serial console (x86 standard serial ports only) -
> + You send a BREAK, then within 5 seconds a command key. Sending
> + BREAK twice is interpreted as a normal BREAK.
> +
> On other - If you know of the key combos for other architectures, please
> let me know so I can add them to this section.
>
> diff -ruN linux-2.2.12-pre7.orig/drivers/char/serial.c linux-2.2.12-pre7.new/drivers/char/serial.c
> --- linux-2.2.12-pre7.orig/drivers/char/serial.c Tue Aug 17 18:14:12 1999
> +++ linux-2.2.12-pre7.new/drivers/char/serial.c Tue Aug 17 22:33:26 1999
> @@ -141,6 +141,7 @@
> #include <linux/delay.h>
> #ifdef CONFIG_SERIAL_CONSOLE
> #include <linux/console.h>
> +#include <linux/sysrq.h>
> #endif
>
> #include <asm/system.h>
> @@ -177,6 +178,9 @@
> static int IRQ_timeout[NR_IRQS];
> #ifdef CONFIG_SERIAL_CONSOLE
> static struct console sercons;
> +# ifdef CONFIG_MAGIC_SYSRQ
> + static int sysrq_pressed; /* break, really ... */
> +# endif
> #endif
>
> static unsigned detect_uart_irq (struct serial_state * state);
> @@ -376,7 +380,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;
> @@ -401,6 +405,15 @@
> * For statistics only
> */
> if (*status & UART_LSR_BI) {
> +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> + if (info->line == sercons.index) {
> + if (!sysrq_pressed) {
> + sysrq_pressed = jiffies;
> + goto ignore_char;
> + }
> + sysrq_pressed = 0;
> + }
> +#endif
> *status &= ~(UART_LSR_FE | UART_LSR_PE);
> icount->brk++;
> } else if (*status & UART_LSR_PE)
> @@ -447,6 +460,17 @@
> }
> }
> }
> +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> + if (sysrq_pressed && info->line == sercons.index) {
> + if (ch != 0 &&
> + time_before(jiffies, sysrq_pressed + HZ*5)) {
> + handle_sysrq(ch, regs, NULL, NULL);
> + sysrq_pressed = 0;
> + goto ignore_char;
> + }
> + sysrq_pressed = 0;
> + }
> +#endif
> tty->flip.flag_buf_ptr++;
> tty->flip.char_buf_ptr++;
> tty->flip.count++;
> @@ -612,7 +636,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 +700,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 +763,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);
> @@ -1351,6 +1375,10 @@
> if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
> info->read_status_mask |= UART_LSR_BI;
>
> +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> + if (info->line == sercons.index)
> + info->read_status_mask |= UART_LSR_BI;
> +#endif
> /*
> * Characters to ignore
> */
> --
> ... somehow I have a feeling the hurting hasn't even begun yet
> -- Bill, "The Terrible Thunderlizards"
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/
--
Lab tests show that use of micro$oft causes cancer in lab animals

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:3.583 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site