* ser-go32.c: First cut at adapting to new serial interface.
This commit is contained in:
parent
4e772f4426
commit
5d2b030a03
2 changed files with 113 additions and 174 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Apr 6 03:10:44 1993 Stu Grossman (grossman@cygnus.com)
|
||||||
|
|
||||||
|
* ser-go32.c: First cut at adapting to new serial interface.
|
||||||
|
|
||||||
Mon Apr 5 22:29:43 1993 Stu Grossman (grossman@cygnus.com)
|
Mon Apr 5 22:29:43 1993 Stu Grossman (grossman@cygnus.com)
|
||||||
|
|
||||||
* Makefile.in (SFILES OBS): Add serial.[co] & ser-hardwire.[co].
|
* Makefile.in (SFILES OBS): Add serial.[co] & ser-hardwire.[co].
|
||||||
|
|
283
gdb/ser-go32.c
283
gdb/ser-go32.c
|
@ -1,5 +1,5 @@
|
||||||
/* Remote serial interface for GO32, for GDB, the GNU Debugger.
|
/* Remote serial interface for local (hardwired) serial ports for GO32.
|
||||||
Copyright 1992 Free Software Foundation, Inc.
|
Copyright 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GDB.
|
This file is part of GDB.
|
||||||
|
|
||||||
|
@ -17,30 +17,15 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/* This file shows most of the obvious problems of code written for
|
|
||||||
the IBM PC. FIXME. -- gnu@cygnus.com, Sep92 */
|
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
/* dummy */
|
|
||||||
struct ttystate;
|
|
||||||
|
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
#include <sys/dos.h>
|
#include <sys/dos.h>
|
||||||
|
|
||||||
#define SIGNATURE 0x4154
|
#define SIGNATURE 0x4154
|
||||||
#define VERSION 1
|
#define VERSION 1
|
||||||
#define OFFSET 0x104
|
#define OFFSET 0x104
|
||||||
|
|
||||||
/*#define MONO 1*/
|
|
||||||
|
|
||||||
#define dprintf if(0)printf
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define far
|
|
||||||
#define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
|
#define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short jmp_op;
|
short jmp_op;
|
||||||
|
@ -53,7 +38,7 @@ typedef struct {
|
||||||
short iov;
|
short iov;
|
||||||
} ASYNC_STRUCT;
|
} ASYNC_STRUCT;
|
||||||
|
|
||||||
static ASYNC_STRUCT far *async;
|
static ASYNC_STRUCT *async;
|
||||||
static int iov;
|
static int iov;
|
||||||
#define com_rb iov
|
#define com_rb iov
|
||||||
#define com_tb iov
|
#define com_tb iov
|
||||||
|
@ -66,46 +51,22 @@ static int iov;
|
||||||
|
|
||||||
static int fd;
|
static int fd;
|
||||||
|
|
||||||
|
static char *
|
||||||
#if MONO
|
aptr(p)
|
||||||
#include <sys/pc.h>
|
short p;
|
||||||
static int mono_pos=0;
|
|
||||||
#define mono_rx 0x07
|
|
||||||
#define mono_tx 0x70
|
|
||||||
|
|
||||||
void
|
|
||||||
mono_put(char byte, char attr)
|
|
||||||
{
|
{
|
||||||
ScreenSecondary[320+mono_pos+80] = 0x0720;
|
|
||||||
ScreenSecondary[320+mono_pos] = (attr<<8) | (byte&0xff);
|
|
||||||
mono_pos = (mono_pos+1) % 1200;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char far *
|
|
||||||
aptr(short p)
|
|
||||||
{
|
|
||||||
#ifdef __GNUC__
|
|
||||||
return (char *)((unsigned)async - OFFSET + p);
|
return (char *)((unsigned)async - OFFSET + p);
|
||||||
#else
|
|
||||||
return (char far *)MK_FP(FP_SEG(async), p);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ASYNC_STRUCT far *
|
static ASYNC_STRUCT *
|
||||||
getivec(int which)
|
getivec(int which)
|
||||||
{
|
{
|
||||||
ASYNC_STRUCT far *a;
|
ASYNC_STRUCT *a;
|
||||||
|
|
||||||
if (peek(0, which*4) != OFFSET)
|
if (peek(0, which*4) != OFFSET)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef __GNUC__
|
|
||||||
a = (ASYNC_STRUCT *)(0xe0000000 + peek(0, which*4+2)*16 + peek(0, which*4));
|
a = (ASYNC_STRUCT *)(0xe0000000 + peek(0, which*4+2)*16 + peek(0, which*4));
|
||||||
|
|
||||||
#else
|
|
||||||
a = (ASYNC_STRUCT far *)MK_FP(peek(0,which*4+2),peek(0,which*4));
|
|
||||||
#endif
|
|
||||||
if (a->signature != SIGNATURE)
|
if (a->signature != SIGNATURE)
|
||||||
return 0;
|
return 0;
|
||||||
if (a->version != VERSION)
|
if (a->version != VERSION)
|
||||||
|
@ -113,12 +74,12 @@ getivec(int which)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
dos_async_init()
|
dos_async_init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ASYNC_STRUCT far *a1;
|
ASYNC_STRUCT *a1;
|
||||||
ASYNC_STRUCT far *a2;
|
ASYNC_STRUCT *a2;
|
||||||
a1 = getivec(12);
|
a1 = getivec(12);
|
||||||
a2 = getivec(11);
|
a2 = getivec(11);
|
||||||
async = 0;
|
async = 0;
|
||||||
|
@ -149,190 +110,164 @@ C> gdb \n");
|
||||||
outportb(com_mcr, 0x0b);
|
outportb(com_mcr, 0x0b);
|
||||||
async->getp = async->putp = async->buffer_start;
|
async->getp = async->putp = async->buffer_start;
|
||||||
|
|
||||||
#if MONO
|
|
||||||
for (i=0; i<1200; i++)
|
|
||||||
ScreenSecondary[320+i] = 0x0720;
|
|
||||||
#endif
|
|
||||||
if (iov > 0x300)
|
if (iov > 0x300)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
dos_async_tx(char c)
|
dos_async_tx(c)
|
||||||
|
const char c;
|
||||||
{
|
{
|
||||||
dprintf("dos_async_tx: enter %x - with IOV %x", c, com_lsr);
|
|
||||||
fflush(stdout);
|
|
||||||
while (~inportb(com_lsr) & 0x20);
|
while (~inportb(com_lsr) & 0x20);
|
||||||
|
|
||||||
outportb(com_tb, c);
|
outportb(com_tb, c);
|
||||||
#if MONO
|
|
||||||
mono_put(c, mono_tx);
|
|
||||||
#endif
|
|
||||||
dprintf("exit\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
dos_async_ready()
|
dos_async_ready()
|
||||||
{
|
{
|
||||||
return (async->getp != async->putp);
|
return (async->getp != async->putp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
dos_async_rx()
|
dos_async_rx()
|
||||||
{
|
{
|
||||||
char rv;
|
char rv;
|
||||||
dprintf("dos_async_rx: enter - ");
|
|
||||||
fflush(stdout);
|
|
||||||
while (!dos_async_ready())
|
while (!dos_async_ready())
|
||||||
if (kbhit())
|
if (kbhit())
|
||||||
{
|
{
|
||||||
printf("abort!\n");
|
printf("abort!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dprintf("async=%x getp=%x\n", async, async->getp);
|
|
||||||
fflush(stdout);
|
|
||||||
rv = *aptr(async->getp++);
|
rv = *aptr(async->getp++);
|
||||||
#if MONO
|
|
||||||
mono_put(rv, mono_rx);
|
|
||||||
#endif
|
|
||||||
if (async->getp >= async->buffer_end)
|
if (async->getp >= async->buffer_end)
|
||||||
async->getp = async->buffer_start;
|
async->getp = async->buffer_start;
|
||||||
dprintf("exit %x\n", rv);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
dos_kb_ready()
|
dosasync_read (fd, buf, len, timeout)
|
||||||
{
|
int fd;
|
||||||
return (peek(0x40,0x1a) != peek(0x40,0x1c));
|
char *buf;
|
||||||
}
|
int len;
|
||||||
|
int timeout;
|
||||||
int
|
|
||||||
dos_kb_rx()
|
|
||||||
{
|
|
||||||
#ifdef __GNUC__
|
|
||||||
return getkey();
|
|
||||||
#else
|
|
||||||
return getch();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dosasync_read (int fd, char *buffer, int length, int timeout)
|
|
||||||
{
|
{
|
||||||
long now, then;
|
long now, then;
|
||||||
int l = length;
|
int l = len;
|
||||||
|
|
||||||
time (&now);
|
time (&now);
|
||||||
then = now+timeout;
|
then = now + timeout;
|
||||||
dprintf("dosasync_read: enter(%d,%d)\n", length, timeout);
|
|
||||||
while (l--)
|
while (l--)
|
||||||
{
|
|
||||||
if (timeout)
|
|
||||||
{
|
{
|
||||||
while (!dos_async_ready())
|
if (timeout)
|
||||||
{
|
{
|
||||||
time (&now);
|
while (!dos_async_ready())
|
||||||
if (now == then)
|
{
|
||||||
{
|
time (&now);
|
||||||
dprintf("dosasync_read: timeout(%d)\n", length-l-1);
|
if (now >= then)
|
||||||
return length-l-1;
|
return len - l - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*buf++ = dos_async_rx();
|
||||||
}
|
}
|
||||||
*buffer++ = dos_async_rx();
|
|
||||||
}
|
return len;
|
||||||
dprintf("dosasync_read: exit %d\n", length);
|
|
||||||
return length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
dosasync_write(int fd, const char *buffer, int length)
|
dosasync_write(fd, buf, len)
|
||||||
|
int fd;
|
||||||
|
const char *buf;
|
||||||
|
int len;
|
||||||
{
|
{
|
||||||
int l = length;
|
int l = len;
|
||||||
|
|
||||||
while (l--)
|
while (l--)
|
||||||
dos_async_tx(*buffer++);
|
dos_async_tx (*buf++);
|
||||||
return length;
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
go32_open (scb, name)
|
||||||
char *
|
serial_t scb;
|
||||||
strlwr(char *s)
|
const char *name;
|
||||||
{
|
{
|
||||||
char *p = s;
|
scb->fd = dos_async_init();
|
||||||
while (*s)
|
if (scb->fd)
|
||||||
{
|
return 1;
|
||||||
if ((*s >= 'A') && (*s <= 'Z'))
|
|
||||||
*s += 'a'-'A';
|
return 0;
|
||||||
s++;
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sigsetmask()
|
static void
|
||||||
{
|
go32_raw (scb)
|
||||||
}
|
serial_t scb;
|
||||||
|
|
||||||
const char *
|
|
||||||
serial_default_name ()
|
|
||||||
{
|
|
||||||
return "com1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
serial_raw (fd, old)
|
|
||||||
int fd;
|
|
||||||
struct ttystate *old;
|
|
||||||
{
|
{
|
||||||
/* Always in raw mode */
|
/* Always in raw mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
int
|
go32_readchar (scb, timeout)
|
||||||
serial_open (name)
|
serial_t scb;
|
||||||
const char *name;
|
int timeout;
|
||||||
{
|
|
||||||
fd = dos_async_init();
|
|
||||||
if (fd) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
serial_readchar (to)
|
|
||||||
int to;
|
|
||||||
{
|
{
|
||||||
char buf;
|
char buf;
|
||||||
if (dosasync_read(fd, &buf, 1, to))
|
|
||||||
|
if (dosasync_read(scb->fd, &buf, 1, timeout))
|
||||||
return buf;
|
return buf;
|
||||||
else
|
else
|
||||||
return -2; /* Timeout, I guess */
|
return -2; /* Timeout, I guess */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
serial_setbaudrate (rate)
|
go32_setbaudrate (scb, rate)
|
||||||
int rate;
|
serial_t scb;
|
||||||
|
int rate;
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
serial_nextbaudrate (rate)
|
go32_write (scb, str, len)
|
||||||
int rate;
|
serial_t scb;
|
||||||
|
const char *str;
|
||||||
|
int len;
|
||||||
{
|
{
|
||||||
return 0;
|
dosasync_write(scb->fd, str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static void
|
||||||
serial_write (str, len)
|
go32_close ()
|
||||||
const char *str;
|
|
||||||
int len;
|
|
||||||
{
|
{
|
||||||
dosasync_write(fd, str, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
serial_close ()
|
go32_restore (scb)
|
||||||
|
serial_t scb;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct serial_ops go32_ops =
|
||||||
|
{
|
||||||
|
"hardwire",
|
||||||
|
0,
|
||||||
|
go32_open,
|
||||||
|
go32_close,
|
||||||
|
go32_readchar,
|
||||||
|
go32_write,
|
||||||
|
go32_raw,
|
||||||
|
go32_restore,
|
||||||
|
go32_setbaudrate
|
||||||
|
};
|
||||||
|
|
||||||
|
_initialize_ser_go32 ()
|
||||||
|
{
|
||||||
|
serial_add_interface (&go32_ops);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue