simh-testsetgenerator/S3/s3_cd.c
Bob Supnik 2c2dd5ea33 Notes For V2.10-0
WARNING: V2.10 has reorganized and renamed some of the definition
files for the PDP-10, PDP-11, and VAX.  Be sure to delete all
previous source files before you unpack the Zip archive, or
unpack it into a new directory structure.

WARNING: V2.10 has a new, more comprehensive save file format.
Restoring save files from previous releases will cause 'invalid
register' errors and loss of CPU option flags, device enable/
disable flags, unit online/offline flags, and unit writelock
flags.

WARNING: If you are using Visual Studio .NET through the IDE,
be sure to turn off the /Wp64 flag in the project settings, or
dozens of spurious errors will be generated.

WARNING: Compiling Ethernet support under Windows requires
extra steps; see the Ethernet readme file.  Ethernet support is
currently available only for Windows, Linux, NetBSD, and OpenBSD.

1. New Features

1.1 SCP and Libraries

- The VT emulation package has been replaced by the capability
  to remote the console to a Telnet session.  Telnet clients
  typically have more complete and robust VT100 emulation.
- Simulated devices may now have statically allocated buffers,
  in addition to dynamically allocated buffers or disk-based
  data stores.
- The DO command now takes substitutable arguments (max 9).
  In command files, %n represents substitutable argument n.
- The initial command line is now interpreted as the command
  name and substitutable arguments for a DO command.  This is
  backward compatible to prior versions.
- The initial command line parses switches.  -Q is interpreted
  as quiet mode; informational messages are suppressed.
- The HELP command now takes an optional argument.  HELP <cmd>
  types help on the specified command.
- Hooks have been added for implementing GUI-based consoles,
  as well as simulator-specific command extensions.  A few
  internal data structures and definitions have changed.
- Two new routines (tmxr_open_master, tmxr_close_master) have
  been added to sim_tmxr.c.  The calling sequence for
  sim_accept_conn has been changed in sim_sock.c.
- The calling sequence for the VM boot routine has been modified
  to add an additional parameter.
- SAVE now saves, and GET now restores, controller and unit flags.
- Library sim_ether.c has been added for Ethernet support.

1.2 VAX

- Non-volatile RAM (NVR) can behave either like a memory or like
  a disk-based peripheral.  If unattached, it behaves like memory
  and is saved and restored by SAVE and RESTORE, respectively.
  If attached, its contents are loaded from disk by ATTACH and
  written back to disk at DETACH and EXIT.
- SHOW <device> VECTOR displays the device's interrupt vector.
  A few devices allow the vector to be changed with SET
  <device> VECTOR=nnn.
- SHOW CPU IOSPACE displays the I/O space address map.
- The TK50 (TMSCP tape) has been added.
- The DEQNA/DELQA (Qbus Ethernet controllers) have been added.
- Autoconfiguration support has been added.
- The paper tape reader has been removed from vax_stddev.c and
  now references a common implementation file, dec_pt.h.
- Examine and deposit switches now work on all devices, not just
  the CPU.
- Device address conflicts are not detected until simulation starts.

1.3 PDP-11

- SHOW <device> VECTOR displays the device's interrupt vector.
  Most devices allow the vector to be changed with SET
  <device> VECTOR=nnn.
- SHOW CPU IOSPACE displays the I/O space address map.
- The TK50 (TMSCP tape), RK611/RK06/RK07 (cartridge disk),
  RX211 (double density floppy), and KW11P programmable clock
  have been added.
- The DEQNA/DELQA (Qbus Ethernet controllers) have been added.
- Autoconfiguration support has been added.
- The paper tape reader has been removed from pdp11_stddev.c and
  now references a common implementation file, dec_pt.h.
- Device bootstraps now use the actual CSR specified by the
  SET ADDRESS command, rather than just the default CSR.  Note
  that PDP-11 operating systems may NOT support booting with
  non-standard addresses.
- Specifying more than 256KB of memory, or changing the bus
  configuration, causes all peripherals that are not compatible
  with the current bus configuration to be disabled.
- Device address conflicts are not detected until simulation starts.

1.4 PDP-10

- SHOW <device> VECTOR displays the device's interrupt vector.
  A few devices allow the vector to be changed with SET
  <device> VECTOR=nnn.
