Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add options DDB_BREAK_CHAR. This overrides break on the...



details:   https://anonhg.NetBSD.org/src/rev/dc2c81b07aae
branches:  trunk
changeset: 495687:dc2c81b07aae
user:      jeffs <jeffs%NetBSD.org@localhost>
date:      Thu Aug 03 00:30:47 2000 +0000

description:
Add options DDB_BREAK_CHAR.  This overrides break on the serial console
break character with the supplied one.  This is useful for cases where
break is hard to generate, or you are connected to a PC that "sends"
breaks when power cycled.  For this mode in com, interpret break char
in the polling section, which allows entry into the debugger before
the tty is opened.  Only supported in the com driver currently.

diffstat:

 sys/conf/files   |   4 +-
 sys/dev/ic/com.c |  60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 3 deletions(-)

diffs (140 lines):

diff -r 1f81d0894f5f -r dc2c81b07aae sys/conf/files
--- a/sys/conf/files    Thu Aug 03 00:09:39 2000 +0000
+++ b/sys/conf/files    Thu Aug 03 00:30:47 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.380 2000/08/01 20:01:52 mjacob Exp $
+#      $NetBSD: files,v 1.381 2000/08/03 00:30:49 jeffs Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -115,7 +115,7 @@
 
 # debugging options
 defopt DDB
-defopt opt_ddbparam.h  DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE
+defopt opt_ddbparam.h  DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR
 defopt LOCKDEBUG
 defopt SYSCALL_DEBUG
 
diff -r 1f81d0894f5f -r dc2c81b07aae sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Thu Aug 03 00:09:39 2000 +0000
+++ b/sys/dev/ic/com.c  Thu Aug 03 00:30:47 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com.c,v 1.173 2000/07/06 01:47:36 thorpej Exp $        */
+/*     $NetBSD: com.c,v 1.174 2000/08/03 00:30:47 jeffs Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -77,6 +77,7 @@
  */
 
 #include "opt_ddb.h"
+#include "opt_ddbparam.h"
 #include "opt_com.h"
 
 #include "rnd.h"
@@ -1942,6 +1943,7 @@
                lsr = bus_space_read_1(iot, ioh, com_lsr);
 #if defined(DDB) || defined(KGDB)
                if (ISSET(lsr, LSR_BI)) {
+#ifndef DDB_BREAK_CHAR
 #ifdef DDB 
                        if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
                                console_debugger();
@@ -1954,6 +1956,7 @@
                                continue;
                        }
 #endif
+#endif
                }
 #endif /* DDB || KGDB */
 
@@ -1962,6 +1965,18 @@
                        while (cc > 0) {
                                put[0] = bus_space_read_1(iot, ioh, com_data);
                                put[1] = lsr;
+#if defined(DDB) && defined(DDB_BREAKCHAR)
+                               if (put[0] == DDB_BREAK_CHAR &&
+                                   ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
+                                       console_debugger();
+
+                                       lsr = bus_space_read_1(iot, ioh, com_lsr);
+                                       if (!ISSET(lsr, LSR_RCV_MASK))
+                                               break;
+
+                                       continue;
+                               }
+#endif
                                put += 2;
                                if (put >= end)
                                        put = sc->sc_rbuf;
@@ -2148,6 +2163,12 @@
  * by the console and kgdb glue.
  */
 
+#if defined(DDB) && defined(DDB_BREAK_CHAR)
+#define MAX_UNGETC     20
+static int com_ungetc[MAX_UNGETC];
+static int com_ungetccount = 0;
+#endif
+
 int
 com_common_getc(iot, ioh)
        bus_space_tag_t iot;
@@ -2156,12 +2177,36 @@
        int s = splserial();
        u_char stat, c;
 
+#if defined(DDB) && defined(DDB_BREAK_CHAR)
+       /* got a character from reading things earlier */
+       if (com_ungetccount > 0) {
+               int i;
+
+               c = com_ungetc[0];
+               for (i = 1; i < com_ungetccount; i++) {
+                       com_ungetc[i -1] = com_ungetc[i];
+               }
+               com_ungetccount--;
+               splx(s);
+               return (c);
+       }
+#endif
+
        /* block until a character becomes available */
        while (!ISSET(stat = bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY))
                ;
 
        c = bus_space_read_1(iot, ioh, com_data);
        stat = bus_space_read_1(iot, ioh, com_iir);
+#if defined(DDB) && defined(DDB_BREAK_CHAR)
+       if (c == DDB_BREAK_CHAR) {
+               extern int db_active;
+
+               if (db_active == 0) {
+                       console_debugger();
+               }
+       }
+#endif
        splx(s);
        return (c);
 }
@@ -2175,6 +2220,19 @@
        int s = splserial();
        int timo;
 
+#if defined(DDB) && defined(DDB_BREAK_CHAR)
+       int cin, stat;
+       if (com_ungetccount < MAX_UNGETC 
+            && ISSET(stat = bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)) {
+               cin = bus_space_read_1(iot, ioh, com_data);
+               stat = bus_space_read_1(iot, ioh, com_iir);
+               if (cin == DDB_BREAK_CHAR) {
+                       console_debugger();
+               }
+               com_ungetc[com_ungetccount++] = cin;
+       }
+#endif
+
        /* wait for any pending transmission to finish */
        timo = 150000;
        while (!ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY) && --timo)



Home | Main Index | Thread Index | Old Index