;                         HP 21XX/1000 DIAGNOSTICS SUITE
;
; The HP Diagnostics Suite executes all of the diagnostics relevant to
; verification of proper SIMH operation.  It is run to confirm operation of the
; HP2100 simulator before a release.  Because some diagnostics are expected
; to give failures, comparison of the output log with a "known-good" log is
; performed to judge simulator compliance.
;
; Invocation:
;
;    hp2100 diag-suite [ <path-to-diagnostics> ]
;
; If <path-to-diagnostics> is null, the current directory is assumed.  The path
; must end with a backslash if it is specified and must not contain embedded
; spaces, even if it is quoted.
;
; The diagnostics are divided into those that will run on a 1000 and those that
; should or must run on a 2100, 2116, 2115, or 2114.  Most diagnostics, even
; those created before the 1000, will run on that machine, as they have no
; CPU-specific code.  Some, however, rely on features present in the earlier
; machines and absent in later ones (e.g., 2100 FFP) or test features of
; specific machines when running on those machines (e.g., 2116 DMA).  All that
; will run on the 1000 and have no CPU-specific features are executed first.
; Then diagnostics specific to the 21xx machines are run in turn.
;
; Most of the diagnostics are loaded from one of two HP 24396 magnetic tape
; images.  The remainder are loaded from individual paper tape images.  Most
; diagnostics cooperate with the diagnostic configurator, whose "loader"
; function is called to load the next diagnostic.  Exceptions are the 2607
; diagnostic, which overlays the configurator loader, and certain older
; diagnostics.  For these, the diagnostic configurator must be reloaded prior to
; each diagnostic.  The diagnostic configurator also must be reloaded when
; changing CPU types.
;
; Some diagnostics require the use of a "standard I/O card" to test I/O-related
; functions of the diagnostic target.  The 12566B Microcircuit Interface
; provides this function when the device is set into diagnostic mode with the
; SET MC DIAGNOSTIC command.  Diagnostic mode is specifically constructed to
; use the card jumper settings required by the various DMA diagnostics.
; 
; For responses generated by REPLY, a delay of 425,000 instructions is needed
; to ensure that the read is pending after the appropriate RUN UNTIL halt.
;
; NOTE: The diagnostic configurator does not operate correctly if it has been
; restarted on a 1000-M after having been run on a 1000-E.  It only works in the
; other direction, i.e., run on an E after running on an M.  This is because the
; TIMER instruction is inserted into memory for an E but not cleared for an M
; (a reload from tape is needed to clear it).
;
; NOTE: The configurator provides a one millisecond timer that is employed by
; many of the diagnostics.  For the 1000 E/F, the TIMER instruction is used.
; For the others, machine-specific timing loops are employed.  Because all
; instructions take the same amount of time under simulation, this timing
; feature is not accurate.  Diagnostics that time I/O operations may fail when
; run on different CPUs, unless the device simulation alters its event timing
; accordingly.


; Capture the suite execution console log.

set -n console log=DIAG-SUITE.log


; Report the simulator version and starting time.

echo
echo
echo Run started on %DATE_MMM% %DATE_DD%, %DATE_YYYY% at %TIME_HH%:%TIME_MM%:%TIME_SS%
echo
show version


;  *****************************
;  *                           *
;  *  Diagnostic Configurator  *
;  *                           *
;  *****************************

echo
echo
echo -------------------------------
echo Diagnostic Configurator Pretest
echo -------------------------------


; Establish the initial environment.
;
; Note that the tape drive select code must be <= 17 to work on a 2114; this is
; a limitation of the 12607B DMA controller.

set -F CPU 1000-M,32K
set MSC SC=16

if "%SIM_MAJOR%" != "3" set env reply=send


; Enable normally disabled I/O devices, so that the full complement is available.

echo
echo Configuring the simulation environment.

set LPS ENABLED
set MTC ENABLED
set IPL ENABLED
set MC1 ENABLED
set MC2 ENABLED


; Load the diagnostic configurator.

attach -E -R MSC0 %124396-13601_Rev-2326.abin.tape

echo
echo Loading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Run the diagnostic configurator pretest.

echo
echo Executing the diagnostic configurator pretest.
echo Expect halt 102077 for successful completion.

deposit P 000002
deposit S 000011
reset
go

assert T=102077


; Test the diagnostic configurator CPU detection.
;
; Memory location 115 octal indicates the computer type and options, as follows:
;
;   bit 15 = \               0001 = 2116A   0101 = 2114A     1001 = 1000-E
;   bit 14 =  \  computer    0010 = 2116B   0110 = 2114B
;   bit 13 =  /  type code   0011 = 2116C   0111 = 2100A/S
;   bit 12 = /               0100 = 2115A   1000 = 1000-M
;
;   bit 11 = \
;   bit 10 =  \  reserved
;   bit  9 =  /  bits
;   bit  8 = / 
;
;   bit  7 = Single-Channel DMA 
;   bit  6 = Floating Point
;   bit  5 = Memory Protect
;   bit  4 = Memory Parity Checking
;   bit  3 = Central Interrupt Register
;   bit  2 = DMA/DCPC
;   bit  1 = Extended Arithmetic Unit
;   bit  0 = Power Fail/Auto Restart

