Changeset c8b1ab9 in rtems


Ignore:
Timestamp:
Aug 18, 2008, 9:51:35 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
c553a233
Parents:
02aaec7
Message:

2008-08-18 Allan Hessenflow <allanh@…>

  • Makefile.am, console/console-io.c, startup/bspstart.c: Update to use shared libcpu version of code implemented as part of bf537Stamp effort.
Location:
c/src/lib/libbsp/bfin/eZKit533
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/bfin/eZKit533/ChangeLog

    r02aaec7 rc8b1ab9  
     12008-08-18      Allan Hessenflow <allanh@kallisti.com>
     2
     3        * Makefile.am, console/console-io.c, startup/bspstart.c: Update to use
     4        shared libcpu version of code implemented as part of bf537Stamp
     5        effort.
     6
    172008-08-15      Joel Sherrill <joel.sherrill@OARcorp.com>
    28
  • c/src/lib/libbsp/bfin/eZKit533/Makefile.am

    r02aaec7 rc8b1ab9  
    2828dist_project_lib_DATA += startup/linkcmds
    2929
    30 startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
    31     ../../shared/bsppredriverhook.c startup/bspstart.c \
    32     ../../shared/bspclean.c ../../shared/sbrk.c ../../shared/setvec.c \
    33     ../../shared/bootcard.c ../../shared/gnatinstallhandler.c
    34 clock_SOURCES = ../shared/clock/clockdrv.c ../shared/clock/rtc.c
    35 console_SOURCES = console/console-io.c ../shared/console/console.c
    36 timer_SOURCES = ../shared/timer/timer.c
     30noinst_PROGRAMS += startup.rel
     31startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
     32        ../../shared/bsppredriverhook.c startup/bspstart.c \
     33        ../../shared/bspclean.c ../../shared/sbrk.c ../../shared/setvec.c \
     34        ../../shared/bootcard.c ../../shared/gnatinstallhandler.c
     35startup_rel_CPPFLAGS = $(AM_CPPFLAGS)
     36startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
     37
     38noinst_PROGRAMS += console.rel
     39console_rel_SOURCES = console/console-io.c
     40console_rel_CPPFLAGS = $(AM_CPPFLAGS)
     41console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
    3742
    3843noinst_LIBRARIES = libbsp.a
    39 libbsp_a_SOURCES = $(startup_SOURCES) $(clock_SOURCES) $(console_SOURCES) \
    40     $(timer_SOURCES)
     44libbsp_a_SOURCES =
     45libbsp_a_LIBADD = startup.rel console.rel
     46libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/mmu.rel
     47libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/interrupt.rel
     48libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/cache.rel
     49libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/uart.rel
     50libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/clock.rel
     51libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/rtc.rel
     52libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/timer.rel
    4153
    4254EXTRA_DIST += times
  • c/src/lib/libbsp/bfin/eZKit533/console/console-io.c

    r02aaec7 rc8b1ab9  
    1616 
    1717
     18#include <rtems.h>
     19#include <rtems/libio.h>
    1820#include <bsp.h>
    19 #include <cplb.h>
    20 #include <rtems/libio.h>
    21 #include <stdlib.h>
    22 #include <assert.h>
    23 #include <inttypes.h>
     21#include <rtems/bspIo.h>
    2422
    25 /*
    26  *  console_initialize_hardware
    27  *
    28  *  This routine initializes the console hardware.
    29  *
    30  */
     23#include <libcpu/bf533.h>
     24#include <libcpu/interrupt.h>
     25#include <libcpu/uart.h>
    3126
    32 /*
    33  * console_initialize_hardware does not compile with optimizations.
    34  * Makefile.am has been changed to compile the console driver with -O0.
    35  */
    36 void console_initialize_hardware(void)
    37 {
    38   unsigned int divisor;
    39  
    40   /* Set DLAB to access divisor registers */
    41   *((uint16_t*)UART_LCR) = DLAB;
     27static bfin_uart_channel_t channels[] = {
     28  {"/dev/console",
     29   (char *) UART0_BASE_ADDRESS,
     30   CONSOLE_USE_INTERRUPTS,
     31#ifdef CONSOLE_FORCE_BAUD
     32   CONSOLE_FORCE_BAUD,
     33#else
     34   0,
     35#endif
     36   NULL,
     37   0}
     38};
    4239
    43   /* Set divisor registers
    44    * BAUDRATE = SCLK/(16xDIVISOR)
    45    */
    46   divisor = SCLK/(BAUDRATE*16);                /* 1300000/(16x57600) */
    47   *((uint16_t*)UART_DLL) = (divisor & 0x00ff);
    48   *((uint16_t*)UART_DLH) = ((divisor >> 8) & 0x00ff);
     40static bfin_uart_config_t config = {
     41  SCLK,
     42  sizeof(channels) / sizeof(channels[0]),
     43  channels
     44};
    4945
    50   /* Set Control Register - 8 bits, no parity, 1 stop bit*/
    51   *((uint16_t*)UART_LCR) = WORD_8BITS;
     46#if CONSOLE_USE_INTERRUPTS
     47static bfin_isr_t bfinUARTISRs[] = {
     48  {SIC_DMA6_UART0_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
     49  {SIC_DMA7_UART0_TX_VECTOR, bfin_uart_isr, 0, 0, NULL},
     50};
     51#endif
    5252
    53   /* Enable Serial Clocks */
    54   *((uint16_t*)UART_GCTL) = UCEN;
    5553
    56   return;
     54static void eZKit533_BSP_output_char(char c) {
     55
     56  bfin_uart_poll_write(0, c);
    5757}
    5858
    59 /*
    60  *  console_outbyte_polled
    61  *
    62  *  This routine transmits a character using polling.
    63  */
     59static char eZKit533_BSP_poll_char(void) {
    6460
    65 void console_outbyte_polled(
    66   int  port,
    67   char ch
    68 )
    69 {
    70   while (!((*((uint16_t*)UART_LSR))&THRE)){} /* Wait for sending last byte */
    71   *((uint16_t*)UART_THR) = ch;
     61  return bfin_uart_poll_read(0);
    7262}
    7363
    74 /*
    75  *  console_inbyte_nonblocking
    76  *
    77  *  This routine polls for a character.
    78  */
     64BSP_output_char_function_type BSP_output_char = eZKit533_BSP_output_char;
     65BSP_polling_getchar_function_type BSP_poll_char = eZKit533_BSP_poll_char;
    7966
    80 int console_inbyte_nonblocking(
    81   int port
    82 )
    83 {
    84   char c;
    85  
    86   if ( *((uint16_t*)UART_LSR) & DR){
    87     c = *((uint16_t*)UART_RBR);
    88   }else{
    89     return -1;
     67rtems_device_driver console_initialize(rtems_device_major_number major,
     68                                       rtems_device_minor_number minor,
     69                                       void *arg) {
     70  rtems_status_code status;
     71#if CONSOLE_USE_INTERRUPTS
     72  int i;
     73#endif
     74
     75  status = bfin_uart_initialize(major, &config);
     76#if CONSOLE_USE_INTERRUPTS
     77  for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
     78    bfin_interrupt_register(&bfinUARTISRs[i]);
     79    bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
    9080  }
     81#endif
    9182
    92   return c;
     83  if (status != RTEMS_SUCCESSFUL)
     84    rtems_fatal_error_occurred(status);
     85
     86  return RTEMS_SUCCESSFUL;
    9387}
    9488
    95 #if (CONSOLE_USE_INTERRUPTS)
     89rtems_device_driver console_open(rtems_device_major_number major,
     90                                 rtems_device_minor_number minor,
     91                                 void *arg) {
    9692
    97 #include <rtems/ringbuf.h>
    98 
    99 Ring_buffer_t  TX_Buffer[ 1 ];
    100 boolean        Is_TX_active[ 1 ];
    101 
    102 extern void *console_termios_data[ 1 ];
    103 /*
    104  *  console_isr
    105  *
    106  *  This routine is the console interrupt handler for Channel A.
    107  *
    108  *  Input parameters:
    109  *    vector - vector number
    110  *
    111  *  Output parameters: NONE
    112  *
    113  *  Return values:     NONE
    114  */
    115 rtems_isr console_isr(
    116   rtems_vector_number vector
    117 )
    118 {
    119   char ch;
    120   uint16_t UStat;
    121 
    122   UStat = *((uint16_t*)UART_IIR);
    123 
    124   if ( ((UStat&0x06) == 0x04) && ( (*((uint16_t*)UART_LSR)) & DR)) {
    125     ch = *((uint16_t*)UART_RBR);
    126     rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 );
    127   }
    128 
    129   if ( ((UStat&0x06) == 0x02) && ((*((uint16_t*)UART_LSR))&THRE) ) {
    130     if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) {
    131       Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch );
    132       *((uint16_t*)UART_THR) = ch;
    133     } else {
    134       Is_TX_active[ 0 ] = FALSE;
    135     }
    136   }
     93  return bfin_uart_open(major, minor, arg);
    13794}
    13895
    139 /*
    140  *  console_exit
    141  *
    142  *  This routine allows the console to exit by masking its associated interrupt
    143  *  vectors.
    144  *
    145  *  Input parameters:  NONE
    146  *
    147  *  Output parameters: NONE
    148  *
    149  *  Return values:     NONE
    150  */
    151 void console_exit()
    152 {
    153   uint32_t         port;
    154   uint16_t         ch;
     96rtems_device_driver console_close(rtems_device_major_number major,
     97                                  rtems_device_minor_number minor,
     98                                  void *arg) {
    15599
    156   /*
    157    *  Although the interrupts for the UART are unmasked, the PIL is set to
    158    *  disable all external interrupts.  So we might as well do this first.
    159    */
    160 
    161   /* Disable UART interruptions */
    162   *((uint16_t*)UART_IER) = 0x0000;
    163   *((uint16_t*)SIC_IMASK) &= 0xFFFF3FBF;
    164 
    165   while ( !Ring_buffer_Is_empty( &TX_Buffer[ port ] ) ) {
    166     Ring_buffer_Remove_character( &TX_Buffer[ port ], ch );
    167     console_outbyte_polled( port, ch );
    168   }
    169 
    170   /*
    171    *  Now wait for all the data to actually get out ... the send register
    172    *  should be empty.
    173    */
    174 
    175   while ( !((*((uint16_t*)UART_LSR))&THRE) );
     100  return rtems_termios_close(arg);
    176101}
    177102
    178 /*
    179  *  console_initialize_interrupts
    180  *
    181  *  This routine initializes the console's receive and transmit
    182  *  ring buffers and loads the appropriate vectors to handle the interrupts.
    183  *
    184  *  Input parameters:  NONE
    185  *
    186  *  Output parameters: NONE
    187  *
    188  *  Return values:     NONE
    189  */
     103rtems_device_driver console_read(rtems_device_major_number major,
     104                                 rtems_device_minor_number minor,
     105                                 void *arg) {
    190106
    191 /*#ifdef RDB_BREAK_IN
    192   extern uint32_t   trap_table[];
    193 #endif*/
    194 
    195 void console_initialize_interrupts( void )
    196 {
    197   Ring_buffer_Initialize( &TX_Buffer[ 0 ] );
    198 
    199   Is_TX_active[ 0 ] = FALSE;
    200 
    201   atexit( console_exit );
    202 
    203   /* Setting priority - IVG10*/
    204   *((uint32_t*)SIC_IAR0)  &= 0xF0FFFFFF;
    205   *((uint32_t*)SIC_IAR0)  |= 0x03000000;
    206   *((uint32_t*)SIC_IAR1)  &= 0x00FFFFFF;
    207   *((uint32_t*)SIC_IAR1)  |= 0x33000000;
    208  
    209   /* System Interrupt Mask */
    210   *((uint32_t*)SIC_IMASK) |= 0x0000C040;
    211  
    212   set_vector( console_isr, UART_VECTOR, 1 );
    213  
    214   /* Enable UART Interruption
    215    * ELSI - RX error interrupt
    216    * ETBEI - TX buffer empty
    217    * ERBFI - RX buffer full
    218    */
    219   *((uint16_t*)UART_IER) = ELSI | ETBEI | ERBFI;
     107  return rtems_termios_read(arg);
    220108}
    221109
    222 void console_outbyte_interrupt(
    223   int   port,
    224   char  ch
    225 )
    226 {
    227   /*
    228    *  If this is the first character then we need to prime the pump
    229    */
     110rtems_device_driver console_write(rtems_device_major_number major,
     111                                  rtems_device_minor_number minor,
     112                                  void *arg) {
    230113
    231   if ( Is_TX_active[ port ] == FALSE ) {
    232     Is_TX_active[ port ] = TRUE;
    233     console_outbyte_polled( port, ch );
    234     return;
    235   }
    236 
    237   while ( Ring_buffer_Is_full( &TX_Buffer[ port ] ) );
    238 
    239   Ring_buffer_Add_character( &TX_Buffer[ port ], ch );
     114  return rtems_termios_write(arg);
    240115}
    241116
    242 #endif
     117rtems_device_driver console_control(rtems_device_major_number major,
     118                                    rtems_device_minor_number minor,
     119                                    void *arg) {
    243120
    244 #include <rtems/bspIo.h>
     121  return rtems_termios_ioctl(arg);
     122}
    245123
    246 void bfsim_BSP_output_char(char c) { console_outbyte_polled( 0, c ); }
    247 
    248 BSP_output_char_function_type           BSP_output_char = bfsim_BSP_output_char;
    249 BSP_polling_getchar_function_type       BSP_poll_char = NULL;
  • c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c

    r02aaec7 rc8b1ab9  
    2424#include <rtems/libio.h>
    2525#include <rtems/libcsupport.h>
    26 
     26#include <libcpu/interrupt.h>
    2727
    2828const unsigned int dcplbs_table[16][2] = { 
     
    104104    void         *heapStart = &HeapBase;
    105105    unsigned long heapSize = (unsigned long)&HeapSize;
     106
     107    bfin_interrupt_init();
    106108
    107109    bsp_libc_init(heapStart, heapSize, 0);
Note: See TracChangeset for help on using the changeset viewer.