From 26b6ea69c31b079d74cdf314bb751d50b1241837 Mon Sep 17 00:00:00 2001 From: Paul Saab Date: Wed, 14 Jun 2000 06:41:33 +0000 Subject: [PATCH] Add option ALT_BREAK_TO_DEBUGGER. Implement the Solaris way to break into DDB over a serial console instead of sending a break. Sending the character sequence CR ~ ^b will break the kernel into DDB (if DDB is enabled). Reviewed by: peter --- sys/conf/NOTES | 5 +++++ sys/conf/options | 1 + sys/dev/sio/sio.c | 29 +++++++++++++++++++++++++++++ sys/i386/conf/NOTES | 5 +++++ sys/isa/sio.c | 29 +++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 746dbaebad9c..305225dbe232 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1242,6 +1242,11 @@ options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to #DDB, if available. options CONSPEED=9600 #default speed for serial console (default 9600) +# Solaris implements a new BREAK which is initiated by a character +# sequence CR ~ ^b which is similar to a familiar pattern used on +# Sun servers by the Remote Console. +options ALT_BREAK_TO_DEBUGGER + # Options for sio: options COM_ESP #code for Hayes ESP options COM_MULTIPORT #code for some cards with shared IRQs diff --git a/sys/conf/options b/sys/conf/options index 91b96d930a9d..7d614e930e98 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -427,6 +427,7 @@ METEOR_DEALLOC_ABOVE opt_meteor.h COM_ESP opt_sio.h COM_MULTIPORT opt_sio.h BREAK_TO_DEBUGGER opt_comconsole.h +ALT_BREAK_TO_DEBUGGER opt_comconsole.h # Include tweaks for running under the SimOS machine simulator. SIMOS opt_simos.h diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 8a299bd65625..5fef0d92f387 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -1868,6 +1868,35 @@ siointr1(com) recv_data = 0; else recv_data = inb(com->data_port); +#if defined(DDB) && defined(ALT_BREAK_TO_DEBUGGER) + /* + * Solaris implements a new BREAK which is initiated + * by a character sequence CR ~ ^b which is similar + * to a familiar pattern used on Sun servers by the + * Remote Console. + */ +#define KEY_CRTLB 2 /* ^B */ +#define KEY_CR 13 /* CR '\r' */ +#define KEY_TILDE 126 /* ~ */ + + if (com->unit == comconsole) { + static int brk_state1 = 0, brk_state2 = 0; + if (recv_data == KEY_CR) { + brk_state1 = recv_data; + brk_state2 = 0; + } else if (brk_state1 == KEY_CR && (recv_data == KEY_TILDE || recv_data == KEY_CRTLB)) { + if (recv_data == KEY_TILDE) + brk_state2 = recv_data; + else if (brk_state2 == KEY_TILDE && recv_data == KEY_CRTLB) { + breakpoint(); + brk_state1 = brk_state2 = 0; + goto cont; + } else + brk_state2 = 0; + } else + brk_state1 = 0; + } +#endif if (line_status & (LSR_BI | LSR_FE | LSR_PE)) { /* * Don't store BI if IGNBRK or FE/PE if IGNPAR. diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 746dbaebad9c..305225dbe232 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -1242,6 +1242,11 @@ options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to #DDB, if available. options CONSPEED=9600 #default speed for serial console (default 9600) +# Solaris implements a new BREAK which is initiated by a character +# sequence CR ~ ^b which is similar to a familiar pattern used on +# Sun servers by the Remote Console. +options ALT_BREAK_TO_DEBUGGER + # Options for sio: options COM_ESP #code for Hayes ESP options COM_MULTIPORT #code for some cards with shared IRQs diff --git a/sys/isa/sio.c b/sys/isa/sio.c index 8a299bd65625..5fef0d92f387 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -1868,6 +1868,35 @@ siointr1(com) recv_data = 0; else recv_data = inb(com->data_port); +#if defined(DDB) && defined(ALT_BREAK_TO_DEBUGGER) + /* + * Solaris implements a new BREAK which is initiated + * by a character sequence CR ~ ^b which is similar + * to a familiar pattern used on Sun servers by the + * Remote Console. + */ +#define KEY_CRTLB 2 /* ^B */ +#define KEY_CR 13 /* CR '\r' */ +#define KEY_TILDE 126 /* ~ */ + + if (com->unit == comconsole) { + static int brk_state1 = 0, brk_state2 = 0; + if (recv_data == KEY_CR) { + brk_state1 = recv_data; + brk_state2 = 0; + } else if (brk_state1 == KEY_CR && (recv_data == KEY_TILDE || recv_data == KEY_CRTLB)) { + if (recv_data == KEY_TILDE) + brk_state2 = recv_data; + else if (brk_state2 == KEY_TILDE && recv_data == KEY_CRTLB) { + breakpoint(); + brk_state1 = brk_state2 = 0; + goto cont; + } else + brk_state2 = 0; + } else + brk_state1 = 0; + } +#endif if (line_status & (LSR_BI | LSR_FE | LSR_PE)) { /* * Don't store BI if IGNBRK or FE/PE if IGNPAR.