echo
echo
echo Testing CPU and option detection.


; Configure as a 2114B with DMA.

echo
echo
echo Configuring the CPU as a 2114 with DMA.

set -F CPU 2114,16K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=060214


; Configure as a 2115A with DMA.

echo
echo
echo Configuring the CPU as a 2115 with DMA.

set -f CPU 2115,8K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=040004


; Configure as a 2116 with DMA, MP, and EAU.

echo
echo
echo Configuring the CPU as a 2116 with DMA and MPRT.

set -f CPU 2116,32K,EAU

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=010044


; Configure as a 2100 with DMA, MP, and EAU.

echo
echo
echo Configuring the CPU as a 2100 with DMA and MPRT.

set CPU 2100,32K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=070077


; Configure as a 1000-M with DMA and MP.

echo
echo
echo Configuring the CPU as a 1000-M (21MX-M) with DMA and MPRT.

set CPU 1000-M,128K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=100177


; Configure as a 1000-E with DMA and MP.

echo
echo
echo Configuring the CPU as a 1000-E (21MX-E) with DMA and MPRT.

set CPU 1000-E,128K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=110177


; Configure as a 1000-F with DMA and MP.

echo
echo
echo Configuring the CPU as a 1000-F (21MX-F) with DMA and MPRT.

set CPU 1000-F,128K

deposit S 000011
reset
go 100 until "MEMORY\r\n"

deposit M 115
assert T=110177


; CPU and option detection complete.

echo
echo
echo Detection tests complete.




;  *******************************
;  *                             *
;  *  HP 1000 Diagnostics Suite  *
;  *                             *
;  *******************************

echo
echo
echo
echo
echo -------------------------
echo HP 1000 Diagnostics Suite
echo -------------------------


; Establish the base CPU for the diagnostics.

echo
echo Configuring the CPU as a 1000-E with 128K.

set CPU 1000-E,128K


; Establish the standard break time for diagnostic responses.

if "%SIM_MAJOR%" == "3" break after=425000
if "%SIM_MAJOR%" != "3" expect haltafter=425000


; Prepare for automatic configuration with program load from magnetic tape.

echo
echo Configuring the diagnostic configurator for magnetic tape loading.
echo Expect halt 102077 if successful.

deposit P 000100
deposit S 011611
reset
go

assert T=102077



; Memory Reference Instruction Group diagnostic (DSN = 101100).

do %1CPU-MRG.inc


; Alter-Skip Instructions diagnostic (DSN = 101001).

do %1CPU-ASG.inc


; Shift-Rotate Instructions diagnostic (DSN = 101002).

do %1CPU-SRG.inc


; Semiconductor Memory diagnostic (DSN = 102104).

do %121MX-RAM.inc


; EAU Instruction Group diagnostic (DSN = 101004).

do %1CPU-EAU.inc


; Floating Point Instruction Group diagnostic (DSN = 101207).

do %1CPU-FP.inc


; Memory Protect/Parity Error diagnostic (DSN = 102305).

do %1MP-PE.inc


; I/O Instruction Group diagnostic (DSN = 141203).

do %1CPU-IOG.inc


; General Purpose Register diagnostic (DSN = 143300) for the 12653A Line Printer Interface.

do %12767-GPREG.inc


; Direct Memory Access diagnostic (2100/21MX) (DSN = 101220).

do %1DMA.inc


; Extended Instruction Group (Index) diagnostic (DSN = 101011).

do %121MX-EIG-IDX.inc


; Extended Instruction Group (Word, Byte, Bit) diagnostic (DSN = 101112).

do %121MX-EIG-WBB.inc


; M/E-Series Fast FORTRAN Package 1 diagnostic (DSN = 101213).

do %121MX-FFP-1.inc


; M/E-Series Fast FORTRAN Package 2 diagnostic (DSN = 101114).

do %121MX-FFP-2.inc


; F-Series FPP-SIS-FFP diagnostic (DSN = 101121).

do %1FPP-SIS-FFP.inc


; Memory Expansion Unit diagnostic (DSN = 102103).

do %1MEM.inc


; Time Base Generator diagnostic (DSN = 103301).

do %1TBG.inc


; 12936 Privileged interrupt diagnostic (DSN = 103115)

do %1PIF-12936.inc


; General Purpose Register diagnostic (DSN = 143300) for the 12620A PIF

do %1PIF-12620.inc


