source: rtems/c/src/lib/libbsp/i960/cvme961/console/console.c @ 49ed8e7

4.104.114.84.95
Last change on this file since 49ed8e7 was 49ed8e7, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 16, 2001 at 6:50:03 PM

2001-10-16 Ralf Corsepius <corsepiu@…>

  • include/zilog/Makefile.am: Remove.
  • include/motorola/Makefile.am: Remove.
  • include/sys/Makefile.am: Remove.
  • include/rtems/Makefile.am: Remove.
  • include/Makefile.am: Handle subdirs, require automake-1.5
  • Makefile.am: Require automake-1.5.
  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 *  This file contains the CVME961 console IO package.
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <bsp.h>
15#include <rtems/libio.h>
16
17/*  console_initialize
18 *
19 *  This routine initializes the console IO driver.
20 *
21 *  Input parameters: NONE
22 *
23 *  Output parameters:  NONE
24 *
25 *  Return values:
26 */
27
28rtems_device_driver console_initialize(
29  rtems_device_major_number  major,
30  rtems_device_minor_number  minor,
31  void                      *arg
32)
33{
34 rtems_status_code status;
35 
36  status = rtems_io_register_name(
37    "/dev/console",
38    major,
39    (rtems_device_minor_number) 0
40  );
41 
42  if (status != RTEMS_SUCCESSFUL)
43    rtems_fatal_error_occurred(status);
44 
45  return RTEMS_SUCCESSFUL;
46}
47
48/*
49 *  NINDY_IO( ... )
50 *
51 *  Interface to NINDY.
52 */
53
54#define NINDY_INPUT   0
55#define NINDY_OUTPUT  1
56
57void NINDY_IO();
58
59void ___NINDY_IO_WRAPPER( void )  /* never called */
60{
61   asm volatile ( "       .text" );
62   asm volatile ( "       .align 4" );
63   asm volatile ( "       .globl _NINDY_IO" );
64   asm volatile ( "_NINDY_IO:" );
65   asm volatile ( "        calls   0       /* call console routines */" );
66   asm volatile ( "        ret" );
67}
68
69/*  inbyte
70 *
71 *  This routine reads a character from the console using NINDY.
72 *
73 *  Input parameters: NONE
74 *
75 *  Output parameters:  NONE
76 *
77 *  Return values:
78 *    character read from UART
79 */
80
81char inbyte( void )
82{
83  char ch;
84
85  NINDY_IO( NINDY_INPUT, &ch );
86  return ch;
87}
88
89
90/*  outbyte
91 *
92 *  This routine transmits a character out the console using NINDY.
93 *
94 *  Input parameters:
95 *    ch  - character to be transmitted
96 *
97 *  Output parameters:  NONE
98 */
99
100void outbyte(
101  char ch
102)
103{
104  NINDY_IO( NINDY_OUTPUT, ch );
105}
106
107/*
108 *  Open entry point
109 */
110 
111rtems_device_driver console_open(
112  rtems_device_major_number major,
113  rtems_device_minor_number minor,
114  void                    * arg
115)
116{
117  return RTEMS_SUCCESSFUL;
118}
119 
120/*
121 *  Close entry point
122 */
123 
124rtems_device_driver console_close(
125  rtems_device_major_number major,
126  rtems_device_minor_number minor,
127  void                    * arg
128)
129{
130  return RTEMS_SUCCESSFUL;
131}
132 
133/*
134 * read bytes from the serial port. We only have stdin.
135 */
136 
137rtems_device_driver console_read(
138  rtems_device_major_number major,
139  rtems_device_minor_number minor,
140  void                    * arg
141)
142{
143  rtems_libio_rw_args_t *rw_args;
144  char *buffer;
145  int maximum;
146  int count = 0;
147 
148  rw_args = (rtems_libio_rw_args_t *) arg;
149 
150  buffer = rw_args->buffer;
151  maximum = rw_args->count;
152 
153  for (count = 0; count < maximum; count++) {
154    buffer[ count ] = inbyte();
155    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
156      buffer[ count++ ]  = '\n';
157      break;
158    }
159  }
160 
161  rw_args->bytes_moved = count;
162  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
163}
164 
165/*
166 * write bytes to the serial port. Stdout and stderr are the same.
167 */
168 
169rtems_device_driver console_write(
170  rtems_device_major_number major,
171  rtems_device_minor_number minor,
172  void                    * arg
173)
174{
175  int count;
176  int maximum;
177  rtems_libio_rw_args_t *rw_args;
178  char *buffer;
179 
180  rw_args = (rtems_libio_rw_args_t *) arg;
181 
182  buffer = rw_args->buffer;
183  maximum = rw_args->count;
184 
185  for (count = 0; count < maximum; count++) {
186    if ( buffer[ count ] == '\n') {
187      outbyte('\r');
188    }
189    outbyte( buffer[ count ] );
190  }
191
192  rw_args->bytes_moved = maximum;
193  return 0;
194}
195 
196/*
197 *  IO Control entry point
198 */
199 
200rtems_device_driver console_control(
201  rtems_device_major_number major,
202  rtems_device_minor_number minor,
203  void                    * arg
204)
205{
206  return RTEMS_SUCCESSFUL;
207}
208
Note: See TracBrowser for help on using the repository browser.