OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [shared/] [console-polled.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  This file contains the hardware specific portions of the TTY driver
3
 *  for the serial ports on the erc32.
4
 *
5
 *  COPYRIGHT (c) 1989-1997.
6
 *  On-Line Applications Research Corporation (OAR).
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  console-polled.c,v 1.4 2001/10/12 21:04:47 joel Exp
13
 */
14
 
15
#include <bsp.h>
16
#include <rtems/libio.h>
17
#include <stdlib.h>
18
#include <assert.h>
19
 
20
/* external prototypes for monitor interface routines */
21
 
22
void console_outbyte_polled(
23
  int  port,
24
  char ch
25
);
26
 
27
int console_inbyte_nonblocking(
28
  int port
29
);
30
 
31
void console_initialize_hardware(void);
32
 
33
/*
34
 *  Console Termios Support Entry Points
35
 *
36
 */
37
 
38
int 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
 
59
rtems_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
  rtems_termios_initialize();
68
 
69
  /*
70
   *  Make sure the hardware is initialized.
71
   */
72
 
73
  console_initialize_hardware();
74
 
75
  /*
76
   *  Register Device Names
77
   */
78
 
79
  status = rtems_io_register_name( "/dev/console", major, 0 );
80
  if (status != RTEMS_SUCCESSFUL)
81
    rtems_fatal_error_occurred(status);
82
 
83
  return RTEMS_SUCCESSFUL;
84
}
85
 
86
rtems_device_driver console_open(
87
  rtems_device_major_number major,
88
  rtems_device_minor_number minor,
89
  void                    * arg
90
)
91
{
92
  rtems_status_code sc;
93
  static const rtems_termios_callbacks pollCallbacks = {
94
    NULL,                        /* firstOpen */
95
    NULL,                        /* lastClose */
96
    console_inbyte_nonblocking,  /* pollRead */
97
    console_write_support,       /* write */
98
    NULL,                        /* setAttributes */
99
    NULL,                        /* stopRemoteTx */
100
    NULL,                        /* startRemoteTx */
101
 
102
  };
103
 
104
 
105
  assert( minor <= 1 );
106
  if ( minor > 2 )
107
    return RTEMS_INVALID_NUMBER;
108
 
109
  sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
110
 
111
  return RTEMS_SUCCESSFUL;
112
}
113
 
114
rtems_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
 
123
rtems_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
 
132
rtems_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
 
141
rtems_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
}
149
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.