Commit graph

68 commits

Author SHA1 Message Date
Mark Pizzolato
0daa80e03d SCP: Add support for library unit test routines 2018-08-26 18:15:30 -07:00
Mark Pizzolato
6070692581 SCP: Add unit to AIO_VALIDATE context message 2018-08-08 11:51:54 -07:00
Mark Pizzolato
28e4311039 SCP: Extended debugging to allow for unit specific debug for disk and tape 2018-04-07 21:38:26 -07:00
Mark Pizzolato
3d1f092573 SCP: Provide command context for messages emitted during ATTACH and DETACH
Context and non error messages will be suppressed in quiet mode or when -Q
switch is explicitly supplied on command line
2017-10-22 08:33:21 -07:00
Mark Pizzolato
c470d1e5e2 SCP: Allow the presence of DEVICE DEBTAB array to imply the DEV_DEBUG flag 2017-06-07 18:56:06 -07:00
Mark Pizzolato
8baac06f7f TAPE: Fix potential race (Coverity) 2017-06-03 08:56:51 -07:00
Mark Pizzolato
fae6a18835 TAPE: Update tape gap support (Dave Bryan)
With this update, the erase gap operation has been split out of
"sim_tape_wrgap" into a separate, internal "tape_erase_fwd" routine that
is called from "sim_tape_wrgap" as well as from the new "sim_tape_errecf"
routine.  There's a corresponding internal "tape_erase_rev" that's called
from the new "sim_tape_errecr" routine.

I've shimmed "sim_tape_rdlntf" and "sim_tape_rdlntr" to move the tape
context and debug stuff out of the routines that I'm maintaining.  This
will allow me to replace those functions in their entirety with the
corresponding functions in my development sources for future updates.
It also allows me to keep Bob's version in sync.  As my routines are static
and only called once from the shims, compilers should optimize away
the function calls and instead inline the code, so there'd be no extra call
overhead.

I'd also like to keep "tape_erase_fwd" and "tape_erase_rev" untouched for
the same reason.  If you wish to add debug calls to "sim_tape_errecf" and
"sim_tape_errecr", that's fine.
2017-06-02 00:54:13 -07:00
Mark Pizzolato
2d1b969cb7 TAPE: Stub extended gap behaviors to avoid link time errors. 2017-03-20 23:05:47 -07:00
Mark Pizzolato
5135f137ea TAPE: Fix Coverity potential NULL pointer dereference 2017-03-15 21:01:37 -07:00
Mark Pizzolato
872b2f238d TAPE: Fix potential NULL references (COVERITY) 2017-03-10 12:01:38 -08:00
Mark Pizzolato
7c2d20f26f SCP: Make sim_cancel more efficient by stopping search as soon as canceled 2016-12-24 09:49:32 -08:00
Mark Pizzolato
39d2944ede TIMER: Add support for catchup clock ticks and cleaned up asynchronous clocks
Asynchronous clocks are now built for all simulators which are built with
SIM_ASYNCH_IO defined.  The default behavior has asynchronous clocks
disabled since this is still experimental, but it can be enabled with
SET TIMER ASYNC.

Catchup clock ticks are now available, but since they're experimental,
they aren't enabled by default.  Catchup ticks are only available if the
simulators clock device calls sim_rtcn_tick_ack to acknowledge processing
of clock ticks.  The VAX simulators have been modified to leverage this.
Catchup clock ticks can be enabled with SET TIMER CATCHUP

Additionally, an idle threshold is provided which can be used to
influence when clock calibration may be suppressed.  The default is not
to suppress calibration activities.

The various timer behaviors are visible with the SHOW TIMER command.

The state of the operating timer facilities is visible with: SHOW CLOCK

Timer events which are queued are visible with the SHOW QUEUE command.
2016-11-16 23:50:53 -08:00
Mark Pizzolato
2acdf26c53 TAPE: Add support to allow tape debug output when using sim_tape_attach 2016-10-20 14:48:15 -07:00
Mark Pizzolato
17abb1223a TAPE: Make sure that all tape library APIs only work after sim_tape_attach
- Detects and fixes the problem reported in #345
2016-10-20 13:32:51 -07:00
Mark Pizzolato
a24aba69ae VIDEO: Added priority boost to thread performing SDL processing and updates
Reworked all priority adjustment code to leverage a new
sim_os_set_thread_priority API which is coded to use pthreads or OS
priority adjustment APIs as necessary.
2016-06-11 09:52:33 -07:00
Mark Pizzolato
89f8aff2cf TAPE: Fix potential compiler warning. 2016-05-16 20:04:10 -07:00
Mark Pizzolato
5531ccb175 ALL: Massive 'const' cleanup
These changes facilitate more robust parameter type checking and helps
to identify unexpected coding errors.

