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

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on 09/19/95 at 14:53:29

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[ac7d5ef0]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
[3a4ae6c]17#include <bsp.h>
18#include <rtems/libio.h>
[ac7d5ef0]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,
[3a4ae6c]34  void                      *arg
[ac7d5ef0]35)
36{
[3a4ae6c]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;
[ac7d5ef0]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
[3a4ae6c]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 
[ac7d5ef0]135/*
[3a4ae6c]136 *  Close entry point
[ac7d5ef0]137 */
138
[3a4ae6c]139rtems_device_driver console_close(
140  rtems_device_major_number major,
141  rtems_device_minor_number minor,
142  void                    * arg
[ac7d5ef0]143)
144{
[3a4ae6c]145  return RTEMS_SUCCESSFUL;
146}
147
148/*
149 * read bytes from the serial port. We only have stdin.
150 */
[ac7d5ef0]151
[3a4ae6c]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;
[ac7d5ef0]173      break;
174    }
175  }
[3a4ae6c]176
177  rw_args->bytes_moved = count;
178  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
[ac7d5ef0]179}
180
181/*
[3a4ae6c]182 * write bytes to the serial port. Stdout and stderr are the same.
[ac7d5ef0]183 */
184
[3a4ae6c]185rtems_device_driver console_write(
186  rtems_device_major_number major,
187  rtems_device_minor_number minor,
188  void                    * arg
[ac7d5ef0]189)
190{
[3a4ae6c]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;
[ac7d5ef0]197
[3a4ae6c]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');
[ac7d5ef0]204    }
[3a4ae6c]205    outbyte( buffer[ count ] );
[ac7d5ef0]206  }
[3652ad35]207
208  rw_args->bytes_moved = maximum;
209  return 0;
[3a4ae6c]210}
211
212/*
213 *  IO Control entry point
214 */
215
216rtems_device_driver console_control(
217  rtems_device_major_number major,
218  rtems_device_minor_number minor,
219  void                    * arg
220)
221{
222  return RTEMS_SUCCESSFUL;
[ac7d5ef0]223}
Note: See TracBrowser for help on using the repository browser.