Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:40

0001 /*  Console driver for bf537Stamp
0002  */
0003 
0004 /*
0005  *  Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
0006  *             written by Allan Hessenflow <allanh@kallisti.com>
0007  *
0008  *  The license and distribution terms for this file may be
0009  *  found in the file LICENSE in this distribution or at
0010  *  http://www.rtems.org/license/LICENSE.
0011  */
0012 
0013 
0014 #include <rtems.h>
0015 #include <rtems/libio.h>
0016 #include <bsp.h>
0017 #include <rtems/bspIo.h>
0018 #include <rtems/console.h>
0019 
0020 #include <libcpu/bf537.h>
0021 #include <libcpu/interrupt.h>
0022 #include <libcpu/uart.h>
0023 
0024 /*
0025 #undef CONSOLE_USE_INTERRUPTS
0026 #define CONSOLE_USE_INTERRUPTS 1
0027 */
0028 
0029 static bfin_uart_channel_t channels[] = {
0030     {"/dev/console",
0031      UART0_BASE_ADDRESS,
0032      0,
0033      0,
0034      CONSOLE_USE_INTERRUPTS,
0035      0,
0036   #ifdef CONSOLE_FORCE_BAUD
0037      CONSOLE_FORCE_BAUD,
0038   #else
0039      0,
0040   #endif
0041      NULL,
0042      0,
0043      0}
0044 
0045 #if (!BFIN_ON_SKYEYE)
0046 ,
0047   {"/dev/tty1",
0048    UART1_BASE_ADDRESS,
0049    CONSOLE_USE_INTERRUPTS,
0050    0,
0051    NULL,
0052    0}
0053 #endif
0054 };
0055 
0056 static bfin_uart_config_t config = {
0057   SCLK,
0058   sizeof(channels) / sizeof(channels[0]),
0059   channels
0060 };
0061 
0062 #if CONSOLE_USE_INTERRUPTS
0063 static bfin_isr_t bfinUARTISRs[] = {
0064   {SIC_DMA8_UART0_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL},
0065   {SIC_DMA10_UART1_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL},
0066   {SIC_DMA9_UART0_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL},
0067   {SIC_DMA11_UART1_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL}
0068 };
0069 #endif
0070 
0071 
0072 static void bf537Stamp_BSP_output_char(char c) {
0073 
0074   bfin_uart_poll_write(0, c);
0075 }
0076 
0077 static int bf537Stamp_BSP_poll_char(void) {
0078 
0079   return bfin_uart_poll_read(0);
0080 }
0081 
0082 BSP_output_char_function_type BSP_output_char = bf537Stamp_BSP_output_char;
0083 BSP_polling_getchar_function_type BSP_poll_char = bf537Stamp_BSP_poll_char;
0084 
0085 rtems_device_driver console_initialize(rtems_device_major_number major,
0086                                        rtems_device_minor_number minor,
0087                                        void *arg) {
0088   rtems_status_code status;
0089 #if CONSOLE_USE_INTERRUPTS
0090   int i;
0091 #endif
0092 
0093   status = bfin_uart_initialize(major, &config);
0094 #if CONSOLE_USE_INTERRUPTS
0095   for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
0096     bfin_interrupt_register(&bfinUARTISRs[i]);
0097     bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
0098   }
0099 #endif
0100 
0101   if (status != RTEMS_SUCCESSFUL)
0102     rtems_fatal_error_occurred(status);
0103 
0104   return RTEMS_SUCCESSFUL;
0105 }
0106 
0107 rtems_device_driver console_open(rtems_device_major_number major,
0108                                  rtems_device_minor_number minor,
0109                                  void *arg) {
0110 
0111   return bfin_uart_open(major, minor, arg);
0112 }
0113 
0114 rtems_device_driver console_close(rtems_device_major_number major,
0115                                   rtems_device_minor_number minor,
0116                                   void *arg) {
0117 
0118   return rtems_termios_close(arg);
0119 }
0120 
0121 rtems_device_driver console_read(rtems_device_major_number major,
0122                                  rtems_device_minor_number minor,
0123                                  void *arg) {
0124 
0125   return rtems_termios_read(arg);
0126 }
0127 
0128 rtems_device_driver console_write(rtems_device_major_number major,
0129                                   rtems_device_minor_number minor,
0130                                   void *arg) {
0131 
0132   return rtems_termios_write(arg);
0133 }
0134 
0135 rtems_device_driver console_control(rtems_device_major_number major,
0136                                     rtems_device_minor_number minor,
0137                                     void *arg) {
0138 
0139   return rtems_termios_ioctl(arg);
0140 }
0141