1 /* Remote serial interface for local (hardwired) serial 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #define SIGNATURE 0x4154
28 #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
41 static ASYNC_STRUCT *async;
58 return (char *)((unsigned)async - OFFSET + p);
66 if (peek(0, which*4) != OFFSET)
68 a = (ASYNC_STRUCT *)(0xe0000000 + peek(0, which*4+2)*16 + peek(0, which*4));
70 if (a->signature != SIGNATURE)
72 if (a->version != VERSION)
99 error("GDB can not connect to asynctsr program, check that it is installed\n\
100 and that serial I/O is not being redirected (perhaps by NFS)\n\n\
101 example configuration:\n\
102 C> mode com2:9600,n,8,1,p\n\
108 outportb(com_ier, 0x0f);
109 outportb(com_bfr, 0x03);
110 outportb(com_mcr, 0x0b);
111 async->getp = async->putp = async->buffer_start;
123 while (~inportb(com_lsr) & 0x20);
131 return (async->getp != async->putp);
139 while (!dos_async_ready())
146 rv = *aptr(async->getp++);
147 if (async->getp >= async->buffer_end)
148 async->getp = async->buffer_start;
154 dosasync_read (fd, buf, len, timeout)
164 then = now + timeout;
170 while (!dos_async_ready())
177 *buf++ = dos_async_rx();
184 dosasync_write(fd, buf, len)
192 dos_async_tx (*buf++);
198 go32_open (scb, name)
202 scb->fd = dos_async_init();
213 /* Always in raw mode */
217 go32_readchar (scb, timeout)
223 if (dosasync_read(scb->fd, &buf, 1, timeout))
226 return -2; /* Timeout, I guess */
230 go32_setbaudrate (scb, rate)
238 go32_write (scb, str, len)
243 dosasync_write(scb->fd, str, len);
257 static struct serial_ops go32_ops =
270 _initialize_ser_go32 ()
272 serial_add_interface (&go32_ops);