* infrun.c (IN_SOLIB_TRAMPOLINE): Correct comment, trampolines
[binutils-gdb.git] / gdb / nlm / alpha-uart.c
1 /*
2 * Copyright (C) 1993, 1994 by
3 * Digital Equipment Corporation, Maynard, Massachusetts.
4 * All rights reserved.
5 *
6 * This software is furnished under a license and may be used and copied
7 * only in accordance of the terms of such license and with the
8 * inclusion of the above copyright notice. This software or any other
9 * copies thereof may not be provided or otherwise made available to any
10 * other person. No title to and ownership of the software is hereby
11 * transferred.
12 *
13 * The information in this software is subject to change without notice
14 * and should not be construed as a commitment by Digital Equipment
15 * Corporation.
16 *
17 * Digital assumes no responsibility for the use or reliability of its
18 * software on equipment which is not supplied by Digital.
19 *
20 */
21
22
23
24 /*$Id$*/
25
26 #include "nwtypes.h"
27 #include "alpha-uart.h"
28 /*#include "alphansi.h"*/
29 #include "alpha-patch.h"
30 #include <stdio.h>
31
32 ULONG com_interrupt()
33 {
34 if (inVti(com1Lsr) & 1)
35 return COM1 | inVti (com1Rbr);
36
37 return 0;
38 }
39
40 void
41 putcLpt(int c)
42 {
43 int i, s;
44 while(!((s = inVti(lptSr)) & 0x80))
45 ;
46
47 for(i=0;i<lptDly;++i)
48 ;
49
50 outVti(lptDr, c);
51 for(i=0;i<lptDly;++i)
52 ;
53
54 outVti(lptCr, lptnInit|lptSTB|lptAFD);
55 for(i=0;i<lptDly;++i)
56 ;
57
58 outVti(lptCr, lptnInit|lptAFD);
59 for(i=0;i<lptDly;++i)
60 ;
61
62 s = inVti(lptSr);
63 }
64
65
66
67 void
68 uart_putchar(int port, char c)
69 {
70 int lsr, thr;
71 switch(port)
72 {
73 case COM1:
74 lsr = com1Lsr;
75 thr = com1Thr;
76 break;
77 case COM2:
78 lsr = com2Lsr;
79 thr = com2Thr;
80 break;
81 #if 0
82 case LPT:
83 putcLpt(c);
84 return;
85 case VGA:
86 vga_putc(c);
87 return;
88 #endif
89 default:
90 return;
91 }
92
93 while ((inVti(lsr) & 0x20) == 0);
94 outVti(thr,c);
95 if (c == '\n') uart_putchar(port, '\r');
96 }
97
98
99
100 int uart_init_line(int line, int baud)
101 {
102 int i;
103 int baudconst;
104
105 switch (baud)
106 {
107 case 57600: baudconst = 2; break;
108 case 38400: baudconst = 3; break;
109 case 19200: baudconst = 6; break;
110 case 9600: baudconst = 12; break;
111 case 4800: baudconst = 24; break;
112 case 2400: baudconst = 48; break;
113 case 1200: baudconst = 96; break;
114 case 300: baudconst = 384; break;
115 case 150: baudconst = 768; break;
116 default: baudconst = 12; break;
117 }
118
119 if (line == 1)
120 {
121 outVti(com1Lcr, 0x87);
122 outVti(com1Dlm, 0);
123 outVti(com1Dll, baudconst);
124 outVti(com1Lcr, 0x07);
125 outVti(com1Mcr, 0x0F);
126 com1_disable_int();
127 }
128
129 else if (line == 2)
130 {
131 outVti(com2Lcr, 0x87);
132 outVti(com2Dlm, 0);
133 outVti(com2Dll, baudconst);
134 outVti(com2Lcr, 0x07);
135 outVti(com2Mcr, 0x0F);
136 }
137 fprintf (stderr, "com1Ier = 0x%x\n", inVti(com1Ier));
138 fprintf (stderr, "com1Lcr = 0x%x\n", inVti(com1Lcr));
139 fprintf (stderr, "com1Dlm = 0x%x\n", inVti(com1Dlm));
140 fprintf (stderr, "com1Dll = 0x%x\n", inVti(com1Dll));
141 fprintf (stderr, "com1Lcr = 0x%x\n", inVti(com1Lcr));
142 fprintf (stderr, "com1Mcr = 0x%x\n", inVti(com1Mcr));
143 }
144
145
146
147 int
148 uart_init()
149 {
150 uart_init_line(1, 19200);
151 }
152
153
154
155 com1_enable_int()
156 {
157 outVti(com1Ier, 0x01);
158 }
159
160
161
162 com1_disable_int()
163 {
164 outVti(com1Ier, 0x0);
165 }
166
167
168
169 com2_enable_int()
170 {
171 outVti(com2Ier, 0x01);
172 }
173
174
175
176 com2_disable_int()
177 {
178 outVti(com2Ier, 0x0);
179 }