From 6ce8d99cd8089907255bd0c900d3bfff6beeb5cd Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 28 Mar 2014 08:20:05 -0700 Subject: [PATCH] SCP: Added generic output routine sim_printf to output to stdout and sim_log (and sim_deb when enabled) The goals here being to simplify calling code while getting consistent output delivered everywhere it may be useful. Modified most places which explicitly used sim_log or merely called printf to now avoid doing that and merely call sim_printf(). --- PDP10/pdp10_ksio.c | 7 +- PDP10/pdp10_sys.c | 2 +- PDP11/pdp11_cpumod.c | 4 +- PDP11/pdp11_dmc.c | 15 ++- PDP11/pdp11_dup.c | 4 +- PDP11/pdp11_dz.c | 8 +- PDP11/pdp11_io_lib.c | 37 ++---- PDP11/pdp11_pt.c | 2 +- PDP11/pdp11_rh.c | 7 +- PDP11/pdp11_tc.c | 12 +- PDP11/pdp11_xq.c | 3 +- PDP11/pdp11_xu.c | 16 ++- PDP18B/pdp18b_cpu.c | 7 +- PDP18B/pdp18b_dt.c | 12 +- PDP18B/pdp18b_stddev.c | 2 +- PDP8/pdp8_cpu.c | 9 +- PDP8/pdp8_dt.c | 12 +- PDP8/pdp8_sys.c | 10 +- SDS/sds_io.c | 7 +- SDS/sds_stddev.c | 2 +- VAX/vax610_sysdev.c | 8 +- VAX/vax730_stddev.c | 12 +- VAX/vax730_sys.c | 12 +- VAX/vax730_uba.c | 8 +- VAX/vax750_cmi.c | 12 +- VAX/vax750_stddev.c | 12 +- VAX/vax750_uba.c | 8 +- VAX/vax780_mem.c | 4 +- VAX/vax780_sbi.c | 12 +- VAX/vax780_uba.c | 8 +- VAX/vax7x0_mba.c | 11 +- VAX/vax860_abus.c | 8 +- VAX/vax860_sbia.c | 6 +- VAX/vax860_stddev.c | 4 +- VAX/vax_cpu.c | 12 +- VAX/vax_lk.c | 2 +- scp.c | 268 ++++++++++++++++++++--------------------- scp.h | 2 + sim_disk.c | 83 ++++--------- sim_ether.c | 69 ++++------- sim_serial.c | 4 +- sim_sock.c | 28 ++--- sim_tape.c | 3 +- sim_timer.c | 26 ++-- sim_tmxr.c | 22 ++-- sim_video.c | 8 +- 46 files changed, 332 insertions(+), 498 deletions(-) diff --git a/PDP10/pdp10_ksio.c b/PDP10/pdp10_ksio.c index 1737332b..bf0ce7ba 100644 --- a/PDP10/pdp10_ksio.c +++ b/PDP10/pdp10_ksio.c @@ -1548,11 +1548,8 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru dev */ (curr->ba < (dibp->ba + dibp->lnt))) || ((end >= dibp->ba) && /* overlap end? */ (end < (dibp->ba + dibp->lnt)))) { - printf ("Device %s address conflict at %08o\n", - sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Device %s address conflict at %08o\n", - sim_dname (dptr), dibp->ba); + sim_printf ("Device %s address conflict at %08o\n", + sim_dname (dptr), dibp->ba); return TRUE; } } diff --git a/PDP10/pdp10_sys.c b/PDP10/pdp10_sys.c index 8b6094d9..2aeaed21 100644 --- a/PDP10/pdp10_sys.c +++ b/PDP10/pdp10_sys.c @@ -383,7 +383,7 @@ switch (fmt) { /* case fmt */ return load_exe (fileref); } -printf ("Can't determine load file format\n"); +sim_printf ("Can't determine load file format\n"); return SCPE_FMT; } diff --git a/PDP11/pdp11_cpumod.c b/PDP11/pdp11_cpumod.c index 935d2fb5..80263765 100644 --- a/PDP11/pdp11_cpumod.c +++ b/PDP11/pdp11_cpumod.c @@ -1185,9 +1185,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { if ((dptr->flags & DEV_DISABLE) && /* disable-able? */ !(dptr->flags & DEV_DIS) && /* enabled? */ ((dptr->flags & mask) == 0)) { /* not allowed? */ - printf ("Disabling %s\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "Disabling %s\n", sim_dname (dptr)); + sim_printf ("Disabling %s\n", sim_dname (dptr)); dptr->flags = dptr->flags | DEV_DIS; } } diff --git a/PDP11/pdp11_dmc.c b/PDP11/pdp11_dmc.c index cb430350..55f14a8d 100644 --- a/PDP11/pdp11_dmc.c +++ b/PDP11/pdp11_dmc.c @@ -1514,7 +1514,7 @@ controller->control_out_operations_completed = 0; controller->ddcmp_control_packets_received = 0; controller->ddcmp_control_packets_sent = 0; -printf("Statistics reset\n" ); +sim_printf("Statistics reset\n"); return SCPE_OK; } @@ -2569,6 +2569,15 @@ if (!buffer) { dmc_showddcmp (sim_log, controller->unit, 0, NULL); fflush (sim_log); } + if (sim_deb) { + fprintf (sim_deb, "DDCMP Buffer allocation failure.\n"); + fprintf (sim_deb, "This is a fatal error which should never happen.\n"); + fprintf (sim_deb, "Please submit this output when you report this bug.\n"); + dmc_showqueues (sim_deb, controller->unit, 0, NULL); + dmc_showstats (sim_deb, controller->unit, 0, NULL); + dmc_showddcmp (sim_deb, controller->unit, 0, NULL); + fflush (sim_deb); + } return buffer; } buffer->address = 0; @@ -3741,9 +3750,7 @@ if (!cptr || !*cptr) if (!(uptr->flags & UNIT_ATTABLE)) return SCPE_NOATT; if (!peer[0]) { - printf ("Peer must be specified before attach\n"); - if (sim_log) - fprintf (sim_log, "Peer must be specified before attach\n"); + sim_printf ("Peer must be specified before attach\n"); return SCPE_ARG; } sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr); diff --git a/PDP11/pdp11_dup.c b/PDP11/pdp11_dup.c index 8fc6bfb1..31c939e7 100644 --- a/PDP11/pdp11_dup.c +++ b/PDP11/pdp11_dup.c @@ -1199,7 +1199,7 @@ sim_debug(DBG_TRC, dptr, "dup_reset()\n"); dup_desc.packet = TRUE; if ((UNIBUS) && (dptr == &dpv_dev)) { if (!(dptr->flags & DEV_DIS)) { - printf ("Can't enable Qbus device on Unibus system\n"); + sim_printf ("Can't enable Qbus device on Unibus system\n"); dptr->flags |= DEV_DIS; return SCPE_ARG; } @@ -1208,7 +1208,7 @@ if ((UNIBUS) && (dptr == &dpv_dev)) { if ((!UNIBUS) && (dptr == &dup_dev)) { if (!(dptr->flags & DEV_DIS)) { - printf ("Can't enable Unibus device on Qbus system\n"); + sim_printf ("Can't enable Unibus device on Qbus system\n"); dptr->flags |= DEV_DIS; return SCPE_ARG; } diff --git a/PDP11/pdp11_dz.c b/PDP11/pdp11_dz.c index c18d792f..6e7bb748 100644 --- a/PDP11/pdp11_dz.c +++ b/PDP11/pdp11_dz.c @@ -769,14 +769,10 @@ if (r != SCPE_OK) { /* error? */ } if (sim_switches & SWMASK ('M')) { /* modem control? */ dz_mctl = 1; - printf ("Modem control activated\n"); - if (sim_log) - fprintf (sim_log, "Modem control activated\n"); + sim_printf ("Modem control activated\n"); if (sim_switches & SWMASK ('A')) { /* autodisconnect? */ dz_auto = 1; - printf ("Auto disconnect activated\n"); - if (sim_log) - fprintf (sim_log, "Auto disconnect activated\n"); + sim_printf ("Auto disconnect activated\n"); } } diff --git a/PDP11/pdp11_io_lib.c b/PDP11/pdp11_io_lib.c index 0cbfce9d..665f23a9 100644 --- a/PDP11/pdp11_io_lib.c +++ b/PDP11/pdp11_io_lib.c @@ -313,16 +313,10 @@ if (vec && !(sim_switches & SWMASK ('P'))) { if (!cdname) { cdname = "CPU"; } - printf ("Device %s interrupt vector conflict with %s at ", - sim_dname (dptr), cdname); - fprint_val (stdout, (t_value) dibp->vec, DEV_RDX, 32, PV_LEFT); - printf ("\n"); - if (sim_log) { - fprintf (sim_log, "Device %s interrupt vector conflict with %s at ", - sim_dname (dptr), cdname); - fprint_val (sim_log, (t_value) dibp->vec, DEV_RDX, 32, PV_LEFT); - fprintf (sim_log, "\n"); - } + sim_printf ("Device %s interrupt vector conflict with %s at ", + sim_dname (dptr), cdname); + sim_print_val ((t_value) dibp->vec, DEV_RDX, 32, PV_LEFT); + sim_printf ("\n"); return SCPE_STOP; } } @@ -336,11 +330,8 @@ for (i = 0; i < dibp->vnum; i++) { /* loop thru vec */ (int_ack[ilvl][ibit] != dibp->ack[i])) || (int_vec[ilvl][ibit] && vec && (int_vec[ilvl][ibit] != vec))) { - printf ("Device %s interrupt slot conflict at %d\n", - sim_dname (dptr), idx); - if (sim_log) - fprintf (sim_log, "Device %s interrupt slot conflict at %d\n", - sim_dname (dptr), idx); + sim_printf ("Device %s interrupt slot conflict at %d\n", + sim_dname (dptr), idx); return SCPE_STOP; } if (dibp->ack[i]) @@ -373,15 +364,9 @@ for (i = 0; i < (int32) dibp->lnt; i = i + 2) { /* create entries */ if (!cdname) { cdname = "CPU"; } - printf ("Device %s address conflict with %s at ", sim_dname (dptr), cdname); - fprint_val (stdout, (t_value) dibp->ba, DEV_RDX, 32, PV_LEFT); - printf ("\n"); - if (sim_log) { - fprintf (sim_log, "Device %s address conflict with %s at ", sim_dname (dptr), - cdname); - fprint_val (sim_log, (t_value) dibp->ba, DEV_RDX, 32, PV_LEFT); - fprintf (sim_log, "\n"); - } + sim_printf ("Device %s address conflict with %s at ", sim_dname (dptr), cdname); + sim_print_val ((t_value) dibp->ba, DEV_RDX, 32, PV_LEFT); + sim_printf ("\n"); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ @@ -812,9 +797,7 @@ for (autp = auto_tab; autp->numc >= 0; autp++) { /* loop thru table */ dptr->flags |= DEV_DIS; if (sim_switches & SWMASK ('P')) continue; - printf ("%s device not compatible with system bus\n", sim_dname(dptr)); - if (sim_log) - fprintf (sim_log, "%s device not compatible with system bus\n", sim_dname(dptr)); + sim_printf ("%s device not compatible with system bus\n", sim_dname(dptr)); return SCPE_NOFNC; } dibp = (DIB *) dptr->ctxt; /* get DIB */ diff --git a/PDP11/pdp11_pt.c b/PDP11/pdp11_pt.c index 1ad71e09..27a21201 100644 --- a/PDP11/pdp11_pt.c +++ b/PDP11/pdp11_pt.c @@ -242,7 +242,7 @@ if ((ptr_unit.flags & UNIT_ATT) == 0) if ((temp = getc (ptr_unit.fileref)) == EOF) { if (feof (ptr_unit.fileref)) { if (ptr_stopioe) - printf ("PTR end of file\n"); + sim_printf ("PTR end of file\n"); else return SCPE_OK; } else perror ("PTR I/O error"); diff --git a/PDP11/pdp11_rh.c b/PDP11/pdp11_rh.c index 2c8218a3..2bc094bf 100644 --- a/PDP11/pdp11_rh.c +++ b/PDP11/pdp11_rh.c @@ -908,11 +908,8 @@ if ((mbregR[idx] && dibp->rd && /* conflict? */ (mbregW[idx] != dibp->wr)) || (mbabort[idx] && dibp->ack[0] && (mbabort[idx] != dibp->ack[0]))) { - printf ("Massbus %s assignment conflict at %d\n", - sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Massbus %s assignment conflict at %d\n", - sim_dname (dptr), dibp->ba); + sim_printf ("Massbus %s assignment conflict at %d\n", + sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/PDP11/pdp11_tc.c b/PDP11/pdp11_tc.c index 46d00670..1672c4c4 100644 --- a/PDP11/pdp11_tc.c +++ b/PDP11/pdp11_tc.c @@ -1242,13 +1242,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */ return SCPE_MEM; } fbuf = (uint32 *) uptr->filebuf; /* file buffer */ -printf ("%s%d: ", sim_dname (&dt_dev), u); +sim_printf ("%s%d: ", sim_dname (&dt_dev), u); if (uptr->flags & UNIT_8FMT) - printf ("12b format"); + sim_printf ("12b format"); else if (uptr->flags & UNIT_11FMT) - printf ("16b format"); -else printf ("18b/36b format"); -printf (", buffering file in memory\n"); + sim_printf ("16b format"); +else sim_printf ("18b/36b format"); +sim_printf (", buffering file in memory\n"); uptr->io_flush = dt_flush; if (uptr->flags & UNIT_8FMT) { /* 12b? */ for (ba = 0; ba < uptr->capac; ) { /* loop thru file */ @@ -1356,7 +1356,7 @@ if (sim_is_active (uptr)) { /* active? cancel op */ uptr->STATE = uptr->pos = 0; } if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */ - printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); + sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); dt_flush (uptr); } /* end if hwmark */ free (uptr->filebuf); /* release buf */ diff --git a/PDP11/pdp11_xq.c b/PDP11/pdp11_xq.c index ff551b16..8d4ab2d7 100644 --- a/PDP11/pdp11_xq.c +++ b/PDP11/pdp11_xq.c @@ -2705,8 +2705,7 @@ t_stat xq_attach(UNIT* uptr, char* cptr) char buf[32]; eth_mac_fmt(&xq->var->mac, buf); /* format ethernet mac address */ - printf("%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf); - if (sim_log) fprintf (sim_log, "%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf); + sim_printf("%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf); eth_close(xq->var->etherface); free(tptr); free(xq->var->etherface); diff --git a/PDP11/pdp11_xu.c b/PDP11/pdp11_xu.c index 36e7161a..1d78b7bd 100644 --- a/PDP11/pdp11_xu.c +++ b/PDP11/pdp11_xu.c @@ -1078,7 +1078,7 @@ int32 xu_command(CTLR* xu) break; default: /* Unknown (unimplemented) command. */ - printf("%s: unknown ancilliary command 0%o requested !\n", xu->dev->name, fnc); + sim_printf("%s: unknown ancilliary command 0%o requested !\n", xu->dev->name, fnc); return PCSR0_PCEI; break; @@ -1497,8 +1497,7 @@ void xu_port_command (CTLR* xu) case CMD_BOOT: /* BOOT */ /* not implemented */ msg = "%s: BOOT command not implemented!\n"; - printf (msg, xu->dev->name); - if (sim_log) fprintf(sim_log, msg, xu->dev->name); + sim_printf (msg, xu->dev->name); xu->var->pcsr0 |= PCSR0_PCEI; break; @@ -1660,8 +1659,7 @@ t_stat xu_attach(UNIT* uptr, char* cptr) char buf[32]; eth_mac_fmt(&xu->var->mac, buf); /* format ethernet mac address */ - printf("%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf); - if (sim_log) fprintf (sim_log, "%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf); + sim_printf("%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf); eth_close(xu->var->etherface); free(tptr); free(xu->var->etherface); @@ -1760,7 +1758,7 @@ void xu_dump_rxring (CTLR* xu) { int i; int rrlen = xu->var->rrlen; - printf ("receive ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->rdrb, xu->var->rrlen, xu->var->relen, xu->var->rxnext); + sim_printf ("receive ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->rdrb, xu->var->rrlen, xu->var->relen, xu->var->rxnext); for (i=0; ivar->rdrb + (xu->var->relen * 2) * i; @@ -1769,7 +1767,7 @@ void xu_dump_rxring (CTLR* xu) int len = rxhdr[0]; uint32 addr = rxhdr[1] + ((rxhdr[2] & 3) << 16); if (rstatus == 0) - printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, rxhdr[0], rxhdr[1], rxhdr[2], rxhdr[3]); + sim_printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, rxhdr[0], rxhdr[1], rxhdr[2], rxhdr[3]); } } @@ -1777,7 +1775,7 @@ void xu_dump_txring (CTLR* xu) { int i; int trlen = xu->var->trlen; - printf ("transmit ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->tdrb, xu->var->trlen, xu->var->telen, xu->var->txnext); + sim_printf ("transmit ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->tdrb, xu->var->trlen, xu->var->telen, xu->var->txnext); for (i=0; ivar->tdrb + (xu->var->telen * 2) * i; @@ -1786,7 +1784,7 @@ void xu_dump_txring (CTLR* xu) int len = txhdr[0]; uint32 addr = txhdr[1] + ((txhdr[2] & 3) << 16); if (tstatus == 0) - printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, txhdr[0], txhdr[1], txhdr[2], txhdr[3]); + sim_printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, txhdr[0], txhdr[1], txhdr[2], txhdr[3]); } } diff --git a/PDP18B/pdp18b_cpu.c b/PDP18B/pdp18b_cpu.c index 20bcc2f2..3e2f0cd1 100644 --- a/PDP18B/pdp18b_cpu.c +++ b/PDP18B/pdp18b_cpu.c @@ -2259,11 +2259,8 @@ for (i = p = 0; (dptr = sim_devices[i]) != NULL; i++) { /* add devices * for (j = 0; j < dibp->num; j++) { /* loop thru disp */ if (dibp->dsp[j]) { /* any dispatch? */ if (dev_tab[dibp->dev + j]) { /* already filled? */ - printf ("%s device number conflict at %02o\n", - sim_dname (dptr), dibp->dev + j); - if (sim_log) - fprintf (sim_log, "%s device number conflict at %02o\n", - sim_dname (dptr), dibp->dev + j); + sim_printf ("%s device number conflict at %02o\n", + sim_dname (dptr), dibp->dev + j); return TRUE; } dev_tab[dibp->dev + j] = dibp->dsp[j]; /* fill */ diff --git a/PDP18B/pdp18b_dt.c b/PDP18B/pdp18b_dt.c index 09d920ba..cdea389c 100644 --- a/PDP18B/pdp18b_dt.c +++ b/PDP18B/pdp18b_dt.c @@ -1436,13 +1436,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */ return SCPE_MEM; } fbuf = (uint32 *) uptr->filebuf; /* file buffer */ -printf ("%s%d: ", sim_dname (&dt_dev), u); +sim_printf ("%s%d: ", sim_dname (&dt_dev), u); if (uptr->flags & UNIT_8FMT) - printf ("12b format"); + sim_printf ("12b format"); else if (uptr->flags & UNIT_11FMT) - printf ("16b format"); -else printf ("18b/36b format"); -printf (", buffering file in memory\n"); + sim_printf ("16b format"); +else sim_printf ("18b/36b format"); +sim_printf (", buffering file in memory\n"); uptr->io_flush = dt_flush; if (uptr->flags & UNIT_8FMT) { /* 12b? */ for (ba = 0; ba < uptr->capac; ) { /* loop thru file */ @@ -1548,7 +1548,7 @@ if (sim_is_active (uptr)) { uptr->STATE = uptr->pos = 0; } if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */ - printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); + sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); dt_flush (uptr); } /* end if hwmark */ free (uptr->filebuf); /* release buf */ diff --git a/PDP18B/pdp18b_stddev.c b/PDP18B/pdp18b_stddev.c index fd1959e3..4b202d31 100644 --- a/PDP18B/pdp18b_stddev.c +++ b/PDP18B/pdp18b_stddev.c @@ -573,7 +573,7 @@ if ((temp = getc (ptr_unit.fileref)) == EOF) { /* end of file? */ #endif if (feof (ptr_unit.fileref)) { if (ptr_stopioe) - printf ("PTR end of file\n"); + sim_printf ("PTR end of file\n"); else return SCPE_OK; } else perror ("PTR I/O error"); diff --git a/PDP8/pdp8_cpu.c b/PDP8/pdp8_cpu.c index 67b74fe7..cb4471c3 100644 --- a/PDP8/pdp8_cpu.c +++ b/PDP8/pdp8_cpu.c @@ -1499,12 +1499,9 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* add devices */ for (j = 0; j < dibp->num; j++) { /* loop thru disp */ if (dibp->dsp[j]) { /* any dispatch? */ if (dev_tab[dibp->dev + j]) { /* already filled? */ - printf ("%s device number conflict at %02o\n", - sim_dname (dptr), dibp->dev + j); - if (sim_log) - fprintf (sim_log, "%s device number conflict at %02o\n", - sim_dname (dptr), dibp->dev + j); - return TRUE; + sim_printf ("%s device number conflict at %02o\n", + sim_dname (dptr), dibp->dev + j); + return TRUE; } dev_tab[dibp->dev + j] = dibp->dsp[j]; /* fill */ } /* end if dsp */ diff --git a/PDP8/pdp8_dt.c b/PDP8/pdp8_dt.c index 2c846655..f77840b2 100644 --- a/PDP8/pdp8_dt.c +++ b/PDP8/pdp8_dt.c @@ -1234,13 +1234,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */ return SCPE_MEM; } fbuf = (uint16 *) uptr->filebuf; /* file buffer */ -printf ("%s%d: ", sim_dname (&dt_dev), u); +sim_printf ("%s%d: ", sim_dname (&dt_dev), u); if (uptr->flags & UNIT_8FMT) - printf ("12b format"); + sim_printf ("12b format"); else if (uptr->flags & UNIT_11FMT) - printf ("16b format"); -else printf ("18b/36b format"); -printf (", buffering file in memory\n"); + sim_printf ("16b format"); +else sim_printf ("18b/36b format"); +sim_printf (", buffering file in memory\n"); uptr->io_flush = dt_flush; if (uptr->flags & UNIT_8FMT) /* 12b? */ uptr->hwmark = fxread (uptr->filebuf, sizeof (uint16), @@ -1332,7 +1332,7 @@ if (sim_is_active (uptr)) { uptr->STATE = uptr->pos = 0; } if (uptr->hwmark && ((uptr->flags & UNIT_RO)== 0)) { /* any data? */ - printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); + sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); dt_flush (uptr); } /* end if hwmark */ free (uptr->filebuf); /* release buf */ diff --git a/PDP8/pdp8_sys.c b/PDP8/pdp8_sys.c index 3c0c9d95..ef308605 100644 --- a/PDP8/pdp8_sys.c +++ b/PDP8/pdp8_sys.c @@ -196,12 +196,14 @@ int32 sections_read = 0; for (;;) { csum = origin = field = newf = 0; /* init */ do { /* skip leader */ - if ((hi = sim_bin_getc (fi, &newf)) == EOF) + if ((hi = sim_bin_getc (fi, &newf)) == EOF) { if (sections_read != 0) { - printf ("%d sections sucessfully read\n\r", sections_read); + sim_printf ("%d sections sucessfully read\n\r", sections_read); return SCPE_OK; - } else + } + else return SCPE_FMT; + } } while ((hi == 0) || (hi >= 0200)); for (;;) { /* data blocks */ if ((lo = sim_bin_getc (fi, &newf)) == EOF) /* low char */ @@ -213,7 +215,7 @@ for (;;) { if (hi == 0200) { /* end of tape? */ if ((csum - wd) & 07777) { /* valid csum? */ if (sections_read != 0) - printf ("%d sections sucessfully read\n\r", sections_read); + sim_printf ("%d sections sucessfully read\n\r", sections_read); return SCPE_CSUM; } if (!(sim_switches & SWMASK ('A'))) /* Load all sections? */ diff --git a/SDS/sds_io.c b/SDS/sds_io.c index e021cf5f..ef8070e0 100644 --- a/SDS/sds_io.c +++ b/SDS/sds_io.c @@ -982,11 +982,8 @@ for (i = 0; (dptr = sim_devices[i]); i++) { /* loop thru devices */ for (j = 0; j < tplp->num; j++) { /* repeat as needed */ doff = dev + tplp->off + j; /* get offset dnum */ if (dev_map[doff][ch]) { /* slot in use? */ - printf ("Device number conflict, chan = %s, devno = %02o\n", - chname[ch], doff); - if (sim_log) - fprintf (sim_log, "Device number conflict, chan = %s, dev = %02o\n", - chname[ch], doff); + sim_printf ("Device number conflict, chan = %s, devno = %02o\n", + chname[ch], doff); return TRUE; } dev_map[doff][ch] = dibp->xfr; /* set xfr flag */ diff --git a/SDS/sds_stddev.c b/SDS/sds_stddev.c index b35cbdbf..672ed363 100644 --- a/SDS/sds_stddev.c +++ b/SDS/sds_stddev.c @@ -278,7 +278,7 @@ if ((temp = getc (ptr_unit.fileref)) == EOF) { /* end of file? */ ptr_set_err (); /* yes, err, disc */ if (feof (ptr_unit.fileref)) { /* end of file? */ if (ptr_stopioe) - printf ("PTR end of file\n"); + sim_printf ("PTR end of file\n"); else return SCPE_OK; } else perror ("PTR I/O error"); /* I/O error */ diff --git a/VAX/vax610_sysdev.c b/VAX/vax610_sysdev.c index 2036f366..7c99025b 100644 --- a/VAX/vax610_sysdev.c +++ b/VAX/vax610_sysdev.c @@ -379,9 +379,7 @@ t_stat r; r = vax610_boot_parse (flag, ptr); /* parse the boot cmd */ if (r != SCPE_OK) { /* error? */ if (r >= SCPE_BASE) { /* message available? */ - printf ("%s\n", sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (r)); + sim_printf ("%s\n", sim_error_text (r)); r |= SCPE_NOMESSAGE; } return r; @@ -504,9 +502,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */ (reset_all (0) != SCPE_OK) || /* reset the world */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ ABORT (STOP_BOOT); /* any error? */ -printf ("Rebooting...\n"); -if (sim_log) - fprintf (sim_log, "Rebooting...\n"); +sim_printf ("Rebooting...\n"); return cc; } diff --git a/VAX/vax730_stddev.c b/VAX/vax730_stddev.c index fb3bedae..956000bd 100644 --- a/VAX/vax730_stddev.c +++ b/VAX/vax730_stddev.c @@ -489,7 +489,7 @@ switch (opcode) { case TD_OPDAT: if (td_state != TD_WRITE1) { /* expecting data? */ - printf("TU58 protocol error 1\n"); + sim_printf("TU58 protocol error 1\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ @@ -502,7 +502,7 @@ switch (opcode) { case TD_OPCMD: if (td_state != TD_IDLE) { /* expecting command? */ - printf("TU58 protocol error 2\n"); + sim_printf("TU58 protocol error 2\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ @@ -521,7 +521,7 @@ switch (opcode) { break; case TD_CMDINI: - printf("Warning: TU58 command 'INIT' not implemented\n"); + sim_printf("Warning: TU58 command 'INIT' not implemented\n"); break; case TD_CMDRD: @@ -543,11 +543,11 @@ switch (opcode) { break; case TD_CMDPOS: - printf("Warning: TU58 command 'Position' not implemented\n"); + sim_printf("Warning: TU58 command 'Position' not implemented\n"); break; case TD_CMDDIA: - printf("Warning: TU58 command 'Diagnose' not implemented\n"); + sim_printf("Warning: TU58 command 'Diagnose' not implemented\n"); break; case TD_CMDMRSP: /* MRSP supported? */ @@ -574,7 +574,7 @@ switch (opcode) { case TD_OPBOO: if (td_state != TD_IDLE) { - printf("TU58 protocol error 3\n"); + sim_printf("TU58 protocol error 3\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ diff --git a/VAX/vax730_sys.c b/VAX/vax730_sys.c index 6454c477..0d641ba4 100644 --- a/VAX/vax730_sys.c +++ b/VAX/vax730_sys.c @@ -465,9 +465,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */ (reset_all (0) != SCPE_OK) || /* reset the world */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ ABORT (STOP_BOOT); /* any error? */ -printf ("Rebooting...\n"); -if (sim_log) - fprintf (sim_log, "Rebooting...\n"); +sim_printf ("Rebooting...\n"); return cc; } @@ -485,9 +483,7 @@ t_stat r; r = vax730_boot_parse (flag, ptr); /* parse the boot cmd */ if (r != SCPE_OK) { /* error? */ if (r >= SCPE_BASE) { /* message available? */ - printf ("%s\n", sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (r)); + sim_printf ("%s\n", sim_error_text (r)); r |= SCPE_NOMESSAGE; } return r; @@ -633,9 +629,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */ (nexusR[idx] != dibp->rd)) || (nexusW[idx] && dibp->wr && (nexusW[idx] != dibp->wr))) { - printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); + sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/VAX/vax730_uba.c b/VAX/vax730_uba.c index e19563d7..72094503 100644 --- a/VAX/vax730_uba.c +++ b/VAX/vax730_uba.c @@ -192,7 +192,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt) int32 idx, ofs; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); // **FIXME** - Set error bit? return SCPE_OK; } @@ -243,7 +243,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt) int32 idx, ofs; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); // **FIXME** - Set error bit? return SCPE_OK; } @@ -335,7 +335,7 @@ if ((lnt == L_BYTE) || /* byte? */ iod = iod << 16; } else { - printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); // **FIXME** - Set error bit? iod = 0; } @@ -360,7 +360,7 @@ if (lnt == L_BYTE) /* byte? DATOB */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ WriteUb (pa, val, WRITE); /* DATO */ else { - printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); // **FIXME** - Set error bit? } SET_IRQL; /* update ints */ diff --git a/VAX/vax750_cmi.c b/VAX/vax750_cmi.c index 91e460bd..2251b0a2 100644 --- a/VAX/vax750_cmi.c +++ b/VAX/vax750_cmi.c @@ -549,9 +549,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */ (reset_all (0) != SCPE_OK) || /* reset the world */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ ABORT (STOP_BOOT); /* any error? */ -printf ("Rebooting...\n"); -if (sim_log) - fprintf (sim_log, "Rebooting...\n"); +sim_printf ("Rebooting...\n"); return cc; } @@ -569,9 +567,7 @@ t_stat r; r = vax750_boot_parse (flag, ptr); /* parse the boot cmd */ if (r != SCPE_OK) { /* error? */ if (r >= SCPE_BASE) { /* message available? */ - printf ("%s\n", sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (r)); + sim_printf ("%s\n", sim_error_text (r)); r |= SCPE_NOMESSAGE; } return r; @@ -720,9 +716,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */ (nexusR[idx] != dibp->rd)) || (nexusW[idx] && dibp->wr && (nexusW[idx] != dibp->wr))) { - printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); + sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/VAX/vax750_stddev.c b/VAX/vax750_stddev.c index bddb2a5a..5be2a8bf 100644 --- a/VAX/vax750_stddev.c +++ b/VAX/vax750_stddev.c @@ -487,7 +487,7 @@ switch (opcode) { case TD_OPDAT: if (td_state != TD_WRITE1) { /* expecting data? */ - printf("TU58 protocol error 1\n"); + sim_printf("TU58 protocol error 1\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ @@ -500,7 +500,7 @@ switch (opcode) { case TD_OPCMD: if (td_state != TD_IDLE) { /* expecting command? */ - printf("TU58 protocol error 2\n"); + sim_printf("TU58 protocol error 2\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ @@ -518,7 +518,7 @@ switch (opcode) { break; case TD_CMDINI: - printf("Warning: TU58 command 'INIT' not implemented\n"); + sim_printf("Warning: TU58 command 'INIT' not implemented\n"); break; case TD_CMDRD: @@ -538,11 +538,11 @@ switch (opcode) { break; case TD_CMDPOS: - printf("Warning: TU58 command 'Position' not implemented\n"); + sim_printf("Warning: TU58 command 'Position' not implemented\n"); break; case TD_CMDDIA: - printf("Warning: TU58 command 'Diagnose' not implemented\n"); + sim_printf("Warning: TU58 command 'Diagnose' not implemented\n"); break; case TD_CMDMRSP: @@ -568,7 +568,7 @@ switch (opcode) { case TD_OPBOO: if (td_state != TD_IDLE) { - printf("TU58 protocol error 3\n"); + sim_printf("TU58 protocol error 3\n"); return; } if (td_ibptr < 2) { /* whole packet read? */ diff --git a/VAX/vax750_uba.c b/VAX/vax750_uba.c index 17b4fe11..a6225bd1 100644 --- a/VAX/vax750_uba.c +++ b/VAX/vax750_uba.c @@ -193,7 +193,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt) int32 idx, ofs; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); /* FIXME: set appropriate error bits */ return SCPE_OK; } @@ -242,7 +242,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt) int32 idx, ofs; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); /* FIXME: set appropriate error bits */ return SCPE_OK; } @@ -339,7 +339,7 @@ if ((lnt == L_BYTE) || /* byte? */ iod = iod << 16; } else { - printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); /* FIXME: set appropriate error bits */ iod = 0; } @@ -364,7 +364,7 @@ if (lnt == L_BYTE) /* byte? DATOB */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ WriteUb (pa, val, WRITE); /* DATO */ else { - printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); /* FIXME: set appropriate error bits */ } SET_IRQL; /* update ints */ diff --git a/VAX/vax780_mem.c b/VAX/vax780_mem.c index a79d999f..2ef245ab 100644 --- a/VAX/vax780_mem.c +++ b/VAX/vax780_mem.c @@ -168,7 +168,7 @@ int32 mctl, ofs; t_bool extmem = MEMSIZE > MAXMEMSIZE; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>MCTL: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>MCTL: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ return SCPE_OK; } @@ -213,7 +213,7 @@ int32 mctl, ofs, mask; t_bool extmem = MEMSIZE > MAXMEMSIZE; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>MCTL: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>MCTL: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ return SCPE_OK; } diff --git a/VAX/vax780_sbi.c b/VAX/vax780_sbi.c index ac554d5b..02e56bb4 100644 --- a/VAX/vax780_sbi.c +++ b/VAX/vax780_sbi.c @@ -615,9 +615,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */ (reset_all (0) != SCPE_OK) || /* reset the world */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ ABORT (STOP_BOOT); /* any error? */ -printf ("Rebooting...\n"); -if (sim_log) - fprintf (sim_log, "Rebooting...\n"); +sim_printf ("Rebooting...\n"); return cc; } @@ -635,9 +633,7 @@ t_stat r; r = vax780_boot_parse (flag, ptr); /* parse the boot cmd */ if (r != SCPE_OK) { /* error? */ if (r >= SCPE_BASE) { /* message available? */ - printf ("%s\n", sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (r)); + sim_printf ("%s\n", sim_error_text (r)); r |= SCPE_NOMESSAGE; } return r; @@ -792,9 +788,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */ (nexusR[idx] != dibp->rd)) || (nexusW[idx] && dibp->wr && (nexusW[idx] != dibp->wr))) { - printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); + sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/VAX/vax780_uba.c b/VAX/vax780_uba.c index 3b78a057..dbbe8797 100644 --- a/VAX/vax780_uba.c +++ b/VAX/vax780_uba.c @@ -304,7 +304,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt) int32 idx, ofs; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ return SCPE_OK; } @@ -393,7 +393,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt) int32 idx, ofs, old_cr; if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); + sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ return SCPE_OK; } @@ -526,7 +526,7 @@ if ((lnt == L_BYTE) || /* byte? */ iod = iod << 16; } else { - printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ iod = 0; } @@ -551,7 +551,7 @@ if (lnt == L_BYTE) /* byte? DATOB */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ WriteUb (pa, val, WRITE); /* DATO */ else { - printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); + sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); sbi_set_errcnf (); /* err confirmation */ } SET_IRQL; /* update ints */ diff --git a/VAX/vax7x0_mba.c b/VAX/vax7x0_mba.c index 0bc4d493..f52d11b1 100644 --- a/VAX/vax7x0_mba.c +++ b/VAX/vax7x0_mba.c @@ -366,7 +366,7 @@ t_stat r; mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>MBA%d: invalid adapter read mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); + sim_printf (">>MBA%d: invalid adapter read mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); #if defined(VAX_780) sbi_set_errcnf (); /* err confirmation */ #endif @@ -460,7 +460,7 @@ t_bool cs1dt; mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ - printf (">>MBA%d: invalid adapter write mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); + sim_printf (">>MBA%d: invalid adapter write mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); #if defined(VAX_780) sbi_set_errcnf (); /* err confirmation */ #endif @@ -935,11 +935,8 @@ if ((mbregR[idx] && dibp->rd && /* conflict? */ (mbregW[idx] != dibp->wr)) || (mbabort[idx] && dibp->ack[0] && (mbabort[idx] != dibp->ack[0]))) { - printf ("Massbus %s assignment conflict at %d\n", - sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Massbus %s assignment conflict at %d\n", - sim_dname (dptr), dibp->ba); + sim_printf ("Massbus %s assignment conflict at %d\n", + sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/VAX/vax860_abus.c b/VAX/vax860_abus.c index 1f720ef0..60284a9c 100644 --- a/VAX/vax860_abus.c +++ b/VAX/vax860_abus.c @@ -682,9 +682,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */ (reset_all (0) != SCPE_OK) || /* reset the world */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ ABORT (STOP_BOOT); /* any error? */ -printf ("Rebooting...\n"); -if (sim_log) - fprintf (sim_log, "Rebooting...\n"); +sim_printf ("Rebooting...\n"); return cc; } @@ -702,9 +700,7 @@ t_stat r; r = vax860_boot_parse (flag, ptr); /* parse the boot cmd */ if (r != SCPE_OK) { /* error? */ if (r >= SCPE_BASE) { /* message available? */ - printf ("%s\n", sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (r)); + sim_printf ("%s\n", sim_error_text (r)); r |= SCPE_NOMESSAGE; } return r; diff --git a/VAX/vax860_sbia.c b/VAX/vax860_sbia.c index 47c652ef..b54ec421 100644 --- a/VAX/vax860_sbia.c +++ b/VAX/vax860_sbia.c @@ -186,7 +186,7 @@ void sbia_wr (int32 pa, int32 val, int32 lnt) break; case 1: /* SBICSR */ - printf ("sbi_csr wr: %08X\n", val); + sim_printf ("sbi_csr wr: %08X\n", val); sbi_csr = sbi_csr & SBICSR_WR; break; @@ -350,9 +350,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */ (nexusR[idx] != dibp->rd)) || (nexusW[idx] && dibp->wr && (nexusW[idx] != dibp->wr))) { - printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); - if (sim_log) - fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); + sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); return SCPE_STOP; } if (dibp->rd) /* set rd dispatch */ diff --git a/VAX/vax860_stddev.c b/VAX/vax860_stddev.c index a5e04be8..ec404fb7 100644 --- a/VAX/vax860_stddev.c +++ b/VAX/vax860_stddev.c @@ -558,7 +558,7 @@ switch (fnc) { break; default: - printf ("CS: Unknown Command: %d\n", fnc); + sim_printf ("CS: Unknown Command: %d\n", fnc); } } @@ -1073,7 +1073,7 @@ else switch (lc_fnc) { /* idle, case */ break; default: /* all others */ - printf ("TTO3: Unknown console command: %X\n", lc_fnc); + sim_printf ("TTO3: Unknown console command: %X\n", lc_fnc); break; } return SCPE_OK; diff --git a/VAX/vax_cpu.c b/VAX/vax_cpu.c index 99491b08..2eab04ec 100644 --- a/VAX/vax_cpu.c +++ b/VAX/vax_cpu.c @@ -3514,9 +3514,7 @@ t_stat cpu_load_bootcode (const char *filename, const unsigned char *builtin_cod char args[CBUFSIZE]; t_stat r; -printf ("Loading boot code from %s\n", filename); -if (sim_log) - fprintf (sim_log, "Loading boot code from %s\n", filename); +sim_printf ("Loading boot code from %s\n", filename); if (rom) sprintf (args, "-R %s", filename); else @@ -3527,14 +3525,10 @@ if (r != SCPE_OK) { FILE *f; if ((f = sim_fopen (filename, "wb"))) { - printf ("Saving boot code to %s\n", filename); - if (sim_log) - fprintf (sim_log, "Saving boot code to %s\n", filename); + sim_printf ("Saving boot code to %s\n", filename); sim_fwrite ((void *)builtin_code, 1, size, f); fclose (f); - printf ("Loading boot code from %s\n", filename); - if (sim_log) - fprintf (sim_log, "Loading boot code from %s\n", filename); + sim_printf ("Loading boot code from %s\n", filename); r = load_cmd (0, args); } } diff --git a/VAX/vax_lk.c b/VAX/vax_lk.c index 5afe3242..29b6ef58 100644 --- a/VAX/vax_lk.c +++ b/VAX/vax_lk.c @@ -354,7 +354,7 @@ if (lk_rbuf[0] & 1) { /* peripheral command */ break; default: - printf ("lk: unknown cmd %02X\n", lk_rbuf[0]); + sim_printf ("lk: unknown cmd %02X\n", lk_rbuf[0]); break; } } diff --git a/scp.c b/scp.c index 734f8533..df134eb0 100644 --- a/scp.c +++ b/scp.c @@ -1717,11 +1717,8 @@ while (stat != SCPE_EXIT) { /* in case exit */ if (cmdp && (cmdp->message)) /* special message handler? */ cmdp->message (NULL, stat); /* let it deal with display */ else - if (stat >= SCPE_BASE) { /* error? */ - printf ("%s\n", sim_error_text (stat)); - if (sim_log) - fprintf (sim_log, "%s\n", sim_error_text (stat)); - } + if (stat >= SCPE_BASE) /* error? */ + sim_printf ("%s\n", sim_error_text (stat)); } if (sim_vm_post != NULL) (*sim_vm_post) (TRUE); @@ -2297,6 +2294,8 @@ if ((cptr == NULL) || (strlen (cptr) == 0)) fflush(stdout); /* flush stdout */ if (sim_log) /* flush log if enabled */ fflush (sim_log); +if (sim_deb) /* flush debug if enabled */ + fflush (sim_deb); status = system (cptr); #if defined (VMS) printf ("\n"); @@ -4041,7 +4040,7 @@ if ((!cptr) || (*cptr == 0)) return SCPE_2FARG; sim_trim_endspc(cptr); if (chdir(cptr) != 0) { - printf("Unable to change to: %s\n", cptr); + sim_printf("Unable to directory change to: %s\n", cptr); return SCPE_IOERR & SCPE_NOMESSAGE; } return SCPE_OK; @@ -4087,57 +4086,37 @@ if ((hFind = FindFirstFileA (cptr, &File)) != INVALID_HANDLE_VALUE) { else { getcwd(DirName, PATH_MAX); } - printf (" Directory of %s\n\n", DirName); - if (sim_log) - fprintf (sim_log, " Directory of %s\n\n", DirName); + sim_printf (" Directory of %s\n\n", DirName); do { FileSize = (((t_int64)(File.nFileSizeHigh)) << 32) | File.nFileSizeLow; sprintf (FileName, "%s%c%s", DirName, pathsep, File.cFileName); stat (FileName, &filestat); local = localtime (&filestat.st_mtime); - printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); - if (sim_log) - fprintf (sim_log, "%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); + sim_printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); if (filestat.st_mode & S_IFDIR) { ++DirCount; - printf (" "); - if (sim_log) - fprintf (sim_log, " "); + sim_printf (" "); } else { if (filestat.st_mode & S_IFREG) { ++FileCount; - fprint_val (stdout, (t_value) FileSize, 10, 17, PV_RCOMMA); - if (sim_log) - fprint_val (sim_log, (t_value) FileSize, 10, 17, PV_RCOMMA); + sim_print_val ((t_value) FileSize, 10, 17, PV_RCOMMA); TotalSize += FileSize; } else { - printf ("%17s", ""); - if (sim_log) - fprintf (sim_log, "%17s", ""); + sim_printf ("%17s", ""); } } - printf (" %s\n", File.cFileName); - if (sim_log) - fprintf (sim_log, " %s\n", File.cFileName); + sim_printf (" %s\n", File.cFileName); } while (FindNextFile (hFind, &File)); - printf ("%16d File(s)", FileCount); - fprint_val (stdout, (t_value) TotalSize, 10, 15, PV_RCOMMA); - printf (" bytes\n"); - printf ("%16d Dir(s)\n", DirCount); - if (sim_log) { - fprintf (sim_log, "%16d File(s)", FileCount); - fprint_val (sim_log, (t_value) TotalSize, 10, 15, PV_RCOMMA); - fprintf (sim_log, " bytes\n"); - fprintf (sim_log, "%16d Dir(s)\n", DirCount); - } + sim_printf ("%16d File(s)", FileCount); + sim_print_val ((t_value) TotalSize, 10, 15, PV_RCOMMA); + sim_printf (" bytes\n"); + sim_printf ("%16d Dir(s)\n", DirCount); FindClose (hFind); } else { - printf ("Can't list files for %s\n", cptr); - if (sim_log) - fprintf (sim_log, "Can't list files for %s\n", cptr); + sim_printf ("Can't list files for %s\n", cptr); return SCPE_ARG; } return SCPE_OK; @@ -4227,9 +4206,7 @@ if (dir) { #endif MatchName = 1 + strrchr (cptr, '/'); - printf (" Directory of %s\n\n", DirName[0] ? DirName : "/"); - if (sim_log) - fprintf (sim_log, " Directory of %s\n\n", DirName[0] ? DirName : "/"); + sim_printf (" Directory of %s\n\n", DirName[0] ? DirName : "/"); #if defined (HAVE_GLOB) for (i=0; itm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); - if (sim_log) - fprintf (sim_log, "%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); + sim_printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); if (filestat.st_mode & S_IFDIR) { ++DirCount; - printf (" "); - if (sim_log) - fprintf (sim_log, " "); + sim_printf (" "); } else { if (filestat.st_mode & S_IFREG) { ++FileCount; FileSize = sim_fsize_name_ex (FileName); - fprint_val (stdout, (t_value) FileSize, 10, 17, PV_RCOMMA); - if (sim_log) - fprint_val (sim_log, (t_value) FileSize, 10, 17, PV_RCOMMA); + sim_print_val ((t_value) FileSize, 10, 17, PV_RCOMMA); TotalSize += FileSize; } else { - printf ("%17s", ""); - if (sim_log) - fprintf (sim_log, "%17s", ""); + sim_printf ("%17s", ""); } } c = strrchr (FileName, '/'); - printf (" %s\n", c ? c + 1 : FileName); - if (sim_log) - fprintf (sim_log, " %s\n", c ? c + 1 : FileName); + sim_printf (" %s\n", c ? c + 1 : FileName); } if (FileCount) { - printf ("%16d File(s)", FileCount); - fprint_val (stdout, (t_value) TotalSize, 10, 15, PV_RCOMMA); - printf (" bytes\n"); - printf ("%16d Dir(s)\n", DirCount); - if (sim_log) { - fprintf (sim_log, "%16d File(s)", FileCount); - fprint_val (sim_log, (t_value) TotalSize, 10, 15, PV_RCOMMA); - fprintf (sim_log, " bytes\n"); - fprintf (sim_log, "%16d Dir(s)\n", DirCount); - } + sim_printf ("%16d File(s)", FileCount); + sim_print_val ((t_value) TotalSize, 10, 15, PV_RCOMMA); + sim_printf (" bytes\n"); + sim_printf ("%16d Dir(s)\n", DirCount); } else { - printf ("File Not Found\n"); - if (sim_log) - fprintf (sim_log, "File Not Found\n"); + sim_printf ("File Not Found\n"); } #if defined (HAVE_GLOB) globfree (&paths); @@ -4296,9 +4255,7 @@ if (dir) { #endif } else { - printf ("Can't list files for %s\n", cptr); - if (sim_log) - fprintf (sim_log, "Can't list files for %s\n", cptr); + sim_printf ("Can't list files for %s\n", cptr); return SCPE_ARG; } return SCPE_OK; @@ -4569,9 +4526,7 @@ if (sim_switches & SWMASK ('R')) { /* read only? */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ if (!sim_quiet) { - printf ("%s: unit is read only\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: unit is read only\n", sim_dname (dptr)); + sim_printf ("%s: unit is read only\n", sim_dname (dptr)); } } else { @@ -4580,9 +4535,7 @@ else { if (uptr->fileref == NULL) /* open fail? */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */ if (!sim_quiet) { - printf ("%s: creating new file\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: creating new file\n", sim_dname (dptr)); + sim_printf ("%s: creating new file\n", sim_dname (dptr)); } } else { /* normal */ @@ -4600,9 +4553,7 @@ else { return attach_err (uptr, SCPE_OPENERR); /* yes, error */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ if (!sim_quiet) { - printf ("%s: unit is read only\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: unit is read only\n", sim_dname (dptr)); + sim_printf ("%s: unit is read only\n", sim_dname (dptr)); } } else { /* doesn't exist */ @@ -4612,9 +4563,7 @@ else { if (uptr->fileref == NULL) /* open fail? */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */ if (!sim_quiet) { - printf ("%s: creating new file\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: creating new file\n", sim_dname (dptr)); + sim_printf ("%s: creating new file\n", sim_dname (dptr)); } } } /* end if null */ @@ -4627,9 +4576,7 @@ if (uptr->flags & UNIT_BUFABLE) { /* buffer? */ if (uptr->filebuf == NULL) /* no buffer? */ return attach_err (uptr, SCPE_MEM); /* error */ if (!sim_quiet) { - printf ("%s: buffering file in memory\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: buffering file in memory\n", sim_dname (dptr)); + sim_printf ("%s: buffering file in memory\n", sim_dname (dptr)); } uptr->hwmark = (uint32)sim_fread (uptr->filebuf, /* read file */ SZ_D (dptr), cap, uptr->fileref); @@ -4745,9 +4692,7 @@ if (uptr->flags & UNIT_BUF) { uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr; if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { if (!sim_quiet) { - printf ("%s: writing buffer to file\n", sim_dname (dptr)); - if (sim_log) - fprintf (sim_log, "%s: writing buffer to file\n", sim_dname (dptr)); + sim_printf ("%s: writing buffer to file\n", sim_dname (dptr)); } rewind (uptr->fileref); sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref); @@ -5043,31 +4988,23 @@ if (strcmp (buf, save_vercur) == 0) /* version 3.5? */ else if (strcmp (buf, save_ver32) == 0) /* version 3.2? */ v32 = TRUE; else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */ - printf ("Invalid file version: %s\n", buf); - if (sim_log) - fprintf (sim_log, "Invalid file version: %s\n", buf); + sim_printf ("Invalid file version: %s\n", buf); return SCPE_INCOMP; } READ_S (buf); /* read sim name */ if (strcmp (buf, sim_name)) { /* name match? */ - printf ("Wrong system type: %s\n", buf); - if (sim_log) - fprintf (sim_log, "Wrong system type: %s\n", buf); + sim_printf ("Wrong system type: %s\n", buf); return SCPE_INCOMP; } if (v35) { /* [V3.5+] options */ READ_S (buf); /* integer size */ if (strcmp (buf, sim_si64) != 0) { - printf ("Incompatible integer size, save file = %s\n", buf); - if (sim_log) - fprintf (sim_log, "Incompatible integer size, save file = %s\n", buf); + sim_printf ("Incompatible integer size, save file = %s\n", buf); return SCPE_INCOMP; } READ_S (buf); /* address size */ if (strcmp (buf, sim_sa64) != 0) { - printf ("Incompatible address size, save file = %s\n", buf); - if (sim_log) - fprintf (sim_log, "Incompatible address size, save file = %s\n", buf); + sim_printf ("Incompatible address size, save file = %s\n", buf); return SCPE_INCOMP; } READ_S (buf); /* Ethernet */ @@ -5084,9 +5021,7 @@ for ( ;; ) { /* device loop */ if (buf[0] == 0) /* last? */ break; if ((dptr = find_dev (buf)) == NULL) { /* locate device */ - printf ("Invalid device name: %s\n", buf); - if (sim_log) - fprintf (sim_log, "Invalid device name: %s\n", buf); + sim_printf ("Invalid device name: %s\n", buf); return SCPE_INCOMP; } READ_S (buf); /* [V3.0+] logical name */ @@ -5106,9 +5041,7 @@ for ( ;; ) { /* device loop */ if (unitno < 0) /* end units? */ break; if ((uint32) unitno >= dptr->numunits) { /* too big? */ - printf ("Invalid unit number: %s%d\n", sim_dname (dptr), unitno); - if (sim_log) - fprintf (sim_log, "Invalid unit number: %s%d\n", sim_dname (dptr), unitno); + sim_printf ("Invalid unit number: %s%d\n", sim_dname (dptr), unitno); return SCPE_INCOMP; } READ_I (time); /* event time */ @@ -5157,9 +5090,7 @@ for ( ;; ) { /* device loop */ if (high > 0) { /* [V2.5+] any memory? */ if (((uptr->flags & (UNIT_FIX + UNIT_ATTABLE)) != UNIT_FIX) || (dptr->deposit == NULL)) { - printf ("Can't restore memory: %s%d\n", sim_dname (dptr), unitno); - if (sim_log) - fprintf (sim_log, "Can't restore memory: %s%d\n", sim_dname (dptr), unitno); + sim_printf ("Can't restore memory: %s%d\n", sim_dname (dptr), unitno); return SCPE_INCOMP; } if (high != old_capac) { /* size change? */ @@ -5167,11 +5098,8 @@ for ( ;; ) { /* device loop */ if ((dptr->flags & DEV_DYNM) && ((dptr->msize == NULL) || (dptr->msize (uptr, (int32) high, NULL, NULL) != SCPE_OK))) { - printf ("Can't change memory size: %s%d\n", - sim_dname (dptr), unitno); - if (sim_log) - fprintf (sim_log, "Can't change memory size: %s%d\n", - sim_dname (dptr), unitno); + sim_printf ("Can't change memory size: %s%d\n", + sim_dname (dptr), unitno); return SCPE_INCOMP; } uptr->capac = high; /* new memory size */ @@ -5219,28 +5147,21 @@ for ( ;; ) { /* device loop */ break; READ_I (depth); /* [V2.10+] depth */ if ((rptr = find_reg (buf, NULL, dptr)) == NULL) { - printf ("Invalid register name: %s %s\n", sim_dname (dptr), buf); - if (sim_log) - fprintf (sim_log, "Invalid register name: %s %s\n", sim_dname (dptr), buf); + sim_printf ("Invalid register name: %s %s\n", sim_dname (dptr), buf); for (us = 0; us < depth; us++) { /* skip values */ READ_I (val); } continue; } if (depth != rptr->depth) { /* [V2.10+] mismatch? */ - printf ("Register depth mismatch: %s %s, file = %d, sim = %d\n", - sim_dname (dptr), buf, depth, rptr->depth); - if (sim_log) - fprintf (sim_log, "Register depth mismatch: %s %s, file = %d, sim = %d\n", - sim_dname (dptr), buf, depth, rptr->depth); + sim_printf ("Register depth mismatch: %s %s, file = %d, sim = %d\n", + sim_dname (dptr), buf, depth, rptr->depth); } mask = width_mask[rptr->width]; /* get mask */ for (us = 0; us < depth; us++) { /* loop thru values */ READ_I (val); /* read value */ if (val > mask) { /* value ok? */ - printf ("Invalid register value: %s %s\n", sim_dname (dptr), buf); - if (sim_log) - fprintf (sim_log, "Invalid register value: %s %s\n", sim_dname (dptr), buf); + sim_printf ("Invalid register value: %s %s\n", sim_dname (dptr), buf); } else if (us < rptr->depth) /* in range? */ put_rval (rptr, us, val); @@ -5260,23 +5181,16 @@ for (j=0, r = SCPE_OK; j rstat.st_mtime + 30) { r = SCPE_INCOMP; - printf ("Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime)); - printf ("restore with the -F switch to override this sanity check\n"); - if (sim_log) { - fprintf (sim_log, "Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime)); - fprintf (sim_log, "restore with the -F switch to override this sanity check\n"); - } + sim_printf ("Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime)); + sim_printf ("restore with the -F switch to override this sanity check\n"); continue; } saved_pos = attunits[j]->pos; sim_switches = attswitches[j]; r = scp_attach_unit (dptr, attunits[j], attnames[j]);/* reattach unit */ attunits[j]->pos = saved_pos; - if (r != SCPE_OK) { - printf ("Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]); - if (sim_log) - fprintf (sim_log, "Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]); - } + if (r != SCPE_OK) + sim_printf ("Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]); } free (attnames[j]); } @@ -5463,6 +5377,8 @@ if (unechoed_cmdline) { fprint_stopped (stdout, r); /* print msg */ if (sim_log) /* log if enabled */ fprint_stopped (sim_log, r); +if (sim_deb) /* log if enabled */ + fprint_stopped (sim_deb, r); } /* Common setup for RUN or BOOT */ @@ -7074,6 +6990,25 @@ if (fputs (dbuf, stream) == EOF) return SCPE_OK; } +t_stat sim_print_val (t_value val, uint32 radix, + uint32 width, uint32 format) +{ +char dbuf[MAX_WIDTH + 1]; + +if (width > MAX_WIDTH) + width = MAX_WIDTH; +sprint_val (dbuf, val, radix, width, format); +if (fputs (dbuf, stdout) == EOF) + return SCPE_IOERR; +if (sim_log && (sim_log != stdout)) + if (fputs (dbuf, sim_log) == EOF) + return SCPE_IOERR; +if (sim_deb && (sim_deb != stdout)) + if (fputs (dbuf, sim_deb) == EOF) + return SCPE_IOERR; +return SCPE_OK; +} + /* Event queue package sim_activate add entry to event queue @@ -7892,6 +7827,65 @@ if (sim_deb && (dptr->dctrl & dbits)) { } } +/* Print message to stdout, sim_log (if enabled) and sim_deb (if enabled) */ +void sim_printf (const char* fmt, ...) +{ +char stackbuf[STACKBUFSIZE]; +int32 bufsize = sizeof(stackbuf); +char *buf = stackbuf; +int32 len; +va_list arglist; + +while (1) { /* format passed string, args */ + va_start (arglist, fmt); +#if defined(NO_vsnprintf) +#if defined(HAS_vsprintf_void) + +/* Note, this could blow beyond the buffer, and we couldn't tell */ +/* That is a limitation of the C runtime library available on this platform */ + + vsprintf (buf, fmt, arglist); + for (len = 0; len < bufsize-1; len++) + if (buf[len] == 0) break; +#else + len = vsprintf (buf, fmt, arglist); +#endif /* HAS_vsprintf_void */ +#else /* NO_vsnprintf */ +#if defined(HAS_vsnprintf_void) + vsnprintf (buf, bufsize-1, fmt, arglist); + for (len = 0; len < bufsize-1; len++) + if (buf[len] == 0) break; +#else + len = vsnprintf (buf, bufsize-1, fmt, arglist); +#endif /* HAS_vsnprintf_void */ +#endif /* NO_vsnprintf */ + va_end (arglist); + +/* If the formatted result didn't fit into the buffer, then grow the buffer and try again */ + + if ((len < 0) || (len >= bufsize-1)) { + if (buf != stackbuf) + free (buf); + bufsize = bufsize * 2; + buf = (char *) malloc (bufsize); + if (buf == NULL) /* out of memory */ + return; + buf[bufsize-1] = '\0'; + continue; + } + break; + } + +printf("%s", buf); +if (sim_log && (sim_log != stdout)) + fprintf (sim_log, "%s", buf); +if (sim_deb && (sim_deb != stdout)) + fprintf (sim_deb, "%s", buf); + +if (buf != stackbuf) + free (buf); +} + /* Inline debugging - will print debug message if debug file is set and the bitmask matches the current device debug options. Extra returns are added for un*x systems, since the output diff --git a/scp.h b/scp.h index fbd28c4b..3bb6e473 100644 --- a/scp.h +++ b/scp.h @@ -118,6 +118,7 @@ char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi, uint32 rdx, t_addr max, char term); t_value strtotv (const char *cptr, char **endptr, uint32 radix); t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt); +t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format); char *read_line (char *cptr, int32 size, FILE *stream); void fprint_reg_help (FILE *st, DEVICE *dptr); void fprint_set_help (FILE *st, DEVICE *dptr); @@ -142,6 +143,7 @@ t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cpt const char *sim_error_text (t_stat stat); t_stat sim_string_to_stat (char *cptr, t_stat *cond); t_stat sim_cancel_step (void); +void sim_printf (const char* fmt, ...); void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs, uint32 before, uint32 after, int terminate); #if defined (__DECC) && defined (__VMS) && (defined (__VAX) || (__DECC_VER < 60590001)) diff --git a/sim_disk.c b/sim_disk.c index c680ef62..9d5fd4e4 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -444,8 +444,7 @@ t_stat sim_disk_set_async (UNIT *uptr, int latency) { #if !defined(SIM_ASYNCH_IO) char *msg = "Disk: can't operate asynchronously\r\n"; -printf ("%s", msg); -if (sim_log) fprintf (sim_log, "%s", msg); +sim_printf ("%s", msg); return SCPE_NOFNC; #else struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; @@ -877,17 +876,13 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop return r; } if (!sim_quiet) { - printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); - if (sim_log) - fprintf (sim_log, "%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); + sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); } capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */ vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1)); if (!vhd) { if (!sim_quiet) { - printf ("%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); - if (sim_log) - fprintf (sim_log, "%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); + sim_printf ("%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); } return SCPE_OPENERR; } @@ -904,11 +899,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop return SCPE_MEM; } for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) { - if (!sim_quiet) { - printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); - if (sim_log) - fprintf (sim_log, "%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); - } + if (!sim_quiet) + sim_printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); sects = sectors_per_buffer; if (lba + sects > total_sectors) sects = total_sectors - lba; @@ -925,16 +917,10 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop } } if (!sim_quiet) { - if (r == SCPE_OK) { - printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); - if (sim_log) - fprintf (sim_log, "\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); - } - else { - printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r)); - if (sim_log) - fprintf (sim_log, "\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r)); - } + if (r == SCPE_OK) + sim_printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); + else + sim_printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r)); } if ((r == SCPE_OK) && (sim_switches & SWMASK ('V'))) { uint8 *verify_buf = (uint8*) malloc (1024*1024); @@ -946,11 +932,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop return SCPE_MEM; } for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) { - if (!sim_quiet) { - printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); - if (sim_log) - fprintf (sim_log, "%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); - } + if (!sim_quiet) + sim_printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); sects = sectors_per_buffer; if (lba + sects > total_sectors) sects = total_sectors - lba; @@ -971,11 +954,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop } } if (!sim_quiet) { - if (r == SCPE_OK) { - printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); - if (sim_log) - fprintf (sim_log, "\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); - } + if (r == SCPE_OK) + sim_printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); else { t_lba i; uint32 save_dctrl = dptr->dctrl; @@ -984,9 +964,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop for (i = 0; i < (1024*1024/sector_size); ++i) if (0 != memcmp (copy_buf+i*sector_size, verify_buf+i*sector_size, sector_size)) break; - printf ("\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i); - if (sim_log) - fprintf (sim_log, "\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i); + sim_printf ("\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i); dptr->dctrl = 0xFFFFFFFF; sim_deb = stdout; sim_disk_data_trace (uptr, copy_buf+i*sector_size, lba+i, sector_size, "Expected", TRUE, 1); @@ -1076,9 +1054,7 @@ if (sim_switches & SWMASK ('R')) { /* read only? */ return _err_return (uptr, SCPE_OPENERR); /* yes, error */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ if (!sim_quiet) { - printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); - if (sim_log) - fprintf (sim_log, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); + sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); } } else { /* normal */ @@ -1092,7 +1068,7 @@ else { /* normal */ return _err_return (uptr, SCPE_OPENERR);/* yes, error */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ if (!sim_quiet) - printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); + sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); } else { /* doesn't exist */ if (sim_switches & SWMASK ('E')) /* must exist? */ @@ -1104,7 +1080,7 @@ else { /* normal */ if (uptr->fileref == NULL) /* open fail? */ return _err_return (uptr, SCPE_OPENERR);/* yes, error */ if (!sim_quiet) - printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units)); + sim_printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units)); created = TRUE; } } /* end if null */ @@ -1162,18 +1138,11 @@ if (capac && (capac != (t_offset)-1)) { if (dontautosize) { if ((capac < (((t_offset)uptr->capac)*ctx->capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1))) && (DKUF_F_STD != DK_GET_FMT (uptr))) { if (!sim_quiet) { - printf ("%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr); - fprint_val (stdout, (t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT); - printf ("%s < ", (ctx->capac_factor == 2) ? "W" : ""); - fprint_val (stdout, uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT); - printf ("%s)\n", (ctx->capac_factor == 2) ? "W" : ""); - if (sim_log) { - fprintf (sim_log, "%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr); - fprint_val (sim_log, (t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT); - fprintf (sim_log, "%s < ", (ctx->capac_factor == 2) ? "W" : ""); - fprint_val (sim_log, uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT); - fprintf (sim_log, "%s)\n", (ctx->capac_factor == 2) ? "W" : ""); - } + sim_printf ("%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr); + sim_print_val ((t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT); + sim_printf ("%s < ", (ctx->capac_factor == 2) ? "W" : ""); + sim_print_val (uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT); + sim_printf ("%s)\n", (ctx->capac_factor == 2) ? "W" : ""); } } } @@ -2815,7 +2784,7 @@ if ((sDynamic) && } if (!*szParentVHDPath) { Return = EINVAL; /* File Corrupt */ - fprintf (stderr, "Error Invalid Parent VHD for Differencing VHD\n"); + sim_printf ("Error Invalid Parent VHD for Differencing VHD\n"); } } } @@ -3024,7 +2993,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD) ++BlocksToMerge; } if (!sim_quiet) - printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath); + sim_printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath); for (BlockNumber=NeededBlock=0; BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries); ++BlockNumber) { uint32 BlockSectors = SectorsPerBlock; @@ -3048,7 +3017,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD) SectorsPerBlock*BlockNumber)) break; if (!sim_quiet) - printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge)); + sim_printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge)); hVHD->BAT[BlockNumber] = VHD_BAT_FREE_ENTRY; } if (BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries)) { @@ -3057,7 +3026,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD) else { Status = 0; if (!sim_quiet) - printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000)); + sim_printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000)); fclose (hVHD->File); hVHD->File = NULL; remove (szVHDPath); diff --git a/sim_ether.c b/sim_ether.c index e62c3051..2cd6b1d8 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -735,8 +735,7 @@ t_stat ethq_init(ETH_QUE* que, int max) if (!que->item) { /* failed to allocate memory */ char* msg = "EthQ: failed to allocate dynamic queue[%d]\r\n"; - printf(msg, max); - if (sim_log) fprintf(sim_log, msg, max); + sim_printf(msg, max); return SCPE_MEM; }; que->max = max; @@ -1005,8 +1004,7 @@ static void load_function(char* function, _func* func_ptr) { if (*func_ptr == 0) { char* msg = "Eth: Failed to find function '%s' in %s\r\n"; - printf (msg, function, lib_name); - if (sim_log) fprintf (sim_log, msg, function, lib_name); + sim_printf (msg, function, lib_name); lib_loaded = 3; } } @@ -1031,12 +1029,8 @@ int load_pcap(void) { "Eth: You must install libpcap to use networking\r\n"; #endif - printf (msg, lib_name); - printf ("%s", msg2); - if (sim_log) { - fprintf (sim_log, msg, lib_name); - fprintf (sim_log, "%s", msg2); - } + sim_printf (msg, lib_name); + sim_printf ("%s", msg2); lib_loaded = 2; break; } else { @@ -1071,10 +1065,7 @@ int load_pcap(void) { if (lib_loaded == 1) { /* log successful load */ - char* version = p_pcap_lib_version(); - printf("%s\n", version); - if (sim_log) - fprintf(sim_log, "%s\n", version); + sim_printf("%s\n", p_pcap_lib_version()); } break; default: /* loaded or failed */ @@ -1693,8 +1684,7 @@ t_stat eth_set_async (ETH_DEV *dev, int latency) { #if !defined(USE_READER_THREAD) || !defined(SIM_ASYNCH_IO) char *msg = "Eth: can't operate asynchronously, must poll\r\n"; -printf ("%s", msg); -if (sim_log) fprintf (sim_log, "%s", msg); +sim_printf ("%s", msg); return SCPE_NOFNC; #else int wakeup_needed; @@ -1772,8 +1762,7 @@ if (0 == strncmp("tap:", savname, 4)) { #if defined(HAVE_TAP_NETWORK) if (!strcmp(savname, "tap:tapN")) { msg = "Eth: Must specify actual tap device name (i.e. tap:tap0)\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } #endif @@ -1858,8 +1847,7 @@ else memset(&voa, 0, sizeof(voa)); if (!strcmp(savname, "vde:vdedevice")) { msg = "Eth: Must specify actual vde device name (i.e. vde:/tmp/switch)\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } if (!(dev->handle = (void*) vde_open(savname+4, "simh", &voa))) @@ -1879,8 +1867,7 @@ else if (!strcmp(savname, "udp:sourceport:remotehost:remoteport")) { msg = "Eth: Must specify actual udp host and ports(i.e. udp:1224:somehost.com:2234)\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } @@ -1893,8 +1880,7 @@ else if ((SCPE_OK == sim_parse_addr (hostport, NULL, 0, NULL, NULL, 0, NULL, "localhost")) && (0 == strcmp (localport, port))) { msg = "Eth: Must specify different udp localhost ports\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } dev->fd_handle = sim_connect_sock_ex (localport, hostport, NULL, NULL, TRUE, FALSE); @@ -1908,8 +1894,7 @@ else dev->handle = (void*) pcap_open_live(savname, bufsz, ETH_PROMISC, PCAP_READ_TIMEOUT, errbuf); if (!dev->handle) { /* can't open device */ msg = "Eth: pcap_open_live error - %s\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } dev->eth_api = ETH_API_PCAP; @@ -1920,13 +1905,11 @@ else } if (errbuf[0]) { msg = "Eth: open error - %s\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); return SCPE_OPENERR; } msg = "Eth: opened OS device %s\r\n"; -printf (msg, savname); -if (sim_log) fprintf (sim_log, msg, savname); +sim_printf (msg, savname); /* get the NIC's hardware MAC address */ eth_get_nic_hw_addr(dev, savname); @@ -1982,8 +1965,7 @@ if (1) { /* set ethernet device non-blocking so pcap_dispatch() doesn't hang */ if ((dev->eth_api == ETH_API_PCAP) && (pcap_setnonblock (dev->handle, 1, errbuf) == -1)) { msg = "Eth: Failed to set non-blocking: %s\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); } #endif #endif /* !defined (USE_READER_THREAD */ @@ -2065,8 +2047,7 @@ switch (dev->eth_api) { break; #endif } -printf (msg, dev->name); -if (sim_log) fprintf (sim_log, msg, dev->name); +sim_printf (msg, dev->name); /* clean up the mess */ free(dev->name); @@ -2183,8 +2164,7 @@ if (status != SCPE_OK) { "which is at least 0.9 from your OS vendor or www.tcpdump.org\r\n" : "Eth: Error Transmitting packet: %s\r\n" "You may need to run as root.\r\n"; - printf(msg, strerror(errno)); - if (sim_log) fprintf (sim_log, msg, strerror(errno)); + sim_printf(msg, strerror(errno)); return status; } @@ -3216,22 +3196,17 @@ if (dev->eth_api == ETH_API_PCAP) { if ((status = pcap_compile(dev->handle, &bpf, buf, 1, bpf_netmask)) < 0) { sprintf(errbuf, "%s", pcap_geterr(dev->handle)); msg = "Eth: pcap_compile error: %s\r\n"; - printf(msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); - sim_debug(dev->dbit, dev->dptr, "Eth: pcap_compile error: %s\n", errbuf); + sim_printf(msg, errbuf); /* show erroneous BPF string */ msg = "Eth: BPF string is: |%s|\r\n"; - printf (msg, buf); - if (sim_log) fprintf (sim_log, msg, buf); + sim_printf (msg, buf); } else { /* apply compiled filter string */ if ((status = pcap_setfilter(dev->handle, &bpf)) < 0) { sprintf(errbuf, "%s", pcap_geterr(dev->handle)); msg = "Eth: pcap_setfilter error: %s\r\n"; - printf(msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); - sim_debug(dev->dbit, dev->dptr, "Eth: pcap_setfilter error: %s\n", errbuf); + sim_printf(msg, errbuf); } else { #ifdef USE_SETNONBLOCK @@ -3382,8 +3357,7 @@ errbuf[0] = '\0'; /* retrieve the device list */ if (pcap_findalldevs(&alldevs, errbuf) == -1) { char* msg = "Eth: error in pcap_findalldevs: %s\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); } else { /* copy device list into the passed structure */ @@ -3407,8 +3381,7 @@ i = eth_host_devices(i, max, list); /* If no devices were found and an error message was left in the buffer, display it */ if ((i == 0) && (errbuf[0])) { char* msg = "Eth: pcap_findalldevs warning: %s\r\n"; - printf (msg, errbuf); - if (sim_log) fprintf (sim_log, msg, errbuf); + sim_printf (msg, errbuf); } /* return device count */ diff --git a/sim_serial.c b/sim_serial.c index c7af62f5..703b171b 100644 --- a/sim_serial.c +++ b/sim_serial.c @@ -215,9 +215,7 @@ for (i=0; itape_ctx; diff --git a/sim_timer.c b/sim_timer.c index 4663c509..d79929a0 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -118,12 +118,14 @@ UNIT sim_throt_unit = { UDATA (&sim_throt_svc, 0, 0) }; #define DBG_TRC 0x004 /* tracing */ #define DBG_CAL 0x008 /* calibration activities */ #define DBG_TIM 0x010 /* timer thread activities */ +#define DBG_THR 0x020 /* throttle activities */ DEBTAB sim_timer_debug[] = { {"TRACE", DBG_TRC}, {"IDLE", DBG_IDL}, {"QUEUE", DBG_QUE}, {"CALIB", DBG_CAL}, {"TIME", DBG_TIM}, + {"THROT", DBG_THR}, {0} }; @@ -907,15 +909,11 @@ t_stat r; uint32 v; if (sim_idle_rate_ms == 0) { - printf ("Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); - if (sim_log) - fprintf (sim_log, "Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); + sim_printf ("Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); return SCPE_NOFNC; } if ((val != 0) && (sim_idle_rate_ms > (uint32) val)) { - printf ("Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val); - if (sim_log) - fprintf (sim_log, "Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val); + sim_printf ("Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val); return SCPE_NOFNC; } if (cptr) { @@ -927,9 +925,7 @@ if (cptr) { sim_idle_enab = TRUE; if (sim_throt_type != SIM_THROT_NONE) { sim_set_throt (0, NULL); - printf ("Throttling disabled\n"); - if (sim_log) - fprintf (sim_log, "Throttling disabled\n"); + sim_printf ("Throttling disabled\n"); } return SCPE_OK; } @@ -969,9 +965,7 @@ if (arg == 0) { sim_throt_cancel (); } else if (sim_idle_rate_ms == 0) { - printf ("Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); - if (sim_log) - fprintf (sim_log, "Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); + sim_printf ("Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); return SCPE_NOFNC; } else { @@ -995,9 +989,7 @@ else { } else return SCPE_ARG; if (sim_idle_enab) { - printf ("Idling disabled\n"); - if (sim_log) - fprintf (sim_log, "Idling disabled\n"); + sim_printf ("Idling disabled\n"); sim_clr_idle (NULL, 0, NULL, NULL); } sim_throt_val = (uint32) val; @@ -1121,8 +1113,8 @@ switch (sim_throt_state) { } sim_throt_ms_start = sim_throt_ms_stop; sim_throt_state = 2; -// fprintf (stderr, "Throttle values a_cps = %f, d_cps = %f, wait = %d\n", -// a_cps, d_cps, sim_throt_wait); + sim_debug (DBG_THR, &sim_timer_dev, "sim_throt_svc() Throttle values a_cps = %f, d_cps = %f, wait = %d\n", + a_cps, d_cps, sim_throt_wait); } break; diff --git a/sim_tmxr.c b/sim_tmxr.c index eb75e5ac..5319b754 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -2310,9 +2310,7 @@ while (*tptr) { free (mp->port); mp->port = NULL; } - printf ("Listening on port %s\n", listen); - if (sim_log) - fprintf (sim_log, "Listening on port %s\n", listen); + sim_printf ("Listening on port %s\n", listen); mp->port = (char *)realloc (mp->port, 1 + strlen (listen)); strcpy (mp->port, listen); /* save port */ mp->master = sock; /* save master socket */ @@ -2337,9 +2335,7 @@ while (*tptr) { if (loopback) { if (mp->lines > 1) return SCPE_ARG; /* ambiguous */ - printf ("Operating in loopback mode\n"); - if (sim_log) - fprintf (sim_log, "Operating in loopback mode\n"); + sim_printf ("Operating in loopback mode\n"); for (i = 0; i < mp->lines; i++) { lp = mp->ldsc + i; tmxr_set_line_loopback (lp, loopback); @@ -2452,9 +2448,7 @@ while (*tptr) { if (sock == INVALID_SOCKET) /* open error */ return SCPE_OPENERR; _mux_detach_line (lp, TRUE, FALSE); - printf ("Line %d Listening on port %s\n", line, listen); - if (sim_log) - fprintf (sim_log, "Line %d Listening on port %s\n", line, listen); + sim_printf ("Line %d Listening on port %s\n", line, listen); lp->port = (char *)realloc (lp->port, 1 + strlen (listen)); strcpy (lp->port, listen); /* save port */ lp->master = sock; /* save master socket */ @@ -2513,9 +2507,7 @@ while (*tptr) { } if (loopback) { tmxr_set_line_loopback (lp, loopback); - printf ("Line %d operating in loopback mode\n", line); - if (sim_log) - fprintf (sim_log, "Line %d operating in loopback mode\n", line); + sim_printf ("Line %d operating in loopback mode\n", line); } lp->modem_control = modem_control; r = SCPE_OK; @@ -2794,7 +2786,7 @@ while (sim_asynch_enabled) { wait_count = 0; if (select_errno == EINTR) break; - fprintf (stderr, "select() returned -1, errno=%d - %s\r\n", select_errno, strerror(select_errno)); + sim_printf ("select() returned -1, errno=%d - %s\r\n", select_errno, strerror(select_errno)); abort(); break; default: @@ -2915,7 +2907,7 @@ while (sim_asynch_enabled) { pthread_mutex_lock (&sim_tmxr_poll_lock); switch (status) { case WAIT_FAILED: - fprintf (stderr, "WaitForMultipleObjects() Failed, LastError=%d\r\n", GetLastError()); + sim_printf ("WaitForMultipleObjects() Failed, LastError=%d\r\n", GetLastError()); abort(); break; case WAIT_TIMEOUT: @@ -3030,7 +3022,7 @@ while (sim_asynch_enabled) { IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR | IO$M_TIMED | IO$M_TRMNOECHO, &iosb, 0, 0, buf, 1, 1, term, 0, 0); if (status != SS$_NORMAL) { - fprintf (stderr, "_tmxr_serial_line_poll() - QIO Failed, Status=%d\r\n", status); + sim_printf ("_tmxr_serial_line_poll() - QIO Failed, Status=%d\r\n", status); abort(); } wait_count = 0; diff --git a/sim_video.c b/sim_video.c index a4bbb8b9..b5210b82 100644 --- a/sim_video.c +++ b/sim_video.c @@ -1521,9 +1521,7 @@ SDL_Init (SDL_INIT_VIDEO); SDL_CreateWindowAndRenderer (vid_width, vid_height, SDL_WINDOW_SHOWN, &vid_window, &vid_renderer); if ((vid_window == NULL) || (vid_renderer == NULL)) { - printf ("%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError()); - if (sim_log) - fprintf (sim_log, "%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError()); + sim_printf ("%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError()); SDL_Quit (); return 0; } @@ -1537,9 +1535,7 @@ vid_texture = SDL_CreateTexture (vid_renderer, SDL_TEXTUREACCESS_STREAMING, vid_width, vid_height); if (!vid_texture) { - printf ("%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError()); - if (sim_log) - fprintf (sim_log, "%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError()); + sim_printf ("%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError()); SDL_DestroyRenderer(vid_renderer); vid_renderer = NULL; SDL_DestroyWindow(vid_window);