This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix baudrate setting for CYGPKG_REDBOOT_ANY_CONSOLE


Index: redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.80
diff -u -p -5 -r1.80 ChangeLog
--- redboot/current/ChangeLog	13 Sep 2002 21:33:26 -0000	1.80
+++ redboot/current/ChangeLog	16 Sep 2002 13:17:54 -0000
@@ -1,5 +1,10 @@
+2002-09-16  Mark Salter  <msalter@redhat.com>
+
+	* src/main.c (set_console_baud_rate): Handle CYGPKG_REDBOOT_ANY_CONSOLE.
+	(set_comm_baud_rate): New function.
+
 2002-09-13  Mark Salter  <msalter@redhat.com>
 
 	* src/decompress.c: Move error handling back into gzip_close to
 	fix xyzmodem loads.
 
Index: redboot/current/src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.35
diff -u -p -5 -r1.35 main.c
--- redboot/current/src/main.c	11 Sep 2002 12:14:52 -0000	1.35
+++ redboot/current/src/main.c	16 Sep 2002 13:17:54 -0000
@@ -445,27 +445,45 @@ do_reset(int argc, char *argv[])
 #ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
 #include <flash_config.h>
 #endif
 
+static int
+set_comm_baud_rate(hal_virtual_comm_table_t *chan, int rate)
+{
+    int current_rate;
+
+    current_rate = CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_SETBAUD, rate);
+    if (rate != current_rate)
+        return CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_SETBAUD, rate);
+
+    return 0;
+}
+
 int
 set_console_baud_rate(int rate)
 {
-    hal_virtual_comm_table_t *__chan;
-    static int current_rate = CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD;
-    int ret = current_rate;
-
-    if (rate != current_rate) {
-        __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
-        ret = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SETBAUD, rate);
-        if (ret < 0) {
-            diag_printf("Setting console baud rate to %d failed\n", rate);
-            return ret;
+    int ret;
+#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
+    if (!console_selected) {
+        int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+        int i;
+        // Set baud for all channels
+        for (i = 0;  i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS;  i++) {
+            CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
+	    ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
+	    if (ret < 0)
+		break;
         }
-        ret = current_rate;
-        current_rate = rate;
-    }
+        CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
+    } else
+#endif
+    ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
+
+    if (ret < 0)
+	diag_printf("Setting console baud rate to %d failed\n", rate);
+
     return ret;
 }
 
 static void
 _sleep(int ms)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]