[561e4ff6] | 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 |
---|
[0bc91860] | 26 | * http://www.rtems.com/license/LICENSE. |
---|
[561e4ff6] | 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 | |
---|
[ce9f3d1] | 40 | static rtems_driver_name_t low_level_device_info; |
---|
[561e4ff6] | 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 | { |
---|
[ce9f3d1] | 59 | rtems_device_driver status; |
---|
[561e4ff6] | 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 | |
---|
[ce9f3d1] | 70 | status = rtems_io_lookup_name( BSP_CONSOLE_DEVNAME, &low_level_device_info ); |
---|
[561e4ff6] | 71 | if (status != RTEMS_SUCCESSFUL) |
---|
| 72 | rtems_fatal_error_occurred(status); |
---|
| 73 | |
---|
| 74 | return RTEMS_SUCCESSFUL; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /* |
---|
| 79 | * Open entry point |
---|
| 80 | */ |
---|
| 81 | |
---|
| 82 | rtems_device_driver console_open( |
---|
| 83 | rtems_device_major_number major, |
---|
| 84 | rtems_device_minor_number minor, |
---|
| 85 | void * arg |
---|
| 86 | ) |
---|
| 87 | { |
---|
[ce9f3d1] | 88 | return rtems_io_open( low_level_device_info.major, |
---|
| 89 | low_level_device_info.minor, |
---|
[561e4ff6] | 90 | arg ); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | /* |
---|
| 94 | * Close entry point |
---|
| 95 | */ |
---|
| 96 | |
---|
| 97 | rtems_device_driver console_close( |
---|
| 98 | rtems_device_major_number major, |
---|
| 99 | rtems_device_minor_number minor, |
---|
| 100 | void * arg |
---|
| 101 | ) |
---|
| 102 | { |
---|
[ce9f3d1] | 103 | return rtems_io_close( low_level_device_info.major, |
---|
| 104 | low_level_device_info.minor, |
---|
[561e4ff6] | 105 | arg ); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | /* |
---|
| 109 | * read bytes from the serial port. We only have stdin. |
---|
| 110 | */ |
---|
| 111 | |
---|
| 112 | rtems_device_driver console_read( |
---|
| 113 | rtems_device_major_number major, |
---|
| 114 | rtems_device_minor_number minor, |
---|
| 115 | void * arg |
---|
| 116 | ) |
---|
| 117 | { |
---|
[ce9f3d1] | 118 | return rtems_io_read( low_level_device_info.major, |
---|
| 119 | low_level_device_info.minor, |
---|
[561e4ff6] | 120 | arg ); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | /* |
---|
| 124 | * write bytes to the serial port. Stdout and stderr are the same. |
---|
| 125 | */ |
---|
| 126 | |
---|
| 127 | rtems_device_driver console_write( |
---|
| 128 | rtems_device_major_number major, |
---|
| 129 | rtems_device_minor_number minor, |
---|
| 130 | void * arg |
---|
| 131 | ) |
---|
| 132 | { |
---|
[ce9f3d1] | 133 | return rtems_io_write( low_level_device_info.major, |
---|
| 134 | low_level_device_info.minor, |
---|
[561e4ff6] | 135 | arg ); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | /* |
---|
| 139 | * IO Control entry point |
---|
| 140 | */ |
---|
| 141 | |
---|
| 142 | rtems_device_driver console_control( |
---|
| 143 | rtems_device_major_number major, |
---|
| 144 | rtems_device_minor_number minor, |
---|
| 145 | void * arg |
---|
| 146 | ) |
---|
| 147 | { |
---|
[ce9f3d1] | 148 | return rtems_io_control( low_level_device_info.major, |
---|
| 149 | low_level_device_info.minor, |
---|
[561e4ff6] | 150 | arg ); |
---|
| 151 | } |
---|