1 /* Remote parallel interface for local parallel ports for GO32.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #define disable() asm("cli")
26 #define enable() asm("sti")
29 /* this is a duumy to fill the ops structure */
35 static int go32_open PARAMS ((serial_t scb, const char *name));
36 static void go32_raw PARAMS ((serial_t scb));
37 static int go32_readchar PARAMS ((serial_t scb, int timeout));
38 static int go32_setbaudrate PARAMS ((serial_t scb, int rate));
39 static int go32_write PARAMS ((serial_t scb, const char *str, int len));
40 static void go32_close PARAMS ((serial_t scb));
41 static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb));
42 static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
43 static unsigned long getivec PARAMS ((int which));
44 static int dos_read PARAMS ((int fd, char *buf, int len));
45 static int dos_write PARAMS ((int fd, const char *buf, int len));
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
63 if (GET_WORD (which * 4) != OFFSET)
66 /* Find out where in memory this lives */
67 tryaindex = GET_WORD (which * 4 + 2) * 16 + GET_WORD (which * 4);
69 if (GET_WORD (tryaindex + 2) != SIGNATURE)
71 if (GET_WORD (tryaindex + 4) != VERSION)
77 static int biosprn (cmd, byte, port)
86 int86 (0x17, ®s, ®s);
91 dos_read (fd, buf, len)
98 for (i = 0; i < len; i++)
100 *buf++ = biosprn (2, 0, fd);
106 dos_write (fd, buf, len)
113 for (l = 0; l < len; l++)
114 biosprn (0, *buf++, fd);
120 go32_open (scb, name)
126 if (strncasecmp (name, "lpt", 3) != 0)
132 port = name[3] - '0';
134 if (port != 1 && port != 2 && port != 3)
140 ret = biosprn (1, 0, port);
159 /* Always in raw mode */
163 go32_readchar (scb, timeout)
169 if (dos_read (scb->fd, &buf, 1))
172 return SERIAL_TIMEOUT;
176 go32_write (scb, str, len)
181 dos_write (scb->fd, str, len);
185 /* go32_{get set}_tty_state() are both dummys to fill out the function
186 vector. Someday, they may do something real... */
188 static serial_ttystate
189 go32_get_tty_state (scb)
192 struct go32_ttystate *state;
194 state = (struct go32_ttystate *) xmalloc (sizeof *state);
196 return (serial_ttystate) state;
200 go32_set_tty_state (scb, ttystate)
202 serial_ttystate ttystate;
208 go32_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
210 serial_ttystate new_ttystate;
211 serial_ttystate old_ttystate;
217 go32_print_tty_state (scb, ttystate)
219 serial_ttystate ttystate;
221 /* Nothing to print. */
226 go32_setbaudrate (scb, rate)
234 go32_setstopbits (scb, num)
247 static struct serial_ops go32_ops =
255 go32_noop, /* flush output */
256 go32_noop, /* flush input */
257 go32_noop, /* send break -- currently used only for nindy */
261 go32_print_tty_state,
262 go32_noflush_set_tty_state,
268 _initialize_ser_go32 ()
270 serial_add_interface (&go32_ops);