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 | * |
---|
24 | * The license and distribution terms for this file may be |
---|
25 | * found in the file LICENSE in this distribution or at |
---|
26 | * http://www.OARcorp.com/rtems/license.html. |
---|
27 | * |
---|
28 | * $Id$ |
---|
29 | */ |
---|
30 | |
---|
31 | #include <bsp.h> |
---|
32 | #include <rtems.h> |
---|
33 | #include <rtems/libio.h> |
---|
34 | #include <iosupp.h> |
---|
35 | |
---|
36 | #ifndef BSP_CONSOLE_DEVNAME |
---|
37 | #error Missing BSP_CONSOLE_DEVNAME |
---|
38 | #endif |
---|
39 | |
---|
40 | static rtems_driver_name_t *low_level_device_info = NULL ; |
---|
41 | |
---|
42 | /* console_initialize |
---|
43 | * |
---|
44 | * This routine initializes the console IO driver. |
---|
45 | * |
---|
46 | * Input parameters: NONE |
---|
47 | * |
---|
48 | * Output parameters: NONE |
---|
49 | * |
---|
50 | * Return values: |
---|
51 | */ |
---|
52 | |
---|
53 | rtems_device_driver console_initialize( |
---|
54 | rtems_device_major_number major, |
---|
55 | rtems_device_minor_number minor, |
---|
56 | void *arg |
---|
57 | ) |
---|
58 | { |
---|
59 | rtems_device_driver status ; |
---|
60 | |
---|
61 | status = rtems_io_register_name( |
---|
62 | "/dev/console", |
---|
63 | major, |
---|
64 | (rtems_device_minor_number) 0 |
---|
65 | ); |
---|
66 | |
---|
67 | if (status != RTEMS_SUCCESSFUL) |
---|
68 | rtems_fatal_error_occurred(status); |
---|
69 | |
---|
70 | status = rtems_io_lookup_name( BSP_CONSOLE_DEVNAME, |
---|
71 | &low_level_device_info ); |
---|
72 | if (status != RTEMS_SUCCESSFUL) |
---|
73 | rtems_fatal_error_occurred(status); |
---|
74 | |
---|
75 | return RTEMS_SUCCESSFUL; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | /* |
---|
80 | * Open entry point |
---|
81 | */ |
---|
82 | |
---|
83 | rtems_device_driver console_open( |
---|
84 | rtems_device_major_number major, |
---|
85 | rtems_device_minor_number minor, |
---|
86 | void * arg |
---|
87 | ) |
---|
88 | { |
---|
89 | return rtems_io_open( low_level_device_info->major, |
---|
90 | low_level_device_info->minor, |
---|
91 | arg ); |
---|
92 | } |
---|
93 | |
---|
94 | /* |
---|
95 | * Close entry point |
---|
96 | */ |
---|
97 | |
---|
98 | rtems_device_driver console_close( |
---|
99 | rtems_device_major_number major, |
---|
100 | rtems_device_minor_number minor, |
---|
101 | void * arg |
---|
102 | ) |
---|
103 | { |
---|
104 | return rtems_io_close( low_level_device_info->major, |
---|
105 | low_level_device_info->minor, |
---|
106 | arg ); |
---|
107 | } |
---|
108 | |
---|
109 | /* |
---|
110 | * read bytes from the serial port. We only have stdin. |
---|
111 | */ |
---|
112 | |
---|
113 | rtems_device_driver console_read( |
---|
114 | rtems_device_major_number major, |
---|
115 | rtems_device_minor_number minor, |
---|
116 | void * arg |
---|
117 | ) |
---|
118 | { |
---|
119 | return rtems_io_read( low_level_device_info->major, |
---|
120 | low_level_device_info->minor, |
---|
121 | arg ); |
---|
122 | } |
---|
123 | |
---|
124 | /* |
---|
125 | * write bytes to the serial port. Stdout and stderr are the same. |
---|
126 | */ |
---|
127 | |
---|
128 | rtems_device_driver console_write( |
---|
129 | rtems_device_major_number major, |
---|
130 | rtems_device_minor_number minor, |
---|
131 | void * arg |
---|
132 | ) |
---|
133 | { |
---|
134 | return rtems_io_write( low_level_device_info->major, |
---|
135 | low_level_device_info->minor, |
---|
136 | arg ); |
---|
137 | } |
---|
138 | |
---|
139 | /* |
---|
140 | * IO Control entry point |
---|
141 | */ |
---|
142 | |
---|
143 | rtems_device_driver console_control( |
---|
144 | rtems_device_major_number major, |
---|
145 | rtems_device_minor_number minor, |
---|
146 | void * arg |
---|
147 | ) |
---|
148 | { |
---|
149 | return rtems_io_control( low_level_device_info->major, |
---|
150 | low_level_device_info->minor, |
---|
151 | arg ); |
---|
152 | } |
---|