[0bbd2de] | 1 | diff -ruw gdb-7.11.orig1/sim/erc32/erc32.c gdb-7.11/sim/erc32/erc32.c |
---|
| 2 | --- gdb-7.11.orig1/sim/erc32/erc32.c 2016-03-16 14:00:04.632565918 +1100 |
---|
| 3 | +++ gdb-7.11/sim/erc32/erc32.c 2016-03-16 14:06:57.604576368 +1100 |
---|
| 4 | @@ -19,6 +19,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 | @@ -36,6 +37,7 @@ |
---|
| 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 | |
---|
| 18 | /* MEC registers */ |
---|
| 19 | #define MEC_START 0x01f80000 |
---|
| 20 | @@ -293,12 +295,15 @@ |
---|
| 21 | |
---|
| 22 | extern int ext_irl; |
---|
| 23 | |
---|
| 24 | +static host_callback *callback; |
---|
| 25 | + |
---|
| 26 | |
---|
| 27 | /* One-time init */ |
---|
| 28 | |
---|
| 29 | void |
---|
| 30 | init_sim() |
---|
| 31 | { |
---|
| 32 | + callback = sim_callback; |
---|
| 33 | port_init(); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | @@ -321,12 +326,12 @@ |
---|
| 37 | sys_reset(); |
---|
| 38 | mec_ersr = 0x8000; |
---|
| 39 | if (sis_verbose) |
---|
| 40 | - printf("Error manager reset - IU in error mode\n"); |
---|
| 41 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager reset - IU in error mode\n"); |
---|
| 42 | } else { |
---|
| 43 | sys_halt(); |
---|
| 44 | mec_ersr |= 0x2000; |
---|
| 45 | if (sis_verbose) |
---|
| 46 | - printf("Error manager halt - IU in error mode\n"); |
---|
| 47 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager halt - IU in error mode\n"); |
---|
| 48 | } |
---|
| 49 | } else |
---|
| 50 | mec_irq(1); |
---|
| 51 | @@ -337,12 +342,12 @@ |
---|
| 52 | sys_reset(); |
---|
| 53 | mec_ersr = 0x8000; |
---|
| 54 | if (sis_verbose) |
---|
| 55 | - printf("Error manager reset - IU comparison error\n"); |
---|
| 56 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager reset - IU comparison error\n"); |
---|
| 57 | } else { |
---|
| 58 | sys_halt(); |
---|
| 59 | mec_ersr |= 0x2000; |
---|
| 60 | if (sis_verbose) |
---|
| 61 | - printf("Error manager halt - IU comparison error\n"); |
---|
| 62 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager halt - IU comparison error\n"); |
---|
| 63 | } |
---|
| 64 | } else |
---|
| 65 | mec_irq(1); |
---|
| 66 | @@ -353,12 +358,12 @@ |
---|
| 67 | sys_reset(); |
---|
| 68 | mec_ersr = 0x8000; |
---|
| 69 | if (sis_verbose) |
---|
| 70 | - printf("Error manager reset - MEC hardware error\n"); |
---|
| 71 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager reset - MEC hardware error\n"); |
---|
| 72 | } else { |
---|
| 73 | sys_halt(); |
---|
| 74 | mec_ersr |= 0x2000; |
---|
| 75 | if (sis_verbose) |
---|
| 76 | - printf("Error manager halt - MEC hardware error\n"); |
---|
| 77 | + (*sim_callback->printf_filtered) (sim_callback, "Error manager halt - MEC hardware error\n"); |
---|
| 78 | } |
---|
| 79 | } else |
---|
| 80 | mec_irq(1); |
---|
| 81 | @@ -416,7 +421,7 @@ |
---|
| 82 | mem_rammask = RAM_MASK; |
---|
| 83 | } |
---|
| 84 | if (sis_verbose) |
---|
| 85 | - printf("RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n", |
---|
| 86 | + (*sim_callback->printf_filtered) (sim_callback, "RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n", |
---|
| 87 | mem_ramstart, mem_ramsz >> 10, mem_romsz >> 10); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | @@ -432,7 +437,7 @@ |
---|
| 91 | } |
---|
| 92 | mem_romw_ws = (mec_wcr >> 8) & 0x0f; |
---|
| 93 | if (sis_verbose) |
---|
| 94 | - printf("Waitstates = RAM read: %d, RAM write: %d, ROM read: %d, ROM write: %d\n", |
---|
| 95 | + (*sim_callback->printf_filtered) (sim_callback, "Waitstates = RAM read: %d, RAM write: %d, ROM read: %d, ROM write: %d\n", |
---|
| 96 | mem_ramr_ws, mem_ramw_ws, mem_romr_ws, mem_romw_ws); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | @@ -442,15 +447,15 @@ |
---|
| 100 | mem_accprot = (mec_wpr[0] | mec_wpr[1]); |
---|
| 101 | mem_blockprot = (mec_mcr >> 3) & 1; |
---|
| 102 | if (sis_verbose && mem_accprot) |
---|
| 103 | - printf("Memory block write protection enabled\n"); |
---|
| 104 | + (*sim_callback->printf_filtered) (sim_callback, "Memory block write protection enabled\n"); |
---|
| 105 | if (mec_mcr & 0x08000) { |
---|
| 106 | mec_ersr |= 0x20; |
---|
| 107 | decode_ersr(); |
---|
| 108 | } |
---|
| 109 | if (sis_verbose && (mec_mcr & 2)) |
---|
| 110 | - printf("Software reset enabled\n"); |
---|
| 111 | + (*sim_callback->printf_filtered) (sim_callback, "Software reset enabled\n"); |
---|
| 112 | if (sis_verbose && (mec_mcr & 1)) |
---|
| 113 | - printf("Power-down mode enabled\n"); |
---|
| 114 | + (*sim_callback->printf_filtered) (sim_callback, "Power-down mode enabled\n"); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | /* Flush ports when simulator stops */ |
---|
| 118 | @@ -553,7 +558,7 @@ |
---|
| 119 | int irq_test; |
---|
| 120 | |
---|
| 121 | if (sis_verbose) |
---|
| 122 | - printf("interrupt %d acknowledged\n", level); |
---|
| 123 | + (*sim_callback->printf_filtered) (sim_callback, "interrupt %d acknowledged\n", level); |
---|
| 124 | irq_test = mec_tcr & 0x80000; |
---|
| 125 | if ((irq_test) && (mec_ifr & (1 << level))) |
---|
| 126 | mec_ifr &= ~(1 << level); |
---|
| 127 | @@ -578,7 +583,7 @@ |
---|
| 128 | for (i = 15; i > 0; i--) { |
---|
| 129 | if (((itmp >> i) & 1) != 0) { |
---|
| 130 | if ((sis_verbose) && (i > old_irl)) |
---|
| 131 | - printf("IU irl: %d\n", i); |
---|
| 132 | + (*sim_callback->printf_filtered) (sim_callback, "IU irl: %d\n", i); |
---|
| 133 | ext_irl = i; |
---|
| 134 | set_int(i, mec_intack, i); |
---|
| 135 | break; |
---|
| 136 | @@ -753,7 +758,7 @@ |
---|
| 137 | uint32 data; |
---|
| 138 | { |
---|
| 139 | if (sis_verbose > 1) |
---|
| 140 | - printf("MEC write a: %08x, d: %08x\n",addr,data); |
---|
| 141 | + (*sim_callback->printf_filtered) (sim_callback, "MEC write a: %08x, d: %08x\n",addr,data); |
---|
| 142 | switch (addr & 0x0ff) { |
---|
| 143 | |
---|
| 144 | case MEC_MCR: |
---|
| 145 | @@ -767,7 +772,7 @@ |
---|
| 146 | sys_reset(); |
---|
| 147 | mec_ersr = 0x4000; |
---|
| 148 | if (sis_verbose) |
---|
| 149 | - printf(" Software reset issued\n"); |
---|
| 150 | + (*sim_callback->printf_filtered) (sim_callback, " Software reset issued\n"); |
---|
| 151 | } |
---|
| 152 | break; |
---|
| 153 | |
---|
| 154 | @@ -782,7 +787,7 @@ |
---|
| 155 | mec_wpr[0] = (data >> 23) & 0x03; |
---|
| 156 | mem_accprot = mec_wpr[0] || mec_wpr[1]; |
---|
| 157 | if (sis_verbose && mec_wpr[0]) |
---|
| 158 | - printf("Segment 1 memory protection enabled (0x02%06x - 0x02%06x)\n", |
---|
| 159 | + (*sim_callback->printf_filtered) (sim_callback, "Segment 1 memory protection enabled (0x02%06x - 0x02%06x)\n", |
---|
| 160 | mec_ssa[0] << 2, mec_sea[0] << 2); |
---|
| 161 | break; |
---|
| 162 | case MEC_SEA1: /* 0x24 */ |
---|
| 163 | @@ -795,7 +800,7 @@ |
---|
| 164 | mec_wpr[1] = (data >> 23) & 0x03; |
---|
| 165 | mem_accprot = mec_wpr[0] || mec_wpr[1]; |
---|
| 166 | if (sis_verbose && mec_wpr[1]) |
---|
| 167 | - printf("Segment 2 memory protection enabled (0x02%06x - 0x02%06x)\n", |
---|
| 168 | + (*sim_callback->printf_filtered) (sim_callback, "Segment 2 memory protection enabled (0x02%06x - 0x02%06x)\n", |
---|
| 169 | mec_ssa[1] << 2, mec_sea[1] << 2); |
---|
| 170 | break; |
---|
| 171 | case MEC_SEA2: /* 0x2c */ |
---|
| 172 | @@ -909,7 +914,7 @@ |
---|
| 173 | if (wdog_status == init) { |
---|
| 174 | wdog_status = disabled; |
---|
| 175 | if (sis_verbose) |
---|
| 176 | - printf("Watchdog disabled\n"); |
---|
| 177 | + (*sim_callback->printf_filtered) (sim_callback, "Watchdog disabled\n"); |
---|
| 178 | } |
---|
| 179 | break; |
---|
| 180 | |
---|
| 181 | @@ -936,10 +941,14 @@ |
---|
| 182 | { |
---|
| 183 | if (dumbio) |
---|
| 184 | return; /* do nothing */ |
---|
| 185 | - if (!ifd1) |
---|
| 186 | + if (ifd1 == 0 && f1open) { |
---|
| 187 | tcsetattr(0, TCSANOW, &ioc1); |
---|
| 188 | - if (!ifd2) |
---|
| 189 | + tcflush(ifd1, TCIFLUSH); |
---|
| 190 | + } |
---|
| 191 | + if (ifd2 == 0 && f1open) { |
---|
| 192 | tcsetattr(0, TCSANOW, &ioc2); |
---|
| 193 | + tcflush(ifd2, TCIFLUSH); |
---|
| 194 | + } |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | void |
---|
| 198 | @@ -947,16 +956,18 @@ |
---|
| 199 | { |
---|
| 200 | if (dumbio) |
---|
| 201 | return; /* do nothing */ |
---|
| 202 | - if (!ifd1) |
---|
| 203 | + if (ifd1 == 0 && f1open && tty_setup) |
---|
| 204 | tcsetattr(0, TCSANOW, &iocold1); |
---|
| 205 | - if (!ifd2) |
---|
| 206 | + if (ifd2 == 0 && f2open && tty_setup) |
---|
| 207 | tcsetattr(0, TCSANOW, &iocold2); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | #define DO_STDIO_READ( _fd_, _buf_, _len_ ) \ |
---|
| 211 | - ( dumbio \ |
---|
| 212 | + ( dumbio || nouartrx \ |
---|
| 213 | ? (0) /* no bytes read, no delay */ \ |
---|
| 214 | - : read( _fd_, _buf_, _len_ ) ) |
---|
| 215 | + : (_fd_) == 1 && callback ? \ |
---|
| 216 | + callback->read_stdin (callback, _buf_, _len_) : \ |
---|
| 217 | + read( _fd_, _buf_, _len_ ) ) |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | static void |
---|
| 221 | @@ -976,39 +987,44 @@ |
---|
| 222 | } |
---|
| 223 | if (uart_dev1[0] != 0) |
---|
| 224 | if ((fd1 = open(uart_dev1, O_RDWR | O_NONBLOCK)) < 0) { |
---|
| 225 | - printf("Warning, couldn't open output device %s\n", uart_dev1); |
---|
| 226 | + (*sim_callback->printf_filtered) (sim_callback, "Warning, couldn't open output device %s\n", uart_dev1); |
---|
| 227 | } else { |
---|
| 228 | if (sis_verbose) |
---|
| 229 | - printf("serial port A on %s\n", uart_dev1); |
---|
| 230 | + (*sim_callback->printf_filtered) (sim_callback, "serial port A on %s\n", uart_dev1); |
---|
| 231 | f1in = f1out = fdopen(fd1, "r+"); |
---|
| 232 | setbuf(f1out, NULL); |
---|
| 233 | f1open = 1; |
---|
| 234 | } |
---|
| 235 | if (f1in) ifd1 = fileno(f1in); |
---|
| 236 | if (ifd1 == 0) { |
---|
| 237 | + if (callback && !callback->isatty(callback, ifd1)) { |
---|
| 238 | + tty_setup = 0; |
---|
| 239 | + } |
---|
| 240 | if (sis_verbose) |
---|
| 241 | - printf("serial port A on stdin/stdout\n"); |
---|
| 242 | + (*sim_callback->printf_filtered) (sim_callback, "serial port A on stdin/stdout\n"); |
---|
| 243 | if (!dumbio) { |
---|
| 244 | tcgetattr(ifd1, &ioc1); |
---|
| 245 | + if (tty_setup) { |
---|
| 246 | iocold1 = ioc1; |
---|
| 247 | ioc1.c_lflag &= ~(ICANON | ECHO); |
---|
| 248 | ioc1.c_cc[VMIN] = 0; |
---|
| 249 | ioc1.c_cc[VTIME] = 0; |
---|
| 250 | } |
---|
| 251 | + } |
---|
| 252 | f1open = 1; |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | if (f1out) { |
---|
| 256 | ofd1 = fileno(f1out); |
---|
| 257 | - if (!dumbio && ofd1 == 1) setbuf(f1out, NULL); |
---|
| 258 | + if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL); |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | if (uart_dev2[0] != 0) |
---|
| 262 | if ((fd2 = open(uart_dev2, O_RDWR | O_NONBLOCK)) < 0) { |
---|
| 263 | - printf("Warning, couldn't open output device %s\n", uart_dev2); |
---|
| 264 | + (*sim_callback->printf_filtered) (sim_callback, "Warning, couldn't open output device %s\n", uart_dev2); |
---|
| 265 | } else { |
---|
| 266 | if (sis_verbose) |
---|
| 267 | - printf("serial port B on %s\n", uart_dev2); |
---|
| 268 | + (*sim_callback->printf_filtered) (sim_callback, "serial port B on %s\n", uart_dev2); |
---|
| 269 | f2in = f2out = fdopen(fd2, "r+"); |
---|
| 270 | setbuf(f2out, NULL); |
---|
| 271 | f2open = 1; |
---|
| 272 | @@ -1016,20 +1032,22 @@ |
---|
| 273 | if (f2in) ifd2 = fileno(f2in); |
---|
| 274 | if (ifd2 == 0) { |
---|
| 275 | if (sis_verbose) |
---|
| 276 | - printf("serial port B on stdin/stdout\n"); |
---|
| 277 | + (*sim_callback->printf_filtered) (sim_callback, "serial port B on stdin/stdout\n"); |
---|
| 278 | if (!dumbio) { |
---|
| 279 | tcgetattr(ifd2, &ioc2); |
---|
| 280 | + if (tty_setup) { |
---|
| 281 | iocold2 = ioc2; |
---|
| 282 | ioc2.c_lflag &= ~(ICANON | ECHO); |
---|
| 283 | ioc2.c_cc[VMIN] = 0; |
---|
| 284 | ioc2.c_cc[VTIME] = 0; |
---|
| 285 | } |
---|
| 286 | + } |
---|
| 287 | f2open = 1; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | if (f2out) { |
---|
| 291 | ofd2 = fileno(f2out); |
---|
| 292 | - if (!dumbio && ofd2 == 1) setbuf(f2out, NULL); |
---|
| 293 | + if (!dumbio && tty_setup && ofd2 == 1) setbuf(f2out, NULL); |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | wnuma = wnumb = 0; |
---|
| 297 | @@ -1058,6 +1076,9 @@ |
---|
| 298 | if (f1open) { |
---|
| 299 | anum = DO_STDIO_READ(ifd1, aq, UARTBUF); |
---|
| 300 | } |
---|
| 301 | + else { |
---|
| 302 | + anum = 0; |
---|
| 303 | + } |
---|
| 304 | if (anum > 0) { |
---|
| 305 | aind = 0; |
---|
| 306 | if ((aind + 1) < anum) |
---|
| 307 | @@ -1090,6 +1111,9 @@ |
---|
| 308 | if (f2open) { |
---|
| 309 | bnum = DO_STDIO_READ(ifd2, bq, UARTBUF); |
---|
| 310 | } |
---|
| 311 | + else { |
---|
| 312 | + bnum = 0; |
---|
| 313 | + } |
---|
| 314 | if (bnum > 0) { |
---|
| 315 | bind = 0; |
---|
| 316 | if ((bind + 1) < bnum) |
---|
| 317 | @@ -1122,6 +1146,9 @@ |
---|
| 318 | if (f1open) { |
---|
| 319 | anum = DO_STDIO_READ(ifd1, aq, UARTBUF); |
---|
| 320 | } |
---|
| 321 | + else { |
---|
| 322 | + anum = 0; |
---|
| 323 | + } |
---|
| 324 | if (anum > 0) { |
---|
| 325 | Ucontrol |= 0x00000001; |
---|
| 326 | aind = 0; |
---|
| 327 | @@ -1134,6 +1161,9 @@ |
---|
| 328 | if (f2open) { |
---|
| 329 | bnum = DO_STDIO_READ(ifd2, bq, UARTBUF); |
---|
| 330 | } |
---|
| 331 | + else { |
---|
| 332 | + bnum = 0; |
---|
| 333 | + } |
---|
| 334 | if (bnum > 0) { |
---|
| 335 | Ucontrol |= 0x00010000; |
---|
| 336 | bind = 0; |
---|
| 337 | @@ -1152,7 +1182,7 @@ |
---|
| 338 | break; |
---|
| 339 | default: |
---|
| 340 | if (sis_verbose) |
---|
| 341 | - printf("Read from unimplemented MEC register (%x)\n", addr); |
---|
| 342 | + (*sim_callback->printf_filtered) (sim_callback, "Read from unimplemented MEC register (%x)\n", addr); |
---|
| 343 | |
---|
| 344 | } |
---|
| 345 | return 0; |
---|
| 346 | @@ -1174,8 +1204,12 @@ |
---|
| 347 | if (wnuma < UARTBUF) |
---|
| 348 | wbufa[wnuma++] = c; |
---|
| 349 | else { |
---|
| 350 | - while (wnuma) |
---|
| 351 | + while (wnuma) { |
---|
| 352 | + if (ofd1 == 1 && callback) |
---|
| 353 | + wnuma -= callback->write_stdout(callback, wbufa, wnuma); |
---|
| 354 | + else |
---|
| 355 | wnuma -= fwrite(wbufa, 1, wnuma, f1out); |
---|
| 356 | + } |
---|
| 357 | wbufa[wnuma++] = c; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | @@ -1198,8 +1232,12 @@ |
---|
| 361 | if (wnumb < UARTBUF) |
---|
| 362 | wbufb[wnumb++] = c; |
---|
| 363 | else { |
---|
| 364 | - while (wnumb) |
---|
| 365 | + while (wnumb) { |
---|
| 366 | + if (ofd1 == 1 && callback) |
---|
| 367 | + wnumb -= callback->write_stdout(callback, wbufb, wnumb); |
---|
| 368 | + else |
---|
| 369 | wnumb -= fwrite(wbufb, 1, wnumb, f2out); |
---|
| 370 | + } |
---|
| 371 | wbufb[wnumb++] = c; |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | @@ -1229,7 +1267,8 @@ |
---|
| 375 | break; |
---|
| 376 | default: |
---|
| 377 | if (sis_verbose) |
---|
| 378 | - printf("Write to unimplemented MEC register (%x)\n", addr); |
---|
| 379 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 380 | + "Write to unimplemented MEC register (%x)\n", addr); |
---|
| 381 | |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | @@ -1237,19 +1276,37 @@ |
---|
| 385 | static void |
---|
| 386 | flush_uart() |
---|
| 387 | { |
---|
| 388 | - while (wnuma && f1open) |
---|
| 389 | + while (wnuma && f1open) { |
---|
| 390 | + if (ofd1 == 1 && callback) { |
---|
| 391 | + wnuma -= callback->write_stdout(callback, wbufa, wnuma); |
---|
| 392 | + callback->flush_stdout(callback); |
---|
| 393 | + } |
---|
| 394 | + else |
---|
| 395 | wnuma -= fwrite(wbufa, 1, wnuma, f1out); |
---|
| 396 | - while (wnumb && f2open) |
---|
| 397 | + } |
---|
| 398 | + while (wnumb && f2open) { |
---|
| 399 | + if (ofd2 == 1 && callback) { |
---|
| 400 | + wnuma -= callback->write_stdout(callback, wbufb, wnuma); |
---|
| 401 | + callback->flush_stdout(callback); |
---|
| 402 | + } |
---|
| 403 | + else |
---|
| 404 | wnumb -= fwrite(wbufb, 1, wnumb, f2out); |
---|
| 405 | } |
---|
| 406 | +} |
---|
| 407 | |
---|
| 408 | |
---|
| 409 | |
---|
| 410 | static void |
---|
| 411 | uarta_tx() |
---|
| 412 | { |
---|
| 413 | - |
---|
| 414 | - while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1); |
---|
| 415 | + while (f1open) { |
---|
| 416 | + if (ofd1 == 1 && callback) { |
---|
| 417 | + while (callback->write_stdout(callback, &uarta_sreg, 1) != 1); |
---|
| 418 | + } |
---|
| 419 | + else { |
---|
| 420 | + while (fwrite(&uarta_sreg, 1, 1, f1out) != 1); |
---|
| 421 | + } |
---|
| 422 | + } |
---|
| 423 | if (uart_stat_reg & UARTA_HRE) { |
---|
| 424 | uart_stat_reg |= UARTA_SRE; |
---|
| 425 | } else { |
---|
| 426 | @@ -1263,7 +1320,14 @@ |
---|
| 427 | static void |
---|
| 428 | uartb_tx() |
---|
| 429 | { |
---|
| 430 | - while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1); |
---|
| 431 | + while (f2open) { |
---|
| 432 | + if (ofd2 == 1 && callback) { |
---|
| 433 | + while (callback->write_stdout(callback, &uarta_sreg, 1) != 1); |
---|
| 434 | + } |
---|
| 435 | + else { |
---|
| 436 | + while (fwrite(&uartb_sreg, 1, 1, f2out) != 1); |
---|
| 437 | + } |
---|
| 438 | + } |
---|
| 439 | if (uart_stat_reg & UARTB_HRE) { |
---|
| 440 | uart_stat_reg |= UARTB_SRE; |
---|
| 441 | } else { |
---|
| 442 | @@ -1285,6 +1349,8 @@ |
---|
| 443 | rsize = 0; |
---|
| 444 | if (f1open) |
---|
| 445 | rsize = DO_STDIO_READ(ifd1, &rxd, 1); |
---|
| 446 | + else |
---|
| 447 | + rsize = 0; |
---|
| 448 | if (rsize > 0) { |
---|
| 449 | uarta_data = UART_DR | rxd; |
---|
| 450 | if (uart_stat_reg & UARTA_HRE) |
---|
| 451 | @@ -1301,6 +1367,8 @@ |
---|
| 452 | rsize = 0; |
---|
| 453 | if (f2open) |
---|
| 454 | rsize = DO_STDIO_READ(ifd2, &rxd, 1); |
---|
| 455 | + else |
---|
| 456 | + rsize = 0; |
---|
| 457 | if (rsize) { |
---|
| 458 | uartb_data = UART_DR | rxd; |
---|
| 459 | if (uart_stat_reg & UARTB_HRE) |
---|
| 460 | @@ -1354,7 +1422,7 @@ |
---|
| 461 | event(wdog_intr, 0, wdog_scaler + 1); |
---|
| 462 | } else { |
---|
| 463 | if (wdog_rston) { |
---|
| 464 | - printf("Watchdog reset!\n"); |
---|
| 465 | + (*sim_callback->printf_filtered) (sim_callback, "Watchdog reset!\n"); |
---|
| 466 | sys_reset(); |
---|
| 467 | mec_ersr = 0xC000; |
---|
| 468 | } else { |
---|
| 469 | @@ -1372,7 +1440,8 @@ |
---|
| 470 | { |
---|
| 471 | event(wdog_intr, 0, wdog_scaler + 1); |
---|
| 472 | if (sis_verbose) |
---|
| 473 | - printf("Watchdog started, scaler = %d, counter = %d\n", |
---|
| 474 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 475 | + "Watchdog started, scaler = %d, counter = %d\n", |
---|
| 476 | wdog_scaler, wdog_counter); |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | @@ -1399,7 +1468,8 @@ |
---|
| 480 | rtc_enabled = 1; |
---|
| 481 | } else { |
---|
| 482 | if (sis_verbose) |
---|
| 483 | - printf("RTC stopped\n\r"); |
---|
| 484 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 485 | + "RTC stopped\n\r"); |
---|
| 486 | rtc_enabled = 0; |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | @@ -1408,7 +1478,8 @@ |
---|
| 490 | rtc_start() |
---|
| 491 | { |
---|
| 492 | if (sis_verbose) |
---|
| 493 | - printf("RTC started (period %d)\n\r", rtc_scaler + 1); |
---|
| 494 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 495 | + "RTC started (period %d)\n\r", rtc_scaler + 1); |
---|
| 496 | event(rtc_intr, 0, rtc_scaler + 1); |
---|
| 497 | rtc_scaler_start = now(); |
---|
| 498 | rtc_enabled = 1; |
---|
| 499 | @@ -1452,7 +1523,7 @@ |
---|
| 500 | gpt_enabled = 1; |
---|
| 501 | } else { |
---|
| 502 | if (sis_verbose) |
---|
| 503 | - printf("GPT stopped\n\r"); |
---|
| 504 | + (*sim_callback->printf_filtered) (sim_callback, "GPT stopped\n\r"); |
---|
| 505 | gpt_enabled = 0; |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | @@ -1461,7 +1532,8 @@ |
---|
| 509 | gpt_start() |
---|
| 510 | { |
---|
| 511 | if (sis_verbose) |
---|
| 512 | - printf("GPT started (period %d)\n\r", gpt_scaler + 1); |
---|
| 513 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 514 | + "GPT started (period %d)\n\r", gpt_scaler + 1); |
---|
| 515 | event(gpt_intr, 0, gpt_scaler + 1); |
---|
| 516 | gpt_scaler_start = now(); |
---|
| 517 | gpt_enabled = 1; |
---|
| 518 | @@ -1566,7 +1638,8 @@ |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | if (sis_verbose) |
---|
| 522 | - printf ("Memory exception at %x (illegal address)\n", addr); |
---|
| 523 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 524 | + "Memory exception at %x (illegal address)\n", addr); |
---|
| 525 | if (sregs.psr & 0x080) |
---|
| 526 | asi = 9; |
---|
| 527 | else |
---|
| 528 | @@ -1589,7 +1662,7 @@ |
---|
| 529 | #ifdef ERRINJ |
---|
| 530 | if (errmec) { |
---|
| 531 | if (sis_verbose) |
---|
| 532 | - printf("Inserted MEC error %d\n",errmec); |
---|
| 533 | + (*sim_callback->printf_filtered) (sim_callback, "Inserted MEC error %d\n",errmec); |
---|
| 534 | set_sfsr(errmec, addr, asi, 1); |
---|
| 535 | if (errmec == 5) mecparerror(); |
---|
| 536 | if (errmec == 6) iucomperr(); |
---|
| 537 | @@ -1641,7 +1714,8 @@ |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | if (sis_verbose) |
---|
| 541 | - printf ("Memory exception at %x (illegal address)\n", addr); |
---|
| 542 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 543 | + "Memory exception at %x (illegal address)\n", addr); |
---|
| 544 | set_sfsr(UIMP_ACC, addr, asi, 1); |
---|
| 545 | *ws = MEM_EX_WS; |
---|
| 546 | return 1; |
---|
| 547 | @@ -1666,7 +1740,8 @@ |
---|
| 548 | #ifdef ERRINJ |
---|
| 549 | if (errmec) { |
---|
| 550 | if (sis_verbose) |
---|
| 551 | - printf("Inserted MEC error %d\n",errmec); |
---|
| 552 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 553 | + "Inserted MEC error %d\n",errmec); |
---|
| 554 | set_sfsr(errmec, addr, asi, 0); |
---|
| 555 | if (errmec == 5) mecparerror(); |
---|
| 556 | if (errmec == 6) iucomperr(); |
---|
| 557 | @@ -1690,7 +1765,8 @@ |
---|
| 558 | !((mec_wpr[0] && wphit[0]) || (mec_wpr[1] && wphit[1])) |
---|
| 559 | )) { |
---|
| 560 | if (sis_verbose) |
---|
| 561 | - printf("Memory access protection error at 0x%08x\n", addr); |
---|
| 562 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 563 | + "Memory access protection error at 0x%08x\n", addr); |
---|
| 564 | set_sfsr(PROT_EXC, addr, asi, 0); |
---|
| 565 | *ws = MEM_EX_WS; |
---|
| 566 | return 1; |
---|
| 567 | diff -ruw gdb-7.11.orig1/sim/erc32/exec.c gdb-7.11/sim/erc32/exec.c |
---|
| 568 | --- gdb-7.11.orig1/sim/erc32/exec.c 2016-03-16 14:00:04.632565918 +1100 |
---|
| 569 | +++ gdb-7.11/sim/erc32/exec.c 2016-03-16 14:08:17.484578389 +1100 |
---|
| 570 | @@ -1903,7 +1903,8 @@ |
---|
| 571 | if (errftt) { |
---|
| 572 | sregs->fsr = (sregs->fsr & ~FSR_TT) | (errftt << 14); |
---|
| 573 | sregs->fpstate = FP_EXC_PE; |
---|
| 574 | - if (sis_verbose) printf("Inserted fpu error %X\n",errftt); |
---|
| 575 | + if (sis_verbose) (*sim_callback->printf_filtered) (sim_callback, |
---|
| 576 | + "Inserted fpu error %X\n",errftt); |
---|
| 577 | errftt = 0; |
---|
| 578 | } |
---|
| 579 | #endif |
---|
| 580 | @@ -2023,7 +2024,8 @@ |
---|
| 581 | #ifdef ERRINJ |
---|
| 582 | if (errtt) { |
---|
| 583 | sregs->trap = errtt; |
---|
| 584 | - if (sis_verbose) printf("Inserted error trap 0x%02X\n",errtt); |
---|
| 585 | + if (sis_verbose) (*sim_callback->printf_filtered) (sim_callback, |
---|
| 586 | + "Inserted error trap 0x%02X\n",errtt); |
---|
| 587 | errtt = 0; |
---|
| 588 | } |
---|
| 589 | #endif |
---|
| 590 | diff -ruw gdb-7.11.orig1/sim/erc32/func.c gdb-7.11/sim/erc32/func.c |
---|
| 591 | --- gdb-7.11.orig1/sim/erc32/func.c 2016-03-16 14:00:04.628565918 +1100 |
---|
| 592 | +++ gdb-7.11/sim/erc32/func.c 2016-03-16 14:17:33.328592454 +1100 |
---|
| 593 | @@ -47,6 +47,8 @@ |
---|
| 594 | char uart_dev2[128] = ""; |
---|
| 595 | extern int ext_irl; |
---|
| 596 | uint32 last_load_addr = 0; |
---|
| 597 | +int nouartrx = 0; |
---|
| 598 | +host_callback *sim_callback; |
---|
| 599 | |
---|
| 600 | #ifdef ERRINJ |
---|
| 601 | uint32 errcnt = 0; |
---|
| 602 | @@ -80,14 +82,15 @@ |
---|
| 603 | size_t slen; |
---|
| 604 | |
---|
| 605 | if ((fp = fopen(fname, "r")) == NULL) { |
---|
| 606 | - fprintf(stderr, "couldn't open batch file %s\n", fname); |
---|
| 607 | + (*sim_callback->printf_filtered) (sim_callback, |
---|
| 608 | + "couldn't open batch file %s\n", fname); |
---|
| 609 | return 0; |
---|
| 610 | } |
---|
| 611 | while (getline(&lbuf, &len, fp) > -1) { |
---|
| 612 | slen = strlen(lbuf); |
---|
| 613 | if (slen && (lbuf[slen - 1] == '\n')) { |
---|
| 614 | lbuf[slen - 1] = 0; |
---|
| 615 | - printf("sis> %s\n", lbuf); |
---|
| 616 | + (*sim_callback->printf_filtered) (sim_callback, "sis> %s\n", lbuf); |
---|
| 617 | exec_cmd(sregs, lbuf); |
---|
| 618 | } |
---|
| 619 | } |
---|
| 620 | @@ -279,13 +282,13 @@ |
---|
| 621 | err = 1; |
---|
| 622 | switch (err) { |
---|
| 623 | case 0: |
---|
| 624 | - printf("%s = %d (0x%08x)\n", reg, rval, rval); |
---|
| 625 | + (*sim_callback->printf_filtered) (sim_callback, "%s = %d (0x%08x)\n", reg, rval, rval); |
---|
| 626 | break; |
---|
| 627 | case 1: |
---|
| 628 | - printf("no such regiser: %s\n", reg); |
---|
| 629 | + (*sim_callback->printf_filtered) (sim_callback, "no such regiser: %s\n", reg); |
---|
| 630 | break; |
---|
| 631 | case 2: |
---|
| 632 | - printf("cannot set g0\n"); |
---|
| 633 | + (*sim_callback->printf_filtered) (sim_callback, "cannot set g0\n"); |
---|
| 634 | break; |
---|
| 635 | default: |
---|
| 636 | break; |
---|
| 637 | @@ -358,7 +361,7 @@ |
---|
| 638 | if ((flim > ebase.simtime) && (flim < 4294967296.0)) { |
---|
| 639 | lim = (uint32) flim; |
---|
| 640 | } else { |
---|
| 641 | - printf("error in expression\n"); |
---|
| 642 | + (*sim_callback->printf_filtered) (sim_callback, "error in expression\n"); |
---|
| 643 | lim = -1; |
---|
| 644 | } |
---|
| 645 | } |
---|
| 646 | @@ -381,12 +384,12 @@ |
---|
| 647 | clen = strlen(cmd1); |
---|
| 648 | if (strncmp(cmd1, "bp", clen) == 0) { |
---|
| 649 | for (i = 0; i < sregs->bptnum; i++) { |
---|
| 650 | - printf(" %d : 0x%08x\n", i + 1, sregs->bpts[i]); |
---|
| 651 | + (*sim_callback->printf_filtered) (sim_callback, " %d : 0x%08x\n", i + 1, sregs->bpts[i]); |
---|
| 652 | } |
---|
| 653 | } else if (strncmp(cmd1, "+bp", clen) == 0) { |
---|
| 654 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 655 | sregs->bpts[sregs->bptnum] = VAL(cmd1) & ~0x3; |
---|
| 656 | - printf("added breakpoint %d at 0x%08x\n", |
---|
| 657 | + (*sim_callback->printf_filtered) (sim_callback, "added breakpoint %d at 0x%08x\n", |
---|
| 658 | sregs->bptnum + 1, sregs->bpts[sregs->bptnum]); |
---|
| 659 | sregs->bptnum += 1; |
---|
| 660 | } |
---|
| 661 | @@ -394,7 +397,7 @@ |
---|
| 662 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 663 | i = VAL(cmd1) - 1; |
---|
| 664 | if ((i >= 0) && (i < sregs->bptnum)) { |
---|
| 665 | - printf("deleted breakpoint %d at 0x%08x\n", i + 1, |
---|
| 666 | + (*sim_callback->printf_filtered) (sim_callback, "deleted breakpoint %d at 0x%08x\n", i + 1, |
---|
| 667 | sregs->bpts[i]); |
---|
| 668 | for (; i < sregs->bptnum - 1; i++) { |
---|
| 669 | sregs->bpts[i] = sregs->bpts[i + 1]; |
---|
| 670 | @@ -404,7 +407,7 @@ |
---|
| 671 | } |
---|
| 672 | } else if (strncmp(cmd1, "batch", clen) == 0) { |
---|
| 673 | if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) { |
---|
| 674 | - printf("no file specified\n"); |
---|
| 675 | + (*sim_callback->printf_filtered) (sim_callback, "no file specified\n"); |
---|
| 676 | } else { |
---|
| 677 | batch(sregs, cmd1); |
---|
| 678 | } |
---|
| 679 | @@ -420,7 +423,7 @@ |
---|
| 680 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 681 | sis_verbose = VAL(cmd1); |
---|
| 682 | } |
---|
| 683 | - printf("Debug level = %d\n",sis_verbose); |
---|
| 684 | + (*sim_callback->printf_filtered) (sim_callback, "Debug level = %d\n",sis_verbose); |
---|
| 685 | } else if (strncmp(cmd1, "dis", clen) == 0) { |
---|
| 686 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 687 | daddr = VAL(cmd1); |
---|
| 688 | @@ -429,13 +432,13 @@ |
---|
| 689 | len = VAL(cmd2); |
---|
| 690 | } else |
---|
| 691 | len = 16; |
---|
| 692 | - printf("\n"); |
---|
| 693 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 694 | dis_mem(daddr, len, &dinfo); |
---|
| 695 | - printf("\n"); |
---|
| 696 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 697 | daddr += len * 4; |
---|
| 698 | } else if (strncmp(cmd1, "echo", clen) == 0) { |
---|
| 699 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 700 | - printf("%s\n", (&cmdsave[clen+1])); |
---|
| 701 | + (*sim_callback->printf_filtered) (sim_callback, "%s\n", (&cmdsave[clen+1])); |
---|
| 702 | } |
---|
| 703 | #ifdef ERRINJ |
---|
| 704 | } else if (strncmp(cmd1, "error", clen) == 0) { |
---|
| 705 | @@ -443,9 +446,9 @@ |
---|
| 706 | errper = VAL(cmd1); |
---|
| 707 | if (errper) { |
---|
| 708 | event(errinj, 0, (len = (random()%errper))); |
---|
| 709 | - printf("Error injection started with period %d\n",len); |
---|
| 710 | + (*sim_callback->printf_filtered) (sim_callback, "Error injection started with period %d\n",len); |
---|
| 711 | } |
---|
| 712 | - } else printf("Injected errors: %d\n",errcnt); |
---|
| 713 | + } else (*sim_callback->printf_filtered) (sim_callback, "Injected errors: %d\n",errcnt); |
---|
| 714 | #endif |
---|
| 715 | } else if (strncmp(cmd1, "float", clen) == 0) { |
---|
| 716 | stat = disp_fpu(sregs); |
---|
| 717 | @@ -459,7 +462,7 @@ |
---|
| 718 | sregs->npc = sregs->pc + 4; |
---|
| 719 | if ((sregs->pc != 0) && (ebase.simtime == 0)) |
---|
| 720 | boot_init(); |
---|
| 721 | - printf("resuming at 0x%08x\n",sregs->pc); |
---|
| 722 | + (*sim_callback->printf_filtered) (sim_callback, "resuming at 0x%08x\n",sregs->pc); |
---|
| 723 | if ((cmd2 = strtok(NULL, " \t\n\r")) != NULL) { |
---|
| 724 | stat = run_sim(sregs, VAL(cmd2), 0); |
---|
| 725 | } else { |
---|
| 726 | @@ -475,7 +478,7 @@ |
---|
| 727 | if (sregs->histbuf != NULL) |
---|
| 728 | free(sregs->histbuf); |
---|
| 729 | sregs->histbuf = (struct histype *) calloc(sregs->histlen, sizeof(struct histype)); |
---|
| 730 | - printf("trace history length = %d\n\r", sregs->histlen); |
---|
| 731 | + (*sim_callback->printf_filtered) (sim_callback, "trace history length = %d\n\r", sregs->histlen); |
---|
| 732 | sregs->histind = 0; |
---|
| 733 | |
---|
| 734 | } else { |
---|
| 735 | @@ -483,7 +486,7 @@ |
---|
| 736 | for (i = 0; i < sregs->histlen; i++) { |
---|
| 737 | if (j >= sregs->histlen) |
---|
| 738 | j = 0; |
---|
| 739 | - printf(" %8d ", sregs->histbuf[j].time); |
---|
| 740 | + (*sim_callback->printf_filtered) (sim_callback, " %8d ", sregs->histbuf[j].time); |
---|
| 741 | dis_mem(sregs->histbuf[j].addr, 1, &dinfo); |
---|
| 742 | j++; |
---|
| 743 | } |
---|
| 744 | @@ -495,7 +498,7 @@ |
---|
| 745 | while ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) |
---|
| 746 | last_load_addr = bfd_load(cmd1); |
---|
| 747 | } else { |
---|
| 748 | - printf("load: no file specified\n"); |
---|
| 749 | + (*sim_callback->printf_filtered) (sim_callback, "load: no file specified\n"); |
---|
| 750 | } |
---|
| 751 | } else if (strncmp(cmd1, "mem", clen) == 0) { |
---|
| 752 | if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) |
---|
| 753 | @@ -565,14 +568,14 @@ |
---|
| 754 | } |
---|
| 755 | sregs->pc = len & ~3; |
---|
| 756 | sregs->npc = sregs->pc + 4; |
---|
| 757 | - printf("resuming at 0x%08x\n",sregs->pc); |
---|
| 758 | + (*sim_callback->printf_filtered) (sim_callback, "resuming at 0x%08x\n",sregs->pc); |
---|
| 759 | stat = run_sim(sregs, UINT64_MAX, 0); |
---|
| 760 | daddr = sregs->pc; |
---|
| 761 | sim_halt(); |
---|
| 762 | } else if (strncmp(cmd1, "tlimit", clen) == 0) { |
---|
| 763 | sregs->tlimit = limcalc(sregs->freq); |
---|
| 764 | if (sregs->tlimit != (uint32) -1) |
---|
| 765 | - printf("simulation limit = %u (%.3f ms)\n",(uint32) sregs->tlimit, |
---|
| 766 | + (*sim_callback->printf_filtered) (sim_callback, "simulation limit = %u (%.3f ms)\n",(uint32) sregs->tlimit, |
---|
| 767 | sregs->tlimit / sregs->freq / 1000); |
---|
| 768 | } else if (strncmp(cmd1, "tra", clen) == 0) { |
---|
| 769 | if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) { |
---|
| 770 | @@ -580,7 +583,7 @@ |
---|
| 771 | } else { |
---|
| 772 | stat = run_sim(sregs, VAL(cmd1), 1); |
---|
| 773 | } |
---|
| 774 | - printf("\n"); |
---|
| 775 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 776 | daddr = sregs->pc; |
---|
| 777 | sim_halt(); |
---|
| 778 | } else if (strncmp(cmd1, "trun", clen) == 0) { |
---|
| 779 | @@ -592,7 +595,7 @@ |
---|
| 780 | daddr = sregs->pc; |
---|
| 781 | sim_halt(); |
---|
| 782 | } else |
---|
| 783 | - printf("syntax error\n"); |
---|
| 784 | + (*sim_callback->printf_filtered) (sim_callback, "syntax error\n"); |
---|
| 785 | } |
---|
| 786 | if (cmdsave2 != NULL) |
---|
| 787 | free(cmdsave2); |
---|
| 788 | @@ -636,42 +639,42 @@ |
---|
| 789 | sregs->nbranch; |
---|
| 790 | #endif |
---|
| 791 | |
---|
| 792 | - printf("\n Cycles : %9" PRIu64 "\n\r", ebase.simtime - sregs->simstart); |
---|
| 793 | - printf(" Instructions : %9" PRIu64 "\n", sregs->ninst); |
---|
| 794 | + (*sim_callback->printf_filtered) (sim_callback, "\n Cycles : %9" PRIu64 "\n\r", ebase.simtime - sregs->simstart); |
---|
| 795 | + (*sim_callback->printf_filtered) (sim_callback, " Instructions : %9" PRIu64 "\n", sregs->ninst); |
---|
| 796 | |
---|
| 797 | #ifdef STAT |
---|
| 798 | - printf(" integer : %9.2f %%\n", 100.0 * (float) iinst / (float) sregs->ninst); |
---|
| 799 | - printf(" load : %9.2f %%\n", |
---|
| 800 | + (*sim_callback->printf_filtered) (sim_callback, " integer : %9.2f %%\n", 100.0 * (float) iinst / (float) sregs->ninst); |
---|
| 801 | + (*sim_callback->printf_filtered) (sim_callback, " load : %9.2f %%\n", |
---|
| 802 | 100.0 * (float) sregs->nload / (float) sregs->ninst); |
---|
| 803 | - printf(" store : %9.2f %%\n", |
---|
| 804 | + (*sim_callback->printf_filtered) (sim_callback, " store : %9.2f %%\n", |
---|
| 805 | 100.0 * (float) sregs->nstore / (float) sregs->ninst); |
---|
| 806 | - printf(" branch : %9.2f %%\n", |
---|
| 807 | + (*sim_callback->printf_filtered) (sim_callback, " branch : %9.2f %%\n", |
---|
| 808 | 100.0 * (float) sregs->nbranch / (float) sregs->ninst); |
---|
| 809 | - printf(" float : %9.2f %%\n", |
---|
| 810 | + (*sim_callback->printf_filtered) (sim_callback, " float : %9.2f %%\n", |
---|
| 811 | 100.0 * (float) sregs->finst / (float) sregs->ninst); |
---|
| 812 | - printf(" Integer CPI : %9.2f\n", |
---|
| 813 | + (*sim_callback->printf_filtered) (sim_callback, " Integer CPI : %9.2f\n", |
---|
| 814 | ((float) (stime - sregs->pwdtime - sregs->fholdt - sregs->finst)) |
---|
| 815 | / |
---|
| 816 | (float) (sregs->ninst - sregs->finst)); |
---|
| 817 | - printf(" Float CPI : %9.2f\n", |
---|
| 818 | + (*sim_callback->printf_filtered) (sim_callback, " Float CPI : %9.2f\n", |
---|
| 819 | ((float) sregs->fholdt / (float) sregs->finst) + 1.0); |
---|
| 820 | #endif |
---|
| 821 | - printf(" Overall CPI : %9.2f\n", |
---|
| 822 | + (*sim_callback->printf_filtered) (sim_callback, " Overall CPI : %9.2f\n", |
---|
| 823 | (float) (stime - sregs->pwdtime) / (float) sregs->ninst); |
---|
| 824 | - printf("\n ERC32 performance (%4.1f MHz): %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n", |
---|
| 825 | + (*sim_callback->printf_filtered) (sim_callback, "\n ERC32 performance (%4.1f MHz): %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n", |
---|
| 826 | sregs->freq, sregs->freq * (float) sregs->ninst / (float) (stime - sregs->pwdtime), |
---|
| 827 | sregs->freq * (float) (sregs->ninst - sregs->finst) / |
---|
| 828 | (float) (stime - sregs->pwdtime), |
---|
| 829 | sregs->freq * (float) sregs->finst / (float) (stime - sregs->pwdtime)); |
---|
| 830 | - printf(" Simulated ERC32 time : %.2f s\n", |
---|
| 831 | + (*sim_callback->printf_filtered) (sim_callback, " Simulated ERC32 time : %.2f s\n", |
---|
| 832 | (float) (ebase.simtime - sregs->simstart) / 1000000.0 / sregs->freq); |
---|
| 833 | - printf(" Processor utilisation : %.2f %%\n", |
---|
| 834 | + (*sim_callback->printf_filtered) (sim_callback, " Processor utilisation : %.2f %%\n", |
---|
| 835 | 100.0 * (1.0 - ((float) sregs->pwdtime / (float) stime))); |
---|
| 836 | - printf(" Real-time performance : %.2f %%\n", |
---|
| 837 | + (*sim_callback->printf_filtered) (sim_callback, " Real-time performance : %.2f %%\n", |
---|
| 838 | 100.0 / (sregs->tottime / ((double) (stime) / (sregs->freq * 1.0E6)))); |
---|
| 839 | - printf(" Simulator performance : %.2f MIPS\n", |
---|
| 840 | + (*sim_callback->printf_filtered) (sim_callback, " Simulator performance : %.2f MIPS\n", |
---|
| 841 | (double)(sregs->ninst) / sregs->tottime / 1E6); |
---|
| 842 | - printf(" Used time (sys + user) : %.2f s\n\n", sregs->tottime); |
---|
| 843 | + (*sim_callback->printf_filtered) (sim_callback, " Used time (sys + user) : %.2f s\n\n", sregs->tottime); |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | |
---|
| 847 | @@ -692,7 +695,7 @@ |
---|
| 848 | int32 sig; |
---|
| 849 | { |
---|
| 850 | if (sig != 2) |
---|
| 851 | - printf("\n\n Signal handler error (%d)\n\n", sig); |
---|
| 852 | + (*sim_callback->printf_filtered) (sim_callback, "\n\n Signal handler error (%d)\n\n", sig); |
---|
| 853 | ctrl_c = 1; |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | @@ -721,7 +724,7 @@ |
---|
| 857 | int i; |
---|
| 858 | float t; |
---|
| 859 | |
---|
| 860 | - printf("\n fsr: %08X\n\n", sregs->fsr); |
---|
| 861 | + (*sim_callback->printf_filtered) (sim_callback, "\n fsr: %08X\n\n", sregs->fsr); |
---|
| 862 | |
---|
| 863 | #ifdef HOST_LITTLE_ENDIAN |
---|
| 864 | for (i = 0; i < 32; i++) |
---|
| 865 | @@ -730,13 +733,13 @@ |
---|
| 866 | |
---|
| 867 | for (i = 0; i < 32; i++) { |
---|
| 868 | t = sregs->fs[i]; |
---|
| 869 | - printf(" f%02d %08x %14e ", i, sregs->fsi[i], sregs->fs[i]); |
---|
| 870 | + (*sim_callback->printf_filtered) (sim_callback, " f%02d %08x %14e ", i, sregs->fsi[i], sregs->fs[i]); |
---|
| 871 | if (!(i & 1)) |
---|
| 872 | - printf("%14e\n", sregs->fd[i >> 1]); |
---|
| 873 | + (*sim_callback->printf_filtered) (sim_callback, "%14e\n", sregs->fd[i >> 1]); |
---|
| 874 | else |
---|
| 875 | - printf("\n"); |
---|
| 876 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 877 | } |
---|
| 878 | - printf("\n"); |
---|
| 879 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 880 | return OK; |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | @@ -749,9 +752,9 @@ |
---|
| 884 | int i; |
---|
| 885 | |
---|
| 886 | cwp = ((cwp & 0x7) << 4); |
---|
| 887 | - printf("\n\t INS LOCALS OUTS GLOBALS\n"); |
---|
| 888 | + (*sim_callback->printf_filtered) (sim_callback, "\n\t INS LOCALS OUTS GLOBALS\n"); |
---|
| 889 | for (i = 0; i < 8; i++) { |
---|
| 890 | - printf(" %d: %08X %08X %08X %08X\n", i, |
---|
| 891 | + (*sim_callback->printf_filtered) (sim_callback, " %d: %08X %08X %08X %08X\n", i, |
---|
| 892 | sregs->r[(cwp + i + 24) & 0x7f], |
---|
| 893 | sregs->r[(cwp + i + 16) & 0x7f], sregs->r[(cwp + i + 8) & 0x7f], |
---|
| 894 | sregs->g[i]); |
---|
| 895 | @@ -776,7 +779,7 @@ |
---|
| 896 | |
---|
| 897 | uint32 i; |
---|
| 898 | |
---|
| 899 | - printf("\n psr: %08X wim: %08X tbr: %08X y: %08X\n", |
---|
| 900 | + (*sim_callback->printf_filtered) (sim_callback, "\n psr: %08X wim: %08X tbr: %08X y: %08X\n", |
---|
| 901 | sregs->psr, sregs->wim, sregs->tbr, sregs->y); |
---|
| 902 | sis_memory_read (sregs->pc, (char *) &i, 4); |
---|
| 903 | printf ("\n pc: %08X = %08X ", sregs->pc, i); |
---|
| 904 | @@ -785,8 +788,8 @@ |
---|
| 905 | printf ("\n npc: %08X = %08X ", sregs->npc, i); |
---|
| 906 | print_insn_sparc_sis(sregs->npc, &dinfo); |
---|
| 907 | if (sregs->err_mode) |
---|
| 908 | - printf("\n IU in error mode"); |
---|
| 909 | - printf("\n\n"); |
---|
| 910 | + (*sim_callback->printf_filtered) (sim_callback, "\n IU in error mode"); |
---|
| 911 | + (*sim_callback->printf_filtered) (sim_callback, "\n\n"); |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | static void |
---|
| 915 | @@ -804,13 +807,13 @@ |
---|
| 916 | char *p; |
---|
| 917 | |
---|
| 918 | for (i = addr & ~3; i < ((addr + len) & ~3); i += 16) { |
---|
| 919 | - printf("\n %8X ", i); |
---|
| 920 | + (*sim_callback->printf_filtered) (sim_callback, "\n %8X ", i); |
---|
| 921 | for (j = 0; j < 4; j++) { |
---|
| 922 | sis_memory_read ((i + (j * 4)), data.u8, 4); |
---|
| 923 | printf ("%08x ", data.u32); |
---|
| 924 | mem[j] = data.u32; |
---|
| 925 | } |
---|
| 926 | - printf(" "); |
---|
| 927 | + (*sim_callback->printf_filtered) (sim_callback, " "); |
---|
| 928 | p = (char *) mem; |
---|
| 929 | for (j = 0; j < 16; j++) { |
---|
| 930 | if (isprint (p[j ^ EBT])) |
---|
| 931 | @@ -819,7 +822,7 @@ |
---|
| 932 | putchar('.'); |
---|
| 933 | } |
---|
| 934 | } |
---|
| 935 | - printf("\n\n"); |
---|
| 936 | + (*sim_callback->printf_filtered) (sim_callback, "\n\n"); |
---|
| 937 | } |
---|
| 938 | |
---|
| 939 | void |
---|
| 940 | @@ -839,7 +842,7 @@ |
---|
| 941 | printf (" %08x %08x ", i, data.u32); |
---|
| 942 | print_insn_sparc_sis(i, info); |
---|
| 943 | if (i >= 0xfffffffc) break; |
---|
| 944 | - printf("\n"); |
---|
| 945 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 946 | } |
---|
| 947 | } |
---|
| 948 | |
---|
| 949 | @@ -854,7 +857,7 @@ |
---|
| 950 | struct evcell *ev1, *evins; |
---|
| 951 | |
---|
| 952 | if (ebase.freeq == NULL) { |
---|
| 953 | - printf("Error, too many events in event queue\n"); |
---|
| 954 | + (*sim_callback->printf_filtered) (sim_callback, "Error, too many events in event queue\n"); |
---|
| 955 | return; |
---|
| 956 | } |
---|
| 957 | ev1 = &ebase.eq; |
---|
| 958 | @@ -959,7 +962,7 @@ |
---|
| 959 | uint64 endtime; |
---|
| 960 | |
---|
| 961 | if (ebase.eq.nxt == NULL) |
---|
| 962 | - printf("Warning: event queue empty - power-down mode not entered\n"); |
---|
| 963 | + (*sim_callback->printf_filtered) (sim_callback, "Warning: event queue empty - power-down mode not entered\n"); |
---|
| 964 | endtime = ebase.simtime; |
---|
| 965 | while (!ext_irl && (ebase.eq.nxt != NULL)) { |
---|
| 966 | ebase.simtime = ebase.eq.nxt->time; |
---|
| 967 | @@ -971,7 +974,7 @@ |
---|
| 968 | ebase.freeq = evrem; |
---|
| 969 | cfunc(arg); |
---|
| 970 | if (ctrl_c) { |
---|
| 971 | - printf("\bwarning: power-down mode interrupted\n"); |
---|
| 972 | + (*sim_callback->printf_filtered) (sim_callback, "\bwarning: power-down mode interrupted\n"); |
---|
| 973 | break; |
---|
| 974 | } |
---|
| 975 | } |
---|
| 976 | @@ -1039,17 +1042,17 @@ |
---|
| 977 | pbfd = bfd_openr(fname, 0); |
---|
| 978 | |
---|
| 979 | if (pbfd == NULL) { |
---|
| 980 | - printf("open of %s failed\n", fname); |
---|
| 981 | + (*sim_callback->printf_filtered) (sim_callback, "open of %s failed\n", fname); |
---|
| 982 | return -1; |
---|
| 983 | } |
---|
| 984 | if (!bfd_check_format(pbfd, bfd_object)) { |
---|
| 985 | - printf("file %s doesn't seem to be an object file\n", fname); |
---|
| 986 | + (*sim_callback->printf_filtered) (sim_callback, "file %s doesn't seem to be an object file\n", fname); |
---|
| 987 | return -1; |
---|
| 988 | } |
---|
| 989 | |
---|
| 990 | arch = bfd_get_arch_info (pbfd); |
---|
| 991 | if (sis_verbose) |
---|
| 992 | - printf("loading %s:", fname); |
---|
| 993 | + (*sim_callback->printf_filtered) (sim_callback, "loading %s:", fname); |
---|
| 994 | for (section = pbfd->sections; section; section = section->next) { |
---|
| 995 | if (bfd_get_section_flags(pbfd, section) & SEC_ALLOC) { |
---|
| 996 | bfd_vma section_address; |
---|
| 997 | @@ -1087,7 +1090,7 @@ |
---|
| 998 | section_size = bfd_section_size(pbfd, section); |
---|
| 999 | |
---|
| 1000 | if (sis_verbose) |
---|
| 1001 | - printf("\nsection %s at 0x%08lx (0x%lx bytes)", |
---|
| 1002 | + (*sim_callback->printf_filtered) (sim_callback, "\nsection %s at 0x%08lx (0x%lx bytes)", |
---|
| 1003 | section_name, section_address, section_size); |
---|
| 1004 | |
---|
| 1005 | /* Text, data or lit */ |
---|
| 1006 | @@ -1113,11 +1116,11 @@ |
---|
| 1007 | } |
---|
| 1008 | } else /* BSS */ |
---|
| 1009 | if (sis_verbose) |
---|
| 1010 | - printf("(not loaded)"); |
---|
| 1011 | + (*sim_callback->printf_filtered) (sim_callback, "(not loaded)"); |
---|
| 1012 | } |
---|
| 1013 | } |
---|
| 1014 | if (sis_verbose) |
---|
| 1015 | - printf("\n"); |
---|
| 1016 | + (*sim_callback->printf_filtered) (sim_callback, "\n"); |
---|
| 1017 | |
---|
| 1018 | return bfd_get_start_address (pbfd); |
---|
| 1019 | } |
---|
| 1020 | diff -ruw gdb-7.11.orig1/sim/erc32/interf.c gdb-7.11/sim/erc32/interf.c |
---|
| 1021 | --- gdb-7.11.orig1/sim/erc32/interf.c 2016-03-16 14:00:04.628565918 +1100 |
---|
| 1022 | +++ gdb-7.11/sim/erc32/interf.c 2016-03-16 14:09:55.832580878 +1100 |
---|
| 1023 | @@ -57,8 +57,6 @@ |
---|
| 1024 | |
---|
| 1025 | int sis_gdb_break = 1; |
---|
| 1026 | |
---|
| 1027 | -host_callback *sim_callback; |
---|
| 1028 | - |
---|
| 1029 | int |
---|
| 1030 | run_sim(sregs, icount, dis) |
---|
| 1031 | struct pstate *sregs; |
---|
| 1032 | @@ -89,12 +87,12 @@ |
---|
| 1033 | #if 0 /* DELETE ME! for debugging purposes only */ |
---|
| 1034 | if (sis_verbose > 1) |
---|
| 1035 | if (sregs->pc == 0 || sregs->npc == 0) |
---|
| 1036 | - printf ("bogus pc or npc\n"); |
---|
| 1037 | + (*sim_callback->printf_filtered) (sim_callback, "bogus pc or npc\n"); |
---|
| 1038 | #endif |
---|
| 1039 | mexc = memory_iread (sregs->pc, &sregs->inst, &sregs->hold); |
---|
| 1040 | #if 0 /* DELETE ME! for debugging purposes only */ |
---|
| 1041 | if (sis_verbose > 2) |
---|
| 1042 | - printf("pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n", |
---|
| 1043 | + (*sim_callback->printf_filtered) (sim_callback, "pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n", |
---|
| 1044 | sregs->pc, sregs->npc, |
---|
| 1045 | sregs->r[(((sregs->psr & 7) << 4) + 14) & 0x7f], |
---|
| 1046 | sregs->r[(((sregs->psr & 7) << 4) + 30) & 0x7f], |
---|
| 1047 | @@ -192,6 +190,9 @@ |
---|
| 1048 | if (strcmp(argv[stat], "-dumbio") == 0) { |
---|
| 1049 | dumbio = 1; |
---|
| 1050 | } else |
---|
| 1051 | + if (strcmp(argv[stat], "-nouartrx") == 0) { |
---|
| 1052 | + nouartrx = 1; |
---|
| 1053 | + } else |
---|
| 1054 | if (strcmp(argv[stat], "-wrp") == 0) { |
---|
| 1055 | wrp = 1; |
---|
| 1056 | } else |
---|
| 1057 | @@ -430,7 +431,7 @@ |
---|
| 1058 | #if 1 |
---|
| 1059 | if (sis_verbose > 2) { |
---|
| 1060 | uint32 fp = sregs.r[(win * 16 + 30) & 0x7f]; |
---|
| 1061 | - printf("flush_window: win %d, sp %x, fp %x\n", win, sp, fp); |
---|
| 1062 | + (*sim_callback->printf_filtered) (sim_callback, "flush_window: win %d, sp %x, fp %x\n", win, sp, fp); |
---|
| 1063 | } |
---|
| 1064 | #endif |
---|
| 1065 | |
---|
| 1066 | diff -ruw gdb-7.11.orig1/sim/erc32/sis.c gdb-7.11/sim/erc32/sis.c |
---|
| 1067 | --- gdb-7.11.orig1/sim/erc32/sis.c 2016-03-16 14:00:04.632565918 +1100 |
---|
| 1068 | +++ gdb-7.11/sim/erc32/sis.c 2016-03-16 14:01:13.052567649 +1100 |
---|
| 1069 | @@ -199,6 +199,8 @@ |
---|
| 1070 | #endif |
---|
| 1071 | } else if (strcmp(argv[stat], "-dumbio") == 0) { |
---|
| 1072 | dumbio = 1; |
---|
| 1073 | + } else if (strcmp(argv[stat], "-nouartrx") == 0) { |
---|
| 1074 | + nouartrx = 1; |
---|
| 1075 | } else { |
---|
| 1076 | printf("unknown option %s\n", argv[stat]); |
---|
| 1077 | usage(); |
---|
| 1078 | @@ -293,4 +295,3 @@ |
---|
| 1079 | } |
---|
| 1080 | return 0; |
---|
| 1081 | } |
---|
| 1082 | - |
---|
| 1083 | diff -ruw gdb-7.11.orig1/sim/erc32/sis.h gdb-7.11/sim/erc32/sis.h |
---|
| 1084 | --- gdb-7.11.orig1/sim/erc32/sis.h 2016-03-16 14:00:04.632565918 +1100 |
---|
| 1085 | +++ gdb-7.11/sim/erc32/sis.h 2016-03-16 14:00:44.488566926 +1100 |
---|
| 1086 | @@ -158,7 +158,7 @@ |
---|
| 1087 | /* Prototypes */ |
---|
| 1088 | |
---|
| 1089 | /* erc32.c */ |
---|
| 1090 | -extern void init_sim (void); |
---|
| 1091 | +extern void init_sim (); |
---|
| 1092 | extern void reset (void); |
---|
| 1093 | extern void error_mode (uint32 pc); |
---|
| 1094 | extern void sim_halt (void); |
---|
| 1095 | @@ -200,6 +200,8 @@ |
---|
| 1096 | extern void sys_halt (void); |
---|
| 1097 | extern int bfd_load (const char *fname); |
---|
| 1098 | extern double get_time (void); |
---|
| 1099 | +extern int nouartrx; |
---|
| 1100 | +extern host_callback *sim_callback; |
---|
| 1101 | |
---|
| 1102 | /* exec.c */ |
---|
| 1103 | extern int dispatch_instruction (struct pstate *sregs); |
---|