- SHOW CPU IOSPACE displays the I/O space address map.
- The RX211 (double density floppy) has been added; it is off
  by default.
- The paper tape now references a common implementation file,
  dec_pt.h.
- Device address conflicts are not detected until simulation starts.

1.5 PDP-1

- DECtape (then known as MicroTape) support has been added.
- The line printer and DECtape can be disabled and enabled.

1.6 PDP-8

- The RX28 (double density floppy) has been added as an option to
  the existing RX8E controller.
- SHOW <device> DEVNO displays the device's device number.  Most
  devices allow the device number to be changed with SET <device>
  DEVNO=nnn.
- Device number conflicts are not detected until simulation starts.

1.7 IBM 1620

- The IBM 1620 simulator has been released.

1.8 AltairZ80

- A hard drive has been added for increased storage.
- Several bugs have been fixed.

1.9 HP 2100

- The 12845A has been added and made the default line printer (LPT).
  The 12653A has been renamed LPS and is off by default.  It also
  supports the diagnostic functions needed to run the DCPC and DMS
  diagnostics.
- The 12557A/13210A disk defaults to the 13210A (7900/7901).
- The 12559A magtape is off by default.
- New CPU options (EAU/NOEAU) enable/disable the extended arithmetic
  instructions for the 2116.  These instructions are standard on
  the 2100 and 21MX.
- New CPU options (MPR/NOMPR) enable/disable memory protect for the
  2100 and 21MX.
- New CPU options (DMS/NODMS) enable/disable the dynamic mapping
  instructions for the 21MX.
- The 12539 timebase generator autocalibrates.

1.10 Simulated Magtapes

- Simulated magtapes recognize end of file and the marker
  0xFFFFFFFF as end of medium.  Only the TMSCP tape simulator
  can generate an end of medium marker.
- The error handling in simulated magtapes was overhauled to be
  consistent through all simulators.

1.11 Simulated DECtapes

- Added support for RT11 image file format (256 x 16b) to DECtapes.

2. Release Notes

2.1 Bugs Fixed

- TS11/TSV05 was not simulating the XS0_MOT bit, causing failures
  under VMS.  In addition, two of the CTL options were coded
  interchanged.
- IBM 1401 tape was not setting a word mark under group mark for
  load mode reads.  This caused the diagnostics to crash.
- SCP bugs in ssh_break and set_logon were fixed (found by Dave
  Hittner).
- Numerous bugs in the HP 2100 extended arithmetic, floating point,
  21MX, DMS, and IOP instructions were fixed.  Bugs were also fixed
  in the memory protect and DMS functions.  The moving head disks
  (DP, DQ) were revised to simulate the hardware more accurately.
  Missing functions in DQ (address skip, read address) were added.

2.2 HP 2100 Debugging

- The HP 2100 CPU nows runs all of the CPU diagnostics.
- The peripherals run most of the peripheral diagnostics.  There
  is still a problem in overlapped seek operation on the disks.
  See the file hp2100_diag.txt for details.

3. In Progress

These simulators are not finished and are available in a separate
Zip archive distribution.

- Interdata 16b/32b: coded, partially tested.  See the file
  id_diag.txt for details.
- SDS 940: coded, partially tested.
2011-04-15 08:33:49 -07:00

