From d1d310b5fb04894d76f118f75d4ab9f8ff9ffb6d Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Mon, 16 Nov 2020 21:22:29 -0500 Subject: [PATCH] SCP: Update to current. --- scp.c | 37 ++++++++++++++++++++++++++++--------- sim_imd.c | 20 ++++++++------------ sim_imd.h | 9 ++------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/scp.c b/scp.c index ce0a825..78c7c14 100644 --- a/scp.c +++ b/scp.c @@ -708,7 +708,6 @@ static const char *sim_int_expect_description (DEVICE *dptr) return "Expect facility"; } -#define FLUSH_INTERVAL 30*1000000 /* Flush I/O buffers every 30 seconds */ static UNIT sim_expect_unit = { UDATA (&expect_svc, 0, 0) }; DEVICE sim_expect_dev = { "INT-EXPECT", &sim_expect_unit, NULL, NULL, @@ -720,12 +719,18 @@ DEVICE sim_expect_dev = { static const char *sim_int_flush_description (DEVICE *dptr) { -return "Flush facility"; +return "Open File Flush facility"; } +static uint32 sim_flush_interval = 30; /* Flush I/O buffers every 30 seconds */ +static REG sim_flush_reg[] = { + { DRDATAD(FLUSH_INTERVAL, sim_flush_interval, 32, "Periodic Buffer Flush Interval (seconds)") }, + { NULL} + }; + static UNIT sim_flush_unit = { UDATA (&flush_svc, UNIT_IDLE, 0) }; DEVICE sim_flush_dev = { - "INT-FLUSH", &sim_flush_unit, NULL, NULL, + "INT-FLUSH", &sim_flush_unit, sim_flush_reg, NULL, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DEV_NOSAVE, 0, @@ -2868,8 +2873,8 @@ if (cptr == NULL) { } else cptr2 = NULL; -if (cptr && sizeof (nbuf) > strlen (cptr) + strlen ("/simh.ini") + 1) { - sprintf(nbuf, "\"%s%s%ssimh.ini\"", cptr2 ? cptr2 : "", cptr, strchr (cptr, '/') ? "/" : "\\"); +if (cptr && (sizeof (nbuf) > strlen (cptr) + strlen ("/simh.ini") + 3)) { + snprintf(nbuf, sizeof (nbuf), "\"%s%s%ssimh.ini\"", cptr2 ? cptr2 : "", cptr, strchr (cptr, '/') ? "/" : "\\"); stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* simh.ini proc cmd file */ } if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR) @@ -8560,7 +8565,7 @@ tmxr_flush_log_files (); t_stat flush_svc (UNIT *uptr) { -sim_activate_after (uptr, FLUSH_INTERVAL); +sim_activate_after (uptr, sim_flush_interval * 1000000); sim_flush_buffered_files (); return SCPE_OK; } @@ -8757,7 +8762,7 @@ if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */ } if (sim_step) /* set step timer */ sim_sched_step (); -sim_activate_after (&sim_flush_unit, FLUSH_INTERVAL); /* Enable periodic buffer flushing */ +sim_activate_after (&sim_flush_unit, sim_flush_interval * 1000000);/* Enable periodic buffer flushing */ stop_cpu = FALSE; sim_is_running = TRUE; /* flag running */ fflush(stdout); /* flush stdout */ @@ -13258,16 +13263,30 @@ size_t debug_line_bufsize = 0; size_t debug_line_offset = 0; size_t debug_line_count = 0; +static void _debug_fwrite_all (const char *buf, size_t len, FILE *f) +{ +size_t len_written; + +while (len > 0) { + len_written = fwrite (buf, 1, len, f); + len -= len_written; + buf += len_written; + if (errno == EAGAIN) /* Non blocking file descriptor buffer full? */ + sim_os_ms_sleep(10);/* wait a bit to retry */ + errno = 0; + } +} + static void _debug_fwrite (const char *buf, size_t len) { size_t move_size; if (sim_deb_buffer == NULL) { - fwrite (buf, 1, len, sim_deb); /* output now. */ + _debug_fwrite_all (buf, len, sim_deb); /* output now. */ return; } if ((sim_deb == stdout) && (!sim_is_running)) - fwrite (buf, 1, len, stdout); /* output now. */ + _debug_fwrite_all (buf, len, stdout); /* output now. */ while (len > 0) { if (sim_debug_buffer_offset + len <= sim_deb_buffer_size) move_size = len; diff --git a/sim_imd.c b/sim_imd.c index fab8f6a..ded9c0a 100644 --- a/sim_imd.c +++ b/sim_imd.c @@ -1,9 +1,7 @@ /************************************************************************* * * - * $Id: sim_imd.c 1999 2008-07-22 04:25:28Z hharte $ * - * * - * Copyright (c) 2007-2008 Howard M. Harte. * - * http://www.hartetec.com * + * Copyright (c) 2007-2020 Howard M. Harte. * + * https://github.com/hharte * * * * Permission is hereby granted, free of charge, to any person obtaining * * a copy of this software and associated documentation files (the * @@ -36,9 +34,6 @@ * see: http://www.classiccmp.org/dunfield/img/index.htm * * for details on the ImageDisk format and other utilities. * * * - * Environment: * - * User mode only * - * * *************************************************************************/ /* Change log: @@ -240,7 +235,7 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose) /* Now read each sector */ for(i=0;idebugmask, myDisk->device, "Sector Phys: %d/Logical: %d: %d bytes: ", i, sectorMap[i], sectorSize); + sim_debug(myDisk->debugmask, myDisk->device, "Sector Phys: %2d/Logical: %2d: %4d bytes, offset: 0x%05x: ", i, sectorMap[i], sectorSize, (unsigned int)ftell(myDisk->file)); sectRecordType = fgetc(myDisk->file); /* AGN Logical head mapping */ myDisk->track[imd.cyl][imd.head].logicalHead[i] = sectorHeadMap[i]; @@ -279,7 +274,7 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose) if (1) { uint8 cdata = fgetc(myDisk->file); - sim_debug(myDisk->debugmask, myDisk->device, "Compressed Data = 0x%02x\n", cdata); + sim_debug(myDisk->debugmask, myDisk->device, "Compressed Data = 0x%02x", cdata); } } else { @@ -296,15 +291,16 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose) } myDisk->ntracks++; + } while (!feof(myDisk->file)); sim_debug(myDisk->debugmask, myDisk->device, "Processed %d sectors\n", TotalSectorCount); for(i=0;intracks;i++) { uint8 j; - sim_debug(myDisk->verbosedebugmask, myDisk->device, "Track %02d: ", i); - for(j=0;jverbosedebugmask, myDisk->device, "0x%06x ", myDisk->track[i][0].sectorOffsetMap[j]); + sim_debug(myDisk->verbosedebugmask, myDisk->device, "Track %3d: ", i); + for(j=0;jtrack[i >> 1][i & 1].nsects;j++) { + sim_debug(myDisk->verbosedebugmask, myDisk->device, "0x%05x ", myDisk->track[i >> 1][i & 1].sectorOffsetMap[j]); } sim_debug(myDisk->verbosedebugmask, myDisk->device, "\n"); } diff --git a/sim_imd.h b/sim_imd.h index 2c72972..a021547 100644 --- a/sim_imd.h +++ b/sim_imd.h @@ -1,9 +1,7 @@ /************************************************************************* * * - * $Id: sim_imd.h 1987 2008-07-08 03:25:57Z hharte $ * - * * - * Copyright (c) 2007-2008 Howard M. Harte. * - * http://www.hartetec.com * + * Copyright (c) 2007-2020 Howard M. Harte. * + * https://github.com/hharte * * * * Permission is hereby granted, free of charge, to any person obtaining * * a copy of this software and associated documentation files (the * @@ -36,9 +34,6 @@ * See: http://www.classiccmp.org/dunfield/img/index.htm * * for details on the ImageDisk format and other utilities. * * * - * Environment: * - * User mode only * - * * *************************************************************************/ #ifndef SIM_IMD_H_