Proposed change for polled serial output on i386 targets

Eric Norum eric.norum at usask.ca
Fri Jul 12 15:45:11 UTC 2002


While getting the serial-port console stuff working I found that things 
would lock up if a printk was followed closely by a printf when 
BSPConsolePort = BSP_UART_COM2 and BSPPrintkPort  = BSP_UART_COM1.  I 
propose the following change to 
c/src/lib/libbsp/i386/shared/comm/uart.c.  With this change in place, 
printf/printk calls can be intermingled with no apparent problems.


--- /Users/eric/src/work/oldNotes/bsdwork/rtems-
ss-20010525/c/src/lib/libbsp/i386/shared/comm/uart.c    Thu Oct 19 
09:18:20 2000
+++ uart.c      Fri Jul 12 09:13:00 2002
@@ -411,6 +411,22 @@
      }

    uwrite(uart, THR, val & 0xff);
+
+  /*
+   * Wait for character to be transmitted.
+   * This ensures that printk and printf play nicely together
+   * when using the same serial port.
+   * Yes, there's a performance hit here, but if we're doing
+   * polled writes to a serial port we're probably not that
+   * interested in efficiency anyway.....
+   */
+  for(;;)
+    {
+      if((val1=uread(uart, LSR)) & THRE)
+       {
+         break;
+       }
+    }

    return;
  }



--
Eric Norum <eric.norum at usask.ca>
Department of Electrical Engineering
University of Saskatchewan
Saskatoon, Canada.
Phone: (306) 966-5394   FAX:   (306) 966-5407




More information about the users mailing list