]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/standalone/m68k/m68020/mvme136/console.c
Update to LGPL v2.1.
[thirdparty/glibc.git] / sysdeps / standalone / m68k / m68020 / mvme136 / console.c
1 /* Copyright (C) 1994, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
4 On-Line Applications Research Corporation.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 #include <standalone.h>
22 #include "m68020.h"
23
24 /* Console IO routines for a Motorola MVME135/MVME136 board.
25
26 They currently use the B port. It should be possible to
27 use the A port by filling in the reset of the chip structure,
28 adding an ifdef for PORTA/PORTB, and switching the addresses,
29 and maybe the macros based on the macro. */
30
31 /* M68681 DUART chip register structures and constants */
32
33 typedef struct {
34 volatile unsigned char fill1[ 5 ]; /* channel A regs ( not used ) */
35 volatile unsigned char isr; /* interrupt status reg */
36 volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */
37 volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */
38 volatile unsigned char srb; /* status reg channel B */
39 volatile unsigned char fill3; /* do not access */
40 volatile unsigned char rbb; /* receive buffer channel B */
41 volatile unsigned char ivr; /* interrupt vector register */
42 } r_m681_info;
43
44 typedef struct {
45 volatile unsigned char fill1[ 4 ]; /* channel A regs (not used) */
46 volatile unsigned char acr; /* auxillary control reg */
47 volatile unsigned char imr; /* interrupt mask reg */
48 volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */
49 volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */
50 volatile unsigned char csrb; /* clock select reg */
51 volatile unsigned char crb; /* command reg */
52 volatile unsigned char tbb; /* transmit buffer channel B */
53 volatile unsigned char ivr; /* interrupt vector register */
54 } w_m681_info;
55
56 #define RD_M68681 ((r_m681_info *)0xfffb0040) /* ptr to the M68681 */
57 #define WR_M68681 ((w_m681_info *)0xfffb0040) /* ptr to the M68681 */
58 #define RXRDYB 0x01 /* status reg recv ready mask */
59 #define TXRDYB 0x04 /* status reg trans ready mask */
60
61 /* _Console_Putc
62
63 This routine transmits a character out the M68681. It supports
64 XON/XOFF flow control. */
65
66 #define XON 0x11 /* control-Q */
67 #define XOFF 0x13 /* control-S */
68
69 int
70 _Console_Putc (ch)
71 char ch;
72 {
73 while ( ! (RD_M68681->srb & TXRDYB) ) ;
74 while ( RD_M68681->srb & RXRDYB ) /* must be an XOFF */
75 if ( RD_M68681->rbb == XOFF )
76 do {
77 while ( ! (RD_M68681->srb & RXRDYB) ) ;
78 } while ( RD_M68681->rbb != XON );
79
80 WR_M68681->tbb = ch;
81 return( 0 );
82 }
83
84 /* _Console_Getc
85
86 This routine reads a character from the UART and returns it. */
87
88 int
89 _Console_Getc (poll)
90 int poll;
91 {
92 if ( poll ) {
93 if ( !(RD_M68681->srb & RXRDYB) )
94 return -1;
95 else
96 return RD_M68681->rbb;
97 } else {
98 while ( !(RD_M68681->srb & RXRDYB) );
99 return RD_M68681->rbb;
100 }
101 }