source: rtems/c/src/lib/libbsp/powerpc/psim/console/console.c @ 0903597f

4.104.114.84.95
Last change on this file since 0903597f was 0903597f, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/98 at 17:26:41

psim now runs in both debug and non-debug mode.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  This file contains the hardware specific portions of the TTY driver
3 *  for the serial ports on the erc32.
4 *
5 *  COPYRIGHT (c) 1989-1997.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <rtems/libio.h>
18#include <stdlib.h>
19#include <assert.h>
20
21
22/*
23 *  console_outbyte_polled
24 *
25 *  This routine transmits a character using polling.
26 */
27
28void console_outbyte_polled(
29  int  port,
30  char ch
31)
32{
33  outbyte( ch );
34}
35
36/*
37 *  console_inbyte_nonblocking
38 *
39 *  This routine polls for a character.
40 */
41
42int console_inbyte_nonblocking(
43  int port
44)
45{
46  char c;
47
48  c = inbyte();
49  if (!c)
50    return -1;
51  return c;
52}
53
54/*
55 *  DEBUG_puts
56 *
57 *  This should be safe in the event of an error.  It attempts to insure
58 *  that no TX empty interrupts occur while it is doing polled IO.  Then
59 *  it restores the state of that external interrupt.
60 *
61 *  Input parameters:
62 *    string  - pointer to debug output string
63 *
64 *  Output parameters:  NONE
65 *
66 *  Return values:      NONE
67 */
68
69void DEBUG_puts(
70  char *string
71)
72{
73  char *s;
74
75  /* XXX should disable interrupts around this if interrupt driven */
76
77  for ( s = string ; *s ; s++ )
78    console_outbyte_polled( 0, *s );
79
80  console_outbyte_polled( 0, '\r' );
81  console_outbyte_polled( 0, '\n' );
82}
83
84
85/*
86 *  Console Termios Support Entry Points
87 *
88 */
89
90int console_write_support (int minor, char *buf, int len)
91{
92  int nwrite = 0;
93
94  while (nwrite < len) {
95    console_outbyte_polled( minor, *buf++ );
96    nwrite++;
97  }
98  return nwrite;
99}
100
101/*
102 *  Console Device Driver Entry Points
103 *
104 */
105 
106rtems_device_driver console_initialize(
107  rtems_device_major_number  major,
108  rtems_device_minor_number  minor,
109  void                      *arg
110)
111{
112  rtems_status_code status;
113
114  rtems_termios_initialize();
115
116  /*
117   *  Register Device Names
118   */
119
120  status = rtems_io_register_name( "/dev/console", major, 0 );
121  if (status != RTEMS_SUCCESSFUL)
122    rtems_fatal_error_occurred(status);
123
124  return RTEMS_SUCCESSFUL;
125}
126
127rtems_device_driver console_open(
128  rtems_device_major_number major,
129  rtems_device_minor_number minor,
130  void                    * arg
131)
132{
133        rtems_status_code sc;
134
135        assert( minor <= 1 );
136        if ( minor > 2 )
137          return RTEMS_INVALID_NUMBER;
138 
139        sc = rtems_termios_open (major, minor, arg,
140                        NULL,
141                        NULL,
142                        console_inbyte_nonblocking,
143                        console_write_support,
144                        0);
145
146  return RTEMS_SUCCESSFUL;
147}
148 
149rtems_device_driver console_close(
150  rtems_device_major_number major,
151  rtems_device_minor_number minor,
152  void                    * arg
153)
154{
155  return rtems_termios_close (arg);
156}
157 
158rtems_device_driver console_read(
159  rtems_device_major_number major,
160  rtems_device_minor_number minor,
161  void                    * arg
162)
163{
164  return rtems_termios_read (arg);
165}
166 
167rtems_device_driver console_write(
168  rtems_device_major_number major,
169  rtems_device_minor_number minor,
170  void                    * arg
171)
172{
173  return rtems_termios_write (arg);
174}
175 
176rtems_device_driver console_control(
177  rtems_device_major_number major,
178  rtems_device_minor_number minor,
179  void                    * arg
180)
181{
182  return rtems_termios_ioctl (arg);
183}
184
185void console_reserve_resources(
186  rtems_configuration_table *configuration
187)
188{
189  rtems_termios_reserve_resources( configuration, 1 );
190}
Note: See TracBrowser for help on using the repository browser.