; General Purpose Register diagnostic (DSN = 143300) for the 12875A PIK

do %112875-GPREG.inc


; 12920A Asynchronous Multiplexer (Data) diagnostic (DSN = 103110).

do %112920D.inc


; 12920A Asynchronous Multiplexer (Control) diagnostic (DSN = 103011).

do %112920C.inc


; 12966 Asynchronous Data Set diagnostic (DSN = 103017)

do %1BACI.inc


; 12821 ICD Disc Interface diagnostic (DSN = 103024)

do %112821.inc


; 7900/01 Cartridge Disc diagnostic (DSN = 151302), multiple unit test.

do %17900-MU.inc


; 7900/01 Cartridge Disc diagnostic (DSN = 151302), user interaction test.

do %17900-UI.inc


; 7905/06/20/25 Disc diagnostic (DSN = 151403), multiple unit test.

do %17905-MU.inc


; 7905/06/20/25 Disc diagnostic (DSN = 151403), user interaction.

do %17905-UI.inc


; 9-Track Magnetic Tape (7970B, 13181) diagnostic (DSN = 112200).

do %17970B.inc 24396-13601_Rev-2326.abin.tape %1


; 9-Track Magnetic Tape (7970E, 13183) diagnostic (DSN = 112200).

do %17970E.inc 24396-13601_Rev-2326.abin.tape %1


; General Purpose Register diagnostic (DSN = 143300) for the HP 12597A-002 Paper Tape Reader Interface.

do %12748-GPREG.inc


; General Purpose Register diagnostic (DSN = 143300) for the HP 12597A-005 Paper Tape Punch Interface.

do %12895-GPREG.inc


; 2748/2895 Paper Tape Reader/Punch diagnostic (DSN = 146200).

do %12748-2895.inc


; 2752 Teleprinter diagnostic (DSN = 104003).

do %12752.inc


; 2613/17/18 Line Printer diagnostic (DSN = 145103)

do %12613-17-18.inc


; 2607 Line Printer diagnostic (DSN = 105102).
;
; NOTE!  THIS DIAGNOSTIC OVERLAYS THE CONFIGURATOR LOADER LINK,
;        SO IT MUST BE RUN LAST!

do %12607.inc



; -------------------------------------------------------------------
; The following stand-alone diagnostics cooperate with the diagnostic
; configurator, so reset the configurator to load from paper tape.
; -------------------------------------------------------------------


; Reload the diagnostic configurator to change to the paper tape loader.

echo
echo
echo -----------------------------
echo Diagnostic Configuator Reload
echo -----------------------------
echo
echo Reloading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
deposit A 000001
boot -S MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from paper tape.

echo
echo Configuring the diagnostic configurator for paper tape loading.
echo Expect halt 106074 if successful.

deposit S 001011
reset
go 100

assert T=106074



; 2000/Access Comm. Processor Firmware (DSN = 101217).

do %121MX-ACCESS.inc NUL %1


; HP 2100 Fixed Head Disc/Drum (DSN = 177777).

do %12770.inc NUL %1


; HP 2100 Fixed Head Disc/Drum (DSN = 177777).

do %12771.inc NUL %1


; HP 2100 Fixed Head Disc/Drum (DSN = 177777).

do %12773.inc NUL %1


; HP 2100 Fixed Head Disc/Drum (DSN = 177777).

do %12775.inc NUL %1


; 12875 Processor Interconnect Cable diagnostic (DSN = none).

do %112875.inc NUL %1




;  *******************************
;  *                             *
;  *  HP 2100 Diagnostics Suite  *
;  *                             *
;  *******************************

echo
echo
echo
echo
echo -------------------------
echo HP 2100 Diagnostics Suite
echo -------------------------


; Establish base CPU for diagnostics.

echo
echo Reconfiguring the CPU as a 2100 with 32K.

set -f CPU 2100,32K


; Load the diagnostic configurator.

attach -e -r MSC0 %124396-13601_Rev-1713.abin.tape

echo
echo Loading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from magnetic tape.

echo
echo Configuring the diagnostic configurator for magnetic tape loading.
echo Expect halt 102077 if successful.

deposit S 011611
reset
go 100

assert T=102077



; Core Memory diagnostic (2100/16/15/14) (DSN = 102200).

do %121XX-CORE.inc


; Memory Protect diagnostic (DSN = 102001).

do %12100-MP.inc


; Direct Memory Access diagnostic (2100/21MX) (DSN = 101220).

do %1DMA.inc


; 2100 Fast FORTRAN Package diagnostic (DSN = 101110).

do %12100-FFP.inc


; 2767 Line Printer diagnostic (DSN = 105101).

do %12767.inc


; HP2100A Disc File (2883) (DSN = 111001), multiple unit test.

do %12883-MU.inc


; HP2100A Disc File (2883) (DSN = 111001), user interaction test.

