source: rtems/c/src/lib/libbsp/m68k/idp/console/console.c @ 98100d2

4.104.114.84.95
Last change on this file since 98100d2 was 98100d2, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 27, 1998 at 5:09:47 PM

Monstrous patch from Ralf Corsepius <corsepiu@…>. I have
made no attempt to divide the comments up and place them with just
the appropriate files. Here is an excerpt from Ralf's email:

Changes including comments on changes I made after cycling through
all the targets:

  • Added ranlib support. Now all targets use "ranlib" instead of "ar -s" to build an index for a library. If ranlib isn't detected during configuration, check if ar -s is working and try "ar -s" instead of
  • Removed $(XXX_FOR_TARGET) from make/target.cfg.in, use $(XXX) instead now.
  • gcc-target-default.cfg: LINK_XXXX-defines reworked to solve the -l problem under posix (cf gcc-target-default.cfg)
  • rtems-glom replaced by Makefile-rules inside of the wrapup/Makefile.in that has been using rtems-glom until now.
  • Removed CCC and friends in gcc-target-default.cfg, as they have been breaking CXX support.
  • Removed CONFIG.$(TARGET_ARCH).CC lines from several custom/*.cfg files, because this is now set in custom/default.cfg.
  • Added aclocal/ar-s.m4, check whether "ar -s" is working
  • Added aclocal/cygwin.m4 and aclocal/exeext.m4.
  • Reworked aclocal/canonicalize-tools.m4: Added ar -s check; fixes for problems when XXX_FOR_TARGET is given via environment variables (didn't work for gcc until now), adding cygwin check, improved autoconf-cache handling.
  • Removed -l from make rule dependencies. LINK_LIBS is now allowed to contain -L and -l. LINK_OBJS and LINK_FILES must not contain -L or -l. gcc28 make-exe rules now link using $(LINK_OBJS) $(LINK_LIBS) => Almost all custom/*.cfg are modified. This is very likely to break something because of typos or having missed to edit a file.

Open problems, known bugs, things I didn't do:

  • custom/p4000.cfg seems to be out of date and requires to be reviewed.

(JRS NOTE: It is subordinate p4650 and p4600 -- both of which build ok

after minor changes.)

  • custom/psim.cfg needs to be reviewed, I added some changes to it, I am insecure about.

(JRS NOTE: psim had a minor problem endif/endef swapped but runs fine.)

  • rtems-glom.in can now be removed.
  • gcc*.cfg files "make depend" rules don't honor language specific flags (e.g CXXFLAGS is ignored for *.cc) - Nothing to worry about now, but may cause problems for hosts/targets not using gcc or rtems-add-ons that use external packages.
  • AFAIS, the no_bsp BSP can't be build anymore, i.e. configure refused to configure for it whatever I tried.
  • The toplevel and toplevel+1 README files are quite out-dated
  • cygwin.m4 isn't of much use for rtems. In most cases (cf. aclocal/*.m4) it is worked around by directly using $host_os. I think I'll remove it soon after the next snapshot
  • Before release the cygwin patch needs to be tested under cygwin. I may have broken/missed something (esp. the sed-pattern to convert
    into / may be broken).
  • You should try to build/run the posix-BSP under solaris - I don't expect problems, but I am not 100% sure, esp. with regard to ranlib/ar -s.
  • You should consider to convert all make/compilers/*.cfg files into make/compilers/*.cfg.in files and let autoconf generate the *.cfg. This may help getting rid of some if/then/else statements and help hard-coding some defines into those files in future and shouldn't disturb now.
  • Not having installed libc.a/libm.a on a host may still break building rtems, esp. when using -disable-gcc28 as the gcc27-configuration scheme directly accesses libc.a and libm.a. The problem should not appear when using gcc28 because it references libc/libm only through -lc and -lm which may be static or dynamic (I didn't test this).
  • shgen is not yet included (I didn't yet have enough time to integrate it).
  • I know about a few more configure-probs (esp. cross-checking --enable-* flags).

+ warn/refuse to configure when --enable-libcdir and

--enable-gcc28 are given.

+ force --enable-libcdir when --disable-gcc28 is given

  • Replaced KSHELL with @KSH@ in some shell scripts generated by configure.in.
  • Added a dependency to aclocal/*.m4 in the toplevel Makefile => configure and aclocal.m4 will now be rebuild when any aclocal/*.m4 file is changed
  • Some changes to aclocal/gcc-pipe.m4 and aclocal/gcc-specs.m4
  • Replaced i3456?86-unknown-freebsd2.12? with i3456?86-*freebsd2.* in configure.in, as I suppose there might exist a variety of valid vendors (2nd field of the name-tripple)
  • Disabled override MAKEFLAGS in toplevel Makefile.in - Potential side-effects are not really clear to me.
  • In mvme162.cfg, $(LINK_LIBS) is missing in the CC line in gcc28's make-exe rule (yet another one I missed to edit). Just append $(LINK_LIBS) to the "CC" line, like I hopefully did to ALL other custom/*.cfg files.
  • the problem with mvme162lx.cfg is a follow-up problem of the mvme162.cfg-bug.
  • mvme162/console and idp/console had variables named Buffer which conflicted with similarly named variables in some tests.
  • Property mode set to 100644
File size: 5.0 KB
Line 
1/* 
2 *  This file contains the Motorola IDP console IO package.
3 *
4 *  Written by Doug McBride, Colorado Space Grant College
5 *  Based off of the board support packages of RTEMS
6 *
7 *  Updated to RTEMS 3.2.0 by Joel Sherrill.
8 *
9 *  $Id$
10 */
11
12#define MIDP_INIT
13
14#include <bsp.h>
15#include <rtems/libio.h>
16
17#include <ringbuf.h>
18
19Ring_buffer_t  Console_Buffer[ 2 ];
20
21rtems_isr C_Receive_ISR(rtems_vector_number vector);
22
23/*  console_initialize
24 *
25 *  This routine initializes the console IO driver.
26 *
27 *  Input parameters: NONE
28 *
29 *  Output parameters:  NONE
30 *
31 *  Return values:
32 */
33
34rtems_device_driver console_initialize(
35  rtems_device_major_number  major,
36  rtems_device_minor_number  minor,
37  void                      *arg
38)
39{
40  rtems_status_code status;
41
42  Ring_buffer_Initialize( &Console_Buffer[ 0 ] );
43  Ring_buffer_Initialize( &Console_Buffer[ 1 ] );
44
45  init_pit();
46
47  status = rtems_io_register_name(
48    "/dev/console",
49    major,
50    (rtems_device_minor_number) 0
51  );
52 
53  if (status != RTEMS_SUCCESSFUL)
54    rtems_fatal_error_occurred(status);
55 
56  status = rtems_io_register_name(
57    "/dev/tty00",
58    major,
59    (rtems_device_minor_number) 0
60  );
61 
62  if (status != RTEMS_SUCCESSFUL)
63    rtems_fatal_error_occurred(status);
64 
65  status = rtems_io_register_name(
66    "/dev/tty01",
67    major,
68    (rtems_device_minor_number) 1
69  );
70 
71  if (status != RTEMS_SUCCESSFUL)
72    rtems_fatal_error_occurred(status);
73 
74  return RTEMS_SUCCESSFUL;
75}
76
77
78/*  is_character_ready
79 *
80 *  This routine returns TRUE if a character is available.
81 *
82 *  Input parameters: NONE
83 *
84 *  Output parameters:  NONE
85 *
86 *  Return values:
87 */
88
89rtems_boolean is_character_ready( 
90  char *ch,
91  int   port
92)
93{
94  if ( Ring_buffer_Is_empty( &Console_Buffer[ port ] ) )
95    return FALSE;
96
97  Ring_buffer_Remove_character( &Console_Buffer[ port ], *ch );
98  return TRUE;
99}
100
101/*  quick_char_check
102 *
103 *  This routine returns TRUE if a character is available.
104 *  It is different from above because it does not disturb the ring buffer
105 *
106 *  Input parameters: NONE
107 *
108 *  Output parameters:  NONE
109 *
110 *  Return values:
111 */
112
113rtems_boolean quick_char_check( 
114  int   port
115)
116{
117  if ( Ring_buffer_Is_empty( &Console_Buffer[ port ] ) )
118    return FALSE;
119
120  return TRUE;
121}
122
123/*  inbyte
124 *
125 *  This routine reads a character from the UART through a buffer.
126 *
127 *  Input parameters: NONE
128 *
129 *  Output parameters:  NONE
130 *
131 *  Return values:
132 *    character read from UART
133 */
134
135char inbyte( 
136  int port
137)
138{
139  unsigned char tmp_char;
140 
141  /* If you come into this routine without checking is_character_ready() first
142     and you want nonblocking code, then it's your own fault */
143
144  while ( !is_character_ready( &tmp_char, port ) );
145 
146  return tmp_char;
147}
148
149
150/*  outbyte
151 *
152 *  This routine transmits a character out the M68681.  It supports
153 *  XON/XOFF flow control.
154 *
155 *  Input parameters:
156 *    ch  - character to be transmitted
157 *
158 *  Output parameters:  NONE
159 */
160
161void outbyte( 
162  char ch,
163  int  port
164)
165{
166  switch ( port ) {
167    case 0:
168      transmit_char( ch );
169      break;
170    case 1:
171      transmit_char_portb( ch );
172      break;
173  }
174
175}
176
177/*
178 *  Open entry point
179 */
180
181rtems_device_driver console_open(
182  rtems_device_major_number major,
183  rtems_device_minor_number minor,
184  void                    * arg
185)
186{
187  return RTEMS_SUCCESSFUL;
188}
189 
190/*
191 *  Close entry point
192 */
193
194rtems_device_driver console_close(
195  rtems_device_major_number major,
196  rtems_device_minor_number minor,
197  void                    * arg
198)
199{
200  return RTEMS_SUCCESSFUL;
201}
202
203/*
204 * read bytes from the serial port. We only have stdin.
205 */
206
207rtems_device_driver console_read(
208  rtems_device_major_number major,
209  rtems_device_minor_number minor,
210  void                    * arg
211)
212{
213  rtems_libio_rw_args_t *rw_args;
214  char *buffer;
215  int maximum;
216  int count = 0;
217 
218  rw_args = (rtems_libio_rw_args_t *) arg;
219
220  buffer = rw_args->buffer;
221  maximum = rw_args->count;
222
223  if ( minor > 1 )
224    return RTEMS_INVALID_NUMBER;
225
226  for (count = 0; count < maximum; count++) {
227    buffer[ count ] = inbyte( minor );
228    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
229      buffer[ count++ ]  = '\n';
230      break;
231    }
232  }
233
234  rw_args->bytes_moved = count;
235  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
236}
237
238/*
239 * write bytes to the serial port. Stdout and stderr are the same.
240 */
241
242rtems_device_driver console_write(
243  rtems_device_major_number major,
244  rtems_device_minor_number minor,
245  void                    * arg
246)
247{
248  int count;
249  int maximum;
250  rtems_libio_rw_args_t *rw_args;
251  char *buffer;
252
253  rw_args = (rtems_libio_rw_args_t *) arg;
254
255  buffer = rw_args->buffer;
256  maximum = rw_args->count;
257
258  if ( minor > 1 )
259    return RTEMS_INVALID_NUMBER;
260
261  for (count = 0; count < maximum; count++) {
262    if ( buffer[ count ] == '\n') {
263      outbyte('\r', minor );
264    }
265    outbyte( buffer[ count ], minor  );
266  }
267
268  rw_args->bytes_moved = maximum;
269  return 0;
270}
271
272/*
273 *  IO Control entry point
274 */
275
276rtems_device_driver console_control(
277  rtems_device_major_number major,
278  rtems_device_minor_number minor,
279  void                    * arg
280)
281{
282  return RTEMS_SUCCESSFUL;
283}
Note: See TracBrowser for help on using the repository browser.