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

5
Last change on this file since b2ed712 was ba5de753, checked in by Sebastian Huber <sebastian.huber@…>, on 07/25/16 at 11:57:52

bsps: Fix shared polled console fatal error

Fatal errors must uniquely identify the source location.

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