Index: c/src/lib/libbsp/bfin/eZKit533/ChangeLog
===================================================================
--- c/src/lib/libbsp/bfin/eZKit533/ChangeLog	(revision 02aaec7647607e96532b93083557412daca02285)
+++ c/src/lib/libbsp/bfin/eZKit533/ChangeLog	(revision c8b1ab96c82f6ea4a554356a2f6f25ad71973c98)
@@ -1,2 +1,8 @@
+2008-08-18	Allan Hessenflow <allanh@kallisti.com>
+
+	* Makefile.am, console/console-io.c, startup/bspstart.c: Update to use
+	shared libcpu version of code implemented as part of bf537Stamp
+	effort.
+
 2008-08-15	Joel Sherrill <joel.sherrill@OARcorp.com>
 
Index: c/src/lib/libbsp/bfin/eZKit533/Makefile.am
===================================================================
--- c/src/lib/libbsp/bfin/eZKit533/Makefile.am	(revision 02aaec7647607e96532b93083557412daca02285)
+++ c/src/lib/libbsp/bfin/eZKit533/Makefile.am	(revision c8b1ab96c82f6ea4a554356a2f6f25ad71973c98)
@@ -28,15 +28,27 @@
 dist_project_lib_DATA += startup/linkcmds
 
-startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
-    ../../shared/bsppredriverhook.c startup/bspstart.c \
-    ../../shared/bspclean.c ../../shared/sbrk.c ../../shared/setvec.c \
-    ../../shared/bootcard.c ../../shared/gnatinstallhandler.c
-clock_SOURCES = ../shared/clock/clockdrv.c ../shared/clock/rtc.c
-console_SOURCES = console/console-io.c ../shared/console/console.c
-timer_SOURCES = ../shared/timer/timer.c
+noinst_PROGRAMS += startup.rel
+startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
+	../../shared/bsppredriverhook.c startup/bspstart.c \
+	../../shared/bspclean.c ../../shared/sbrk.c ../../shared/setvec.c \
+	../../shared/bootcard.c ../../shared/gnatinstallhandler.c
+startup_rel_CPPFLAGS = $(AM_CPPFLAGS)
+startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += console.rel
+console_rel_SOURCES = console/console-io.c
+console_rel_CPPFLAGS = $(AM_CPPFLAGS)
+console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
 
 noinst_LIBRARIES = libbsp.a
-libbsp_a_SOURCES = $(startup_SOURCES) $(clock_SOURCES) $(console_SOURCES) \
-    $(timer_SOURCES)
+libbsp_a_SOURCES =
+libbsp_a_LIBADD = startup.rel console.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/mmu.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/interrupt.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/cache.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/uart.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/clock.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/rtc.rel
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/timer.rel
 
 EXTRA_DIST += times
Index: c/src/lib/libbsp/bfin/eZKit533/console/console-io.c
===================================================================
--- c/src/lib/libbsp/bfin/eZKit533/console/console-io.c	(revision 02aaec7647607e96532b93083557412daca02285)
+++ c/src/lib/libbsp/bfin/eZKit533/console/console-io.c	(revision c8b1ab96c82f6ea4a554356a2f6f25ad71973c98)
@@ -16,234 +16,108 @@
  
 
+#include <rtems.h>
+#include <rtems/libio.h>
 #include <bsp.h>
-#include <cplb.h>
-#include <rtems/libio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <inttypes.h>
+#include <rtems/bspIo.h>
 
-/*
- *  console_initialize_hardware
- *
- *  This routine initializes the console hardware.
- *
- */
+#include <libcpu/bf533.h>
+#include <libcpu/interrupt.h>
+#include <libcpu/uart.h>
 
