source: rtems/c/src/lib/libbsp/sh/shared/console.c @ 561e4ff6

4.104.114.84.95
Last change on this file since 561e4ff6 was 561e4ff6, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 22, 1999 at 2:03:16 PM

Adding files missed by earlier merger of SH-2.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * /dev/console for Hitachi SH 703X
3 *
4 * The SH doesn't have a designated console device. Therefore we "alias"
5 * another device as /dev/console and revector all calls to /dev/console
6 * to this device.
7 *
8 * This approach is similar to installing a sym-link from one device to
9 * another device. If rtems once will support sym-links for devices files,
10 * this implementation could be dropped.
11 *
12 *  Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de)
13 *
14 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
15 *
16 *  This program is distributed in the hope that it will be useful,
17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 *
21 *  COPYRIGHT (c) 1998.
22 *  On-Line Applications Research Corporation (OAR).
23 *  Copyright assigned to U.S. Government, 1994.
24 *
25 *  The license and distribution terms for this file may be
26 *  found in the file LICENSE in this distribution or at
27 *  http://www.OARcorp.com/rtems/license.html.
28 *
29 *  $Id$
30 */
31
32#include <bsp.h>
33#include <rtems.h>
34#include <rtems/libio.h>
35#include <iosupp.h>
36
37#ifndef BSP_CONSOLE_DEVNAME
38#error Missing BSP_CONSOLE_DEVNAME
39#endif
40
41static rtems_driver_name_t *low_level_device_info = NULL ;
42
43/*  console_initialize
44 *
45 *  This routine initializes the console IO driver.
46 *
47 *  Input parameters: NONE
48 *
49 *  Output parameters:  NONE
50 *
51 *  Return values:
52 */
53
54rtems_device_driver console_initialize(
55  rtems_device_major_number  major,
56  rtems_device_minor_number  minor,
57  void                      *arg
58)
59{
60  rtems_device_driver status ;
61 
62  status = rtems_io_register_name(
63    "/dev/console",
64    major,
65    (rtems_device_minor_number) 0
66  );
67
68  if (status != RTEMS_SUCCESSFUL)
69    rtems_fatal_error_occurred(status);
70
71  status = rtems_io_lookup_name( BSP_CONSOLE_DEVNAME, 
72    &low_level_device_info );
73  if (status != RTEMS_SUCCESSFUL)
74    rtems_fatal_error_occurred(status);
75
76  return RTEMS_SUCCESSFUL;
77}
78
79
80/*
81 *  Open entry point
82 */
83
84rtems_device_driver console_open(
85  rtems_device_major_number major,
86  rtems_device_minor_number minor,
87  void                    * arg
88)
89{
90  return rtems_io_open( low_level_device_info->major,
91    low_level_device_info->minor,
92    arg );
93}
94 
95/*
96 *  Close entry point
97 */
98
99rtems_device_driver console_close(
100  rtems_device_major_number major,
101  rtems_device_minor_number minor,
102  void                    * arg
103)
104{
105  return rtems_io_close( low_level_device_info->major,
106    low_level_device_info->minor,
107    arg );
108}
109
110/*
111 * read bytes from the serial port. We only have stdin.
112 */
113
114rtems_device_driver console_read(
115  rtems_device_major_number major,
116  rtems_device_minor_number minor,
117  void                    * arg
118)
119{
120  return rtems_io_read( low_level_device_info->major,
121    low_level_device_info->minor,
122    arg );
123}
124
125/*
126 * write bytes to the serial port. Stdout and stderr are the same.
127 */
128
129rtems_device_driver console_write(
130  rtems_device_major_number major,
131  rtems_device_minor_number minor,
132  void                    * arg
133)
134{
135  return rtems_io_write( low_level_device_info->major,
136    low_level_device_info->minor,
137    arg );
138}
139
140/*
141 *  IO Control entry point
142 */
143
144rtems_device_driver console_control(
145  rtems_device_major_number major,
146  rtems_device_minor_number minor,
147  void                    * arg
148)
149{
150  return rtems_io_control( low_level_device_info->major,
151    low_level_device_info->minor,
152    arg );
153}
Note: See TracBrowser for help on using the repository browser.