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

4.104.114.84.9
Last change on this file since 8ef3818 was 8ef3818, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 12, 2000 at 7:57:02 PM

Patch from John Cotton <john.cotton@…>, Charles-Antoine Gauthier
<charles.gauthier@…>, and Darlene A. Stewart
<Darlene.Stewart@…> to add support for a number of very
significant things:

+ BSPs for many variations on the Motorola MBX8xx board series
+ Cache Manager including initial support for m68040

and PowerPC

+ Rework of mpc8xx libcpu code so all mpc8xx CPUs now use

same code base.

+ Rework of eth_comm BSP to utiltize above.

John reports this works on the 821 and 860

  • Property mode set to 100644
File size: 6.0 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
34rtems_device_driver console_initialize(rtems_device_major_number major,
35                                       rtems_device_minor_number minor,
36                                       void *arg)
37{
38  rtems_status_code status;
39 
40#ifdef I_WANT_TERMIOS
41  /*
42   * Set up TERMIOS (for /dev/console)
43   */
44  rtems_termios_initialize();
45#endif
46
47  /*
48   *  Do common initialization.
49   */
50  m8xx_uart_initialize();
51
52  /*
53   * Do device-specific initialization
54   */
55  m8xx_uart_smc_initialize(SMC1_MINOR); /* /dev/tty0 */
56  m8xx_uart_smc_initialize(SMC2_MINOR); /* /dev/tty1 */                             
57  m8xx_uart_scc_initialize(SCC2_MINOR); /* /dev/tty2    */
58  m8xx_uart_scc_initialize(SCC3_MINOR); /* /dev/tty3    */
59  m8xx_uart_scc_initialize(SCC4_MINOR); /* /dev/tty4    */
60 
61  /*
62   * Set up interrupts
63   */
64   m8xx_uart_interrupts_initialize();
65
66  /*
67   * Register the devices
68   */
69  status = rtems_io_register_name ("/dev/console", major, SCC2_MINOR);
70  if (status != RTEMS_SUCCESSFUL)
71    rtems_fatal_error_occurred (status);
72  status = rtems_io_register_name ("/dev/tty0", major, SMC1_MINOR);
73  if (status != RTEMS_SUCCESSFUL)
74    rtems_fatal_error_occurred (status);
75  status = rtems_io_register_name ("/dev/tty1", major, SMC2_MINOR);
76  if (status != RTEMS_SUCCESSFUL)
77    rtems_fatal_error_occurred (status);
78  status = rtems_io_register_name ("/dev/tty3", major, SCC3_MINOR);
79  if (status != RTEMS_SUCCESSFUL)
80    rtems_fatal_error_occurred (status);
81  status = rtems_io_register_name ("/dev/tty4", major, SCC4_MINOR);
82  if (status != RTEMS_SUCCESSFUL)
83    rtems_fatal_error_occurred (status);
84  return RTEMS_SUCCESSFUL;
85}
86 
87rtems_device_driver console_open(rtems_device_major_number major,
88                                 rtems_device_minor_number minor,
89                                 void *arg)
90{
91  volatile m8xxSCCRegisters_t *sccregs;
92
93#ifdef I_WANT_TERMIOS
94  static const rtems_termios_callbacks sccPollCallbacks = {
95    NULL,                       /* firstOpen */
96    NULL,                       /* lastClose */
97    m8xx_uart_pollRead,        /* pollRead */
98    m8xx_uart_pollWrite,       /* write */
99    m8xx_uart_setAttributes,    /* setAttributes */
100    NULL,                       /* stopRemoteTx */
101    NULL,                       /* startRemoteTx */
102    0                           /* outputUsesInterrupts */
103  };
104#endif /* I_WANT_TERMIOS */
105
106  sccregs = 0;
107
108  switch (minor) {
109  case 0:
110    m8xx.smc1.smcm = 1;           /* Enable SMC1 RX interrupts */
111    m8xx.cimr |= 1UL <<  4;       /* Enable SMC1 interrupts */
112    break;
113  case 1:
114    m8xx.smc2.smcm = 1;           /* Enable SMC2 RX interrupts */
115    m8xx.cimr |= 1UL <<  3;       /* Enable SMC2 interrupts */
116    break;
117  case 2:
118    m8xx.cimr |= 1UL << 30;      /* Enable SCC1 interrupts */
119    sccregs = &m8xx.scc1;
120    break;
121  case 3: 
122#ifndef I_WANT_TERMIOS
123    m8xx.cimr |= 1UL << 29;      /* Enable SCC2 interrupts */
124#endif /* I_WANT_TERMIOS */
125    sccregs = &m8xx.scc2;
126    break;
127  case 4:
128    m8xx.cimr |= 1UL << 28;      /* Enable SCC3 interrupts */
129    sccregs = &m8xx.scc3;
130    break;
131  case 5:
132    m8xx.cimr |= 1UL << 27;      /* Enable SCC4 interrupts */
133    sccregs = &m8xx.scc4;
134    break;
135  default:
136    rtems_panic ("CONSOLE: bad minor number");
137  }
138
139  if (sccregs)
140    sccregs->sccm=0x3;
141
142#ifdef I_WANT_TERMIOS
143  if (minor == SCC2_MINOR) {
144    return rtems_termios_open (major, minor, arg, &sccPollCallbacks);
145  }
146  else { 
147    return RTEMS_SUCCESSFUL;
148  }
149#else
150  return RTEMS_SUCCESSFUL;
151#endif
152}
153
154rtems_device_driver console_close(rtems_device_major_number major,
155                                  rtems_device_minor_number minor,
156                                  void *arg)
157{
158#ifdef I_WANT_TERMIOS
159  if (minor == SCC2_MINOR) {
160    return rtems_termios_close (arg);
161  }
162  else {
163    return RTEMS_SUCCESSFUL;
164  }
165#else
166  return RTEMS_SUCCESSFUL;
167#endif
168}
169
170rtems_device_driver console_read(rtems_device_major_number major,
171                                 rtems_device_minor_number minor,
172                                 void *arg)
173{
174#ifdef I_WANT_TERMIOS
175  /*
176  if (minor == SCC2_MINOR) {
177  */
178    return rtems_termios_read(arg);
179  /*
180  }
181  else {
182    return m8xx_console_read(major, minor, arg);
183  }
184  */
185#else
186  return m8xx_console_read(major, minor, arg);
187#endif
188}
189
190rtems_device_driver console_write(rtems_device_major_number major,
191                                  rtems_device_minor_number minor,
192                                  void *arg)
193{
194#ifdef I_WANT_TERMIOS
195  /*
196  if (minor == SCC2_MINOR) {
197  */
198    return rtems_termios_write(arg);
199  /*
200  }
201  else {
202    return m8xx_console_write(major, minor, arg);
203  }
204  */
205#else
206  return m8xx_console_write(major, minor, arg);
207#endif
208}
209
210/*
211 * Handle ioctl request.
212 * Should set hardware line speed, bits/char, etc.
213 */
214rtems_device_driver console_control(rtems_device_major_number major,
215                                    rtems_device_minor_number minor,
216                                    void *arg)
217{ 
218#ifdef I_WANT_TERMIOS
219  if (minor == SCC2_MINOR) {
220    return rtems_termios_ioctl (arg);
221  }
222  else {
223    return RTEMS_SUCCESSFUL;
224  }
225#else
226  return RTEMS_SUCCESSFUL;
227#endif
228}
229
Note: See TracBrowser for help on using the repository browser.