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

4.115
Last change on this file since 8df1f408 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  This file contains the hardware independent portion of a polled
3 *  console device driver.  If a BSP chooses to use this, then it
4 *  only has to provide a few board dependent routines.
5 *
6 *  COPYRIGHT (c) 1989-1997.
7 *  On-Line Applications Research Corporation (OAR).
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.rtems.org/license/LICENSE.
12 */
13
14#include <bsp.h>
15#include <rtems/libio.h>
16#include <stdlib.h>
17#include <assert.h>
18
19/* external prototypes for monitor interface routines */
20
21void console_outbyte_polled(
22  int  port,
23  char ch
24);
25
26int console_inbyte_nonblocking(
27  int port
28);
29
30void console_initialize_hardware(void);
31
32/*
33 *  Console Termios Support Entry Points
34 *
35 */
36ssize_t console_write_support (
37  int         minor,
38  const char *bufarg,
39  size_t      len
40)
41{
42  int nwrite = 0;
43  const char *buf = bufarg;
44
45  while (nwrite < len) {
46    console_outbyte_polled( minor, *buf++ );
47    nwrite++;
48  }
49  return nwrite;
50}
51
52/*
53 *  Console Device Driver Entry Points
54 *
55 */
56
57rtems_device_driver console_initialize(
58  rtems_device_major_number  major,
59  rtems_device_minor_number  minor,
60  void                      *arg
61)
62{
63  rtems_status_code status;
64
65  /*
66   *  Ensure Termios is initialized
67   */
68  rtems_termios_initialize();
69
70  /*
71   *  Make sure the hardware is initialized.
72   */
73  console_initialize_hardware();
74
75  /*
76   *  Register Device Names
77   */
78  status = rtems_io_register_name( "/dev/console", major, 0 );
79  if (status != RTEMS_SUCCESSFUL)
80    rtems_fatal_error_occurred(status);
81
82  return RTEMS_SUCCESSFUL;
83}
84
85rtems_device_driver console_open(
86  rtems_device_major_number major,
87  rtems_device_minor_number minor,
88  void                    * arg
89)
90{
91  static const rtems_termios_callbacks pollCallbacks = {
92    NULL,                        /* firstOpen */
93    NULL,                        /* lastClose */
94    console_inbyte_nonblocking,  /* pollRead */
95    console_write_support,       /* write */
96    NULL,                        /* setAttributes */
97    NULL,                        /* stopRemoteTx */
98    NULL,                        /* startRemoteTx */
99    0                            /* outputUsesInterrupts */
100  };
101
102  assert( minor <= 1 );
103  if ( minor > 1 )
104    return RTEMS_INVALID_NUMBER;
105
106  rtems_termios_open( major, minor, arg, &pollCallbacks );
107
108  return RTEMS_SUCCESSFUL;
109}
110
111rtems_device_driver console_close(
112  rtems_device_major_number major,
113  rtems_device_minor_number minor,
114  void                    * arg
115)
116{
117  return rtems_termios_close( arg );
118}
119
120rtems_device_driver console_read(
121  rtems_device_major_number major,
122  rtems_device_minor_number minor,
123  void                    * arg
124)
125{
126  return rtems_termios_read( arg );
127}
128
129rtems_device_driver console_write(
130  rtems_device_major_number major,
131  rtems_device_minor_number minor,
132  void                    * arg
133)
134{
135  return rtems_termios_write( arg );
136}
137
138rtems_device_driver console_control(
139  rtems_device_major_number major,
140  rtems_device_minor_number minor,
141  void                    * arg
142)
143{
144  return rtems_termios_ioctl( arg );
145}
Note: See TracBrowser for help on using the repository browser.