diff options
author | Steve Chamberlain <sac@cygnus> | 1993-12-12 00:00:53 +0000 |
---|---|---|
committer | Steve Chamberlain <sac@cygnus> | 1993-12-12 00:00:53 +0000 |
commit | 08c0d7b84f411aed680b0777b43266171f11c552 (patch) | |
tree | 16232d5ba59d4bb15a4d0c61daa34406ad3e0994 /gdb/ser-go32.c | |
parent | fcf276c4958f7cc906ec389f003aa2a713c98528 (diff) | |
download | gdb-08c0d7b84f411aed680b0777b43266171f11c552.zip gdb-08c0d7b84f411aed680b0777b43266171f11c552.tar.gz gdb-08c0d7b84f411aed680b0777b43266171f11c552.tar.bz2 |
* ser-go32.c: Lint. (strncasecmp): Removed, now in libiberty.
(go32_readchar): Special handling for faster polling. (async
structure): Volatile.
* h8300-tdep.c (print_register_hook): Allocate and use the right
number bytes for the raw register.
* h8500-tdep.c (regoff, frame_find_saved_reg, examine_prologue):
deleted. (h8500_register_size, h8500_register_virtual_type, ):
Use new way of counting registers.
* remote-e7000.c (echo_index): deleted. (expect): Better handling
of user interrupts. (expect_prompt): Remove never used log file
support. (want, want_nopc): Add support for H8/300H.
(fetch_regs_from_dump): Treat \r and \n as whitespace.
(e7000_drain): Send an "end" command before waiting for output to
stop. (e7000_wait): Cope with H8/300H, better handling of user
interrupts. (why_stop, expect_n, sub2_from_pc): New function.
* remote-utils.c (gr_load_image): call fflush and QUIT more regularly.
* utils.c (notice_quit): New function for polling for user interrupts.
Diffstat (limited to 'gdb/ser-go32.c')
-rw-r--r-- | gdb/ser-go32.c | 187 |
1 files changed, 83 insertions, 104 deletions
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c index ff7c0a7..24c55f2 100644 --- a/gdb/ser-go32.c +++ b/gdb/ser-go32.c @@ -1,21 +1,21 @@ /* Remote serial interface for local (hardwired) serial ports for GO32. Copyright 1992, 1993 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "serial.h" @@ -23,38 +23,35 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This is unused for now. We just return a placeholder. */ struct go32_ttystate -{ - int bogus; -}; - -typedef struct { - short jmp_op; - short signature; - short version; - short buffer_start; - short buffer_end; - short getp; - short putp; - short iov; -} ASYNC_STRUCT; + { + int bogus; + }; + +typedef struct + { + short jmp_op; + short signature; + short version; + short buffer_start; + short buffer_end; + short getp; + short putp; + short iov; + } +ASYNC_STRUCT; static int go32_open PARAMS ((serial_t scb, const char *name)); static void go32_raw PARAMS ((serial_t scb)); -static int wait_for PARAMS ((serial_t scb, int timeout)); static int go32_readchar PARAMS ((serial_t scb, int timeout)); -static int rate_to_code PARAMS ((int rate)); static int go32_setbaudrate PARAMS ((serial_t scb, int rate)); static int go32_write PARAMS ((serial_t scb, const char *str, int len)); -static void go32_restore PARAMS ((serial_t scb)); static void go32_close PARAMS ((serial_t scb)); static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb)); static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state)); -static int strncasecmp PARAMS ((const char *str1, const char *str2, int len)); static char *aptr PARAMS ((short p)); static ASYNC_STRUCT *getivec PARAMS ((int which)); static int dos_async_init PARAMS ((int port)); static void dos_async_tx PARAMS ((const char c)); -static int dos_async_ready PARAMS (()); static int dos_async_rx PARAMS (()); static int dosasync_read PARAMS ((int fd, char *buf, int len, int timeout)); static int dosasync_write PARAMS ((int fd, const char *buf, int len)); @@ -65,7 +62,7 @@ static int dosasync_write PARAMS ((int fd, const char *buf, int len)); #define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b))) -static ASYNC_STRUCT *async; +static volatile ASYNC_STRUCT *async; static int iov; #define com_rb iov #define com_tb iov @@ -76,43 +73,22 @@ static int iov; #define com_lsr iov+5 #define com_msr iov+6 -static int -strncasecmp(str1, str2, len) - const char *str1, *str2; - register int len; -{ - unsigned char c1, c2; - - for (; len != 0; --len) - { - c1 = *str1++; - c2 = *str2++; - - if (toupper(c1) != toupper(c2)) - return toupper(c1) - toupper(c2); - - if (c1 == '\0') - return 0; - } - return 0; -} - static char * -aptr(p) +aptr (p) short p; { - return (char *)((unsigned)async - OFFSET + p); + return (char *) ((unsigned) async - OFFSET + p); } static ASYNC_STRUCT * -getivec(int which) +getivec (int which) { ASYNC_STRUCT *a; - if (peek(0, which*4) != OFFSET) + if (peek (0, which * 4) != OFFSET) return 0; - 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)); if (a->signature != SIGNATURE) return 0; @@ -124,11 +100,9 @@ getivec(int which) } static int -dos_async_init(port) +dos_async_init (port) int port; { - int i; - switch (port) { case 1: @@ -143,7 +117,7 @@ dos_async_init(port) if (!async) { - error("GDB cannot connect to asynctsr program, check that it is installed\n\ + error ("GDB cannot connect to asynctsr program, check that it is installed\n\ and that serial I/O is not being redirected (perhaps by NFS)\n\n\ example configuration:\n\ C> mode com%d:9600,n,8,1,p\n\ @@ -152,42 +126,40 @@ C> gdb \n", port, port); } iov = async->iov; - outportb(com_ier, 0x0f); - outportb(com_bfr, 0x03); - outportb(com_mcr, 0x0b); + outportb (com_ier, 0x0f); + outportb (com_bfr, 0x03); + outportb (com_mcr, 0x0b); async->getp = async->putp = async->buffer_start; - + return 1; } static void -dos_async_tx(c) +dos_async_tx (c) const char c; { - while (~inportb(com_lsr) & 0x20); - - outportb(com_tb, c); + while (~inportb (com_lsr) & 0x20) + ; + outportb (com_tb, c); } -static int -dos_async_ready() -{ - return (async->getp != async->putp); -} +#define dos_async_ready() (async->getp != async->putp) static int -dos_async_rx() +dos_async_rx () { char rv; - while (!dos_async_ready()) - if (kbhit()) - { - printf_unfiltered("abort!\n"); - return 0; - } + while (!dos_async_ready ()) + { + if (kbhit ()) + { + printf_unfiltered ("abort!\n"); + return 0; + } + } - rv = *aptr(async->getp++); + rv = *aptr (async->getp++); if (async->getp >= async->buffer_end) async->getp = async->buffer_start; @@ -202,37 +174,36 @@ dosasync_read (fd, buf, len, timeout) int timeout; { long now, then; - int l = len; + int i; time (&now); then = now + timeout; - while (l--) + for (i = 0; i < len; i++) { if (timeout) { - while (!dos_async_ready()) + while (!dos_async_ready ()) { time (&now); if (now >= then) - return len - l - 1; + return i; } } - *buf++ = dos_async_rx(); + *buf++ = dos_async_rx (); } - return len; } static int -dosasync_write(fd, buf, len) +dosasync_write (fd, buf, len) int fd; const char *buf; int len; { - int l = len; + int l; - while (l--) + for (l = 0; l < len; l++) dos_async_tx (*buf++); return len; @@ -259,7 +230,7 @@ go32_open (scb, name) return -11; } - scb->fd = dos_async_init(port); + scb->fd = dos_async_init (port); if (!scb->fd) return -1; @@ -287,7 +258,17 @@ go32_readchar (scb, timeout) { char buf; - if (dosasync_read(scb->fd, &buf, 1, timeout)) + /* Shortcut for polling */ + if (timeout == 0) + { + if (dos_async_ready ()) + { + return dos_async_rx (); + } + return SERIAL_TIMEOUT; + } + + if (dosasync_read (scb->fd, &buf, 1, timeout)) return buf; else return SERIAL_TIMEOUT; @@ -297,23 +278,21 @@ go32_readchar (scb, timeout) vector. Someday, they may do something real... */ static serial_ttystate -go32_get_tty_state(scb) +go32_get_tty_state (scb) serial_t scb; { struct go32_ttystate *state; - state = (struct go32_ttystate *)xmalloc(sizeof *state); + state = (struct go32_ttystate *) xmalloc (sizeof *state); - return (serial_ttystate)state; + return (serial_ttystate) state; } static int -go32_set_tty_state(scb, ttystate) +go32_set_tty_state (scb, ttystate) serial_t scb; serial_ttystate ttystate; { - struct go32_ttystate *state; - return 0; } @@ -349,7 +328,7 @@ go32_write (scb, str, len) const char *str; int len; { - dosasync_write(scb->fd, str, len); + dosasync_write (scb->fd, str, len); return 0; } @@ -368,9 +347,9 @@ static struct serial_ops go32_ops = go32_close, go32_readchar, go32_write, - go32_noop, /* flush output */ - go32_noop, /* flush input */ - go32_noop, /* send break -- currently used only for nindy */ + go32_noop, /* flush output */ + go32_noop, /* flush input */ + go32_noop, /* send break -- currently used only for nindy */ go32_raw, go32_get_tty_state, go32_set_tty_state, |