1 /* Remote serial interface for GO32
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. */
25 #define SIGNATURE 0x4154
31 #define dprintf if(0)printf
35 #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
49 static ASYNC_STRUCT far
*async
;
62 static int mono_pos
=0;
66 void mono_put(char byte
, char attr
)
68 ScreenSecondary
[320+mono_pos
+80] = 0x0720;
69 ScreenSecondary
[320+mono_pos
] = (attr
<<8) | (byte
&0xff);
70 mono_pos
= (mono_pos
+1) % 1200;
75 static char far
*aptr(short p
)
78 return (char *)((unsigned)async
- OFFSET
+ p
);
80 return (char far
*)MK_FP(FP_SEG(async
), p
);
84 static ASYNC_STRUCT far
*getivec(int which
)
88 if (peek(0, which
*4) != OFFSET
)
91 a
= (ASYNC_STRUCT
*)(0xe0000000 + peek(0, which
*4+2)*16 + peek(0, which
*4));
94 a
= (ASYNC_STRUCT far
*)MK_FP(peek(0,which
*4+2),peek(0,which
*4));
96 if (a
->signature
!= SIGNATURE
)
98 if (a
->version
!= VERSION
)
106 ASYNC_STRUCT far
*a1
;
107 ASYNC_STRUCT far
*a2
;
124 error("GDB can not connect to asynctsr program, check that it is installed\n\
125 and that serial I/O is not being redirected (perhaps by NFS)\n\n\
126 example configuration:\n\
127 C> mode com2:9600,n,8,1,p\n\
133 outportb(com_ier
, 0x0f);
134 outportb(com_bfr
, 0x03);
135 outportb(com_mcr
, 0x0b);
136 async
->getp
= async
->putp
= async
->buffer_start
;
139 for (i
=0; i
<1200; i
++)
140 ScreenSecondary
[320+i
] = 0x0720;
150 dprintf("dos_async_tx: enter %x - with IOV %x", c
, com_lsr
);
152 while (~inportb(com_lsr
) & 0x20);
155 mono_put(c
, mono_tx
);
160 int dos_async_ready()
162 return (async
->getp
!= async
->putp
);
168 dprintf("dos_async_rx: enter - ");
170 while (!dos_async_ready())
176 dprintf("async=%x getp=%x\n", async
, async
->getp
);
178 rv
= *aptr(async
->getp
++);
180 mono_put(rv
, mono_rx
);
182 if (async
->getp
>= async
->buffer_end
)
183 async
->getp
= async
->buffer_start
;
184 dprintf("exit %x\n", rv
);
190 return (peek(0x40,0x1a) != peek(0x40,0x1c));
202 int dosasync_read(int fd
, char *buffer
, int length
, int timeout
)
208 dprintf("dosasync_read: enter(%d,%d)\n", length
, timeout
);
213 while (!dos_async_ready())
218 dprintf("dosasync_read: timeout(%d)\n", length
-l
-1);
223 *buffer
++ = dos_async_rx();
225 dprintf("dosasync_read: exit %d\n", length
);
229 int dosasync_write(int fd
, CONST
char *buffer
, int length
)
233 dos_async_tx(*buffer
++);
239 char *strlwr(char *s
)
244 if ((*s
>= 'A') && (*s
<= 'Z'))
259 DEFUN_VOID(serial_default_name
)
266 DEFUN_VOID(serial_raw
)
268 /* Always in raw mode */
273 DEFUN(serial_open
,(name
),
276 fd
= dos_async_init();
282 DEFUN(serial_timedreadchar
,(to
, ok
),
287 if ( dosasync_read(fd
, &buf
, 1, to
))
299 DEFUN(serial_setbaudrate
,(rate
),
306 DEFUN(serial_nextbaudrate
,(rate
),
313 DEFUN(serial_write
,(str
, len
),
317 dosasync_write(fd
, str
, len
);
321 DEFUN_VOID(serial_close
)
This page took 0.046639 seconds and 4 git commands to generate.