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
RevLine 
[5cdcde1]1diff -ur gdb-7.7.orig/sim/erc32/erc32.c gdb-7.7/sim/erc32/erc32.c
2--- gdb-7.7.orig/sim/erc32/erc32.c      2014-01-08 20:23:36.000000000 +1100
3+++ gdb-7.7/sim/erc32/erc32.c   2014-05-19 10:59:56.000000000 +1000
4@@ -22,6 +22,7 @@
5 /* The control space devices */
6 
7 #include "config.h"
8+#include <errno.h>
9 #include <sys/types.h>
10 #include <stdio.h>
11 #include <string.h>
12@@ -40,6 +41,8 @@
13 extern char     uart_dev1[], uart_dev2[];
14 
15 int dumbio = 0; /* normal, smart, terminal oriented IO by default */
16+int tty_setup = 1; /* default setup if not a tty */
17+int disable_uartrx = 0; /* default is to poll for received data */
18 
19 /* MEC registers */
20 #define MEC_START      0x01f80000
21@@ -305,12 +308,16 @@
22 
23 extern int     ext_irl;
24 
25+static host_callback *callback;
26+
27 
28 /* One-time init */
29 
30 void
31-init_sim()
32+init_sim(host_callback* cb, int nouartrx)
33 {
34+    callback = cb;
35+    disable_uartrx = nouartrx;
36     port_init();
37 }
38 
39@@ -940,10 +947,14 @@
40 {
41     if (dumbio)
42         return; /* do nothing */
43-    if (!ifd1)
44+    if (ifd1 == 0 && f1open) {
45        tcsetattr(0, TCSANOW, &ioc1);
46-    if (!ifd2)
47+        tcflush(ifd1, TCIFLUSH);
48+    }
49+    if (ifd2 == 0 && f1open) {
50        tcsetattr(0, TCSANOW, &ioc2);
51+        tcflush(ifd2, TCIFLUSH);
52+    }
53 }
54 
55 void
56@@ -951,16 +962,18 @@
57 {
58     if (dumbio)
59         return; /* do nothing */
60-    if (!ifd1)
61+    if (ifd1 == 0 && f1open && tty_setup)
62        tcsetattr(0, TCSANOW, &iocold1);
63-    if (!ifd2)
64+    if (ifd2 == 0 && f2open && tty_setup)
65        tcsetattr(0, TCSANOW, &iocold2);
66 }
67 
68 #define DO_STDIO_READ( _fd_, _buf_, _len_ )          \
69-             ( dumbio                                \
70+             ( dumbio || disable_uartrx \
71                ? (0) /* no bytes read, no delay */   \
72-               : read( _fd_, _buf_, _len_ ) )
73+               : (_fd_) == 1 && callback ? \
74+                 callback->read_stdin (callback, _buf_, _len_) :  \
75+                 read( _fd_, _buf_, _len_ ) )
76 
77 
78 static void
79@@ -990,21 +1003,26 @@
80        }
81     if (f1in) ifd1 = fileno(f1in);
82     if (ifd1 == 0) {
83+        if (callback && !callback->isatty(callback, ifd1)) {
84+            tty_setup = 0;
85+        }
86        if (sis_verbose)
87            printf("serial port A on stdin/stdout\n");
88         if (!dumbio) {
89             tcgetattr(ifd1, &ioc1);
90+            if (tty_setup) {
91             iocold1 = ioc1;
92             ioc1.c_lflag &= ~(ICANON | ECHO);
93             ioc1.c_cc[VMIN] = 0;
94             ioc1.c_cc[VTIME] = 0;
95         }
96+        }
97        f1open = 1;
98     }
99 
100     if (f1out) {
101        ofd1 = fileno(f1out);
102-       if (!dumbio && ofd1 == 1) setbuf(f1out, NULL);
103+       if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
104     }
105 
106     if (uart_dev2[0] != 0)
107@@ -1023,17 +1041,19 @@
108            printf("serial port B on stdin/stdout\n");
109         if (!dumbio) {
110             tcgetattr(ifd2, &ioc2);
111+            if (tty_setup) {
112             iocold2 = ioc2;
113             ioc2.c_lflag &= ~(ICANON | ECHO);
114             ioc2.c_cc[VMIN] = 0;
115             ioc2.c_cc[VTIME] = 0;
116         }
117+        }
118        f2open = 1;
119     }
120 
121     if (f2out) {
122        ofd2 = fileno(f2out);
123-        if (!dumbio && ofd2 == 1) setbuf(f2out, NULL);
124+        if (!dumbio && tty_setup && ofd2 == 1) setbuf(f2out, NULL);
125     }
126 
127     wnuma = wnumb = 0;
128@@ -1062,6 +1082,9 @@
129            if (f1open) {
130                anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
131            }
132+      else {
133+          anum = 0;
134+      }
135            if (anum > 0) {
136                aind = 0;
137                if ((aind + 1) < anum)
138@@ -1094,6 +1117,9 @@
139            if (f2open) {
140                bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
141            }
142+           else {
143+               bnum = 0;
144+           }
145            if (bnum > 0) {
146                bind = 0;
147                if ((bind + 1) < bnum)
148@@ -1126,6 +1152,9 @@
149            if (f1open) {
150                anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
151             }
152+           else {
153+               anum = 0;
154+           }
155            if (anum > 0) {
156                Ucontrol |= 0x00000001;
157                aind = 0;
158@@ -1138,6 +1167,9 @@
159            if (f2open) {
160                bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
161            }
162+           else {
163+               bnum = 0;
164+           }
165            if (bnum > 0) {
166                Ucontrol |= 0x00010000;
167                bind = 0;
168@@ -1178,8 +1210,12 @@
169            if (wnuma < UARTBUF)
170                wbufa[wnuma++] = c;
171            else {
172-               while (wnuma)
173+               while (wnuma) {
174+              if (ofd1 == 1 && callback)
175+                  wnuma -= callback->write_stdout(callback, wbufa, wnuma);
176+              else
177                    wnuma -= fwrite(wbufa, 1, wnuma, f1out);
178+          }
179                wbufa[wnuma++] = c;
180            }
181        }
182@@ -1202,8 +1238,12 @@
183            if (wnumb < UARTBUF)
184                wbufb[wnumb++] = c;
185            else {
186-               while (wnumb)
187+          while (wnumb) {
188+              if (ofd1 == 1 && callback)
189+                  wnumb -= callback->write_stdout(callback, wbufb, wnumb);
190+              else
191                    wnumb -= fwrite(wbufb, 1, wnumb, f2out);
192+          }
193                wbufb[wnumb++] = c;
194            }
195        }
196@@ -1241,19 +1281,37 @@
197 static void
198 flush_uart()
199 {
200-    while (wnuma && f1open)
201+    while (wnuma && f1open) {
202+        if (ofd1 == 1 && callback) {
203+            wnuma -= callback->write_stdout(callback, wbufa, wnuma);
204+            callback->flush_stdout(callback);
205+        }
206+        else
207        wnuma -= fwrite(wbufa, 1, wnuma, f1out);
208-    while (wnumb && f2open)
209+    }
210+    while (wnumb && f2open) {
211+        if (ofd2 == 1 && callback) {
212+            wnuma -= callback->write_stdout(callback, wbufb, wnuma);
213+            callback->flush_stdout(callback);
214+        }
215+        else
216        wnumb -= fwrite(wbufb, 1, wnumb, f2out);
217 }
218+}
219 
220 
221 
222 static void
223 uarta_tx()
224 {
225-
226-    while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1);
227+    while (f1open) {
228+        if (ofd1 == 1 && callback) {
229+            while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
230+        }
231+        else {
232+            while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
233+        }
234+    }
235     if (uart_stat_reg & UARTA_HRE) {
236        uart_stat_reg |= UARTA_SRE;
237     } else {
238@@ -1267,7 +1325,14 @@
239 static void
240 uartb_tx()
241 {
242-    while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1);
243+    while (f2open) {
244+        if (ofd2 == 1 && callback) {
245+            while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
246+        }
247+        else {
248+            while (fwrite(&uartb_sreg, 1, 1, f2out) != 1);
249+        }
250+    }
251     if (uart_stat_reg & UARTB_HRE) {
252        uart_stat_reg |= UARTB_SRE;
253     } else {
254@@ -1289,6 +1354,8 @@
255     rsize = 0;
256     if (f1open)
257         rsize = DO_STDIO_READ(ifd1, &rxd, 1);
258+    else
259+        rsize = 0;
260     if (rsize > 0) {
261        uarta_data = UART_DR | rxd;
262        if (uart_stat_reg & UARTA_HRE)
263@@ -1305,6 +1372,8 @@
264     rsize = 0;
265     if (f2open)
266         rsize = DO_STDIO_READ(ifd2, &rxd, 1);
267+    else
268+        rsize = 0;
269     if (rsize) {
270        uartb_data = UART_DR | rxd;
271        if (uart_stat_reg & UARTB_HRE)
272diff -ur gdb-7.7.orig/sim/erc32/interf.c gdb-7.7/sim/erc32/interf.c
273--- gdb-7.7.orig/sim/erc32/interf.c     2013-12-08 15:55:48.000000000 +1100
274+++ gdb-7.7/sim/erc32/interf.c  2014-05-19 10:59:56.000000000 +1000
275@@ -185,6 +185,7 @@
276     int             argc = 0;
277     int             stat = 1;
278     int             freq = 0;
279+    int             nouartrx = 0;
280 
281     sim_callback = callback;
282 
283@@ -210,6 +211,9 @@
284             if (strcmp(argv[stat], "-dumbio") == 0) {
285                dumbio = 1;
286            } else
287+            if (strcmp(argv[stat], "-nouartrx") == 0) {
288+               nouartrx = 1;
289+           } else
290             if (strcmp(argv[stat], "-wrp") == 0) {
291                 wrp = 1;
292            } else
293@@ -268,7 +272,7 @@
294     dinfo.endian = BFD_ENDIAN_BIG;
295     reset_all();
296     ebase.simtime = 0;
297-    init_sim();
298+    init_sim(callback, nouartrx);
299     init_bpt(&sregs);
300     reset_stat(&sregs);
301 
302diff -ur gdb-7.7.orig/sim/erc32/sis.c gdb-7.7/sim/erc32/sis.c
303--- gdb-7.7.orig/sim/erc32/sis.c        2014-01-08 20:23:36.000000000 +1100
304+++ gdb-7.7/sim/erc32/sis.c     2014-05-19 10:59:56.000000000 +1000
305@@ -166,6 +166,7 @@
306     int             cont = 1;
307     int             stat = 1;
308     int             freq = 14;
309+    int             nouartrx = 0;
310     int             copt = 0;
311 
312     char           *cfile, *bacmd;
313@@ -214,6 +215,8 @@
314 #endif
315             } else if (strcmp(argv[stat], "-dumbio") == 0) {
316                dumbio = 1;
317+            } else if (strcmp(argv[stat], "-nouartrx") == 0) {
318+               nouartrx = 1;
319            } else {
320                printf("unknown option %s\n", argv[stat]);
321                usage();
322@@ -241,7 +244,7 @@
323     ebase.simtime = 0;
324     reset_all();
325     init_bpt(&sregs);
326-    init_sim();
327+    init_sim(NULL, nouartrx);
328 #ifdef STAT
329     reset_stat(&sregs);
330 #endif
331diff -ur gdb-7.7.orig/sim/erc32/sis.h gdb-7.7/sim/erc32/sis.h
332--- gdb-7.7.orig/sim/erc32/sis.h        2014-01-08 20:23:36.000000000 +1100
333+++ gdb-7.7/sim/erc32/sis.h     2014-05-19 12:36:36.000000000 +1000
334@@ -159,7 +159,7 @@
335 /* Prototypes  */
336 
337 /* erc32.c */
338-extern void    init_sim (void);
339+extern void    init_sim (host_callback* sb, int nouartrx);
340 extern void    reset (void);
341 extern void    error_mode (uint32 pc);
342 extern void    sim_halt (void);
Note: See TracBrowser for help on using the repository browser.