source: rtems/c/src/lib/libbsp/i960/cvme961/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: 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  return maximum;
196}
197 
198/*
199 *  IO Control entry point
200 */
201 
202rtems_device_driver console_control(
203  rtems_device_major_number major,
204  rtems_device_minor_number minor,
205  void                    * arg
206)
207{
208  return RTEMS_SUCCESSFUL;
209}
210
Note: See TracBrowser for help on using the repository browser.