source: rtems/c/src/lib/libbsp/shared/console-polled.c @ e182c620

4.104.114.84.95
Last change on this file since e182c620 was e182c620, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 3, 2001 at 4:44:17 PM

2001-01-03 Joel Sherrill <joel@…>

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