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

4.115
Last change on this file since 9073f554 was 9073f554, checked in by Joel Sherrill <joel.sherrill@…>, on 10/07/14 at 15:02:11

libbsp/shared/console-polled.c: Fix warning

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