* arc-tdep.c: new target dependent codes for arc processor.
[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
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#include "defs.h"
21#include <sys/dos.h>
22
23#if 0
24#define disable() asm("cli")
25#define enable() asm("sti")
26#endif
27
28/* this is a duumy to fill the ops structure */
29struct go32_ttystate
30 {
31 int bogus;
32 };
33
34static int go32_open PARAMS ((serial_t scb, const char *name));
35static void go32_raw PARAMS ((serial_t scb));
36static int go32_readchar PARAMS ((serial_t scb, int timeout));
37static int go32_setbaudrate PARAMS ((serial_t scb, int rate));
38static int go32_write PARAMS ((serial_t scb, const char *str, int len));
39static void go32_close PARAMS ((serial_t scb));
40static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb));
41static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
42static unsigned long getivec PARAMS ((int which));
43static int dos_read PARAMS ((int fd, char *buf, int len, int timeout));
44static int dos_write PARAMS ((int fd, const char *buf, int len));
45
46#if 0
47static int iov[2];
48#define com_rb(n) iov[n]
49#define com_tb(n) iov[n]
50#define com_ier(n) iov[n]+1
51#define com_ifr(n) iov[n]+2
52#define com_bfr(n) iov[n]+3
53#define com_mcr(n) iov[n]+4
54#define com_lsr(n) iov[n]+5
55#define com_msr(n) iov[n]+6
56
57static unsigned long
58getivec (int which)
59{
60 long tryaindex;
61
62 if (GET_WORD (which * 4) != OFFSET)
63 return 0;
64
65 /* Find out where in memory this lives */
66 tryaindex = GET_WORD (which * 4 + 2) * 16 + GET_WORD (which * 4);
67
68 if (GET_WORD (tryaindex + 2) != SIGNATURE)
69 return 0;
70 if (GET_WORD (tryaindex + 4) != VERSION)
71 return 0;
72 return tryaindex;
73}
74#endif /* 0 */
75
76static int biosprn (cmd, byte, port)
77 int cmd;
78 int byte;
79 int port;
80{
81 union REGS regs;
82 regs.h.ah = cmd;
83 regs.h.al = byte;
84 regs.x.dx = port;
85 int86 (0x17, &regs, &regs);
86 return regs.h.ah;
87}
88
89static int
90dos_read (fd, buf, len)
91 int fd;
92 char *buf;
93 int len;
94{
95 int i;
96
97 for (i = 0; i < len; i++)
98 {
99 *buf++ = biosprn (2, 0, fd);
100 }
101 return len;
102}
103
104static int
105dos_write (fd, buf, len)
106 int fd;
107 const char *buf;
108 int len;
109{
110 int l;
111
112 for (l = 0; l < len; l++)
113 biosprn (0, *buf++, fd);
114
115 return len;
116}
117
118static int
119go32_open (scb, name)
120 serial_t scb;
121 const char *name;
122{
123 int port;
124
125 if (strncasecmp (name, "lpt", 3) != 0)
126 {
127 errno = ENOENT;
128 return -1;
129 }
130
131 port = name[3] - '0';
132
133 if (port != 1 && port != 2 && port != 3)
134 {
135 errno = ENOENT;
136 return -11;
137 }
138
139 return = biosprn (1, 0, port);
140 if (!return)
141 return -1;
142
143 scb->fd = port;
144 return 0;
145}
146
147static int
148go32_noop (scb)
149 serial_t scb;
150{
151 return 0;
152}
153
154static void
155go32_raw (scb)
156 serial_t scb;
157{
158 /* Always in raw mode */
159}
160
161static int
162go32_readchar (scb, timeout)
163 serial_t scb;
164 int timeout;
165{
166 char buf;
167
168 if (dos_read (scb->fd, &buf, 1))
169 return buf;
170 else
171 return SERIAL_TIMEOUT;
172}
173
174static int
175go32_write (scb, str, len)
176 serial_t scb;
177 const char *str;
178 int len;
179{
180 dos_write (scb->fd, str, len);
181 return 0;
182}
183
184/* go32_{get set}_tty_state() are both dummys to fill out the function
185 vector. Someday, they may do something real... */
186
187static serial_ttystate
188go32_get_tty_state (scb)
189 serial_t scb;
190{
191 struct go32_ttystate *state;
192
193 state = (struct go32_ttystate *) xmalloc (sizeof *state);
194
195 return (serial_ttystate) state;
196}
197
198static int
199go32_set_tty_state (scb, ttystate)
200 serial_t scb;
201 serial_ttystate ttystate;
202{
203 return 0;
204}
205
206static int
207go32_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
208 serial_t scb;
209 serial_ttystate new_ttystate;
210 serial_ttystate old_ttystate;
211{
212 return 0;
213}
214
215static void
216go32_print_tty_state (scb, ttystate)
217 serial_t scb;
218 serial_ttystate ttystate;
219{
220 /* Nothing to print. */
221 return;
222}
223
224static int
225go32_setbaudrate (scb, rate)
226 serial_t scb;
227 int rate;
228{
229 return 0;
230}
231
232static void
233go32_close (scb)
234 serial_t scb;
235{
236}
237
238static struct serial_ops go32_ops =
239{
240 "parallel",
241 0,
242 go32_open,
243 go32_close,
244 go32_readchar,
245 go32_write,
246 go32_noop, /* flush output */
247 go32_noop, /* flush input */
248 go32_noop, /* send break -- currently used only for nindy */
249 go32_raw,
250 go32_get_tty_state,
251 go32_set_tty_state,
252 go32_print_tty_state,
253 go32_noflush_set_tty_state,
254 go32_setbaudrate,
255};
256
257void
258_initialize_ser_go32 ()
259{
260 serial_add_interface (&go32_ops);
261}
This page took 0.032512 seconds and 4 git commands to generate.