441 lines
12 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* s3_cd.c: IBM 1442 card reader/punch
Copyright (c) 2001, Charles E. Owen
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Charles E. Owen shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Charles E. Owen.
cdr card reader
cdp card punch
cdp2 card punch stacker 2
08-Oct-02 RMS Added impossible function catcher
Normally, cards are represented as ASCII text streams terminated by newlines.
This allows cards to be created and edited as normal files. Set the EBCDIC
flag on the card unit allows cards to be read or punched in EBCDIC format,
suitable for binary data.
*/
#include "s3_defs.h"
#include <ctype.h>
extern uint8 M[];
extern char ebcdic_to_ascii[256];
extern char ascii_to_ebcdic[256];
int32 s1sel, s2sel;
char rbuf[CBUFSIZE]; /* > CDR_WIDTH */
t_stat cdr_svc (UNIT *uptr);
t_stat cdr_boot (int32 unitno, DEVICE *dptr);
t_stat cdr_attach (UNIT *uptr, char *cptr);
t_stat cd_reset (DEVICE *dptr);
t_stat read_card (int32 ilnt, int32 mod);
t_stat punch_card (int32 ilnt, int32 mod);
int32 DAR; /* Data address register */
int32 LCR; /* Length Count Register */
int32 lastcard = 0; /* Last card switch */
int32 carderr = 0; /* Error switch */
int32 pcherror = 0; /* Punch error */
int32 notready = 0; /* Not ready error */
int32 cdr_ebcdic = 0; /* EBCDIC mode on reader */
int32 cdp_ebcdic = 0; /* EBCDIC mode on punch */
extern int32 GetMem(int32 addr);
extern int32 PutMem(int32 addr, int32 data);
/* Card reader data structures
cdr_dev CDR descriptor
cdr_unit CDR unit descriptor
cdr_reg CDR register list
*/
UNIT cdr_unit = {
UDATA (&cdr_svc, UNIT_SEQ+UNIT_ATTABLE, 0), 100 };
REG cdr_reg[] = {
{ FLDATA (LAST, lastcard, 0) },
{ FLDATA (ERR, carderr, 0) },
{ FLDATA (NOTRDY, notready, 0) },
{ HRDATA (DAR, DAR, 16) },
{ HRDATA (LCR, LCR, 16) },
{ FLDATA (EBCDIC, cdr_ebcdic, 0) },
{ FLDATA (S2, s2sel, 0) },
{ DRDATA (POS, cdr_unit.pos, 32), PV_LEFT },
{ DRDATA (TIME, cdr_unit.wait, 24), PV_LEFT },
{ BRDATA (BUF, rbuf, 8, 8, CDR_WIDTH) },
{ NULL } };
DEVICE cdr_dev = {
"CDR", &cdr_unit, cdr_reg, NULL,
1, 10, 31, 1, 8, 7,
NULL, NULL, &cd_reset,
&cdr_boot, &cdr_attach, NULL };
/* CDP data structures
cdp_dev CDP device descriptor
cdp_unit CDP unit descriptor
cdp_reg CDP register list
*/
UNIT cdp_unit = {
UDATA (NULL, UNIT_SEQ+UNIT_ATTABLE, 0) };
REG cdp_reg[] = {
{ FLDATA (ERR, pcherror, 0) },
{ FLDATA (EBCDIC, cdp_ebcdic, 0) },
{ FLDATA (S2, s2sel, 0) },
{ FLDATA (NOTRDY, notready, 0) },
{ HRDATA (DAR, DAR, 16) },
{ HRDATA (LCR, LCR, 16) },
{ DRDATA (POS, cdp_unit.pos, 32), PV_LEFT },
{ NULL } };
DEVICE cdp_dev = {
"CDP", &cdp_unit, cdp_reg, NULL,
1, 10, 31, 1, 8, 7,
NULL, NULL, &cd_reset,
NULL, NULL, NULL };
/* Stacker data structures
stack_dev STACK device descriptor
stack_unit STACK unit descriptors
stack_reg STACK register list
*/
UNIT stack_unit[] = {
{ UDATA (NULL, UNIT_SEQ+UNIT_ATTABLE, 0) } };
REG stack_reg[] = {
{ DRDATA (POS0, stack_unit[0].pos, 32), PV_LEFT },
{ NULL } };
DEVICE stack_dev = {
"CDP2", stack_unit, stack_reg, NULL,
1, 10, 31, 1, 8, 7,
NULL, NULL, &cd_reset,
NULL, NULL, NULL };
/* -------------------------------------------------------------------- */
/* 1442: master routine */
int32 crd (int32 op, int32 m, int32 n, int32 data)
{
int32 iodata;
switch (op) {
case 0: /* SIO 1442 */
/* if (n == 1)
return STOP_IBKPT; */
switch (data) { /* Select stacker */
case 0x00:
break;
case 0x01:
s2sel = 1;
break;
default:
break;
}
switch (n) {
case 0x00: /* Feed */
iodata = SCPE_OK;
break;
case 0x01: /* Read only */
if (cdr_ebcdic)
iodata = read_card(0, 1);
else
iodata = read_card(0, 0);
break;
case 0x02: /* Punch and feed */
iodata = punch_card(0, 0);
break;
case 0x03: /* Read Col Binary */
iodata = read_card(0, 1);
break;
case 0x04: /* Punch no feed */
iodata = punch_card(0, 1);
break;
default:
return STOP_INVDEV;
}
return iodata;
case 1: /* LIO 1442 */
switch (n) {
case 0x00: /* Load LCR */
LCR = data & 0xffff;
break;
case 0x04:
DAR = data & 0xffff;
break;
default:
return STOP_INVDEV;
}
return SCPE_OK;
case 2: /* TIO 1442 */
iodata = 0;
switch (n) {
case 0x00: /* Error */
if (carderr || pcherror || notready)
iodata = 1;
if ((cdr_unit.flags & UNIT_ATT) == 0)
iodata = 1; /* attached? */
break;
case 0x02: /* Busy */
if (sim_is_active (&cdr_unit))
iodata = 1;
break;
default:
return (STOP_INVDEV << 16);
}
return ((SCPE_OK << 16) | iodata);
case 3: /* SNS 1442 */
iodata = 0;
switch (n) {
case 0x01:
break;
case 0x02:
break;
case 0x03:
if (carderr)
iodata |= 0x80;
if (lastcard)
iodata |= 0x40;
if (pcherror)
iodata |= 0x20;
if ((cdr_unit.flags & UNIT_ATT) == 0)
iodata |= 0x08;
if (notready)
iodata |= 0x08;
break;
case 0x04:
iodata = DAR;
break;
default:
return (STOP_INVDEV << 16);
}
iodata |= ((SCPE_OK << 16) & 0xffff0000);
return (iodata);
case 4: /* APL 1442 */
iodata = 0;
switch (n) {
case 0x00: /* Error */
if (carderr || pcherror || notready)
iodata = 1;
if ((cdr_unit.flags & UNIT_ATT) == 0)
iodata = 1; /* attached? */
break;
case 0x02: /* Busy */
if (sim_is_active (&cdr_unit))
iodata = 1;
break;
default:
return (STOP_INVDEV << 16);
}
return ((SCPE_OK << 16) | iodata);
default:
break;
}
printf (">>CRD non-existent function %d\n", op);
return SCPE_OK;
}
/* Card read routine
mod 0 = ASCII read
mod 1 = EBCDIC read
*/
t_stat read_card (int32 ilnt, int32 mod)
{
int32 i;
t_stat r;
if (sim_is_active (&cdr_unit)) { /* busy? */
sim_cancel (&cdr_unit); /* cancel */
if (r = cdr_svc (&cdr_unit)) return r; /* process */
}
if (((cdp_unit.flags & UNIT_ATT) != 0 ||
(stack_unit[0].flags & UNIT_ATT) != 0) && /* Punch is attached and */
(cdr_unit.flags & UNIT_ATT) == 0) { /* reader is not --- */
for (i = 0; i < 80; i++) { /* Assume blank cards in hopper */
PutMem(DAR, 0x40);
DAR++;
}
sim_activate (&cdr_unit, cdr_unit.wait); /* activate */
return SCPE_OK;
}
if ((cdr_unit.flags & UNIT_ATT) == 0) return SCPE_UNATT; /* attached? */
lastcard = carderr = notready = s1sel = s2sel = 0; /* default stacker */
for (i = 0; i < CBUFSIZE; i++) rbuf[i] = 0x20; /* clear buffer */
if (mod) {
for (i = 0; i < 80; i++) {
rbuf[i] = fgetc(cdr_unit.fileref); /* Read EBCDIC */
}
} else {
fgets (rbuf, CBUFSIZE, cdr_unit.fileref); /* read Ascii */
}
if (feof (cdr_unit.fileref)) { /* eof? */
notready = 1;
return STOP_NOCD;
}
if (ferror (cdr_unit.fileref)) { /* error? */
perror ("Card reader I/O error");
clearerr (cdr_unit.fileref);
carderr = 1;
return SCPE_OK; }
cdr_unit.pos = ftell (cdr_unit.fileref); /* update position */
i = getc (cdr_unit.fileref); /* see if more */
if (feof (cdr_unit.fileref)) lastcard = 1; /* eof? set flag */
fseek (cdr_unit.fileref, cdr_unit.pos, SEEK_SET);
for (i = 0; i < 80; i++) {
if (mod == 0) { /* If ASCII mode... */
if (rbuf[i] == '\n' || /* remove ASCII CR/LF */
rbuf[i] == '\r' ||
rbuf[i] == 0x00)
rbuf[i] = ' ';
rbuf[i] = ascii_to_ebcdic[rbuf[i]]; /* convert to EBCDIC */
}
PutMem(DAR, rbuf[i]); /* Copy to main memory */
DAR++;
}
sim_activate (&cdr_unit, cdr_unit.wait); /* activate */
return SCPE_OK;
}
/* Card reader service. If a stacker select is active, copy to the
selected stacker. Otherwise, copy to the normal stacker. If the
unit is unattached, simply exit.
*/
t_stat cdr_svc (UNIT *uptr)
{
int32 i;
if (s2sel) uptr = &stack_unit[0]; /* stacker 1? */
else uptr = &stack_unit[0]; /* then default */
if ((uptr -> flags & UNIT_ATT) == 0) return SCPE_OK; /* attached? */
for (i = 0; i < CDR_WIDTH; i++) rbuf[i] = ebcdic_to_ascii[rbuf[i]];
for (i = CDR_WIDTH - 1; (i >= 0) && (rbuf[i] == ' '); i--) rbuf[i] = 0;
rbuf[CDR_WIDTH] = 0; /* null at end */
fputs (rbuf, uptr -> fileref); /* write card */
fputc ('\n', uptr -> fileref); /* plus new line */
if (ferror (uptr -> fileref)) { /* error? */
perror ("Card stacker I/O error");
clearerr (uptr -> fileref);
}
uptr -> pos = ftell (uptr -> fileref); /* update position */
return SCPE_OK;
}
/* Card punch routine
mod: not used
*/
t_stat punch_card (int32 ilnt, int32 mod)
{
int32 i, colcount;
static char pbuf[CDP_WIDTH + 1]; /* + null */
UNIT *uptr;
if (s2sel) uptr = &stack_unit[0]; /* stack 2? */
else uptr = &cdp_unit; /* normal output */
if ((uptr -> flags & UNIT_ATT) == 0) { /* Attached? */
notready = 1;
return SCPE_OK;
}
pcherror = s1sel = notready = 0; /* clear flags */
colcount = 128 - LCR;
for (i = 0; i < colcount; i++) { /* Fetch data */
if (cdp_ebcdic)
pbuf[i] = GetMem(DAR) & 0xff;
else
pbuf[i] = ebcdic_to_ascii[GetMem(DAR)];
DAR++;
}
for (i = CDP_WIDTH - 1; (i >= 0) && (pbuf[i] == ' '); i--) pbuf[i] = 0;
pbuf[CDP_WIDTH] = 0; /* trailing null */
if (!cdp_ebcdic) {
fputs (pbuf, uptr -> fileref); /* output card */
fputc ('\n', uptr -> fileref); /* plus new line */
} else {
for (i = 0; i < 80; i++) {
fputc(pbuf[i], uptr -> fileref);
}
}
if (ferror (uptr -> fileref)) { /* error? */
perror ("Card punch I/O error");
clearerr (uptr -> fileref);
pcherror = 1;
}
uptr -> pos = ftell (uptr -> fileref); /* update position */
return SCPE_OK;
}
/* Select stack routine
Modifiers have been checked by the caller
Modifiers are 1, 2, for the respective stack
*/
t_stat select_stack (int32 ilnt, int32 mod)
{
if (mod == 1) s1sel = 1;
else if (mod == 2) s2sel = 1;
return SCPE_OK;
}
/* Card reader/punch reset */
t_stat cd_reset (DEVICE *dptr)
{
lastcard = carderr = notready = pcherror = 0; /* clear indicators */
s1sel = s2sel = 0; /* clear stacker sel */
sim_cancel (&cdr_unit); /* clear reader event */
return SCPE_OK;
}
/* Card reader attach */
t_stat cdr_attach (UNIT *uptr, char *cptr)
{
carderr = lastcard = notready = 0; /* clear last card */
return attach_unit (uptr, cptr);
}
/* Bootstrap routine */
t_stat cdr_boot (int32 unitno, DEVICE *dptr)
{
cdr_ebcdic = 1;
DAR = 0;
LCR = 80;
read_card(0, 1);
return SCPE_OK;
}