[PATCH] bsps/sparc: Reduce copy and paste

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jun 30 07:30:17 UTC 2014


---
 c/src/lib/libbsp/sparc/leon2/console/console.c     |   35 ++++++++++---------
 c/src/lib/libbsp/sparc/leon2/console/debugputs.c   |   17 +++++----
 c/src/lib/libbsp/sparc/leon2/include/leon.h        |   35 --------------------
 c/src/lib/libbsp/sparc/leon2/include/rasta.h       |   31 -----------------
 c/src/lib/libbsp/sparc/leon3/console/console.c     |   31 +++++++++--------
 .../libbsp/sparc/leon3/console/printk_support.c    |   13 ++++---
 c/src/lib/libbsp/sparc/leon3/include/leon.h        |   33 ------------------
 c/src/lib/libbsp/sparc/shared/include/apbuart.h    |    1 +
 c/src/lib/libbsp/sparc/shared/uart/apbuart.c       |    8 ++--
 9 files changed, 55 insertions(+), 149 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/leon2/console/console.c b/c/src/lib/libbsp/sparc/leon2/console/console.c
index cac21a6..e5768ee 100644
--- a/c/src/lib/libbsp/sparc/leon2/console/console.c
+++ b/c/src/lib/libbsp/sparc/leon2/console/console.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <rtems/bspIo.h>
+#include <apbuart.h>
 
 /*
  *  console_outbyte_polled
@@ -81,16 +82,16 @@ rtems_isr console_isr_a(
   char ch;
   int UStat;
 
-  if ( (UStat = LEON_REG.UART_Status_1) & LEON_REG_UART_STATUS_DR ) {
-    if (UStat & LEON_REG_UART_STATUS_ERR) {
-      LEON_REG.UART_Status_1 = LEON_REG_UART_STATUS_CLR;
+  if ( (UStat = LEON_REG.UART_Status_1) & APBUART_STATUS_DR ) {
+    if (UStat & APBUART_STATUS_ERR) {
+      LEON_REG.UART_Status_1 = APBUART_STATUS_CLR;
     }
     ch = LEON_REG.UART_Channel_1;
 
     rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 );
   }
 
-  if ( LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE ) {
+  if ( LEON_REG.UART_Status_1 & APBUART_STATUS_THE ) {
     if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) {
       Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch );
       LEON_REG.UART_Channel_1 = (uint32_t) ch;
@@ -121,16 +122,16 @@ rtems_isr console_isr_b(
   char ch;
   int UStat;
 
-  if ( (UStat = LEON_REG.UART_Status_2) & LEON_REG_UART_STATUS_DR ) {
-    if (UStat & LEON_REG_UART_STATUS_ERR) {
-      LEON_REG.UART_Status_2 = LEON_REG_UART_STATUS_CLR;
+  if ( (UStat = LEON_REG.UART_Status_2) & APBUART_STATUS_DR ) {
+    if (UStat & APBUART_STATUS_ERR) {
+      LEON_REG.UART_Status_2 = APBUART_STATUS_CLR;
     }
     ch = LEON_REG.UART_Channel_2;
     rtems_termios_enqueue_raw_characters( console_termios_data[ 1 ], &ch, 1 );
 
   }
 
-  if ( LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE ) {
+  if ( LEON_REG.UART_Status_2 & APBUART_STATUS_THE ) {
     if ( !Ring_buffer_Is_empty( &TX_Buffer[ 1 ] ) ) {
       Ring_buffer_Remove_character( &TX_Buffer[ 1 ], ch );
       LEON_REG.UART_Channel_2 = (uint32_t) ch;
@@ -179,11 +180,11 @@ void console_exit()
    *  should be empty.
    */
 
-  while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) !=
-          LEON_REG_UART_STATUS_THE );
+  while ( (LEON_REG.UART_Status_1 & APBUART_STATUS_THE) !=
+          APBUART_STATUS_THE );
 
-  while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) !=
-          LEON_REG_UART_STATUS_THE );
+  while ( (LEON_REG.UART_Status_2 & APBUART_STATUS_THE) !=
+          APBUART_STATUS_THE );
 
   LEON_REG.UART_Control_1 = 0;
   LEON_REG.UART_Control_2 = 0;
@@ -223,8 +224,8 @@ void console_initialize_interrupts( void )
 
   atexit( console_exit );
 
-  LEON_REG.UART_Control_1 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI;
-  LEON_REG.UART_Control_2 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI;
+  LEON_REG.UART_Control_1 |= APBUART_CTRL_RI | APBUART_CTRL_TI;
+  LEON_REG.UART_Control_2 |= APBUART_CTRL_RI | APBUART_CTRL_TI;
 
   set_vector( console_isr_a, CONSOLE_UART_1_TRAP, 1 );
 #ifdef RDB_BREAK_IN
