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

4.104.114.84.95
Last change on this file since 96e62937 was bfeee88, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/01 at 21:04:47

2001-10-12 Joel Sherrill <joel@…>

  • console-polled.c, console.c: Fixed typo.
  • 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 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <bsp.h>
16#include <rtems/libio.h>
17#include <stdlib.h>
18#include <assert.h>
19
20/* external prototypes for monitor interface routines */
21
22void console_outbyte_polled(
23  int  port,
24  char ch
25);
26
27int console_inbyte_nonblocking(
28  int port
29);
30
31void console_initialize_hardware(void);
32
33/*
34 *  Console Termios Support Entry Points
35 *
36 */
37
38int console_write_support (
39  int minor,
40  const char *bufarg,
41  int len
42)
43{
44  int nwrite = 0;
45  const char *buf = bufarg;
46
47  while (nwrite < len) {
48    console_outbyte_polled( minor, *buf++ );
49    nwrite++;
50  }
51  return nwrite;
52}
53
54/*
55 *  Console Device Driver Entry Points
56 *
57 */
58 
59rtems_device_driver console_initialize(
60  rtems_device_major_number  major,
61  rtems_device_minor_number  minor,
62  void                      *arg
63)
64{
65  rtems_status_code status;
66
67  rtems_termios_initialize();
68
69  /*
70   *  Make sure the hardware is initialized.
71   */
72
73  console_initialize_hardware();
74
75  /*
76   *  Register Device Names
77   */
78
79  status = rtems_io_register_name( "/dev/console", major, 0 );
80  if (status != RTEMS_SUCCESSFUL)
81    rtems_fatal_error_occurred(status);
82
83  return RTEMS_SUCCESSFUL;
84}
85
86rtems_device_driver console_open(
87  rtems_device_major_number major,
88  rtems_device_minor_number minor,
89  void                    * arg
90)
91{
92  rtems_status_code sc;
93  static const rtems_termios_callbacks pollCallbacks = {
94    NULL,                        /* firstOpen */
95    NULL,                        /* lastClose */
96    console_inbyte_nonblocking,  /* pollRead */
97    console_write_support,       /* write */
98    NULL,                        /* setAttributes */
99    NULL,                        /* stopRemoteTx */
100    NULL,                        /* startRemoteTx */
101    0                            /* outputUsesInterrupts */
102  };
103
104
105  assert( minor <= 1 );
106  if ( minor > 2 )
107    return RTEMS_INVALID_NUMBER;
108 
109  sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
110
111  return RTEMS_SUCCESSFUL;
112}
113 
114rtems_device_driver console_close(
115  rtems_device_major_number major,
116  rtems_device_minor_number minor,
117  void                    * arg
118)
119{
120  return rtems_termios_close (arg);
121}
122 
123rtems_device_driver console_read(
124  rtems_device_major_number major,
125  rtems_device_minor_number minor,
126  void                    * arg
127)
128{
129  return rtems_termios_read (arg);
130}
131 
132rtems_device_driver console_write(
133  rtems_device_major_number major,
134  rtems_device_minor_number minor,
135  void                    * arg
136)
137{
138  return rtems_termios_write (arg);
139}
140 
141rtems_device_driver console_control(
142  rtems_device_major_number major,
143  rtems_device_minor_number minor,
144  void                    * arg
145)
146{
147  return rtems_termios_ioctl (arg);
148}
149
Note: See TracBrowser for help on using the repository browser.