Most simulators can now also be compiled with a C++ compiler without
warnings.

Additionally, these changes have also been configured to facilitate easier
backporting of simulator and device simulation modules to run under the
simh v3.9+ SCP framework.
2016-05-15 15:25:33 -07:00
Mark Pizzolato
804b7d8883 TAPE: Fix EOF detection to properly initialize state. 2016-02-08 14:16:28 -08:00
Mark Pizzolato
434a367daf TAPE: Add tolerance when handling TPC formatted tapes which may have garbage at EOT.
If a TPC format tape image has garbage at the end of the image, but the
image contains multiple successive tape marks, then assume that logical
End Of Tape is immediately after the last successive tape marks.
2016-01-04 14:55:03 -08:00
Mark Pizzolato
d66b5a4671 TAPE: Generalize TPC format validation checks to accommodate existing tape images. Fixes #247 2015-11-27 13:52:36 -08:00
Mark Pizzolato
f60390ce89 Compiler suggested cleanup
Cast the results of unit pointer subtraction to int so it can be printed with a %d format specifier.
2015-11-25 05:21:55 -08:00
Mark Pizzolato
391c823e79 TAPE: Fix - Tape read reports "end of medium" even if a gap precedes it from Dave Bryan
OBSERVATION:  Calling "sim_tape_rdrecf" to read a tape record sometimes
     returns MTSE_EOM and sets the "position not updated" (PNU) flag, even when
     an erase gap precedes the EOM.  The correct response should be to return
     MTSE_RUNAWAY to indicate that spacing over a gap did not end with a data
     record or tape mark.  Moreover, PNU should not be set, as the position has
     been updated.

     CAUSE:  The routine attempts to handle this case by returning MTSE_RUNAWAY
     if the EOF was detected while reading a buffer of gap markers.  However, if
     a buffer read ends immediately before an EOM marker or the physical EOF,
     the next read attempt will return a zero buffer length.  The routine
     misinterprets this to mean that no gap was present and returns MTSE_EOM and
     sets the PNU flag.

     RESOLUTION:  Modify "sim_tape_rdlntf" (sim_tape.c) to determine whether the
     EOM marker or physical EOF was seen on the first or a subsequent buffer
     read, and to return MTSE_EOM with PNU or MTSE_RUNAWAY without PNU,
     respectively.
2015-11-25 05:16:13 -08:00
Mark Pizzolato
00a8b74b66 TAPE: Properly report a tape format error when a TPC format tape fails the record structure validation checks. 2015-11-22 21:52:42 -08:00
Mark Pizzolato
73d7aee71f SCP: Add printf style format argument validation for all functions which take printf arguments.
These include: sim_printf(), sim_messagef(), Fprint() and sim_debug().

Fix current use of these functions which had invalid arguments.
2015-10-09 04:12:25 -07:00
Mark Pizzolato
435ea69b20 DISK, TAPE: Make an -F switch specified on a disk/tape attach only change the device format until the unit is detached at which time the unit format will revert to the default format. Fix #219 2015-06-29 14:53:37 -07:00
Mark Pizzolato
e27e396c30 TAPES: Attempt to validate the record structure of TPC formatted tapes when they are attached.
Stubs to validate SIMH and E11 format tapes as well.
Once all validation routines are available, logic to auto detect tape format will be implemented.
2015-05-17 18:50:51 -07:00
Mark Pizzolato
41978eca80 All: Convert from C runtime library perror() to sim_perror so that all messages will arrive in the same place(s). 2015-04-03 19:56:37 -07:00
Mark Pizzolato
ef9d1adce1 PDP10, PDP11, VAX: const cleanup 2015-02-13 06:18:24 -08:00
Mark Pizzolato
813d8f6290 TAPE: Simplify range expression to avoid cast size reduction 2014-12-31 13:53:48 -08:00
Mark Pizzolato
afb5d6277d TAPE: Extensive cleanup of tape operations (gap, end of medium, format change, etc.) from Dave Bryan
256. ENHANCEMENT: Add tape runaway support to the simulator tape library.

     OBSERVATION:  The ANSI specifications for NRZI, PE, and GCR tape recording
     mandate a maximum length of 25 feet for erase gaps.  Currently, an erase
     gap of any length is ignored when reading or spacing.  To allow detection
     of non-compliant tape images, the simulator tape library is enhanced to
     halt positioning and return tape runaway status if a gap of 25 feet or more
     is encountered.

     Runaway detection is enabled by calling the tape library to set the tape
     density in bits per inch.  If this call is not made, erase gaps present in
     a tape image are effectively ignored.  Also, with the addition of a
     separate "set density" call, it is no longer necessary to supply the
     density when writing erase gaps.

     RESOLUTION:  Modify "sim_tape_rdlntf" and "sim_tape_rdlntr" (sim_tape.c) to
     detect tape runaway, and add a new MTSE_RUNAWAY status to sim_tape.h.  Add
     new "sim_tape_set_dens" and "sim_tape_show_dens" functions to set and show
     the bits per inch for a unit, respectively, and eliminate the "bpi"
     parameter to "sim_tape_wrgap" in preference to using the density
     established by a previous "sim_tape_set_dens" call.  Add named constants
     to "sim_tape.h" that specify the density.

