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

4.104.115
Last change on this file since f1e8903 was f1e8903, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/09 at 18:24:10

2009-08-28 Joel Sherrill <joel.sherrill@…>

  • bootcard.c, bsplibc.c, clockdrv_shell.h, console-polled.c: Fix formatting.
  • 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.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <rtems/libio.h>
18#include <stdlib.h>
19#include <assert.h>
20
21/* external prototypes for monitor interface routines */
22
23void console_outbyte_polled(
24  int  port,
25  char ch
26);
27
28int console_inbyte_nonblocking(
29  int port
30);
31
32void console_initialize_hardware(void);
33
34/*
35 *  Console Termios Support Entry Points
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  /*
68   *  Ensure Termios is initialized
69   */
70  rtems_termios_initialize();
71
72  /*
73   *  Make sure the hardware is initialized.
74   */
75  console_initialize_hardware();
76
77  /*
78   *  Register Device Names
79   */
80  status = rtems_io_register_name( "/dev/console", major, 0 );
81  if (status != RTEMS_SUCCESSFUL)
82    rtems_fatal_error_occurred(status);
83
84  return RTEMS_SUCCESSFUL;
85}
86
87rtems_device_driver console_open(
88  rtems_device_major_number major,
89  rtems_device_minor_number minor,
90  void                    * arg
91)
92{
93  rtems_status_code sc;
94  static const rtems_termios_callbacks pollCallbacks = {
95    NULL,                        /* firstOpen */
96    NULL,                        /* lastClose */
97    console_inbyte_nonblocking,  /* pollRead */
98    console_write_support,       /* write */
99    NULL,                        /* setAttributes */
100    NULL,                        /* stopRemoteTx */
101    NULL,                        /* startRemoteTx */
102    0                            /* outputUsesInterrupts */
103  };
104
105  assert( minor <= 1 );
106  if ( minor > 1 )
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}
Note: See TracBrowser for help on using the repository browser.