Index: c/src/lib/libbsp/sparc/leon3/console/console.c
===================================================================
--- c/src/lib/libbsp/sparc/leon3/console/console.c	(revision da416d4f277d23718c620f7a557cdc4296533dc0)
+++ c/src/lib/libbsp/sparc/leon3/console/console.c	(revision 8b8eecbc1d5655f442d4e04bce4612e1b20fadf0)
@@ -41,11 +41,11 @@
 
 /*
- *  console_outbyte_polled
+ *  apbuart_outbyte_polled
  *
  *  This routine transmits a character using polling.
  */
 
-void console_outbyte_polled(
-  int  port,
+extern void apbuart_outbyte_polled(
+  ambapp_apb_uart *regs,
   char ch
 );
@@ -59,5 +59,5 @@
  */
 
-int apbuart_inbyte_nonblocking(int port);
+extern int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs);
 
 /* body is in debugputs.c */
@@ -79,5 +79,5 @@
 
   while (nwrite < len) {
-    console_outbyte_polled(port, *buf++);
+    apbuart_outbyte_polled((ambapp_apb_uart*)LEON3_Console_Uart[port], *buf++);
     nwrite++;
   }
@@ -85,5 +85,5 @@
 }
 
-int console_inbyte_nonblocking(int minor)
+int console_pollRead(int minor)
 {
   int port;
@@ -94,5 +94,5 @@
     port = minor - 1;
 
-  return apbuart_inbyte_nonblocking(port);
+  return apbuart_inbyte_nonblocking((ambapp_apb_uart*)LEON3_Console_Uart[port]);
 }
 
@@ -169,5 +169,5 @@
     NULL,                        /* firstOpen */
     NULL,                        /* lastClose */
-    console_inbyte_nonblocking,  /* pollRead */
+    console_pollRead,            /* pollRead */
     console_write_support,       /* write */
     NULL,                        /* setAttributes */
Index: c/src/lib/libbsp/sparc/leon3/console/debugputs.c
===================================================================
--- c/src/lib/libbsp/sparc/leon3/console/debugputs.c	(revision da416d4f277d23718c620f7a557cdc4296533dc0)
+++ c/src/lib/libbsp/sparc/leon3/console/debugputs.c	(revision 8b8eecbc1d5655f442d4e04bce4612e1b20fadf0)
@@ -22,4 +22,5 @@
 #include <stdlib.h>
 #include <assert.h>
+#include <stdio.h>
 
 /*
@@ -38,4 +39,5 @@
  */
 int debug_uart_index __attribute__((weak)) = 0;
+ambapp_apb_uart *dbg_uart = NULL;
 
 /*
@@ -75,7 +77,7 @@
     /* initialize debug uart if present for printk */
     if (debug_uart_index < uarts) {
-      LEON3_Console_Uart[debug_uart_index]->ctrl |= LEON_REG_UART_CTRL_RE |
-                                                    LEON_REG_UART_CTRL_TE;
-      LEON3_Console_Uart[debug_uart_index]->status = 0;
+      dbg_uart = (ambapp_apb_uart *)LEON3_Console_Uart[debug_uart_index];
+      dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
+      dbg_uart->status = 0;
     }
     isinit = 1;
@@ -86,40 +88,32 @@
 
 /*
- *  console_outbyte_polled
+ *  apbuart_outbyte_polled
  *
  *  This routine transmits a character using polling.
  */
-void console_outbyte_polled(
-  int           port,
+void apbuart_outbyte_polled(
+  ambapp_apb_uart *regs,
   unsigned char ch
 )
 {
-  if ((port >= 0) && (port < uarts)) {
-    return;
-
-  while ( (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_THE) == 0 );
-  LEON3_Console_Uart[port]->data = (unsigned int) ch;
+  while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 );
+  regs->data = (unsigned int) ch;
 }
 
 /*
- *  console_inbyte_nonblocking
+ *  apbuart_inbyte_nonblocking
  *
  *  This routine polls for a character.
  */
-int apbuart_inbyte_nonblocking(int port)
+int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs)
 {
-  if ((port >= 0) && (port < uarts)) {
-    assert( 0 );
-    return -1;
-  }
+  /* Clear errors */
+  if (regs->status & LEON_REG_UART_STATUS_ERR)
+    regs->status = ~LEON_REG_UART_STATUS_ERR;
 
-  /* Clear errors */
-  if (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_ERR)
-    LEON3_Console_Uart[port]->status = ~LEON_REG_UART_STATUS_ERR;
-
-  if ((LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_DR) == 0)
-    return -1;
+  if ((regs->status & LEON_REG_UART_STATUS_DR) == 0)
+    return EOF;
   else
-    return (int) LEON3_Console_Uart[port]->data;
+    return (int) regs->data;
 }
 
@@ -127,5 +121,8 @@
 static void bsp_out_char(char c)
 {
-  console_outbyte_polled(debug_uart_index, c);
+  if (dbg_uart == NULL)
+    return;
+
+  apbuart_outbyte_polled(dbg_uart, c);
 }
 
@@ -142,5 +139,8 @@
   int tmp;
 
-  while ((tmp = apbuart_inbyte_nonblocking(debug_uart_index)) < 0)
+  if (dbg_uart == NULL)
+    return EOF;
+
+  while ((tmp = apbuart_inbyte_nonblocking(dbg_uart)) < 0)
     ;
   return tmp;
