* gencode.c (build_instruction) [MUL]: Cast operands to word64, to
[deliverable/binutils-gdb.git] / gdb / ser-go32-para.c
CommitLineData
249abc98
KH
1/* Remote parallel interface for local parallel ports for GO32.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
6c9638b4 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
249abc98
KH
19
20#include "defs.h"
6396e0c0 21#include "serial.h"
249abc98
KH
22#include <sys/dos.h>
23
24#if 0
25#define disable() asm("cli")
26#define enable() asm("sti")
27#endif
28
29/* this is a duumy to fill the ops structure */
30struct go32_ttystate
31 {
32 int bogus;
33 };
34
35static int go32_open PARAMS ((serial_t scb, const char *name));
36static void go32_raw PARAMS ((serial_t scb));
37static int go32_readchar PARAMS ((serial_t scb, int timeout));
38static int go32_setbaudrate PARAMS ((serial_t scb, int rate));
39static int go32_write PARAMS ((serial_t scb, const char *str, int len));
40static void go32_close PARAMS ((serial_t scb));
41static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb));
42static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
43static unsigned long getivec PARAMS ((int which));
6396e0c0 44static int dos_read PARAMS ((int fd, char *buf, int len));
249abc98
KH
45static int dos_write PARAMS ((int fd, const char *buf, int len));
46
47#if 0
48static int iov[2];
49#define com_rb(n) iov[n]
50#define com_tb(n) iov[n]
51#define com_ier(n) iov[n]+1
52#define com_ifr(n) iov[n]+2
53#define com_bfr(n) iov[n]+3
54#define com_mcr(n) iov[n]+4
55#define com_lsr(n) iov[n]+5
56#define com_msr(n) iov[n]+6
57
58static unsigned long
59getivec (int which)
60{
61 long tryaindex;
62
63 if (GET_WORD (which * 4) != OFFSET)
64 return 0;
65
66 /* Find out where in memory this lives */
67 tryaindex = GET_WORD (which * 4 + 2) * 16 + GET_WORD (which * 4);
68
69 if (GET_WORD (tryaindex + 2) != SIGNATURE)
70 return 0;
71 if (GET_WORD (tryaindex + 4) != VERSION)
72 return 0;
73 return tryaindex;
74}
75#endif /* 0 */
76
77static int biosprn (cmd, byte, port)
78 int cmd;
79 int byte;
80 int port;
81{
82 union REGS regs;
83 regs.h.ah = cmd;
84 regs.h.al = byte;
85 regs.x.dx = port;
86 int86 (0x17, &regs, &regs);
87 return regs.h.ah;
88}
89
90static int
91dos_read (fd, buf, len)
92 int fd;
93 char *buf;
94 int len;
95{
96 int i;
97
98 for (i = 0; i < len; i++)
99 {
100 *buf++ = biosprn (2, 0, fd);
101 }
102 return len;
103}
104
105static int
106dos_write (fd, buf, len)
107 int fd;
108 const char *buf;
109 int len;
110{
111 int l;
112
113 for (l = 0; l < len; l++)
114 biosprn (0, *buf++, fd);
115
116 return len;
117}
118
119static int
120go32_open (scb, name)
121 serial_t scb;
122 const char *name;
123{
6396e0c0 124 int port, ret;
249abc98
KH
125
126 if (strncasecmp (name, "lpt", 3) != 0)
127 {
128 errno = ENOENT;
129 return -1;
130 }
131
132 port = name[3] - '0';
133
134 if (port != 1 && port != 2 && port != 3)
135 {
136 errno = ENOENT;
137 return -11;
138 }
139
6396e0c0
KH
140 ret = biosprn (1, 0, port);
141 if (!ret)
249abc98
KH
142 return -1;
143
144 scb->fd = port;
145 return 0;
146}
147
148static int
149go32_noop (scb)
150 serial_t scb;
151{
152 return 0;
153}
154
155static void
156go32_raw (scb)
157 serial_t scb;
158{
159 /* Always in raw mode */
160}
161
162static int
163go32_readchar (scb, timeout)
164 serial_t scb;
165 int timeout;
166{
167 char buf;
168
169 if (dos_read (scb->fd, &buf, 1))
170 return buf;
171 else
172 return SERIAL_TIMEOUT;
173}
174
175static int
176go32_write (scb, str, len)
177 serial_t scb;
178 const char *str;
179 int len;
180{
181 dos_write (scb->fd, str, len);
182 return 0;
183}
184
185/* go32_{get set}_tty_state() are both dummys to fill out the function
186 vector. Someday, they may do something real... */
187
188static serial_ttystate
189go32_get_tty_state (scb)
190 serial_t scb;
191{
192 struct go32_ttystate *state;
193
194 state = (struct go32_ttystate *) xmalloc (sizeof *state);
195
196 return (serial_ttystate) state;
197}
198
199static int
200go32_set_tty_state (scb, ttystate)
201 serial_t scb;
202 serial_ttystate ttystate;
203{
204 return 0;
205}
206
207static int
208go32_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
209 serial_t scb;
210 serial_ttystate new_ttystate;
211 serial_ttystate old_ttystate;
212{
213 return 0;
214}
215
216static void
217go32_print_tty_state (scb, ttystate)
218 serial_t scb;
219 serial_ttystate ttystate;
220{
221 /* Nothing to print. */
222 return;
223}
224
225static int
226go32_setbaudrate (scb, rate)
227 serial_t scb;
228 int rate;
229{
230 return 0;
231}
232
85c8b135
SG
233static int
234go32_setstopbits (scb, num)
235 serial_t scb;
236 int num;
237{
238 return 0;
239}
240
249abc98
KH
241static void
242go32_close (scb)
243 serial_t scb;
244{
245}
246
247static struct serial_ops go32_ops =
248{
249 "parallel",
250 0,
251 go32_open,
252 go32_close,
253 go32_readchar,
254 go32_write,
255 go32_noop, /* flush output */
256 go32_noop, /* flush input */
257 go32_noop, /* send break -- currently used only for nindy */
258 go32_raw,
259 go32_get_tty_state,
260 go32_set_tty_state,
261 go32_print_tty_state,
262 go32_noflush_set_tty_state,
263 go32_setbaudrate,
85c8b135 264 go32_setstopbits,
249abc98
KH
265};
266
267void
268_initialize_ser_go32 ()
269{
270 serial_add_interface (&go32_ops);
271}
This page took 0.114209 seconds and 4 git commands to generate.