@@ -320,9 +321,9 @@ rtems_device_driver console_initialize(
    *  Initialize Hardware
    */
 
-  LEON_REG.UART_Control_1 |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
-  LEON_REG.UART_Control_2 |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE |
-      LEON_REG_UART_CTRL_RI;  /* rx irq default enable for remote debugger */
+  LEON_REG.UART_Control_1 |= APBUART_CTRL_RE | APBUART_CTRL_TE;
+  LEON_REG.UART_Control_2 |= APBUART_CTRL_RE | APBUART_CTRL_TE |
+      APBUART_CTRL_RI;  /* rx irq default enable for remote debugger */
   LEON_REG.UART_Status_1 = 0;
   LEON_REG.UART_Status_2 = 0;
 #if (CONSOLE_USE_INTERRUPTS)
diff --git a/c/src/lib/libbsp/sparc/leon2/console/debugputs.c b/c/src/lib/libbsp/sparc/leon2/console/debugputs.c
index 4de2afc..6ddaf7b 100644
--- a/c/src/lib/libbsp/sparc/leon2/console/debugputs.c
+++ b/c/src/lib/libbsp/sparc/leon2/console/debugputs.c
@@ -21,6 +21,7 @@
 #include <rtems/libio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <apbuart.h>
 
 /*
  *  console_outbyte_polled
@@ -34,12 +35,12 @@ void console_outbyte_polled(
 )
 {
   if ( port == 0 ) {
-    while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 );
+    while ( (LEON_REG.UART_Status_1 & APBUART_STATUS_TE) == 0 );
       LEON_REG.UART_Channel_1 = (unsigned int) ch;
       return;
     }
 
-    while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 );
+    while ( (LEON_REG.UART_Status_2 & APBUART_STATUS_TE) == 0 );
     LEON_REG.UART_Channel_2 = (unsigned int) ch;
 }
 
@@ -55,21 +56,21 @@ int console_inbyte_nonblocking( int port )
   switch (port) {
 
     case 0:
-      if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
-        LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
+      if (LEON_REG.UART_Status_1 & APBUART_STATUS_ERR) {
+        LEON_REG.UART_Status_1 = ~APBUART_STATUS_ERR;
       }
 
-      if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
+      if ((LEON_REG.UART_Status_1 & APBUART_STATUS_DR) == 0)
          return -1;
       return (int) LEON_REG.UART_Channel_1;
       return 1;
 
     case 1:
-      if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
-        LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
+      if (LEON_REG.UART_Status_2 & APBUART_STATUS_ERR) {
+        LEON_REG.UART_Status_2 = ~APBUART_STATUS_ERR;
       }
 
-      if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
+      if ((LEON_REG.UART_Status_2 & APBUART_STATUS_DR) == 0)
          return -1;
       return (int) LEON_REG.UART_Channel_2;
 
diff --git a/c/src/lib/libbsp/sparc/leon2/include/leon.h b/c/src/lib/libbsp/sparc/leon2/include/leon.h
index 25826bd..708d77f 100644
--- a/c/src/lib/libbsp/sparc/leon2/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon2/include/leon.h
@@ -232,41 +232,6 @@ typedef struct {
 #define LEON_REG_TIMER_CONTROL_LD    0x00000004  /* 1 = load counter */
                                               /* 0 = no function */
 
-/*
- *  The following defines the bits in the UART Control Registers.
- *
- */
-
-#define LEON_REG_UART_CONTROL_RTD  0x000000FF /* RX/TX data */
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-
-#define LEON_REG_UART_STATUS_CLR  0x00000000 /* Clear all status bits */
-#define LEON_REG_UART_STATUS_DR   0x00000001 /* Data Ready */
-#define LEON_REG_UART_STATUS_TSE  0x00000002 /* TX Send Register Empty */
-#define LEON_REG_UART_STATUS_THE  0x00000004 /* TX Hold Register Empty */
-#define LEON_REG_UART_STATUS_BR   0x00000008 /* Break Error */
-#define LEON_REG_UART_STATUS_OE   0x00000010 /* RX Overrun Error */
-#define LEON_REG_UART_STATUS_PE   0x00000020 /* RX Parity Error */
-#define LEON_REG_UART_STATUS_FE   0x00000040 /* RX Framing Error */
-#define LEON_REG_UART_STATUS_ERR  0x00000078 /* Error Mask */
-
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-
-#define LEON_REG_UART_CTRL_RE     0x00000001 /* Receiver enable */
-#define LEON_REG_UART_CTRL_TE     0x00000002 /* Transmitter enable */
-#define LEON_REG_UART_CTRL_RI     0x00000004 /* Receiver interrupt enable */
-#define LEON_REG_UART_CTRL_TI     0x00000008 /* Transmitter interrupt enable */
-#define LEON_REG_UART_CTRL_PS     0x00000010 /* Parity select */
-#define LEON_REG_UART_CTRL_PE     0x00000020 /* Parity enable */
-#define LEON_REG_UART_CTRL_FL     0x00000040 /* Flow control enable */
-#define LEON_REG_UART_CTRL_LB     0x00000080 /* Loop Back enable */
-
 #ifndef ASM
 
 /*
diff --git a/c/src/lib/libbsp/sparc/leon2/include/rasta.h b/c/src/lib/libbsp/sparc/leon2/include/rasta.h
index b7eccb4..d2f765f 100644
--- a/c/src/lib/libbsp/sparc/leon2/include/rasta.h
+++ b/c/src/lib/libbsp/sparc/leon2/include/rasta.h
@@ -55,37 +55,6 @@ extern int rasta_register(void);
 #define UART0_IRQ   (1<<UART0_IRQNO)
 #define UART1_IRQ   (1<<UART1_IRQNO)
 
-/*
- *  The following defines the bits in the UART Control Registers.
- *
- */
-#define LEON_REG_UART_CONTROL_RTD  0x000000FF /* RX/TX data */
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-#define LEON_REG_UART_STATUS_DR   0x00000001 /* Data Ready */
-#define LEON_REG_UART_STATUS_TSE  0x00000002 /* TX Send Register Empty */
-#define LEON_REG_UART_STATUS_THE  0x00000004 /* TX Hold Register Empty */
-#define LEON_REG_UART_STATUS_BR   0x00000008 /* Break Error */
-#define LEON_REG_UART_STATUS_OE   0x00000010 /* RX Overrun Error */
-#define LEON_REG_UART_STATUS_PE   0x00000020 /* RX Parity Error */
-#define LEON_REG_UART_STATUS_FE   0x00000040 /* RX Framing Error */
-#define LEON_REG_UART_STATUS_ERR  0x00000078 /* Error Mask */
-
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-#define LEON_REG_UART_CTRL_RE     0x00000001 /* Receiver enable */
-#define LEON_REG_UART_CTRL_TE     0x00000002 /* Transmitter enable */
-#define LEON_REG_UART_CTRL_RI     0x00000004 /* Receiver interrupt enable */
-#define LEON_REG_UART_CTRL_TI     0x00000008 /* Transmitter interrupt enable */
-#define LEON_REG_UART_CTRL_PS     0x00000010 /* Parity select */
-#define LEON_REG_UART_CTRL_PE     0x00000020 /* Parity enable */
-#define LEON_REG_UART_CTRL_FL     0x00000040 /* Flow control enable */
-#define LEON_REG_UART_CTRL_LB     0x00000080 /* Loop Back enable */
-
 #define UART_SET_SCALER 0
 #define UART_SET_CTRL   1
 #define UART_GET_STAT   2
diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c
index cdfbf2a..235788c 100644
--- a/c/src/lib/libbsp/sparc/leon3/console/console.c
+++ b/c/src/lib/libbsp/sparc/leon3/console/console.c
@@ -34,6 +34,7 @@
 #include <rtems/bspIo.h>
 #include <leon.h>
 #include <rtems/termiostypes.h>
+#include <apbuart.h>
 
 int syscon_uart_index __attribute__((weak)) = 0;
 
@@ -74,7 +75,7 @@ static void leon3_console_isr(void *arg)
   char data;
 
   /* Get all received characters */
-  while ((status=uart->regs->status) & LEON_REG_UART_STATUS_DR) {
+  while ((status=uart->regs->status) & APBUART_STATUS_DR) {
     /* Data has arrived, get new data */
     data = uart->regs->data;
 
@@ -83,8 +84,8 @@ static void leon3_console_isr(void *arg)
   }
 
   if (
-    (status & LEON_REG_UART_STATUS_THE)
-      && (uart->regs->ctrl & LEON_REG_UART_CTRL_TI) != 0
+    (status & APBUART_STATUS_THE)
+      && (uart->regs->ctrl & APBUART_CTRL_TI) != 0
   ) {
     /* write_interrupt will get called from this function */
     rtems_termios_dequeue_characters(uart->cookie, 1);
@@ -102,7 +103,7 @@ static int leon3_console_write_support(int minor, const char *buf, size_t len)
 
   if (len > 0) {
     /* Enable TX interrupt (interrupt is edge-triggered) */
-    uart->regs->ctrl |= LEON_REG_UART_CTRL_TI;
+    uart->regs->ctrl |= APBUART_CTRL_TI;
 
     /* start UART TX, this will result in an interrupt when done */
     uart->regs->data = *buf;
@@ -110,7 +111,7 @@ static int leon3_console_write_support(int minor, const char *buf, size_t len)
     sending = 1;
   } else {
     /* No more to send, disable TX interrupts */
-    uart->regs->ctrl &= ~LEON_REG_UART_CTRL_TI;
+    uart->regs->ctrl &= ~APBUART_CTRL_TI;
 
     /* Tell close that we sent everything */
     sending = 0;
@@ -180,26 +181,26 @@ static int leon3_console_set_attributes(int minor, const struct termios *t)
   switch (t->c_cflag & (PARENB|PARODD)) {
     case (PARENB|PARODD):
       /* Odd parity */
-      ctrl |= LEON_REG_UART_CTRL_PE|LEON_REG_UART_CTRL_PS;
+      ctrl |= APBUART_CTRL_PE|APBUART_CTRL_PS;
       break;
 
     case PARENB:
       /* Even parity */
-      ctrl &= ~LEON_REG_UART_CTRL_PS;
-      ctrl |= LEON_REG_UART_CTRL_PE;
+      ctrl &= ~APBUART_CTRL_PS;
+      ctrl |= APBUART_CTRL_PE;
       break;
 
     default:
     case 0:
     case PARODD:
       /* No Parity */
-      ctrl &= ~(LEON_REG_UART_CTRL_PS|LEON_REG_UART_CTRL_PE);
+      ctrl &= ~(APBUART_CTRL_PS|APBUART_CTRL_PE);
   }
 
   if (!(t->c_cflag & CLOCAL)) {
-    ctrl |= LEON_REG_UART_CTRL_FL;
+    ctrl |= APBUART_CTRL_FL;
   } else {
-    ctrl &= ~LEON_REG_UART_CTRL_FL;
+    ctrl &= ~APBUART_CTRL_FL;
   }
 
   /* Update new settings */
@@ -339,11 +340,11 @@ static int leon3_console_first_open(int major, int minor, void *arg)
 
   uart->sending = 0;
   /* Enable Receiver and transmitter and Turn on RX interrupts */
-  uart->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE |
-                      LEON_REG_UART_CTRL_RI;
+  uart->regs->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE |
+                      APBUART_CTRL_RI;
 #else
   /* Initialize UART on opening */
-  uart->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
+  uart->regs->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
 #endif
   uart->regs->status = 0;
 
@@ -359,7 +360,7 @@ static int leon3_console_last_close(int major, int minor, void *arg)
 
   /* Turn off RX interrupts */
   rtems_termios_interrupt_lock_acquire(tty, level);
-  uart->regs->ctrl &= ~(LEON_REG_UART_CTRL_RI);
+  uart->regs->ctrl &= ~(APBUART_CTRL_RI);
   rtems_termios_interrupt_lock_release(tty, level);
 
   /**** Flush device ****/
diff --git a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
index 35fb4b5..d12099b 100644
--- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
+++ b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <stdio.h>
+#include <apbuart.h>
 
 int debug_uart_index __attribute__((weak)) = 0;
 static struct apbuart_regs *dbg_uart = NULL;
@@ -69,7 +70,7 @@ void bsp_debug_uart_init(void)
      */
     apb = (struct ambapp_apb_info *)adev->devinfo;
     dbg_uart = (struct apbuart_regs *)apb->start;
-    dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
+    dbg_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
     dbg_uart->status = 0;
   }
 }
@@ -87,7 +88,7 @@ void apbuart_outbyte_polled(
 )
 {
 send:
-  while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 ) {
+  while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
     /* Lower bus utilization while waiting for UART */
     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
     __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
@@ -103,7 +104,7 @@ send:
 
   /* Wait until the character has been sent? */
   if (wait_sent) {
-    while ((regs->status & LEON_REG_UART_STATUS_THE) == 0)
+    while ((regs->status & APBUART_STATUS_TE) == 0)
       ;
   }
 }
@@ -116,10 +117,10 @@ send:
 int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
 {
   /* Clear errors */
-  if (regs->status & LEON_REG_UART_STATUS_ERR)
-    regs->status = ~LEON_REG_UART_STATUS_ERR;
+  if (regs->status & APBUART_STATUS_ERR)
+    regs->status = ~APBUART_STATUS_ERR;
 
-  if ((regs->status & LEON_REG_UART_STATUS_DR) == 0)
+  if ((regs->status & APBUART_STATUS_DR) == 0)
     return EOF;
   else
     return (int) regs->data;
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index ccf2fb7..d7048f3 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -86,39 +86,6 @@ extern "C" {
 #define LEON_REG_TIMER_CONTROL_LD    0x00000004  /* 1 = load counter */
                                               /* 0 = no function */
 
-/*
- *  The following defines the bits in the UART Control Registers.
- *
- */
-
-#define LEON_REG_UART_CONTROL_RTD  0x000000FF /* RX/TX data */
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-
-#define LEON_REG_UART_STATUS_DR   0x00000001 /* Data Ready */
-#define LEON_REG_UART_STATUS_TSE  0x00000002 /* TX Send Register Empty */
-#define LEON_REG_UART_STATUS_THE  0x00000004 /* TX Hold Register Empty */
-#define LEON_REG_UART_STATUS_BR   0x00000008 /* Break Error */
-#define LEON_REG_UART_STATUS_OE   0x00000010 /* RX Overrun Error */
-#define LEON_REG_UART_STATUS_PE   0x00000020 /* RX Parity Error */
-#define LEON_REG_UART_STATUS_FE   0x00000040 /* RX Framing Error */
-#define LEON_REG_UART_STATUS_ERR  0x00000078 /* Error Mask */
-
-/*
- *  The following defines the bits in the LEON UART Status Registers.
- */
-
-#define LEON_REG_UART_CTRL_RE     0x00000001 /* Receiver enable */
-#define LEON_REG_UART_CTRL_TE     0x00000002 /* Transmitter enable */
-#define LEON_REG_UART_CTRL_RI     0x00000004 /* Receiver interrupt enable */
-#define LEON_REG_UART_CTRL_TI     0x00000008 /* Transmitter interrupt enable */
-#define LEON_REG_UART_CTRL_PS     0x00000010 /* Parity select */
-#define LEON_REG_UART_CTRL_PE     0x00000020 /* Parity enable */
-#define LEON_REG_UART_CTRL_FL     0x00000040 /* Flow control enable */
-#define LEON_REG_UART_CTRL_LB     0x00000080 /* Loop Back enable */
-
 /* LEON3 Interrupt Controller */
 extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
 /* LEON3 GP Timer */
diff --git a/c/src/lib/libbsp/sparc/shared/include/apbuart.h b/c/src/lib/libbsp/sparc/shared/include/apbuart.h
index 139d1ec..2f34a11 100644
--- a/c/src/lib/libbsp/sparc/shared/include/apbuart.h
+++ b/c/src/lib/libbsp/sparc/shared/include/apbuart.h
@@ -71,6 +71,7 @@ typedef struct {
 #define APBUART_STATUS_OV 0x10
 #define APBUART_STATUS_PE 0x20
 #define APBUART_STATUS_FE 0x40
+#define APBUART_STATUS_ERR 0x78
 #define APBUART_STATUS_TH 0x80
 #define APBUART_STATUS_RH 0x100
 #define APBUART_STATUS_TF 0x200
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
index e64784f..d63b324 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
@@ -158,7 +158,7 @@ static void apbuart_hw_open(apbuart_priv *uart);
 #if 0
 static int apbuart_outbyte_try(struct apbuart_regs *regs, unsigned char ch)
 {
-	if ( (READ_REG(&regs->status) & LEON_REG_UART_STATUS_THE) == 0 )
+	if ( (READ_REG(&regs->status) & APBUART_STATUS_THE) == 0 )
 		return -1; /* Failed */
 
 	/* There is room in fifo, put ch in it */
@@ -171,12 +171,12 @@ static int apbuart_inbyte_try(struct apbuart_regs *regs)
 {
 	unsigned int status;
 	/* Clear errors if any */
-	if ( (status=READ_REG(&regs->status)) & LEON_REG_UART_STATUS_ERR) {
-		regs->status = status & ~LEON_REG_UART_STATUS_ERR;
+	if ( (status=READ_REG(&regs->status)) & APBUART_STATUS_ERR) {
+		regs->status = status & ~APBUART_STATUS_ERR;
 	}
 
 	/* Is Data available? */
-	if ( (READ_REG(&regs->status) & LEON_REG_UART_STATUS_DR) == 0 )
+	if ( (READ_REG(&regs->status) & APBUART_STATUS_DR) == 0 )
 		return -1; /* No data avail */
 
 	/* Return Data */
-- 
1.7.7



More information about the devel mailing list