Back to home page

LXR

 
 

    


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

0001 /*  console-io.c
0002  *
0003  *  This file contains the hardware specific portions of the TTY driver
0004  *  for the serial ports for ezkit533.
0005  *
0006  *  Copyright (c) 2006 by Atos Automacao Industrial Ltda.
0007  *             written by Alain Schaefer <alain.schaefer@easc.ch>
0008  *                    and Antonio Giovanini <antonio@atos.com.br>
0009  *
0010  *  The license and distribution terms for this file may be
0011  *  found in the file LICENSE in this distribution or at
0012  *  http://www.rtems.org/license/LICENSE.
0013  */
0014 
0015 
0016 #include <rtems.h>
0017 #include <rtems/libio.h>
0018 #include <bsp.h>
0019 #include <rtems/bspIo.h>
0020 #include <rtems/console.h>
0021 
0022 #include <libcpu/bf533.h>
0023 #include <libcpu/interrupt.h>
0024 #include <libcpu/uart.h>
0025 
0026 static bfin_uart_channel_t channels[] = {
0027   {"/dev/console",
0028    UART0_BASE_ADDRESS,
0029    0,
0030    0,
0031    CONSOLE_USE_INTERRUPTS,
0032    0,
0033 #ifdef CONSOLE_FORCE_BAUD
0034    CONSOLE_FORCE_BAUD,
0035 #else
0036    0,
0037 #endif
0038    NULL,
0039    0,
0040    0}
0041 };
0042 
0043 static bfin_uart_config_t config = {
0044   SCLK,
0045   sizeof(channels) / sizeof(channels[0]),
0046   channels
0047 };
0048 
0049 #if CONSOLE_USE_INTERRUPTS
0050 static bfin_isr_t bfinUARTISRs[] = {
0051   {SIC_DMA6_UART0_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL},
0052   {SIC_DMA7_UART0_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL},
0053 };
0054 #endif
0055 
0056 
0057 static void eZKit533_BSP_output_char(char c) {
0058 
0059   bfin_uart_poll_write(0, c);
0060 }
0061 
0062 static int eZKit533_BSP_poll_char(void) {
0063 
0064   return bfin_uart_poll_read(0);
0065 }
0066 
0067 BSP_output_char_function_type BSP_output_char = eZKit533_BSP_output_char;
0068 BSP_polling_getchar_function_type BSP_poll_char = eZKit533_BSP_poll_char;
0069 
0070 rtems_device_driver console_initialize(rtems_device_major_number major,
0071                                        rtems_device_minor_number minor,
0072                                        void *arg) {
0073   rtems_status_code status;
0074 #if CONSOLE_USE_INTERRUPTS
0075   int i;
0076 #endif
0077 
0078   status = bfin_uart_initialize(major, &config);
0079 #if CONSOLE_USE_INTERRUPTS
0080   for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
0081     bfin_interrupt_register(&bfinUARTISRs[i]);
0082     bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
0083   }
0084 #endif
0085 
0086   if (status != RTEMS_SUCCESSFUL)
0087     rtems_fatal_error_occurred(status);
0088 
0089   return RTEMS_SUCCESSFUL;
0090 }
0091 
0092 rtems_device_driver console_open(rtems_device_major_number major,
0093                                  rtems_device_minor_number minor,
0094                                  void *arg) {
0095 
0096   return bfin_uart_open(major, minor, arg);
0097 }
0098 
0099 rtems_device_driver console_close(rtems_device_major_number major,
0100                                   rtems_device_minor_number minor,
0101                                   void *arg) {
0102 
0103   return rtems_termios_close(arg);
0104 }
0105 
0106 rtems_device_driver console_read(rtems_device_major_number major,
0107                                  rtems_device_minor_number minor,
0108                                  void *arg) {
0109 
0110   return rtems_termios_read(arg);
0111 }
0112 
0113 rtems_device_driver console_write(rtems_device_major_number major,
0114                                   rtems_device_minor_number minor,
0115                                   void *arg) {
0116 
0117   return rtems_termios_write(arg);
0118 }
0119 
0120 rtems_device_driver console_control(rtems_device_major_number major,
0121                                     rtems_device_minor_number minor,
0122                                     void *arg) {
0123 
0124   return rtems_termios_ioctl(arg);
0125 }
0126