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 */
32 #define SIGNATURE 0x4154
38 #define dprintf if(0)printf
42 #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
56 static ASYNC_STRUCT far
*async
;
72 static int mono_pos
=0;
77 mono_put(char byte
, char attr
)
79 ScreenSecondary
[320+mono_pos
+80] = 0x0720;
80 ScreenSecondary
[320+mono_pos
] = (attr
<<8) | (byte
&0xff);
81 mono_pos
= (mono_pos
+1) % 1200;
90 return (char *)((unsigned)async
- OFFSET
+ p
);
92 return (char far
*)MK_FP(FP_SEG(async
), p
);
96 static ASYNC_STRUCT far
*
101 if (peek(0, which
*4) != OFFSET
)
104 a
= (ASYNC_STRUCT
*)(0xe0000000 + peek(0, which
*4+2)*16 + peek(0, which
*4));
107 a
= (ASYNC_STRUCT far
*)MK_FP(peek(0,which
*4+2),peek(0,which
*4));
109 if (a
->signature
!= SIGNATURE
)
111 if (a
->version
!= VERSION
)
120 ASYNC_STRUCT far
*a1
;
121 ASYNC_STRUCT far
*a2
;
138 error("GDB can not connect to asynctsr program, check that it is installed\n\
139 and that serial I/O is not being redirected (perhaps by NFS)\n\n\
140 example configuration:\n\
141 C> mode com2:9600,n,8,1,p\n\
147 outportb(com_ier
, 0x0f);
148 outportb(com_bfr
, 0x03);
149 outportb(com_mcr
, 0x0b);
150 async
->getp
= async
->putp
= async
->buffer_start
;
153 for (i
=0; i
<1200; i
++)
154 ScreenSecondary
[320+i
] = 0x0720;
165 dprintf("dos_async_tx: enter %x - with IOV %x", c
, com_lsr
);
167 while (~inportb(com_lsr
) & 0x20);
170 mono_put(c
, mono_tx
);
178 return (async
->getp
!= async
->putp
);
185 dprintf("dos_async_rx: enter - ");
187 while (!dos_async_ready())
193 dprintf("async=%x getp=%x\n", async
, async
->getp
);
195 rv
= *aptr(async
->getp
++);
197 mono_put(rv
, mono_rx
);
199 if (async
->getp
>= async
->buffer_end
)
200 async
->getp
= async
->buffer_start
;
201 dprintf("exit %x\n", rv
);
208 return (peek(0x40,0x1a) != peek(0x40,0x1c));
222 dosasync_read (int fd
, char *buffer
, int length
, int timeout
)
228 dprintf("dosasync_read: enter(%d,%d)\n", length
, timeout
);
233 while (!dos_async_ready())
238 dprintf("dosasync_read: timeout(%d)\n", length
-l
-1);
243 *buffer
++ = dos_async_rx();
245 dprintf("dosasync_read: exit %d\n", length
);
250 dosasync_write(int fd
, const char *buffer
, int length
)
254 dos_async_tx(*buffer
++);
266 if ((*s
>= 'A') && (*s
<= 'Z'))
278 serial_default_name ()
287 struct ttystate
*old
;
289 /* Always in raw mode */
297 fd
= dos_async_init();
307 if (dosasync_read(fd
, &buf
, 1, to
))
310 return -2; /* Timeout, I guess */
314 serial_setbaudrate (rate
)
321 serial_nextbaudrate (rate
)
328 serial_write (str
, len
)
332 dosasync_write(fd
, str
, len
);
This page took 0.036446 seconds and 4 git commands to generate.