source: rtems-tools/tools/4.11/gdb/sparc/gdb-7.7-sis-output-nouartrx.diff @ 5cdcde1

4.104.115
Last change on this file since 5cdcde1 was 5cdcde1, checked in by Chris Johns <chrisj@…>, on 05/19/14 at 02:49:52

4.11/sparc: GDB 7.7 SIS simulator output patch.

  • Property mode set to 100644
File size: 8.6 KB
  • sim/erc32/erc32.c

    diff -ur gdb-7.7.orig/sim/erc32/erc32.c gdb-7.7/sim/erc32/erc32.c
    old new  
    2222/* The control space devices */
    2323
    2424#include "config.h"
     25#include <errno.h>
    2526#include <sys/types.h>
    2627#include <stdio.h>
    2728#include <string.h>
     
    4041extern char     uart_dev1[], uart_dev2[];
    4142
    4243int dumbio = 0; /* normal, smart, terminal oriented IO by default */
     44int tty_setup = 1; /* default setup if not a tty */
     45int disable_uartrx = 0; /* default is to poll for received data */
    4346
    4447/* MEC registers */
    4548#define MEC_START       0x01f80000
     
    305308
    306309extern int      ext_irl;
    307310
     311static host_callback *callback;
     312
    308313
    309314/* One-time init */
    310315
    311316void
    312 init_sim()
     317init_sim(host_callback* cb, int nouartrx)
    313318{
     319    callback = cb;
     320    disable_uartrx = nouartrx;
    314321    port_init();
    315322}
    316323
     
    940947{
    941948    if (dumbio)
    942949        return; /* do nothing */
    943     if (!ifd1)
     950    if (ifd1 == 0 && f1open) {
    944951        tcsetattr(0, TCSANOW, &ioc1);
    945     if (!ifd2)
     952        tcflush(ifd1, TCIFLUSH);
     953    }
     954    if (ifd2 == 0 && f1open) {
    946955        tcsetattr(0, TCSANOW, &ioc2);
     956        tcflush(ifd2, TCIFLUSH);
     957    }
    947958}
    948959
    949960void
     
    951962{
    952963    if (dumbio)
    953964        return; /* do nothing */
    954     if (!ifd1)
     965    if (ifd1 == 0 && f1open && tty_setup)
    955966        tcsetattr(0, TCSANOW, &iocold1);
    956     if (!ifd2)
     967    if (ifd2 == 0 && f2open && tty_setup)
    957968        tcsetattr(0, TCSANOW, &iocold2);
    958969}
    959970
    960971#define DO_STDIO_READ( _fd_, _buf_, _len_ )          \
    961              ( dumbio                               \
     972             ( dumbio || disable_uartrx \
    962973               ? (0) /* no bytes read, no delay */   \
    963                : read( _fd_, _buf_, _len_ ) )
     974               : (_fd_) == 1 && callback ? \
     975                 callback->read_stdin (callback, _buf_, _len_) :  \
     976                 read( _fd_, _buf_, _len_ ) )
    964977
    965978
    966979static void
     
    9901003        }
    9911004    if (f1in) ifd1 = fileno(f1in);
    9921005    if (ifd1 == 0) {
     1006        if (callback && !callback->isatty(callback, ifd1)) {
     1007            tty_setup = 0;
     1008        }
    9931009        if (sis_verbose)
    9941010            printf("serial port A on stdin/stdout\n");
    9951011        if (!dumbio) {
    9961012            tcgetattr(ifd1, &ioc1);
     1013            if (tty_setup) {
    9971014            iocold1 = ioc1;
    9981015            ioc1.c_lflag &= ~(ICANON | ECHO);
    9991016            ioc1.c_cc[VMIN] = 0;
    10001017            ioc1.c_cc[VTIME] = 0;
    10011018        }
     1019        }
    10021020        f1open = 1;
    10031021    }
    10041022
    10051023    if (f1out) {
    10061024        ofd1 = fileno(f1out);
    1007         if (!dumbio && ofd1 == 1) setbuf(f1out, NULL);
     1025        if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
    10081026    }
    10091027
    10101028    if (uart_dev2[0] != 0)
     
    10231041            printf("serial port B on stdin/stdout\n");
    10241042        if (!dumbio) {
    10251043            tcgetattr(ifd2, &ioc2);
     1044            if (tty_setup) {
    10261045            iocold2 = ioc2;
    10271046            ioc2.c_lflag &= ~(ICANON | ECHO);
    10281047            ioc2.c_cc[VMIN] = 0;
    10291048            ioc2.c_cc[VTIME] = 0;
    10301049        }
     1050        }
    10311051        f2open = 1;
    10321052    }
    10331053
    10341054    if (f2out) {
    10351055        ofd2 = fileno(f2out);
    1036         if (!dumbio && ofd2 == 1) setbuf(f2out, NULL);
     1056        if (!dumbio && tty_setup && ofd2 == 1) setbuf(f2out, NULL);
    10371057    }
    10381058
    10391059    wnuma = wnumb = 0;
     
    10621082            if (f1open) {
    10631083                anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
    10641084            }
     1085      else {
     1086          anum = 0;
     1087      }
    10651088            if (anum > 0) {
    10661089                aind = 0;
    10671090                if ((aind + 1) < anum)
     
    10941117            if (f2open) {
    10951118                bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
    10961119            }
     1120            else {
     1121                bnum = 0;
     1122            }
    10971123            if (bnum > 0) {
    10981124                bind = 0;
    10991125                if ((bind + 1) < bnum)
     
    11261152            if (f1open) {
    11271153                anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
    11281154            }
     1155            else {
     1156                anum = 0;
     1157            }
    11291158            if (anum > 0) {
    11301159                Ucontrol |= 0x00000001;
    11311160                aind = 0;
     
    11381167            if (f2open) {
    11391168                bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
    11401169            }
     1170            else {
     1171                bnum = 0;
     1172            }
    11411173            if (bnum > 0) {
    11421174                Ucontrol |= 0x00010000;
    11431175                bind = 0;
     
    11781210            if (wnuma < UARTBUF)
    11791211                wbufa[wnuma++] = c;
    11801212            else {
    1181                 while (wnuma)
     1213                while (wnuma) {
     1214              if (ofd1 == 1 && callback)
     1215                  wnuma -= callback->write_stdout(callback, wbufa, wnuma);
     1216              else
    11821217                    wnuma -= fwrite(wbufa, 1, wnuma, f1out);
     1218          }
    11831219                wbufa[wnuma++] = c;
    11841220            }
    11851221        }
     
    12021238            if (wnumb < UARTBUF)
    12031239                wbufb[wnumb++] = c;
    12041240            else {
    1205                 while (wnumb)
     1241          while (wnumb) {
     1242              if (ofd1 == 1 && callback)
     1243                  wnumb -= callback->write_stdout(callback, wbufb, wnumb);
     1244              else
    12061245                    wnumb -= fwrite(wbufb, 1, wnumb, f2out);
     1246          }
    12071247                wbufb[wnumb++] = c;
    12081248            }
    12091249        }
     
    12411281static void
    12421282flush_uart()
    12431283{
    1244     while (wnuma && f1open)
     1284    while (wnuma && f1open) {
     1285        if (ofd1 == 1 && callback) {
     1286            wnuma -= callback->write_stdout(callback, wbufa, wnuma);
     1287            callback->flush_stdout(callback);
     1288        }
     1289        else
    12451290        wnuma -= fwrite(wbufa, 1, wnuma, f1out);
    1246     while (wnumb && f2open)
     1291    }
     1292    while (wnumb && f2open) {
     1293        if (ofd2 == 1 && callback) {
     1294            wnuma -= callback->write_stdout(callback, wbufb, wnuma);
     1295            callback->flush_stdout(callback);
     1296        }
     1297        else
    12471298        wnumb -= fwrite(wbufb, 1, wnumb, f2out);
    12481299}
     1300}
    12491301
    12501302
    12511303
    12521304static void
    12531305uarta_tx()
    12541306{
    1255 
    1256     while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1);
     1307    while (f1open) {
     1308        if (ofd1 == 1 && callback) {
     1309            while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
     1310        }
     1311        else {
     1312            while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
     1313        }
     1314    }
    12571315    if (uart_stat_reg & UARTA_HRE) {
    12581316        uart_stat_reg |= UARTA_SRE;
    12591317    } else {
     
    12671325static void
    12681326uartb_tx()
    12691327{
    1270     while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1);
     1328    while (f2open) {
     1329        if (ofd2 == 1 && callback) {
     1330            while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
     1331        }
     1332        else {
     1333            while (fwrite(&uartb_sreg, 1, 1, f2out) != 1);
     1334        }
     1335    }
    12711336    if (uart_stat_reg & UARTB_HRE) {
    12721337        uart_stat_reg |= UARTB_SRE;
    12731338    } else {
     
    12891354    rsize = 0;
    12901355    if (f1open)
    12911356        rsize = DO_STDIO_READ(ifd1, &rxd, 1);
     1357    else
     1358        rsize = 0;
    12921359    if (rsize > 0) {
    12931360        uarta_data = UART_DR | rxd;
    12941361        if (uart_stat_reg & UARTA_HRE)
     
    13051372    rsize = 0;
    13061373    if (f2open)
    13071374        rsize = DO_STDIO_READ(ifd2, &rxd, 1);
     1375    else
     1376        rsize = 0;
    13081377    if (rsize) {
    13091378        uartb_data = UART_DR | rxd;
    13101379        if (uart_stat_reg & UARTB_HRE)
  • sim/erc32/interf.c

    diff -ur gdb-7.7.orig/sim/erc32/interf.c gdb-7.7/sim/erc32/interf.c
    old new  
    185185    int             argc = 0;
    186186    int             stat = 1;
    187187    int             freq = 0;
     188    int             nouartrx = 0;
    188189
    189190    sim_callback = callback;
    190191
     
    210211            if (strcmp(argv[stat], "-dumbio") == 0) {
    211212                dumbio = 1;
    212213            } else
     214            if (strcmp(argv[stat], "-nouartrx") == 0) {
     215                nouartrx = 1;
     216            } else
    213217            if (strcmp(argv[stat], "-wrp") == 0) {
    214218                wrp = 1;
    215219            } else
     
    268272    dinfo.endian = BFD_ENDIAN_BIG;
    269273    reset_all();
    270274    ebase.simtime = 0;
    271     init_sim();
     275    init_sim(callback, nouartrx);
    272276    init_bpt(&sregs);
    273277    reset_stat(&sregs);
    274278
  • sim/erc32/sis.c

    diff -ur gdb-7.7.orig/sim/erc32/sis.c gdb-7.7/sim/erc32/sis.c
    old new  
    166166    int             cont = 1;
    167167    int             stat = 1;
    168168    int             freq = 14;
     169    int             nouartrx = 0;
    169170    int             copt = 0;
    170171
    171172    char           *cfile, *bacmd;
     
    214215#endif
    215216            } else if (strcmp(argv[stat], "-dumbio") == 0) {
    216217                dumbio = 1;
     218            } else if (strcmp(argv[stat], "-nouartrx") == 0) {
     219                nouartrx = 1;
    217220            } else {
    218221                printf("unknown option %s\n", argv[stat]);
    219222                usage();
     
    241244    ebase.simtime = 0;
    242245    reset_all();
    243246    init_bpt(&sregs);
    244     init_sim();
     247    init_sim(NULL, nouartrx);
    245248#ifdef STAT
    246249    reset_stat(&sregs);
    247250#endif
  • sim/erc32/sis.h

    diff -ur gdb-7.7.orig/sim/erc32/sis.h gdb-7.7/sim/erc32/sis.h
    old new  
    159159/* Prototypes  */
    160160
    161161/* erc32.c */
    162 extern void     init_sim (void);
     162extern void     init_sim (host_callback* sb, int nouartrx);
    163163extern void     reset (void);
    164164extern void     error_mode (uint32 pc);
    165165extern void     sim_halt (void);
Note: See TracBrowser for help on using the repository browser.