do %12883-UI.inc


; 2000/Access Comm. Processor Firmware (DSN = 101016).

do %12100-ACCESS.inc



; -------------------------------------------------------------------
; The following stand-alone diagnostics cooperate with the diagnostic
; configurator, so reset the configurator to load from paper tape.
; -------------------------------------------------------------------


; Reload the diagnostic configurator to change to the paper tape loader.

echo
echo
echo -----------------------------
echo Diagnostic Configuator Reload
echo -----------------------------
echo
echo Reloading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000001
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from paper tape.
; Note: 24396-13601 Rev.1713 gives halt 106070 on PTR not ready, not 106074.

echo
echo Configuring the diagnostic configurator for paper tape loading.
echo Expect halt 106070 if successful.

deposit S 001011
reset
go 100

assert T=106070



; --------------------------------------------------------------------------
; The following stand-alone diagnostics overlay the diagnostic configurator,
; so the configurator must be reloaded as part of each diagnostic execution.
; --------------------------------------------------------------------------


; DSN (none) - HP2100A Cartridge Disc Memory (2870), multiple unit test.

do %12870-MU.inc NUL %1


; DSN (none) - HP2100A Cartridge Disc Memory (2870), user interaction test.

do %12870-UI.inc NUL %1




;  *******************************
;  *                             *
;  *  HP 2116 Diagnostics Suite  *
;  *                             *
;  *******************************

echo
echo
echo
echo
echo -------------------------
echo HP 2116 Diagnostics Suite
echo -------------------------


; Establish base CPU for diagnostics.

echo
echo Reconfiguring the CPU as a 2116 with 16K.

set -f CPU 2116,16K


; Load the diagnostic configurator.

attach -e -r MSC0 %124396-13601_Rev-1713.abin.tape

echo
echo Loading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from magnetic tape.

echo
echo Configuring the diagnostic configurator for magnetic tape loading.
echo Expect halt 102077 if successful.

deposit S 011611
reset
go 100

assert T=102077



; Core Memory diagnostic (2100/16/15/14) (DSN = 102200)

do %121XX-CORE.inc


; Direct Memory Access diagnostic (2114/15/16) (DSN = 101105)

do %1211X-DMA.inc


; 20418-80001 2116B MEMORY PROTECT DIAGNOSTIC



;  *******************************
;  *                             *
;  *  HP 2115 Diagnostics Suite  *
;  *                             *
;  *******************************

echo
echo
echo
echo
echo -------------------------
echo HP 2115 Diagnostics Suite
echo -------------------------


; Establish base CPU for diagnostics.

echo
echo Reconfiguring the CPU as a 2115 with 8K.

set -f CPU 2115,8K


; Load the diagnostic configurator.

attach -e -r MSC0 %124396-13601_Rev-1713.abin.tape

echo
echo Loading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from magnetic tape.

echo
echo Configuring the diagnostic configurator for magnetic tape loading.
echo Expect halt 102077 if successful.

deposit S 011611
reset
go 100

assert T=102077



; Core Memory diagnostic (2100/16/15/14) (DSN = 102200)

do %121XX-CORE.inc


; Direct Memory Access diagnostic (2114/15/16) (DSN = 101105)

do %1211X-DMA.inc




;  *******************************
;  *                             *
;  *  HP 2114 Diagnostics Suite  *
;  *                             *
;  *******************************

echo
echo
echo
echo
echo -------------------------
echo HP 2114 Diagnostics Suite
echo -------------------------


; Establish base CPU for diagnostics.

echo
echo Reconfiguring the CPU as a 2114 with 16K.

set -f CPU 2114,16K


; Load the diagnostic configurator.

attach -e -r MSC0 %124396-13601_Rev-1713.abin.tape

echo
echo Loading the diagnostic configurator from magnetic tape.
echo Expect halt 102077 if successful.

deposit S 000000
boot MSC0

assert T=102077


; Verify the Diagnostic Serial Number.

echo
echo Verifying DSN 000200.

deposit M 126
assert T=000200


; Prepare for automatic configuration with program load from magnetic tape.

echo
echo Configuring the diagnostic configurator for magnetic tape loading.
echo Expect halt 102077 if successful.

deposit S 011611
reset
go 100

assert T=102077



; Core Memory diagnostic (2100/16/15/14) (DSN = 102200)

do %121XX-CORE.inc


; Direct Memory Access diagnostic (2114/15/16) (DSN = 101105)

do %1211X-DMA.inc



; Diagnostics suite run is complete.
;
; Exit the simulator.

echo
echo
echo
echo ------------------------------
echo Diagnostics Suite Run Complete
echo ------------------------------
echo
echo Run ended on %DATE_MMM% %DATE_DD%, %DATE_YYYY% at %TIME_HH%:%TIME_MM%:%TIME_SS%
echo

exit