source: rtems/c/src/lib/libbsp/c4x/c4xsim/console/console.c @ 61ba9763

4.104.114.84.95
Last change on this file since 61ba9763 was 61ba9763, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 22, 2000 at 6:39:52 PM

New port of RTEMS to TI C3x and C4x.

  • Property mode set to 100644
File size: 3.1 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#include <simio.h>
22
23/*
24 *  console_outbyte_polled
25 *
26 *  This routine transmits a character using polling.
27 */
28
29void console_outbyte_polled(
30  int  port,
31  char ch
32);
33
34/*
35 *  console_inbyte_nonblocking
36 *
37 *  This routine polls for a character.
38 */
39
40int console_inbyte_nonblocking(
41  int port
42);
43
44/*
45 *  Console Termios Support Entry Points
46 *
47 */
48
49int console_write_support (
50  int minor,
51  const char *bufarg,
52  int len
53)
54{
55  int nwrite = 0;
56  const char *buf = bufarg;
57
58  while (nwrite < len) {
59    if ( *buf )
60      console_outbyte_polled( minor, *buf & 0x7f );
61    buf++;
62    nwrite++;
63  }
64  return nwrite;
65}
66
67/*
68 *  Console Device Driver Entry Points
69 *
70 */
71 
72rtems_device_driver console_initialize(
73  rtems_device_major_number  major,
74  rtems_device_minor_number  minor,
75  void                      *arg
76)
77{
78  rtems_status_code status;
79
80  rtems_termios_initialize();
81
82  /*
83   *  Register Device Names
84   */
85
86  status = rtems_io_register_name( "/dev/console", major, 0 );
87  if (status != RTEMS_SUCCESSFUL)
88    rtems_fatal_error_occurred(status);
89
90  return RTEMS_SUCCESSFUL;
91}
92
93rtems_device_driver console_open(
94  rtems_device_major_number major,
95  rtems_device_minor_number minor,
96  void                    * arg
97)
98{
99  rtems_status_code sc;
100  static const rtems_termios_callbacks pollCallbacks = {
101    NULL,                        /* firstOpen */
102    NULL,                        /* lastClose */
103    console_inbyte_nonblocking,  /* pollRead */
104    console_write_support,       /* write */
105    NULL,                        /* setAttributes */
106    NULL,                        /* stopRemoteTx */
107    NULL,                        /* startRemoteTx */
108    0                            /* outputUsesInterrupts */
109  };
110
111
112  assert( minor <= 1 );
113  if ( minor > 2 )
114    return RTEMS_INVALID_NUMBER;
115 
116  sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
117
118  return RTEMS_SUCCESSFUL;
119}
120 
121rtems_device_driver console_close(
122  rtems_device_major_number major,
123  rtems_device_minor_number minor,
124  void                    * arg
125)
126{
127  return rtems_termios_close (arg);
128}
129 
130rtems_device_driver console_read(
131  rtems_device_major_number major,
132  rtems_device_minor_number minor,
133  void                    * arg
134)
135{
136  return rtems_termios_read (arg);
137}
138 
139rtems_device_driver console_write(
140  rtems_device_major_number major,
141  rtems_device_minor_number minor,
142  void                    * arg
143)
144{
145  return rtems_termios_write (arg);
146}
147 
148rtems_device_driver console_control(
149  rtems_device_major_number major,
150  rtems_device_minor_number minor,
151  void                    * arg
152)
153{
154  return rtems_termios_ioctl (arg);
155}
Note: See TracBrowser for help on using the repository browser.