source: rtems/c/src/lib/libbsp/m68k/mrm332/console/console.c @ bd3e306

4.104.114.95
Last change on this file since bd3e306 was bd3e306, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/08 at 18:43:28

2008-05-12 Joel Sherrill <joel.sherrill@…>

  • console/console.c, startup/bspstart.c: Refactored and renamed initialization routines to rtems_initialize_data_structures, rtems_initialize_before_drivers, rtems_initialize_device_drivers, and rtems_initialize_start_multitasking. This opened the sequence up so that bootcard() could provide a more robust and flexible framework which is easier to explain and understand. This also lays the groundwork for sharing the division of available memory between the RTEMS workspace and heap and the C library initialization across all BSPs.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  This file contains the generic console driver shell used
3 *  by all console drivers using libchip.
4 *
5 *  This driver uses the termios pseudo driver.
6 *
7 *  COPYRIGHT (c) 1989-1997.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#include <bsp.h>
18#include <rtems/libio.h>
19#include <termios.h>
20#include "sci.h"
21
22/*PAGE
23 *
24 *  console_open
25 *
26 *  open a port as a termios console.
27 */
28
29rtems_device_driver console_open(
30  rtems_device_major_number major,
31  rtems_device_minor_number minor,
32  void                    * arg
33)
34{
35    rtems_status_code status;
36
37    /* the console is opened three times at startup */
38    /* for standard input, output, and error */
39
40    /* Get correct callback structure for the device */
41
42    /* argument of FALSE gives us interrupt driven serial io */
43    /* argument of TRUE  gives us polling   based  serial io */
44
45    /* SCI internal uart */
46
47    status = rtems_termios_open( major, minor, arg, SciGetTermiosHandlers( TRUE ) );
48
49    return status;
50}
51
52/*PAGE
53 *
54 *  console_close
55 *
56 *  This routine closes a port that has been opened as console.
57 */
58
59rtems_device_driver console_close(
60  rtems_device_major_number major,
61  rtems_device_minor_number minor,
62  void                    * arg
63)
64{
65  return rtems_termios_close (arg);
66}
67
68/*PAGE
69 *
70 *  console_read
71 *
72 *  This routine uses the termios driver to read a character.
73 */
74
75rtems_device_driver console_read(
76  rtems_device_major_number major,
77  rtems_device_minor_number minor,
78  void                    * arg
79)
80{
81  return rtems_termios_read (arg);
82}
83
84/*PAGE
85 *
86 *  console_write
87 *
88 *  this routine uses the termios driver to write a character.
89 */
90
91rtems_device_driver console_write(
92  rtems_device_major_number major,
93  rtems_device_minor_number minor,
94  void                    * arg
95)
96{
97  return rtems_termios_write (arg);
98}
99
100/*PAGE
101 *
102 *  console_control
103 *
104 *  this routine uses the termios driver to process io
105 */
106
107rtems_device_driver console_control(
108  rtems_device_major_number major,
109  rtems_device_minor_number minor,
110  void                    * arg
111)
112{
113  return rtems_termios_ioctl (arg);
114}
115
116/*PAGE
117 *
118 *  console_initialize
119 *
120 *  Routine called to initialize the console device driver.
121 */
122
123rtems_device_driver console_initialize(
124  rtems_device_major_number  major,
125  rtems_device_minor_number  minor_arg,
126  void                      *arg
127)
128{
129  rtems_status_code          status;
130
131  /*
132   * initialize the termio interface.
133   */
134  rtems_termios_initialize();
135
136  /*
137   * register the SCI device name for termios
138   * do this over in the sci driver init routine?
139   */
140
141  status = rtems_io_register_name( "/dev/sci", major, 0 );
142
143  if (status != RTEMS_SUCCESSFUL)
144  {
145    rtems_fatal_error_occurred(status);
146  }
147
148  /*
149   * Link the uart device to the console device
150   */
151
152#if 1
153  status = rtems_io_register_name( "/dev/console", major, 0 );
154
155  if (status != RTEMS_SUCCESSFUL)
156  {
157    rtems_fatal_error_occurred(status);
158  }
159#else
160  if ( link( "/dev/sci", "/dev/console") < 0 )
161  {
162    rtems_fatal_error_occurred( RTEMS_IO_ERROR );
163  }
164#endif
165
166  /*
167   * Console Initialize Succesful
168   */
169
170  return RTEMS_SUCCESSFUL;
171}
Note: See TracBrowser for help on using the repository browser.