source: rtems/c/src/lib/libbsp/bfin/bf537Stamp/console/console.c @ 35380ac4

4.104.115
Last change on this file since 35380ac4 was 35380ac4, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/08 at 14:10:45

2008-09-25 Joel Sherrill <joel.sherrill@…>

  • configure.ac, console/console.c: Add BFIN_ON_SKYEYE define to disable features not supported on simulator.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*  Console driver for bf537Stamp
2 *
3 *  Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
4 *             written by Allan Hessenflow <allanh@kallisti.com>
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 */
12 
13
14#include <rtems.h>
15#include <rtems/libio.h>
16#include <bsp.h>
17#include <rtems/bspIo.h>
18
19#include <libcpu/bf537.h>
20#include <libcpu/interrupt.h>
21#include <libcpu/uart.h>
22
23/*
24#undef CONSOLE_USE_INTERRUPTS
25#define CONSOLE_USE_INTERRUPTS 1
26*/
27
28static bfin_uart_channel_t channels[] = {
29  {"/dev/console",
30   (char *) UART0_BASE_ADDRESS,
31   CONSOLE_USE_INTERRUPTS,
32#ifdef CONSOLE_FORCE_BAUD
33   CONSOLE_FORCE_BAUD,
34#else
35   0,
36#endif
37   NULL,
38   0}
39
40#if (!BFIN_ON_SKYEYE)
41,
42  {"/dev/tty1",
43   (char *) UART1_BASE_ADDRESS,
44   CONSOLE_USE_INTERRUPTS,
45   0,
46   NULL,
47   0}
48#endif
49};
50
51static bfin_uart_config_t config = {
52  SCLK,
53  sizeof(channels) / sizeof(channels[0]),
54  channels
55};
56
57#if CONSOLE_USE_INTERRUPTS
58static bfin_isr_t bfinUARTISRs[] = {
59  {SIC_DMA8_UART0_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
60  {SIC_DMA10_UART1_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
61  {SIC_DMA9_UART0_TX_VECTOR, bfin_uart_isr, 0, 0, NULL},
62  {SIC_DMA11_UART1_TX_VECTOR, bfin_uart_isr, 0, 0, NULL}
63};
64#endif
65
66
67static void bf537Stamp_BSP_output_char(char c) {
68
69  bfin_uart_poll_write(0, c);
70}
71
72static char bf537Stamp_BSP_poll_char(void) {
73
74  return bfin_uart_poll_read(0);
75}
76
77BSP_output_char_function_type BSP_output_char = bf537Stamp_BSP_output_char;
78BSP_polling_getchar_function_type BSP_poll_char = bf537Stamp_BSP_poll_char;
79
80rtems_device_driver console_initialize(rtems_device_major_number major,
81                                       rtems_device_minor_number minor,
82                                       void *arg) {
83  rtems_status_code status;
84#if CONSOLE_USE_INTERRUPTS
85  int i;
86#endif
87
88  status = bfin_uart_initialize(major, &config);
89#if CONSOLE_USE_INTERRUPTS
90  for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
91    bfin_interrupt_register(&bfinUARTISRs[i]);
92    bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
93  }
94#endif
95
96  if (status != RTEMS_SUCCESSFUL)
97    rtems_fatal_error_occurred(status);
98
99  return RTEMS_SUCCESSFUL;
100}
101
102rtems_device_driver console_open(rtems_device_major_number major,
103                                 rtems_device_minor_number minor,
104                                 void *arg) {
105
106  return bfin_uart_open(major, minor, arg);
107}
108
109rtems_device_driver console_close(rtems_device_major_number major,
110                                  rtems_device_minor_number minor,
111                                  void *arg) {
112
113  return rtems_termios_close(arg);
114}
115
116rtems_device_driver console_read(rtems_device_major_number major,
117                                 rtems_device_minor_number minor,
118                                 void *arg) {
119
120  return rtems_termios_read(arg);
121}
122
123rtems_device_driver console_write(rtems_device_major_number major,
124                                  rtems_device_minor_number minor,
125                                  void *arg) {
126
127  return rtems_termios_write(arg);
128}
129
130rtems_device_driver console_control(rtems_device_major_number major,
131                                    rtems_device_minor_number minor,
132                                    void *arg) {
133
134  return rtems_termios_ioctl(arg);
135}
136
Note: See TracBrowser for help on using the repository browser.