257. ENHANCEMENT:  Improve performance when reading or spacing over erase gaps.

     OBSERVATION:  Performance when reading or spacing over erase gaps is poor,
     especially in the reverse direction.  Currently, each 4-byte gap marker is
     read individually, and in the reverse direction, each read is preceded by a
     seek to move the file pointer backward.  This combination causes stream
     cache invalidation and a physical disc access for each gap marker.  As a
     single gap consists of over 1000 markers, performance is far worse than if
     a gap was read as a block.

     RESOLUTION:  Modify "sim_tape_rdlntf" and "sim_tape_rdlntr" (sim_tape.c) to
     buffer reads of gap markers.  Using a 128-element buffer, performance
     improves about thirty-fold.

258. PROBLEM:  Writing an end-of-medium positions the tape image after the mark.

     OBSERVATION:  The "sim_tape_wreom" simulator tape library function writes
     an end-of-medium marker on the tape image.  The intent is to erase the
     remainder of the tape.  The "SIMH Magtape Representation and Handling"
     document states that the tape position is not updated by this function.
     However, the function leaves the tape positioned after the marker.

     A subsequent read would stop at the EOM marker.  However, writing a new
     marker over that one would then allow reading of the data following the EOM
     that supposedly had been erased by the original "sim_tape_wreom" call.

     CAUSE:  The tape position is updated by the internal "sim_tape_wrdata" call
     that is used to write the EOM marker, but it is not reset afterward by the
     function.

     RESOLUTION:  Modify "sim_tape_wreom" (sim_tape.c) to reset the tape
     position to point at the EOM marker before returning.  This prevents
     reading past an EOM marker, and a subsequent write will overwrite the
     marker rather than embed it between data records.

259. PROBLEM:  Reading through an erase gap in reverse may return EOM status.

     OBSERVATION:  A reverse read or spacing operation through an erase gap may
     return end-of-medium status.  Reading or spacing forward through the same
     gap works properly.

     CAUSE:  Writing an erase gap over existing records may produce a gap that
     is longer than requested.  This occurs when truncating the last record to
     be overlaid by the gap would leave a record that is shorter than the
     minimum size allowed (eight bytes for the length words plus two bytes for
     the data).  In this case, the gap is lengthened to overlay the entire
     record.  If the new gap size is not evenly divisible by four, a half-gap is
     metadata marker of value 0xFFFF added to the beginning of the gap.

     If a gap that begins with a half-gap marker is written immediately after
     a previous gap, the "seam" between gaps will contain the bytes FE FF FF FF
     ( FF FF ) FE FF FF FF....  Reading forward across this seam will yield a
     metadata value of 0xFFFEFFFF, which is recognized and handled by seeking
     two bytes back to resynchronize reading.  However, reading in reverse will
     yield the value 0xFFFFFFFF, which is interpreted as end-of-medium.

     RESOLUTION:  Modify "sim_tape_rdlntr" (sim_tape.c) to recognize 0xFFFFFFFF
     as a half-gap marker and resynchronize in response.  End of medium cannot
     occur when reading in reverse, as it is impossible to position the tape
     image beyond an EOM marker.  Therefore, any 0xFFFFFFFF value encountered
     must be a half-gap "seam" originating as above.

260. PROBLEM:  sim_tape_wrgap fails when format is changed from SIMH format.

     OBSERVATION:  The HP 2100 magnetic tape simulator supports erase gaps and
     calls sim_tape_wrgap when commanded to write a gap.  However, if a tape
     format other than SIMH format is selected, the call fails with MTSE_FMT.

     CAUSE:  Erase gaps are not supported in formats other than SIMH, but the
     call should not fail.  Instead, the call should be a "no-operation" if the
     underlying format does not support gaps.

     RESOLUTION:  Modify "sim_tape_wrgap" (sim_tape.c) to return MTSE_OK with no
     action performed if a tape format other than SIMH is selected.

