source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c @ ced11f99

4.104.114.84.95
Last change on this file since ced11f99 was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 *  This file contains the template for a console IO package.
3 *
4 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
5 *  On-Line Applications Research Corporation (OAR).
6 *  All rights assigned to U.S. Government, 1994.
7 *
8 *  This material may be reproduced by or for the U.S. Government pursuant
9 *  to the copyright license under the clause at DFARS 252.227-7013.  This
10 *  notice must appear in all copies of this file and its derivatives.
11 *
12 *  $Id$
13 */
14
15#define NO_BSP_INIT
16
17#include <bsp.h>
18#include <rtems/libio.h>
19
20/*  console_initialize
21 *
22 *  This routine initializes the console IO driver.
23 *
24 *  Input parameters: NONE
25 *
26 *  Output parameters:  NONE
27 *
28 *  Return values:
29 */
30
31rtems_device_driver console_initialize(
32  rtems_device_major_number  major,
33  rtems_device_minor_number  minor,
34  void                      *arg
35)
36{
37  rtems_status_code status;
38 
39  status = rtems_io_register_name(
40    "/dev/console",
41    major,
42    (rtems_device_minor_number) 0
43  );
44 
45  if (status != RTEMS_SUCCESSFUL)
46    rtems_fatal_error_occurred(status);
47 
48  return RTEMS_SUCCESSFUL;
49}
50
51
52/*  is_character_ready
53 *
54 *  This routine returns TRUE if a character is available.
55 *
56 *  Input parameters: NONE
57 *
58 *  Output parameters:  NONE
59 *
60 *  Return values:
61 */
62
63rtems_boolean is_character_ready(
64  char *ch
65)
66{
67  *ch = '\0';   /* return NULL for no particular reason */
68  return(TRUE);
69}
70
71/*  inbyte
72 *
73 *  This routine reads a character from the SOURCE.
74 *
75 *  Input parameters: NONE
76 *
77 *  Output parameters:  NONE
78 *
79 *  Return values:
80 *    character read from SOURCE
81 */
82
83char inbyte( void )
84{
85  /*
86   *  If polling, wait until a character is available.
87   */
88
89  return '\0';
90}
91
92/*  outbyte
93 *
94 *  This routine transmits a character out the SOURCE.  It may support
95 *  XON/XOFF flow control.
96 *
97 *  Input parameters:
98 *    ch  - character to be transmitted
99 *
100 *  Output parameters:  NONE
101 */
102
103void outbyte(
104  char ch
105)
106{
107  /*
108   *  If polling, wait for the transmitter to be ready.
109   *  Check for flow control requests and process.
110   *  Then output the character.
111   */
112
113  /*
114   *  Carriage Return/New line translation.
115   */
116
117  if ( ch == '\n' )
118    outbyte( '\r' );
119}
120
121
122/*
123 *  Open entry point
124 */
125
126rtems_device_driver console_open(
127  rtems_device_major_number major,
128  rtems_device_minor_number minor,
129  void                    * arg
130)
131{
132  return RTEMS_SUCCESSFUL;
133}
134 
135/*
136 *  Close entry point
137 */
138
139rtems_device_driver console_close(
140  rtems_device_major_number major,
141  rtems_device_minor_number minor,
142  void                    * arg
143)
144{
145  return RTEMS_SUCCESSFUL;
146}
147
148/*
149 * read bytes from the serial port. We only have stdin.
150 */
151
152rtems_device_driver console_read(
153  rtems_device_major_number major,
154  rtems_device_minor_number minor,
155  void                    * arg
156)
157{
158  rtems_libio_rw_args_t *rw_args;
159  char *buffer;
160  int maximum;
161  int count = 0;
162 
163  rw_args = (rtems_libio_rw_args_t *) arg;
164
165  buffer = rw_args->buffer;
166  maximum = rw_args->count;
167
168  for (count = 0; count < maximum; count++) {
169    buffer[ count ] = inbyte();
170    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
171      buffer[ count++ ]  = '\n';
172      buffer[ count ]  = 0;
173      break;
174    }
175  }
176
177  rw_args->bytes_moved = count;
178  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
179}
180
181/*
182 * write bytes to the serial port. Stdout and stderr are the same.
183 */
184
185rtems_device_driver console_write(
186  rtems_device_major_number major,
187  rtems_device_minor_number minor,
188  void                    * arg
189)
190{
191  int count;
192  int maximum;
193  rtems_libio_rw_args_t *rw_args;
194  char *buffer;
195
196  rw_args = (rtems_libio_rw_args_t *) arg;
197
198  buffer = rw_args->buffer;
199  maximum = rw_args->count;
200
201  for (count = 0; count < maximum; count++) {
202    if ( buffer[ count ] == '\n') {
203      outbyte('\r');
204    }
205    outbyte( buffer[ count ] );
206  }
207  return maximum;
208}
209
210/*
211 *  IO Control entry point
212 */
213
214rtems_device_driver console_control(
215  rtems_device_major_number major,
216  rtems_device_minor_number minor,
217  void                    * arg
218)
219{
220  return RTEMS_SUCCESSFUL;
221}
Note: See TracBrowser for help on using the repository browser.