source: rtems/c/src/lib/libbsp/powerpc/eth_comm/console/console.c @ bbb71a15

4.104.114.84.95
Last change on this file since bbb71a15 was bbb71a15, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 1, 2002 at 9:54:20 PM

2002-11-01 Joel Sherrill <joel@…>

  • canbus/canbus.c, clock/p_clock.c, console/console.c, network/network.c, startup/bspstart.c: Removed warnings.
  • Property mode set to 100644
File size: 5.9 KB
Line 
1#define I_WANT_TERMIOS
2/*
3 *  BSP specific Serial I/O Functions for the eth-comm BSP
4 *
5 * This file contains the BSP specific functions for
6 * performing serial I/O. These are the functions
7 * RTEMS uses (the 6 listed in the device driver
8 * structure)
9 *
10 * The SCCs and SMCs are assigned as follows
11 *
12 *   Channel     Device      Minor   Termios
13 *    SMC1      /dev/tty0      0       no
14 *    SMC2      /dev/tty1      1       no
15 *    SCC1      ethernet
16 *    SCC2      /dev/console   3       yes
17 *    SCC3      /dev/tty3      4       no
18 *    SCC4      /dev/tty4      5       no
19 *
20 * FIXME: This should use termios for /dev/console, but it doesn't
21 *  appear to work correctly yet. On startup, with termios enabled,
22 *  the board hangs for a few seconds before running correctly
23 *
24 * Author: Jay Monkman (jmonkman@frasca.com)
25 * Copyright (C) 1998 by Frasca International, Inc.
26 *
27 *  $Id$
28 */
29
30#include <bsp.h>                /* Must be before libio.h */
31#include <rtems/libio.h>
32#include <termios.h>
33#include <rtems/bspIo.h>
34
35extern void rtems_panic(char *,int);
36
37static void _BSP_null_char( char c ) {return;}
38BSP_output_char_function_type BSP_output_char = _BSP_null_char;
39
40rtems_device_driver console_initialize(rtems_device_major_number major,
41                                       rtems_device_minor_number minor,
42                                       void *arg)
43{
44  rtems_status_code status;
45 
46#ifdef I_WANT_TERMIOS
47  /*
48   * Set up TERMIOS (for /dev/console)
49   */
50  rtems_termios_initialize();
51#endif
52
53  /*
54   *  Do common initialization.
55   */
56  m8xx_uart_initialize();
57
58  /*
59   * Do device-specific initialization
60   */
61  m8xx_uart_smc_initialize(SMC1_MINOR); /* /dev/tty0 */
62  m8xx_uart_smc_initialize(SMC2_MINOR); /* /dev/tty1 */                             
63  m8xx_uart_scc_initialize(SCC2_MINOR); /* /dev/tty2    */
64  m8xx_uart_scc_initialize(SCC3_MINOR); /* /dev/tty3    */
65  m8xx_uart_scc_initialize(SCC4_MINOR); /* /dev/tty4    */
66 
67  /*
68   * Register the devices
69   */
70  status = rtems_io_register_name ("/dev/console", major, SCC2_MINOR);
71  if (status != RTEMS_SUCCESSFUL)
72    rtems_fatal_error_occurred (status);
73  status = rtems_io_register_name ("/dev/tty0", major, SMC1_MINOR);
74  if (status != RTEMS_SUCCESSFUL)
75    rtems_fatal_error_occurred (status);
76  status = rtems_io_register_name ("/dev/tty1", major, SMC2_MINOR);
77  if (status != RTEMS_SUCCESSFUL)
78    rtems_fatal_error_occurred (status);
79  status = rtems_io_register_name ("/dev/tty3", major, SCC3_MINOR);
80  if (status != RTEMS_SUCCESSFUL)
81    rtems_fatal_error_occurred (status);
82  status = rtems_io_register_name ("/dev/tty4", major, SCC4_MINOR);
83  if (status != RTEMS_SUCCESSFUL)
84    rtems_fatal_error_occurred (status);
85  return RTEMS_SUCCESSFUL;
86}
87 
88rtems_device_driver console_open(rtems_device_major_number major,
89                                 rtems_device_minor_number minor,
90                                 void *arg)
91{
92  volatile m8xxSCCRegisters_t *sccregs;
93
94#ifdef I_WANT_TERMIOS
95  static const rtems_termios_callbacks sccPollCallbacks = {
96    NULL,                       /* firstOpen */
97    NULL,                       /* lastClose */
98    m8xx_uart_pollRead,        /* pollRead */
99    m8xx_uart_pollWrite,       /* write */
100    m8xx_uart_setAttributes,    /* setAttributes */
101    NULL,                       /* stopRemoteTx */
102    NULL,                       /* startRemoteTx */
103    0                           /* outputUsesInterrupts */
104  };
105#endif /* I_WANT_TERMIOS */
106
107  sccregs = 0;
108
109  switch (minor) {
110  case 0:
111    m8xx.smc1.smcm = 1;           /* Enable SMC1 RX interrupts */
112    break;
113  case 1:
114    m8xx.smc2.smcm = 1;           /* Enable SMC2 RX interrupts */
115    break;
116  case 2:
117    sccregs = &m8xx.scc1;
118    break;
119  case 3: 
120    sccregs = &m8xx.scc2;
121    break;
122  case 4:
123    sccregs = &m8xx.scc3;
124    break;
125  case 5:
126    sccregs = &m8xx.scc4;
127    break;
128  default:
129    rtems_panic ("CONSOLE: bad minor number", 0);
130  }
131
132  if (sccregs)
133    sccregs->sccm=0x3;
134
135#ifdef I_WANT_TERMIOS
136  if (minor == SCC2_MINOR) {
137    return rtems_termios_open (major, minor, arg, &sccPollCallbacks);
138  }
139  else { 
140    return RTEMS_SUCCESSFUL;
141  }
142#else
143  return RTEMS_SUCCESSFUL;
144#endif
145}
146
147rtems_device_driver console_close(rtems_device_major_number major,
148                                  rtems_device_minor_number minor,
149                                  void *arg)
150{
151#ifdef I_WANT_TERMIOS
152  if (minor == SCC2_MINOR) {
153    return rtems_termios_close (arg);
154  }
155  else {
156    return RTEMS_SUCCESSFUL;
157  }
158#else
159  return RTEMS_SUCCESSFUL;
160#endif
161}
162
163rtems_device_driver console_read(rtems_device_major_number major,
164                                 rtems_device_minor_number minor,
165                                 void *arg)
166{
167#ifdef I_WANT_TERMIOS
168  /*
169  if (minor == SCC2_MINOR) {
170  */
171    return rtems_termios_read(arg);
172  /*
173  }
174  else {
175    return m8xx_console_read(major, minor, arg);
176  }
177  */
178#else
179  return m8xx_console_read(major, minor, arg);
180#endif
181}
182
183rtems_device_driver console_write(rtems_device_major_number major,
184                                  rtems_device_minor_number minor,
185                                  void *arg)
186{
187#ifdef I_WANT_TERMIOS
188  /*
189  if (minor == SCC2_MINOR) {
190  */
191    return rtems_termios_write(arg);
192  /*
193  }
194  else {
195    return m8xx_console_write(major, minor, arg);
196  }
197  */
198#else
199  return m8xx_console_write(major, minor, arg);
200#endif
201}
202
203/*
204 * Handle ioctl request.
205 * Should set hardware line speed, bits/char, etc.
206 */
207rtems_device_driver console_control(rtems_device_major_number major,
208                                    rtems_device_minor_number minor,
209                                    void *arg)
210{ 
211#ifdef I_WANT_TERMIOS
212  if (minor == SCC2_MINOR) {
213    return rtems_termios_ioctl (arg);
214  }
215  else {
216    return RTEMS_SUCCESSFUL;
217  }
218#else
219  return RTEMS_SUCCESSFUL;
220#endif
221}
222
223/*
224 *  Support routine for console-generic
225 */
226
227int mbx8xx_console_get_configuration(void)
228{
229#if NVRAM_CONFIGURE == 1
230  return nvram->console_mode;
231#else
232#if UARTS_IO_MODE == 1
233  return 0x02;
234#else
235  return 0;
236#endif
237#endif
238
239}
240
Note: See TracBrowser for help on using the repository browser.