[PATCH 4/8] i386/pc386: Fix printk with the console changes.

Chris Johns chrisj at rtems.org
Fri May 6 22:23:48 UTC 2016


---
 .../lib/libbsp/i386/pc386/console/printk_support.c | 69 ++++++++++++----------
 1 file changed, 37 insertions(+), 32 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/console/printk_support.c b/c/src/lib/libbsp/i386/pc386/console/printk_support.c
index d4adf55..d6dd569 100644
--- a/c/src/lib/libbsp/i386/pc386/console/printk_support.c
+++ b/c/src/lib/libbsp/i386/pc386/console/printk_support.c
@@ -27,16 +27,7 @@
 #include <libchip/ns16550.h>
 #include "../../../shared/console_private.h"
 
-rtems_device_minor_number         BSPPrintkPort = 0;
-
-#if (BSP_IS_EDISON == 1)
-void edison_write_polled(int minor, char cChar); /* XXX */
-int edison_inbyte_nonblocking_polled(int minor);
-#endif
-
-#if BSP_ENABLE_COM1_COM4
-int ns16550_inbyte_nonblocking_polled( int minor );
-#endif
+rtems_device_minor_number BSPPrintkPort = 0;
 
 void BSP_outch(char ch);
 int BSP_inch(void);
@@ -44,41 +35,55 @@ int BSP_inch(void);
 void BSP_outch(char ch)
 {
   #if BSP_ENABLE_VGA
-    if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
-      _IBMPC_outch( ch );
-      return;
-    }
+    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
+  #else
+    bool isVga = false;
   #endif
-  console_tbl *cptr;
 
-  cptr = &Console_Configuration_Ports[BSPPrintkPort];
-  cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
+  if ( !isVga ) {
+    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
+    if (port->pDeviceFns && port->pDeviceFns->deviceWritePolled) {
+      port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
+      /*
+       * No termios so expand the LF to LF/CR.
+       */
+      if ( ch == '\n')
+        port->pDeviceFns->deviceWritePolled( BSPPrintkPort, '\r' );
+    }
+    return;
+  }
+
+  #if BSP_ENABLE_VGA
+    _IBMPC_outch( ch );
+  #endif
 }
 
-int BSP_inch(void) 
+int BSP_inch(void)
 {
-  int           result = -1;
-
   #if BSP_ENABLE_VGA
-    if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
-      result = BSP_wait_polled_input();
-    } else
+    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
+  #else
+    bool isVga = false;
   #endif
-  #if BSP_ENABLE_COM1_COM4
-    {
+
+  int result = -1;
+
+  if ( !isVga ) {
+    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
+    if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
       do {
-        result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort );
+        result = port->pDeviceFns->deviceRead( BSPPrintkPort );
       } while (result == -1);
+      return result;
     }
+  }
+
+  #if BSP_ENABLE_VGA
+    result = BSP_wait_polled_input();
   #endif
-  #if (BSP_IS_EDISON == 1)
-    do {
-      result = edison_inbyte_nonblocking_polled( BSPPrintkPort );
-    } while (result == -1);
-  #endif
+
   return result;
 }
 
 BSP_output_char_function_type     BSP_output_char = BSP_outch;
 BSP_polling_getchar_function_type BSP_poll_char = BSP_inch;
-
-- 
2.4.6




More information about the devel mailing list