261. PROBLEM:  The magnetic tape format of an attached unit may be changed.

     OBSERVATION:  The magnetic tape library supports several tape image
     formats.  The format to use may be specified either by an "ATTACH -F"
     command or by a "SET <unit> FORMAT" command.  The latter calls the
     "sim_tape_set_fmt" function, which allows the format of a file currently
     attached to be changed.  However, the format is an intrinsic property of
     the tape image file, so changing it once the file has been attached makes
     no sense.

     CAUSE:  Oversight.

     RESOLUTION:  Modify "sim_tape_set_fmt" (sim_tape.c) to return an error
     (SCPE_ALATT, "Unit already attached") if the unit is attached.
2014-12-22 05:48:13 -08:00
Mark Pizzolato
20637cc0df TAPE: Corrected debug output of tape position to be independent of the size of t_addr 2014-12-14 13:13:25 -08:00
Mark Pizzolato
f355749eb5 SCP: Provide a way to display an arbitrary buffer contents as hex in debug output 2014-09-17 09:08:12 -07:00
Mark Pizzolato
c0f9c2e86c PDP11, VAX: Better support for various positioning operations which different OS drivers use. Fix to properly record/tolerate skip n records reaching a tape mark. Fix to #139 2014-05-16 12:46:08 -07:00
Mark Pizzolato
fc2f3675fc TAPES: Make sure that all activities related to TPC formatted tapes are read only.
- A -R flag is forced (attach READ ONLY) when TPC formatted tapes are attached.  This should avoid updating file modified timestamps by any simh simulator.
- All write operations to TPC formatted tapes will fail with a write protected status.
2014-05-16 05:22:45 -07:00
Mark Pizzolato
6ce8d99cd8 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().
2014-03-28 08:20:05 -07:00
Mark Pizzolato
02cb5c2d88 Compiler suggested cleanups.
Mostly silencing noise warnings, but bugs were found in sim_console.c and pdp11_dmc.c
2014-02-14 17:07:45 -08:00
Mark Pizzolato
0605b6dff4 Added support for building on Solaris with the Sun C compiler 2013-03-17 16:50:57 -07:00
Mark Pizzolato
e6e6262f45 Fix ordering of thread activities while detaching disks and tapes 2013-01-22 20:59:49 -08:00
Mark Pizzolato
6eb3804620 Standardized scp command formatting in help output 2013-01-15 06:21:32 -08:00
Mark Pizzolato
784ae24324 - Fixed asynchronous i/o hangs introduced when asynchronous cancel support was added
- Added event debug support to scp and the vax simulator
- Moved external declarations into include files related to modules which define them and removed random externs from modules which referenced them
- Fixed typos in sim_ether
- Fixed sim_disk and sim_tape to properly manage asynchronous threads on an i/o flush
2013-01-09 17:02:58 -08:00
Mark Pizzolato
4f4cbd4157 Avoid asynch thread thrashing on disk and tape detach and enhance the disk and tape help 2013-01-09 11:11:04 -08:00
Mark Pizzolato
7e1840eb5f Fixed bugs in disk and tape operations when running without asynch disabled - bugs reported by Jordi Guillaumes i Pons 2013-01-07 09:25:57 -08:00
Mark Pizzolato
ba0f331fa5 Added framework to support per device help commands 2012-12-30 13:12:15 -08:00
Mark Pizzolato
50cf91d441 Merge branch 'SerialMux' and compiler suggested cleanup 2012-12-18 09:52:14 -08:00
Mark Pizzolato
0450a9b430 Compiler suggested cleanup 2012-12-15 07:56:42 -08:00
Mark Pizzolato
2b5ceae2be Added missing sim_cancel support for device simulation code using the sim_disk and sim_tape libraries and doing asynchronous I/O if asynchronous I/O is active 2012-12-12 10:58:19 -08:00
Mark Pizzolato
928b4a071f Fixed incorrect cleanup when closing tape with asynch I/O enabled 2012-05-02 07:18:35 -07:00
Mark Pizzolato
3775c17034 Fixed asynch disk/tape I/O reset behaviors to reliably synchronize with the I/O thread's startup 2012-04-29 05:55:46 -07:00
Mark Pizzolato
c4659a0903 Fixed issue where asynchronous I/O wouldn't be reliable after a device reset. 2012-04-28 08:37:20 -07:00
Mark Pizzolato
f77a38c3c5 Cleaned up a few compile complaints 2012-04-27 12:11:12 -07:00