2a493bc53d80a8a3b84836df9e8138179e7c20da
1 /* Remote serial interface for GO32
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
29 #define SIGNATURE 0x4154
35 #define dprintf if(0)printf
39 #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
53 static ASYNC_STRUCT far
*async
;
66 static int mono_pos
=0;
70 void mono_put(char byte
, char attr
)
72 ScreenSecondary
[320+mono_pos
+80] = 0x0720;
73 ScreenSecondary
[320+mono_pos
] = (attr
<<8) | (byte
&0xff);
74 mono_pos
= (mono_pos
+1) % 1200;
79 static char far
*aptr(short p
)
82 return (char *)((unsigned)async
- OFFSET
+ p
);
84 return (char far
*)MK_FP(FP_SEG(async
), p
);
88 static ASYNC_STRUCT far
*getivec(int which
)
92 if (peek(0, which
*4) != OFFSET
)
95 a
= (ASYNC_STRUCT
*)(0xe0000000 + peek(0, which
*4+2)*16 + peek(0, which
*4));
98 a
= (ASYNC_STRUCT far
*)MK_FP(peek(0,which
*4+2),peek(0,which
*4));
100 if (a
->signature
!= SIGNATURE
)
102 if (a
->version
!= VERSION
)
110 ASYNC_STRUCT far
*a1
;
111 ASYNC_STRUCT far
*a2
;
128 error("GDB can not connect to asynctsr program, check that it is installed\n\
129 and that serial I/O is not being redirected (perhaps by NFS)\n\n\
130 example configuration:\n\
131 C> mode com2:9600,n,8,1,p\n\
137 outportb(com_ier
, 0x0f);
138 outportb(com_bfr
, 0x03);
139 outportb(com_mcr
, 0x0b);
140 async
->getp
= async
->putp
= async
->buffer_start
;
143 for (i
=0; i
<1200; i
++)
144 ScreenSecondary
[320+i
] = 0x0720;
154 dprintf("dos_async_tx: enter %x - with IOV %x", c
, com_lsr
);
156 while (~inportb(com_lsr
) & 0x20);
159 mono_put(c
, mono_tx
);
164 int dos_async_ready()
166 return (async
->getp
!= async
->putp
);
172 dprintf("dos_async_rx: enter - ");
174 while (!dos_async_ready())
180 dprintf("async=%x getp=%x\n", async
, async
->getp
);
182 rv
= *aptr(async
->getp
++);
184 mono_put(rv
, mono_rx
);
186 if (async
->getp
>= async
->buffer_end
)
187 async
->getp
= async
->buffer_start
;
188 dprintf("exit %x\n", rv
);
194 return (peek(0x40,0x1a) != peek(0x40,0x1c));
206 int dosasync_read(int fd
, char *buffer
, int length
, int timeout
)
212 dprintf("dosasync_read: enter(%d,%d)\n", length
, timeout
);
217 while (!dos_async_ready())
222 dprintf("dosasync_read: timeout(%d)\n", length
-l
-1);
227 *buffer
++ = dos_async_rx();
229 dprintf("dosasync_read: exit %d\n", length
);
233 int dosasync_write(int fd
, CONST
char *buffer
, int length
)
237 dos_async_tx(*buffer
++);
243 char *strlwr(char *s
)
248 if ((*s
>= 'A') && (*s
<= 'Z'))
263 DEFUN_VOID(serial_default_name
)
270 DEFUN_VOID(serial_raw
)
272 /* Always in raw mode */
277 DEFUN(serial_open
,(name
),
280 fd
= dos_async_init();
286 DEFUN(serial_timedreadchar
,(to
, ok
),
291 if ( dosasync_read(fd
, &buf
, 1, to
))
303 DEFUN(serial_setbaudrate
,(rate
),
310 DEFUN(serial_nextbaudrate
,(rate
),
317 DEFUN(serial_write
,(str
, len
),
321 dosasync_write(fd
, str
, len
);
325 DEFUN_VOID(serial_close
)
This page took 0.035122 seconds and 4 git commands to generate.