1 /* Remote serial interface for GO32, for GDB, the GNU Debugger.
2 Copyright 1992 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. */
20 /* This file shows most of the obvious problems of code written for
21 the IBM PC. FIXME. -- gnu@cygnus.com, Sep92 */
28 #define SIGNATURE 0x4154
34 #define dprintf if(0)printf
38 #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
52 static ASYNC_STRUCT far *async;
68 static int mono_pos=0;
73 mono_put(char byte, char attr)
75 ScreenSecondary[320+mono_pos+80] = 0x0720;
76 ScreenSecondary[320+mono_pos] = (attr<<8) | (byte&0xff);
77 mono_pos = (mono_pos+1) % 1200;
86 return (char *)((unsigned)async - OFFSET + p);
88 return (char far *)MK_FP(FP_SEG(async), p);
92 static ASYNC_STRUCT far *
97 if (peek(0, which*4) != OFFSET)
100 a = (ASYNC_STRUCT *)(0xe0000000 + peek(0, which*4+2)*16 + peek(0, which*4));
103 a = (ASYNC_STRUCT far *)MK_FP(peek(0,which*4+2),peek(0,which*4));
105 if (a->signature != SIGNATURE)
107 if (a->version != VERSION)
116 ASYNC_STRUCT far *a1;
117 ASYNC_STRUCT far *a2;
134 error("GDB can not connect to asynctsr program, check that it is installed\n\
135 and that serial I/O is not being redirected (perhaps by NFS)\n\n\
136 example configuration:\n\
137 C> mode com2:9600,n,8,1,p\n\
143 outportb(com_ier, 0x0f);
144 outportb(com_bfr, 0x03);
145 outportb(com_mcr, 0x0b);
146 async->getp = async->putp = async->buffer_start;
149 for (i=0; i<1200; i++)
150 ScreenSecondary[320+i] = 0x0720;
161 dprintf("dos_async_tx: enter %x - with IOV %x", c, com_lsr);
163 while (~inportb(com_lsr) & 0x20);
166 mono_put(c, mono_tx);
174 return (async->getp != async->putp);
181 dprintf("dos_async_rx: enter - ");
183 while (!dos_async_ready())
189 dprintf("async=%x getp=%x\n", async, async->getp);
191 rv = *aptr(async->getp++);
193 mono_put(rv, mono_rx);
195 if (async->getp >= async->buffer_end)
196 async->getp = async->buffer_start;
197 dprintf("exit %x\n", rv);
204 return (peek(0x40,0x1a) != peek(0x40,0x1c));
218 dosasync_read (int fd, char *buffer, int length, int timeout)
224 dprintf("dosasync_read: enter(%d,%d)\n", length, timeout);
229 while (!dos_async_ready())
234 dprintf("dosasync_read: timeout(%d)\n", length-l-1);
239 *buffer++ = dos_async_rx();
241 dprintf("dosasync_read: exit %d\n", length);
246 dosasync_write(int fd, const char *buffer, int length)
250 dos_async_tx(*buffer++);
262 if ((*s >= 'A') && (*s <= 'Z'))
274 serial_default_name ()
283 /* Always in raw mode */
291 fd = dos_async_init();
297 serial_timedreadchar (to, ok)
302 if (dosasync_read(fd, &buf, 1, to))
314 serial_setbaudrate (rate)
321 serial_nextbaudrate (rate)
328 serial_write (str, len)
332 dosasync_write(fd, str, len);