changeset 996:fb41b6cf2513

Add control to force use of serial port during initialization
author gthomas
date Sun, 04 May 2003 17:37:28 +0000
parents bd56b4799886
children 256a8a1a3333
files packages/net/bsd_tcpip/current/ChangeLog packages/net/bsd_tcpip/current/cdl/freebsd_net.cdl packages/net/bsd_tcpip/current/src/ecos/support.c
diffstat 3 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/bsd_tcpip/current/ChangeLog
+++ b/packages/net/bsd_tcpip/current/ChangeLog
@@ -1,3 +1,11 @@
+2003-05-04  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/ecos/support.c: 
+	* cdl/freebsd_net.cdl: Add option to force initialization [debug]
+	messages to go to a serial console.  This seems to be necessary
+	on some hardware as the init sequence can totally foul up a
+	network [debug] connection.
+
 2003-04-11  Michael Checky  <Michael_Checky@Thermoking.com>
 
 	* cdl/freebsd_net.cdl: Deleted the 'CYGPKG_NET_FREEBSD_STACK_BUILD_TESTS'
--- a/packages/net/bsd_tcpip/current/cdl/freebsd_net.cdl
+++ b/packages/net/bsd_tcpip/current/cdl/freebsd_net.cdl
@@ -197,6 +197,18 @@ cdl_package CYGPKG_NET_FREEBSD_STACK {
             "
     }
 
+    cdl_option CYGPKG_NET_FORCE_SERIAL_CONSOLE {
+        display "Force use of serial console during initialization"
+        flavor  bool
+        default_value 0
+        description   "
+            Trying to print initialization messages can fail if the
+            console channel is a network connection (via RedBoot).
+            Use of this option forces the stack to use a serial
+            port during this phase for safety.  It can be used 
+            if the network drivers are unstable at this point."
+    }
+
     cdl_option CYGPKG_NET_MEM_USAGE {
         display "Memory designated for networking buffers."
         flavor  data
--- a/packages/net/bsd_tcpip/current/src/ecos/support.c
+++ b/packages/net/bsd_tcpip/current/src/ecos/support.c
@@ -14,7 +14,7 @@
 // Portions created by Red Hat are
 // Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
 //
-// Copyright (C) 2002 Gary Thomas
+// Copyright (C) 2002, 2003 Gary Thomas
 // Copyright (C) 2003 Andrew Lunn
 // -------------------------------------------
 //
@@ -69,7 +69,7 @@
 #include <cyg/infra/diag.h>
 #include <cyg/hal/hal_intr.h>
 #include <cyg/kernel/kapi.h>
-
+#include <cyg/hal/hal_if.h>
 #include <cyg/infra/cyg_ass.h>
 
 #if !CYGPKG_NET_DRIVER_FRAMEWORK   // Interface
@@ -832,9 +832,20 @@ cyg_net_init(void)
 {
     static int _init = false;
     struct init_tab_entry *init_entry;
+#ifdef CYGPKG_NET_FORCE_SERIAL_CONSOLE
+    int orig_console =
+        CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+#endif
 
     if (_init) return;
 
+#ifdef CYGPKG_NET_FORCE_SERIAL_CONSOLE
+    // Force default serial console during system initialization
+    // This avoids problems with debug messages occurring while the
+    // networking subsystem is being setup.
+    CYGACC_CALL_IF_SET_CONSOLE_COMM(0);
+#endif
+
     cyg_do_net_init();  // Just forces linking in the initializer/constructor
     // Initialize interrupt "flags"
     cyg_flag_init(&netint_flags);
@@ -867,6 +878,11 @@ cyg_net_init(void)
 
     // Done
     _init = true;
+
+#ifdef CYGPKG_NET_FORCE_SERIAL_CONSOLE
+    // Revert to the original console, which might be a network connection
+    CYGACC_CALL_IF_SET_CONSOLE_COMM(orig_console);
+#endif
 }