source: rtems/c/src/lib/libbsp/i960/cvme961/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: 3.9 KB
Line 
1/*
2 *  This file contains the CVME961 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 C961_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 *  NINDY_IO( ... )
53 *
54 *  Interface to NINDY.
55 */
56
57#define NINDY_INPUT   0
58#define NINDY_OUTPUT  1
59
60void NINDY_IO();
61
62void ___NINDY_IO_WRAPPER( void )  /* never called */
63{
64   asm volatile ( "       .text" );
65   asm volatile ( "       .align 4" );
66   asm volatile ( "       .globl _NINDY_IO" );
67   asm volatile ( "_NINDY_IO:" );
68   asm volatile ( "        calls   0       /* call console routines */" );
69   asm volatile ( "        ret" );
70}
71
72/*  inbyte
73 *
74 *  This routine reads a character from the console using NINDY.
75 *
76 *  Input parameters: NONE
77 *
78 *  Output parameters:  NONE
79 *
80 *  Return values:
81 *    character read from UART
82 */
83
84char inbyte( void )
85{
86  char ch;
87
88  NINDY_IO( NINDY_INPUT, &ch );
89  return ch;
90}
91
92
93/*  outbyte
94 *
95 *  This routine transmits a character out the console using NINDY.
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  NINDY_IO( NINDY_OUTPUT, ch );
108}
109
110/*
111 *  Open entry point
112 */
113 
114rtems_device_driver console_open(
115  rtems_device_major_number major,
116  rtems_device_minor_number minor,
117  void                    * arg
118)
119{
120  return RTEMS_SUCCESSFUL;
121}
122 
123/*
124 *  Close entry point
125 */
126 
127rtems_device_driver console_close(
128  rtems_device_major_number major,
129  rtems_device_minor_number minor,
130  void                    * arg
131)
132{
133  return RTEMS_SUCCESSFUL;
134}
135 
136/*
137 * read bytes from the serial port. We only have stdin.
138 */
139 
140rtems_device_driver console_read(
141  rtems_device_major_number major,
142  rtems_device_minor_number minor,
143  void                    * arg
144)
145{
146  rtems_libio_rw_args_t *rw_args;
147  char *buffer;
148  int maximum;
149  int count = 0;
150 
151  rw_args = (rtems_libio_rw_args_t *) arg;
152 
153  buffer = rw_args->buffer;
154  maximum = rw_args->count;
155 
156  for (count = 0; count < maximum; count++) {
157    buffer[ count ] = inbyte();
158    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
159      buffer[ count++ ]  = '\n';
160      buffer[ count ]  = 0;
161      break;
162    }
163  }
164 
165  rw_args->bytes_moved = count;
166  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
167}
168 
169/*
170 * write bytes to the serial port. Stdout and stderr are the same.
171 */
172 
173rtems_device_driver console_write(
174  rtems_device_major_number major,
175  rtems_device_minor_number minor,
176  void                    * arg
177)
178{
179  int count;
180  int maximum;
181  rtems_libio_rw_args_t *rw_args;
182  char *buffer;
183 
184  rw_args = (rtems_libio_rw_args_t *) arg;
185 
186  buffer = rw_args->buffer;
187  maximum = rw_args->count;
188 
189  for (count = 0; count < maximum; count++) {
190    if ( buffer[ count ] == '\n') {
191      outbyte('\r');
192    }
193    outbyte( buffer[ count ] );
194  }
195
196  rw_args->bytes_moved = maximum;
197  return 0;
198}
199 
200/*
201 *  IO Control entry point
202 */
203 
204rtems_device_driver console_control(
205  rtems_device_major_number major,
206  rtems_device_minor_number minor,
207  void                    * arg
208)
209{
210  return RTEMS_SUCCESSFUL;
211}
212
Note: See TracBrowser for help on using the repository browser.