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

4.115
Last change on this file since 991fdb33 was 6279149, checked in by Joel Sherrill <joel.sherrill@…>, on 10/08/14 at 21:04:56

Add console-polled.h and update all BSPs that should use it.

The file console-polled.h provides the prototypes for the three
required methods when implementing a single port polled console
driver. This paradigm is common on simulators and simple hardware.

+ Updated the BSPs Makefile.am to make console-polled.h available.
+ Regenerated the BSPs preinstall.sm.
+ Updated console support files to include <bsp/console-polled.h>.
+ Updated console support files to make printk() support method static.

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