simh-testsetgenerator/Ibm1130/ibm1130_ptrp.c
Bob Supnik b6393b36b4 Notes For V3.3
RESTRICTION: The HP DS disk is not debugged.  DO NOT enable this
feature for normal operations.
WARNING: Massive changes in the PDP-11 make all previous SAVEd
file obsolete.  Do not attempt to use a PDP-11 SAVE file from a
prior release with V3.3!

1. New Features in 3.3

1.1 SCP

- Added -p (powerup) qualifier to RESET
- Changed SET <unit> ONLINE/OFFLINE to SET <unit> ENABLED/DISABLED
- Moved SET DEBUG under SET CONSOLE hierarchy
- Added optional parameter value to SHOW command
- Added output file option to SHOW command

1.2 PDP-11

- Separated RH Massbus adapter from RP controller
- Added TU tape support
- Added model emulation framework
- Added model details

1.3 VAX

- Separated out CVAX-specific features from core instruction simulator
- Implemented capability for CIS, octaword, compatibility mode instructions
- Added instruction display and parse for compatibility mode
- Changed SET CPU VIRTUAL=n to SHOW CPU VIRTUAL=n
- Added =n optional parameter to SHOW CPU HISTORY

1.4 Unibus/Qbus simulators (PDP-11, VAX, PDP-10)

- Simplified DMA API's
- Modified DMA peripherals to use simplified API's

1.5 HP2100 (all changes from Dave Bryan)

CPU	- moved MP into its own device; added MP option jumpers
	- modified DMA to allow disabling
	- modified SET CPU 2100/2116 to truncate memory > 32K
	- added -F switch to SET CPU to force memory truncation
	- modified WRU to be REG_HRO
	- added BRK and DEL to save console settings

DR	- provided protected tracks and "Writing Enabled" status bit
	- added "parity error" status return on writes for 12606
	- added track origin test for 12606
	- added SCP test for 12606
	- added "Sector Flag" status bit
	- added "Read Inhibit" status bit for 12606
	- added TRACKPROT modifier

LPS	- added SET OFFLINE/ONLINE, POWEROFF/POWERON
	- added fast/realistic timing
	- added debug printouts

LPT	- added SET OFFLINE/ONLINE, POWEROFF/POWERON

PTR	- added paper tape loop mode, DIAG/READER modifiers to PTR
	- added PV_LEFT to PTR TRLLIM register

CLK	- modified CLK to permit disable

1.6 IBM 1401, IBM 1620, Interdata 16b, SDS 940, PDP-10

- Added instruction history

1.7 H316, PDP-15, PDP-8

- Added =n optional value to SHOW CPU HISTORY

2. Bugs Fixed in 3.3

2.1 SCP

- Fixed comma-separated SET options (from Dave Bryan)
- Fixed duplicate HELP displays with user-specified commands

2.2 PDP-10

- Replicated RP register state per drive
- Fixed TU to set FCE on short record
- Fixed TU to return bit<15> in drive type
- Fixed TU format specification, 1:0 are don't cares
- Fixed TU handling of TMK status
- Fixed TU handling of DONE, ATA at end of operation
- Implemented TU write check

2.3 PDP-11

- Replicated RP register state per drive
- Fixed RQ, TQ to report correct controller type and stage 1 configuration
  flags on a Unibus system
- Fixed HK CS2<output_ready> flag

2.4 VAX

- Fixed parsing of indirect displacement modes in instruction input

2.5 HP2100 (all fixes from Dave Bryan)

CPU	- fixed S-register behavior on 2116
	- fixed LIx/MIx behavior for DMA on 2116 and 2100
	- fixed LIx/MIx behavior for empty I/O card slots

DP	- fixed enable/disable from either device
	- fixed ANY ERROR status for 12557A interface
	- fixed unattached drive status for 12557A interface
	- status cmd without prior STC DC now completes (12557A)
	- OTA/OTB CC on 13210A interface also does CLC CC
	- fixed RAR model
	- fixed seek check on 13210 if sector out of range

DQ	- fixed enable/disable from either device
	- shortened xtime from 5 to 3 (drive avg 156KW/second)
	- fixed not ready/any error status
	- fixed RAR model

DR	- fixed enable/disable from either device
	- fixed sector return in status word
	- fixed DMA last word write, incomplete sector fill value
	- fixed 12610 SFC operation
	- fixed current-sector determination

IPL	- fixed enable/disable from either device