-/* 
- * console_initialize_hardware does not compile with optimizations.
- * Makefile.am has been changed to compile the console driver with -O0. 
- */
-void console_initialize_hardware(void)
-{
-  unsigned int divisor;
-  
-  /* Set DLAB to access divisor registers */
-  *((uint16_t*)UART_LCR) = DLAB;
+static bfin_uart_channel_t channels[] = {
+  {"/dev/console",
+   (char *) UART0_BASE_ADDRESS,
+   CONSOLE_USE_INTERRUPTS,
+#ifdef CONSOLE_FORCE_BAUD
+   CONSOLE_FORCE_BAUD,
+#else
+   0,
+#endif
+   NULL,
+   0}
+};
 
-  /* Set divisor registers
-   * BAUDRATE = SCLK/(16xDIVISOR)
-   */
-  divisor = SCLK/(BAUDRATE*16);                /* 1300000/(16x57600) */
-  *((uint16_t*)UART_DLL) = (divisor & 0x00ff);
-  *((uint16_t*)UART_DLH) = ((divisor >> 8) & 0x00ff);
+static bfin_uart_config_t config = {
+  SCLK,
+  sizeof(channels) / sizeof(channels[0]),
+  channels
+};
 
-  /* Set Control Register - 8 bits, no parity, 1 stop bit*/
-  *((uint16_t*)UART_LCR) = WORD_8BITS;
+#if CONSOLE_USE_INTERRUPTS
+static bfin_isr_t bfinUARTISRs[] = {
+  {SIC_DMA6_UART0_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
+  {SIC_DMA7_UART0_TX_VECTOR, bfin_uart_isr, 0, 0, NULL},
+};
+#endif
 
-  /* Enable Serial Clocks */
-  *((uint16_t*)UART_GCTL) = UCEN;
 
-  return;
+static void eZKit533_BSP_output_char(char c) {
+
+  bfin_uart_poll_write(0, c);
 }
 
-/*
- *  console_outbyte_polled
- *
- *  This routine transmits a character using polling.
- */
+static char eZKit533_BSP_poll_char(void) {
 
-void console_outbyte_polled(
-  int  port,
-  char ch
-)
-{
-  while (!((*((uint16_t*)UART_LSR))&THRE)){} /* Wait for sending last byte */
-  *((uint16_t*)UART_THR) = ch;
+  return bfin_uart_poll_read(0);
 }
 
-/*
- *  console_inbyte_nonblocking
- *
- *  This routine polls for a character.
- */
+BSP_output_char_function_type BSP_output_char = eZKit533_BSP_output_char;
+BSP_polling_getchar_function_type BSP_poll_char = eZKit533_BSP_poll_char;
 
-int console_inbyte_nonblocking(
-  int port
-)
-{
-  char c;
-  
-  if ( *((uint16_t*)UART_LSR) & DR){
-    c = *((uint16_t*)UART_RBR);
-  }else{
-    return -1;
+rtems_device_driver console_initialize(rtems_device_major_number major,
+                                       rtems_device_minor_number minor,
+                                       void *arg) {
+  rtems_status_code status;
+#if CONSOLE_USE_INTERRUPTS
+  int i;
+#endif
+
+  status = bfin_uart_initialize(major, &config);
+#if CONSOLE_USE_INTERRUPTS
+  for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
+    bfin_interrupt_register(&bfinUARTISRs[i]);
+    bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
   }
+#endif
 
-  return c;
+  if (status != RTEMS_SUCCESSFUL)
+    rtems_fatal_error_occurred(status);
+
+  return RTEMS_SUCCESSFUL;
 }
 
-#if (CONSOLE_USE_INTERRUPTS)
+rtems_device_driver console_open(rtems_device_major_number major,
+                                 rtems_device_minor_number minor,
+                                 void *arg) {
 
-#include <rtems/ringbuf.h>
-
-Ring_buffer_t  TX_Buffer[ 1 ];
-boolean        Is_TX_active[ 1 ];
-
-extern void *console_termios_data[ 1 ];
-/*
- *  console_isr
- *
- *  This routine is the console interrupt handler for Channel A.
- *
- *  Input parameters:
- *    vector - vector number
- *
- *  Output parameters: NONE
- *
- *  Return values:     NONE
- */
-rtems_isr console_isr(
-  rtems_vector_number vector
-)
-{
-  char ch;
-  uint16_t UStat;
-
-  UStat = *((uint16_t*)UART_IIR);
-
-  if ( ((UStat&0x06) == 0x04) && ( (*((uint16_t*)UART_LSR)) & DR)) {
-    ch = *((uint16_t*)UART_RBR);
-    rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 );
-  }
-
-  if ( ((UStat&0x06) == 0x02) && ((*((uint16_t*)UART_LSR))&THRE) ) {
-    if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) {
-      Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch );
-      *((uint16_t*)UART_THR) = ch;
-    } else {
-      Is_TX_active[ 0 ] = FALSE;
-    }
-  }
+  return bfin_uart_open(major, minor, arg);
 }
 
-/*
- *  console_exit
- *
- *  This routine allows the console to exit by masking its associated interrupt
- *  vectors.
- *
- *  Input parameters:  NONE
- *
- *  Output parameters: NONE
- *
- *  Return values:     NONE
- */
-void console_exit()
-{
-  uint32_t         port;
-  uint16_t         ch;
+rtems_device_driver console_close(rtems_device_major_number major,
+                                  rtems_device_minor_number minor,
+                                  void *arg) {
 
-  /*
-   *  Although the interrupts for the UART are unmasked, the PIL is set to
-   *  disable all external interrupts.  So we might as well do this first.
-   */
-
-  /* Disable UART interruptions */
-  *((uint16_t*)UART_IER) = 0x0000; 
-  *((uint16_t*)SIC_IMASK) &= 0xFFFF3FBF; 
-
-  while ( !Ring_buffer_Is_empty( &TX_Buffer[ port ] ) ) {
-    Ring_buffer_Remove_character( &TX_Buffer[ port ], ch );
-    console_outbyte_polled( port, ch );
-  }
-
-  /*
-   *  Now wait for all the data to actually get out ... the send register
-   *  should be empty.
-   */
-
-  while ( !((*((uint16_t*)UART_LSR))&THRE) );
+  return rtems_termios_close(arg);
 }
 
-/*
- *  console_initialize_interrupts
- *
- *  This routine initializes the console's receive and transmit
- *  ring buffers and loads the appropriate vectors to handle the interrupts.
- *
- *  Input parameters:  NONE
- *
- *  Output parameters: NONE
- *
- *  Return values:     NONE
- */
+rtems_device_driver console_read(rtems_device_major_number major,
+                                 rtems_device_minor_number minor,
+                                 void *arg) {
 
-/*#ifdef RDB_BREAK_IN
-  extern uint32_t   trap_table[];
-#endif*/
-
-void console_initialize_interrupts( void )
-{
-  Ring_buffer_Initialize( &TX_Buffer[ 0 ] );
-
-  Is_TX_active[ 0 ] = FALSE;
-
-  atexit( console_exit );
-
-  /* Setting priority - IVG10*/
-  *((uint32_t*)SIC_IAR0)  &= 0xF0FFFFFF;
-  *((uint32_t*)SIC_IAR0)  |= 0x03000000;
-  *((uint32_t*)SIC_IAR1)  &= 0x00FFFFFF;
-  *((uint32_t*)SIC_IAR1)  |= 0x33000000;
-  
-  /* System Interrupt Mask */
-  *((uint32_t*)SIC_IMASK) |= 0x0000C040;
-  
-  set_vector( console_isr, UART_VECTOR, 1 );
-  
-  /* Enable UART Interruption
-   * ELSI - RX error interrupt
-   * ETBEI - TX buffer empty
-   * ERBFI - RX buffer full 
-   */
-  *((uint16_t*)UART_IER) = ELSI | ETBEI | ERBFI;
+  return rtems_termios_read(arg);
 }
 
-void console_outbyte_interrupt(
-  int   port,
-  char  ch
-)
-{
-  /*
-   *  If this is the first character then we need to prime the pump
-   */
+rtems_device_driver console_write(rtems_device_major_number major,
+                                  rtems_device_minor_number minor,
+                                  void *arg) {
 
-  if ( Is_TX_active[ port ] == FALSE ) {
-    Is_TX_active[ port ] = TRUE;
-    console_outbyte_polled( port, ch );
-    return;
-  }
-
-  while ( Ring_buffer_Is_full( &TX_Buffer[ port ] ) );
-
-  Ring_buffer_Add_character( &TX_Buffer[ port ], ch );
+  return rtems_termios_write(arg);
 }
 
-#endif
+rtems_device_driver console_control(rtems_device_major_number major,
+                                    rtems_device_minor_number minor,
+                                    void *arg) {
 
-#include <rtems/bspIo.h>
+  return rtems_termios_ioctl(arg);
+}
 
-void bfsim_BSP_output_char(char c) { console_outbyte_polled( 0, c ); }
-
-BSP_output_char_function_type           BSP_output_char = bfsim_BSP_output_char;
-BSP_polling_getchar_function_type       BSP_poll_char = NULL;
Index: c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c	(revision 02aaec7647607e96532b93083557412daca02285)
+++ c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c	(revision c8b1ab96c82f6ea4a554356a2f6f25ad71973c98)
@@ -24,5 +24,5 @@
 #include <rtems/libio.h>
 #include <rtems/libcsupport.h>
-
+#include <libcpu/interrupt.h>
 
 const unsigned int dcplbs_table[16][2] = {  
@@ -104,4 +104,6 @@
     void         *heapStart = &HeapBase;
     unsigned long heapSize = (unsigned long)&HeapSize;
+
+    bfin_interrupt_init();
 
     bsp_libc_init(heapStart, heapSize, 0);
