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

4.104.114.9
Last change on this file since b642940 was b642940, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 30, 2008 at 11:00:39 PM

2008-08-30 Joel Sherrill <joel.sherrill@…>

  • bootcard.c: Fix formatting.
  • console-polled.c: Error if minor < 2 not just <= 2.
  • 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 *  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 */
38
39int console_write_support (
40  int minor,
41  const char *bufarg,
42  int len
43)
44{
45  int nwrite = 0;
46  const char *buf = bufarg;
47
48  while (nwrite < len) {
49    console_outbyte_polled( minor, *buf++ );
50    nwrite++;
51  }
52  return nwrite;
53}
54
55/*
56 *  Console Device Driver Entry Points
57 *
58 */
59
60rtems_device_driver console_initialize(
61  rtems_device_major_number  major,
62  rtems_device_minor_number  minor,
63  void                      *arg
64)
65{
66  rtems_status_code status;
67
68  rtems_termios_initialize();
69
70  /*
71   *  Make sure the hardware is initialized.
72   */
73
74  console_initialize_hardware();
75
76  /*
77   *  Register Device Names
78   */
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.