LPS	- fixed status returns for error conditions
	- fixed handling of non-printing characters
	- fixed handling of characters after column 80
	- improved timing model accuracy for RTE

LPT	- fixed status returns for error conditions
	- fixed TOF handling so form remains on line 0

SYS	- fixed display of CCA/CCB/CCE instructions

2.5 PDP-15

FPP	- fixed URFST to mask low 9b of fraction
	- fixed exception PC setting
2011-04-15 08:34:40 -07:00

309 lines
9 KiB
C

/* ibm1130_ptrp.c: IBM 1130 paper tape reader/punch emulation
Based on the SIMH simulator package written by Robert M Supnik
Brian Knittel
Revision History
2004.10.22 - Written.
* (C) Copyright 2004, Brian Knittel.
* You may freely use this program, but: it offered strictly on an AS-IS, AT YOUR OWN
* RISK basis, there is no warranty of fitness for any purpose, and the rest of the
* usual yada-yada. Please keep this notice and the copyright in any distributions
* or modifications.
*
* This is not a supported product, but I welcome bug reports and fixes.
* Mail to simh@ibm1130.org
*/
#include "ibm1130_defs.h"
/***************************************************************************************
* 1134 Paper Tape Reader device PTR
* 1055 Paper Tape Punch device PTP (shares DSW with PTR)
***************************************************************************************/
#define PTR1134_DSW_READER_RESPONSE 0x4000
#define PTR1134_DSW_PUNCH_RESPONSE 0x1000
#define PTR1134_DSW_READER_BUSY 0x0800
#define PTR1134_DSW_READER_NOT_READY 0x0400
#define PTR1134_DSW_PUNCH_BUSY 0x0200
#define PTR1134_DSW_PUNCH_NOT_READY 0x0100
#define IS_ONLINE(u) (((u)->flags & (UNIT_ATT|UNIT_DIS)) == UNIT_ATT)
static t_stat ptr_svc (UNIT *uptr);
static t_stat ptr_reset (DEVICE *dptr);
static t_stat ptr_attach (UNIT *uptr, char *cptr);
static t_stat ptr_detach (UNIT *uptr);
static t_stat ptr_boot (int unitno, DEVICE *dptr);
static t_stat ptp_svc (UNIT *uptr);
static t_stat ptp_reset (DEVICE *dptr);
static t_stat ptp_attach (UNIT *uptr, char *cptr);
static t_stat ptp_detach (UNIT *uptr);
static int16 ptr_dsw = 0; /* device status word */
static int32 ptr_wait = 1000; /* character read wait */
static uint8 ptr_char = 0; /* last character read */
static int32 ptp_wait = 1000; /* character punch wait */
UNIT ptr_unit[1] = {
{ UDATA (&ptr_svc, UNIT_ATTABLE, 0) },
};
REG ptr_reg[] = {
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word */
{ DRDATA (WTIME, ptr_wait, 24), PV_LEFT }, /* character read wait */
{ DRDATA (LASTCHAR, ptr_char, 8), PV_LEFT }, /* last character read */
{ NULL } };
DEVICE ptr_dev = {
"PTR", ptr_unit, ptr_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptr_reset,
ptr_boot, ptr_attach, ptr_detach};
UNIT ptp_unit[1] = {
{ UDATA (&ptp_svc, UNIT_ATTABLE, 0) },
};
REG ptp_reg[] = {
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word (this is the same as the reader's!) */
{ DRDATA (WTIME, ptp_wait, 24), PV_LEFT }, /* character punch wait */
{ NULL } };
DEVICE ptp_dev = {
"PTP", ptp_unit, ptp_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptp_reset,
NULL, ptp_attach, ptp_detach};
/* xio_1134_papertape - XIO command interpreter for the 1134 paper tape reader and 1055 paper tape punch */
void xio_1134_papertape (int iocc_addr, int iocc_func, int iocc_mod)
{
char msg[80];
switch (iocc_func) {
case XIO_READ: /* read: return last character read */
M[iocc_addr & mem_mask] = (uint16) (ptr_char << 8);
break;
case XIO_WRITE: /* write: initiate punch operation */
if ((ptr_dsw & PTR1134_DSW_PUNCH_NOT_READY) == 0 && IS_ONLINE(ptp_unit)) {
putc((M[iocc_addr & mem_mask] >> 8) & 0xFF, ptp_unit->fileref);
ptp_unit->pos++;
}
sim_activate(ptp_unit, ptp_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY | PTR1134_DSW_PUNCH_BUSY);
break;
case XIO_SENSE_DEV: /* sense device status */
ACC = ptr_dsw;
if (iocc_mod & 0x01) { /* reset interrupts */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE | PTR1134_DSW_PUNCH_RESPONSE);
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
}
break;
case XIO_CONTROL: /* control: initiate character read */
sim_activate(ptr_unit, ptr_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_NOT_READY);
break;
default:
sprintf(msg, "Invalid 1134 reader/1055 punch XIO function %x", iocc_func);
xio_error(msg);
}
}
// ptr_svc - emulated timeout - 1134 read operation complete
static t_stat ptr_svc (UNIT *uptr)
{
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY); /* clear reader busy flag */
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume at end of file */
if (IS_ONLINE(uptr)) { /* fetch character from file */
ptr_char = getc(uptr->fileref);
uptr->pos++;
if (! feof(uptr->fileref)) /* there's more left */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
}
SETBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE); /* indicate read complete */
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
return SCPE_OK;
}
// ptp_svc - emulated timeout -- 1055 punch operation complete
static t_stat ptp_svc (UNIT *uptr)
{
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY); /* clear punch busy flag */
if (IS_ONLINE(uptr)) /* update punch ready status */
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
else
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_RESPONSE); /* indicate punch complete */
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
return SCPE_OK;
}
/* ptr_reset - reset emulated paper tape reader */
static t_stat ptr_reset (DEVICE *dptr)
{
sim_cancel(ptr_unit);
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
if (IS_ONLINE(ptr_unit) && ! feof(ptr_unit->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
if ((ptr_dsw & PTR1134_DSW_PUNCH_RESPONSE) == 0) { /* punch isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
return SCPE_OK;
}
/* ptp_reset - reset emulated paper tape punch */
static t_stat ptp_reset (DEVICE *dptr)
{
sim_cancel(ptp_unit);
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY | PTR1134_DSW_PUNCH_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
if (IS_ONLINE(ptp_unit))
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
if ((ptr_dsw & PTR1134_DSW_READER_RESPONSE) == 0) { /* reader isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
return SCPE_OK;
}
/* ptr_attach - attach file to simulated paper tape reader */
static t_stat ptr_attach (UNIT *uptr, char *cptr)
{
t_stat rval;
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume failure */
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
if ((ptr_dsw & PTR1134_DSW_READER_BUSY) == 0 && ! feof(uptr->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* we're in business */
return SCPE_OK;
}
/* ptr_attach - detach file from simulated paper tape reader */
static t_stat ptr_detach (UNIT *uptr)
{
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
return detach_unit(uptr);
}
/* ptr_attach - perform paper tape initial program load */
static t_stat ptr_boot (int unitno, DEVICE *dptr)
{
int ch, nch, val, addr;
t_bool leader = TRUE, start = FALSE;
t_stat rval;
addr = 0;
nch = 0;
val = 0;
for (;;) {
if ((ch = getc(ptr_unit->fileref)) == EOF) {
printf("EOF on paper tape without finding Channel 5 end-of-load mark\n");
break;
}
if (leader) {
if ((ch & 0x7F) == 0x7F) // ignore leading rubouts or "delete" characters
continue;
leader = FALSE; // after first nonrubout, any punch in channel 5 terminates load
}
// this is untested -- not sure of actual byte ordering
val = (val << 4) | (ch & 0x0F); // get next nybble
if (++nch == 4) { // if we now have four nybbles, store the word
M[addr & mem_mask] = (uint16) val;
addr++; // prepare for next word
nch = 0;
val = 0;
}
if (ch & 0x10) { // channel 5 punch terminates load
start = TRUE;
break;
}
}
if (! start) // if we didn't get a valid load, report EOF error
return SCPE_EOF;
if ((rval = reset_all(0)) != SCPE_OK) // force a reset
return rval;
IAR = 0; // start running at address 0
return SCPE_OK;
}
/* ptp_attach - attach file to simulated paper tape punch */
static t_stat ptp_attach (UNIT *uptr, char *cptr)
{
t_stat rval;
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* assume failure */
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
fseek(uptr->fileref, 0, SEEK_END); /* if we opened an existing file, append to it */
uptr->pos = ftell(uptr->fileref);
if ((ptr_dsw & PTR1134_DSW_PUNCH_BUSY) == 0)
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* we're in business */
return SCPE_OK;
}
/* ptp_detach - detach file from simulated paper tape punch */
static t_stat ptp_detach (UNIT *uptr)
{
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
return detach_unit(uptr);
}