RESTRICTION: The FP15 and XVM features of the PDP-15 are only partially debugged. Do NOT enable these features for normal operations. 1. New Features in 3.1-0 1.1 SCP and libraries - Added simulated Ethernet support for VMS, FreeBSD, Mac OS/X. - Added status return to tmxr_putc_ln. - Added sim_putchar_s to handle possible output stalls. 1.2 All DECtapes - Added "DECtape off reel" error stop. 1.3 All Asynchronous Consoles - Added support for output congestion stall if using a Telnet connection. 1.4 PDP-1 - Added Type 23 parallel drum support. 1.5 PDP-8 - Added instruction history. - Added TSC8-75 option support for ETOS. - Added TD8E DECtape support. 1.6 PDP-18b - Added instruction history. - Changed PDP-9, PDP-15 API default to enabled. 1.7 PDP-11 - Added support for 18b only Qbus devices. - Formalized bus and addressing definitions. - Added control to enable/disable autoconfiguration. - Added stub support for second Unibus Ethernet controller. 1.7 Interdata 32b - Added instruction history. 1.8 Eclipse - Added floating point support. - Added programmable interval timer support. 1.9 H316 - Added DMA/DMC support. - Added fixed head disk support. - Added moving head disk support. - Added magtape support. 1.10 IBM 1130 (Brian Knittel) - Added support for physical card reader, using the Cardread interface (www.ibm1130.org/sim/downloads). - Added support for physical printer (flushes output buffer after each line). 2. Bugs Fixed in 3.1-0 2.1 SCP and libraries - Fixed numerous bugs in Ethernet library. 2.2 All DECtapes - Fixed reverse checksum value in 'read all' mode. - Simplified (and sped up) timing. 2.3 PDP-8 - Fixed bug in RX28 read status (found by Charles Dickman). - Fixed RX28 double density write. 2.4 PDP-18b - Fixed autoincrement bug in PDP-4, PDP-7, PDP-9. 2.5 PDP-11/VAX - Revised RQ MB->LBN conversion for greater accuracy. - Fixed bug in IO configuration (found by David Hittner). - Fixed bug with multiple RQ RAUSER drives. - Fixed bug in second Qbus Ethernet controller interrupts. 2.6 Nova/Eclipse - Fixed bugs in DKP flag clear, map setup, map usage (Charles Owen). - Fixed bug in MT, reset completes despite I/O reset (Charles Owen). - Fixed bug in MT, space operations return word count (Charles Owen). 2.7 IBM 1130 (Brian Knittel) - Fixed bug in setting carry bit in subtract and subtract double. - Fixed timing problem in console printer simulation. 2.8 1620 - Fixed bug in branch digit (found by Dave Babcock). 3. New Features in 3.0 vs prior releases 3.1 SCP and Libraries - Added ASSIGN/DEASSIGN (logical name) commands. - Changed RESTORE to unconditionally detach files. - Added E11 and TPC format support to magtape library. - Fixed bug in SHOW CONNECTIONS. - Added USE_ADDR64 support. 3.2 All magtapes - Magtapes support SIMH format, E11 format, and TPC format (read only). - SET <tape_unit> FORMAT=format sets the specified tape unit's format. - SHOW <tape_unit> FORMAT displays the specified tape unit's format. - Tape format can also be set as part of the ATTACH command, using the -F switch. 3.3 VAX - VAX can be compiled without USE_INT64. - If compiled with USE_INT64 and USE_ADDR64, RQ and TQ controllers support files > 2GB. - VAX ROM has speed control (SET ROM DELAY/NODELAY). 3.4 PDP-1 - Added block loader format support to LOAD. - Changed BOOT PTR to allow loading of all of the first bank of memory. - The LOAD command takes an optional argument specifying the memory field to be loaded. - The PTR BOOT command takes its starting memory field from the TA (address switch) register. 3.5 PDP-18b Family - Added PDP-4 EAE support. - Added PDP-15 FP15 support. - Added PDP-15 XVM support. - Added PDP-15 "re-entrancy ECO". - Added PDP-7, PDP-9, PDP-15 hardware RIM loader support in BOOT PTR. 4. Bugs Fixed in 3.0 vs prior releases 4.1 SCP and Libraries - Fixed end of file problem in dep, idep. - Fixed handling of trailing spaces in dep, idep. 4.2 VAX - Fixed CVTfi bug: integer overflow not set if exponent out of range - Fixed EMODx bugs: o First and second operands reversed o Separated fraction received wrong exponent o Overflow calculation on separated integer incorrect o Fraction not set to zero if exponent out of range - Fixed interval timer and ROM access to pass power-up self-test even on very fast host processors (fixes from Mark Pizzolato). - Fixed bug in user disk size (found by Chaskiel M Grundman). 4.3 1401 - Fixed mnemonic, instruction lengths, and reverse scan length check bug for MCS. - Fixed MCE bug, BS off by 1 if zero suppress. - Fixed chaining bug, D lost if return to SCP. - Fixed H branch, branch occurs after continue. - Added check for invalid 8 character MCW, LCA. - Fixed magtape load-mode end of record response. - Revised fetch to model hardware more closely. - Fixed tape read end-of-record handling based on real 1401. - Added diagnostic read (space forward). 4.4 Nova - Fixed DSK variable size interaction with restore. - Fixed bug in DSK set size routine. 4.5 PDP-1 - Fixed DT variable size interaction with restore. - Updated CPU, line printer, standard devices to detect indefinite I/O wait. - Fixed incorrect logical, missing activate, break in drum simulator. - Fixed bugs in instruction decoding, overprinting for line printer. - Fixed system hang if continue after PTR error. - Fixed PTR to start/stop on successive rpa instructions. 4.6 PDP-11 - Fixed DT variable size interaction with restore. - Fixed bug in MMR1 update (found by Tim Stark). - Added XQ features and fixed bugs: o Corrected XQ interrupts on IE state transition (code by Tom Evans). o Added XQ interrupt clear on soft reset. o Removed XQ interrupt when setting XL or RL (multiple people). o Added SET/SHOW XQ STATS. o Added SHOW XQ FILTERS. o Added ability to split received packet into multiple buffers. o Added explicit runt and giant packet processing. - Fixed bug in user disk size (found by Chaskiel M Grundman). 4.7 PDP-18B - Fixed DT, RF variable size interaction with restore. - Fixed MT bug in MTTR. - Fixed bug in PDP-4 line printer overprinting. - Fixed bug in PDP-15 memory protect/skip interaction. - Fixed bug in RF set size routine. - Increased PTP TIME for PDP-15 operating systems. - Fixed priorities in PDP-15 API (differs from PDP-9). - Fixed sign handling in PDP-15 EAE unsigned mul/div (differs from PDP-9). - Fixed bug in CAF, clears API subsystem. 4.8 PDP-8 - Fixed DT, DF, RF, RX variable size interaction with restore. - Fixed MT bug in SKTR. - Fixed bug in DF, RF set size routine. 4.9 HP2100 - Fixed bug in DP (13210A controller only), DQ read status. - Fixed bug in DP, DQ seek complete. - Fixed DR drum sizes. - Fixed DR variable capacity interaction with SAVE/RESTORE. 4.10 GRI - Fixed bug in SC queue pointer management. 4.11 PDP-10 - Fixed bug in RP read header. 4.12 Ibm1130 - Fixed bugs found by APL 1130. 4.13 Altairz80 - Fixed bug in real-time clock on Windows host. 4.14 1620 - Fixed bug in immediate index add (found by Michael Short).
479 lines
15 KiB
C
479 lines
15 KiB
C
/* hp2100_mt.c: HP 2100 12559A magnetic tape simulator
|
||
|
||
Copyright (c) 1993-2003, Robert M. Supnik
|
||
|
||
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 Robert M Supnik shall not
|
||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||
in this Software without prior written authorization from Robert M Supnik.
|
||
|
||
mt 12559A 3030 nine track magnetic tape
|
||
|
||
21-Dec-03 RMS Adjusted msc_ctime for TSB (from Mike Gemeny)
|
||
25-Apr-03 RMS Revised for extended file support
|
||
28-Mar-03 RMS Added multiformat support
|
||
28-Feb-03 RMS Revised for magtape library
|
||
30-Sep-02 RMS Revamped error handling
|
||
28-Aug-02 RMS Added end of medium support
|
||
30-May-02 RMS Widened POS to 32b
|
||
22-Apr-02 RMS Added maximum record length test
|
||
20-Jan-02 RMS Fixed bug on last character write
|
||
03-Dec-01 RMS Added read only unit, extended SET/SHOW support
|
||
07-Sep-01 RMS Moved function prototypes
|
||
30-Nov-00 RMS Made variable names unique
|
||
04-Oct-98 RMS V2.4 magtape format
|
||
|
||
Magnetic tapes are represented as a series of variable records
|
||
of the form:
|
||
|
||
32b byte count
|
||
byte 0
|
||
byte 1
|
||
:
|
||
byte n-2
|
||
byte n-1
|
||
32b byte count
|
||
|
||
If the byte count is odd, the record is padded with an extra byte
|
||
of junk. File marks are represented by a byte count of 0.
|
||
|
||
Unusually among HP peripherals, the 12559 does not have a command flop,
|
||
and its flag and flag buffer power up as clear rather than set.
|
||
*/
|
||
|
||
#include "hp2100_defs.h"
|
||
#include "sim_tape.h"
|
||
|
||
#define DB_V_SIZE 16 /* max data buf */
|
||
#define DBSIZE (1 << DB_V_SIZE) /* max data cmd */
|
||
|
||
/* Command - mtc_fnc */
|
||
|
||
#define FNC_CLR 0300 /* clear */
|
||
#define FNC_WC 0031 /* write */
|
||
#define FNC_RC 0023 /* read */
|
||
#define FNC_GAP 0011 /* write gap */
|
||
#define FNC_FSR 0003 /* forward space */
|
||
#define FNC_BSR 0041 /* backward space */
|
||
#define FNC_REW 0201 /* rewind */
|
||
#define FNC_RWS 0101 /* rewind and offline */
|
||
#define FNC_WFM 0035 /* write file mark */
|
||
|
||
/* Status - stored in mtc_sta, (d) = dynamic */
|
||
|
||
#define STA_LOCAL 0400 /* local (d) */
|
||
#define STA_EOF 0200 /* end of file */
|
||
#define STA_BOT 0100 /* beginning of tape */
|
||
#define STA_EOT 0040 /* end of tape */
|
||
#define STA_TIM 0020 /* timing error */
|
||
#define STA_REJ 0010 /* programming error */
|
||
#define STA_WLK 0004 /* write locked (d) */
|
||
#define STA_PAR 0002 /* parity error */
|
||
#define STA_BUSY 0001 /* busy (d) */
|
||
|
||
extern uint32 PC;
|
||
extern uint32 dev_cmd[2], dev_ctl[2], dev_flg[2], dev_fbf[2];
|
||
int32 mtc_fnc = 0; /* function */
|
||
int32 mtc_sta = 0; /* status register */
|
||
int32 mtc_dtf = 0; /* data xfer flop */
|
||
int32 mtc_1st = 0; /* first svc flop */
|
||
int32 mtc_ctime = 40; /* command wait */
|
||
int32 mtc_gtime = 1000; /* gap stop time */
|
||
int32 mtc_xtime = 15; /* data xfer time */
|
||
int32 mtc_stopioe = 1; /* stop on error */
|
||
uint8 mtxb[DBSIZE] = { 0 }; /* data buffer */
|
||
t_mtrlnt mt_ptr = 0, mt_max = 0; /* buffer ptrs */
|
||
static const int32 mtc_cmd[] = {
|
||
FNC_WC, FNC_RC, FNC_GAP, FNC_FSR, FNC_BSR, FNC_REW, FNC_RWS, FNC_WFM };
|
||
|
||
DEVICE mtd_dev, mtc_dev;
|
||
int32 mtdio (int32 inst, int32 IR, int32 dat);
|
||
int32 mtcio (int32 inst, int32 IR, int32 dat);
|
||
t_stat mtc_svc (UNIT *uptr);
|
||
t_stat mtc_reset (DEVICE *dptr);
|
||
t_stat mtc_attach (UNIT *uptr, char *cptr);
|
||
t_stat mtc_detach (UNIT *uptr);
|
||
t_stat mt_map_err (UNIT *uptr, t_stat st);
|
||
|
||
/* MTD data structures
|
||
|
||
mtd_dev MTD device descriptor
|
||
mtd_unit MTD unit list
|
||
mtd_reg MTD register list
|
||
*/
|
||
|
||
DIB mt_dib[] = {
|
||
{ MTD, 0, 0, 0, 0, &mtdio },
|
||
{ MTC, 0, 0, 0, 0, &mtcio } };
|
||
|
||
#define mtd_dib mt_dib[0]
|
||
#define mtc_dib mt_dib[1]
|
||
|
||
UNIT mtd_unit = { UDATA (NULL, 0, 0) };
|
||
|
||
REG mtd_reg[] = {
|
||
{ FLDATA (CMD, mtd_dib.cmd, 0), REG_HRO },
|
||
{ FLDATA (CTL, mtd_dib.ctl, 0), REG_HRO },
|
||
{ FLDATA (FLG, mtd_dib.flg, 0) },
|
||
{ FLDATA (FBF, mtd_dib.fbf, 0), REG_HRO },
|
||
{ BRDATA (DBUF, mtxb, 8, 8, DBSIZE) },
|
||
{ DRDATA (BPTR, mt_ptr, DB_V_SIZE + 1) },
|
||
{ DRDATA (BMAX, mt_max, DB_V_SIZE + 1) },
|
||
{ ORDATA (DEVNO, mtd_dib.devno, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB mtd_mod[] = {
|
||
{ MTUF_WLK, 0, "write enabled", "WRITEENABLED", NULL },
|
||
{ MTUF_WLK, MTUF_WLK, "write locked", "LOCKED", NULL },
|
||
{ MTAB_XTD|MTAB_VUN, 0, "FORMAT", "FORMAT",
|
||
&sim_tape_set_fmt, &sim_tape_show_fmt, NULL },
|
||
{ MTAB_XTD | MTAB_VDV, 1, "DEVNO", "DEVNO",
|
||
&hp_setdev, &hp_showdev, &mtd_dev },
|
||
{ 0 } };
|
||
|
||
DEVICE mtd_dev = {
|
||
"MTD", &mtd_unit, mtd_reg, mtd_mod,
|
||
1, 10, 16, 1, 8, 8,
|
||
NULL, NULL, &mtc_reset,
|
||
NULL, NULL, NULL,
|
||
&mtd_dib, DEV_DISABLE | DEV_DIS };
|
||
|
||
/* MTC data structures
|
||
|
||
mtc_dev MTC device descriptor
|
||
mtc_unit MTC unit list
|
||
mtc_reg MTC register list
|
||
mtc_mod MTC modifier list
|
||
*/
|
||
|
||
UNIT mtc_unit = { UDATA (&mtc_svc, UNIT_ATTABLE + UNIT_ROABLE, 0) };
|
||
|
||
REG mtc_reg[] = {
|
||
{ ORDATA (FNC, mtc_fnc, 8) },
|
||
{ ORDATA (STA, mtc_sta, 9) },
|
||
{ ORDATA (BUF, mtc_unit.buf, 8) },
|
||
{ FLDATA (CMD, mtc_dib.cmd, 0), REG_HRO },
|
||
{ FLDATA (CTL, mtc_dib.ctl, 0) },
|
||
{ FLDATA (FLG, mtc_dib.flg, 0) },
|
||
{ FLDATA (FBF, mtc_dib.fbf, 0) },
|
||
{ FLDATA (DTF, mtc_dtf, 0) },
|
||
{ FLDATA (FSVC, mtc_1st, 0) },
|
||
{ DRDATA (POS, mtc_unit.pos, T_ADDR_W), PV_LEFT },
|
||
{ DRDATA (CTIME, mtc_ctime, 24), REG_NZ + PV_LEFT },
|
||
{ DRDATA (GTIME, mtc_gtime, 24), REG_NZ + PV_LEFT },
|
||
{ DRDATA (XTIME, mtc_xtime, 24), REG_NZ + PV_LEFT },
|
||
{ FLDATA (STOP_IOE, mtc_stopioe, 0) },
|
||
{ ORDATA (DEVNO, mtc_dib.devno, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB mtc_mod[] = {
|
||
{ MTAB_XTD | MTAB_VDV, 1, "DEVNO", "DEVNO",
|
||
&hp_setdev, &hp_showdev, &mtd_dev },
|
||
{ 0 } };
|
||
|
||
DEVICE mtc_dev = {
|
||
"MTC", &mtc_unit, mtc_reg, mtc_mod,
|
||
1, 10, 31, 1, 8, 8,
|
||
NULL, NULL, &mtc_reset,
|
||
NULL, &mtc_attach, &mtc_detach,
|
||
&mtc_dib, DEV_DISABLE | DEV_DIS };
|
||
|
||
/* IOT routines */
|
||
|
||
int32 mtdio (int32 inst, int32 IR, int32 dat)
|
||
{
|
||
int32 devd;
|
||
|
||
devd = IR & I_DEVMASK; /* get device no */
|
||
switch (inst) { /* case on opcode */
|
||
case ioFLG: /* flag clear/set */
|
||
if ((IR & I_HC) == 0) { setFLG (devd); } /* STF */
|
||
break;
|
||
case ioSFC: /* skip flag clear */
|
||
if (FLG (devd) == 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioSFS: /* skip flag set */
|
||
if (FLG (devd) != 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioOTX: /* output */
|
||
mtc_unit.buf = dat & 0377; /* store data */
|
||
break;
|
||
case ioMIX: /* merge */
|
||
dat = dat | mtc_unit.buf;
|
||
break;
|
||
case ioLIX: /* load */
|
||
dat = mtc_unit.buf;
|
||
break;
|
||
case ioCTL: /* control clear/set */
|
||
if (IR & I_CTL) mtc_dtf = 0; /* CLC: clr xfer flop */
|
||
break;
|
||
default:
|
||
break; }
|
||
if (IR & I_HC) { clrFLG (devd); } /* H/C option */
|
||
return dat;
|
||
}
|
||
|
||
int32 mtcio (int32 inst, int32 IR, int32 dat)
|
||
{
|
||
int32 i, devc, devd, valid;
|
||
t_stat st;
|
||
|
||
devc = IR & I_DEVMASK; /* get device no */
|
||
devd = devc - 1;
|
||
switch (inst) { /* case on opcode */
|
||
case ioFLG: /* flag clear/set */
|
||
if ((IR & I_HC) == 0) { setFLG (devc); } /* STF */
|
||
break;
|
||
case ioSFC: /* skip flag clear */
|
||
if (FLG (devc) == 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioSFS: /* skip flag set */
|
||
if (FLG (devc) != 0) PC = (PC + 1) & VAMASK;
|
||
return dat;
|
||
case ioOTX: /* output */
|
||
dat = dat & 0377;
|
||
mtc_sta = mtc_sta & ~STA_REJ; /* clear reject */
|
||
if (dat == FNC_CLR) { /* clear? */
|
||
if (sim_is_active (&mtc_unit) && /* write in prog? */
|
||
(mtc_fnc == FNC_WC) && (mt_ptr > 0)) { /* yes, bad rec */
|
||
if (st = sim_tape_wrrecf (&mtc_unit, mtxb, mt_ptr | MTR_ERF))
|
||
mt_map_err (&mtc_unit, st); }
|
||
if (((mtc_fnc == FNC_REW) || (mtc_fnc == FNC_RWS)) &&
|
||
sim_is_active (&mtc_unit)) sim_cancel (&mtc_unit);
|
||
mtc_1st = mtc_dtf = 0;
|
||
mtc_sta = mtc_sta & STA_BOT;
|
||
clrCTL (devc); /* init device */
|
||
clrFLG (devc);
|
||
clrCTL (devd);
|
||
clrFLG (devd);
|
||
return SCPE_OK; }
|
||
for (i = valid = 0; i < sizeof (mtc_cmd); i++) /* is fnc valid? */
|
||
if (dat == mtc_cmd[i]) valid = 1;
|
||
if (!valid || sim_is_active (&mtc_unit) || /* is cmd valid? */
|
||
((mtc_sta & STA_BOT) && (dat == FNC_BSR)) ||
|
||
(sim_tape_wrp (&mtc_unit) &&
|
||
((dat == FNC_WC) || (dat == FNC_GAP) || (dat == FNC_WFM))))
|
||
mtc_sta = mtc_sta | STA_REJ;
|
||
else {
|
||
sim_activate (&mtc_unit, mtc_ctime); /* start tape */
|
||
mtc_fnc = dat; /* save function */
|
||
mtc_sta = STA_BUSY; /* unit busy */
|
||
mt_ptr = 0; /* init buffer ptr */
|
||
clrFLG (devc); /* clear flags */
|
||
clrFLG (devd);
|
||
mtc_1st = 1; /* set 1st flop */
|
||
mtc_dtf = 1; } /* set xfer flop */
|
||
break;
|
||
case ioLIX: /* load */
|
||
dat = 0;
|
||
case ioMIX: /* merge */
|
||
dat = dat | (mtc_sta & ~(STA_LOCAL | STA_WLK | STA_BUSY));
|
||
if (mtc_unit.flags & UNIT_ATT) { /* construct status */
|
||
if (sim_is_active (&mtc_unit)) dat = dat | STA_BUSY;
|
||
if (sim_tape_wrp (&mtc_unit)) dat = dat | STA_WLK; }
|
||
else dat = dat | STA_BUSY | STA_LOCAL;
|
||
break;
|
||
case ioCTL: /* control clear/set */
|
||
if (IR & I_CTL) { clrCTL (devc); } /* CLC */
|
||
else { setCTL (devc); } /* STC */
|
||
break;
|
||
default:
|
||
break; }
|
||
if (IR & I_HC) { clrFLG (devc); } /* H/C option */
|
||
return dat;
|
||
}
|
||
|
||
/* Unit service
|
||
|
||
If rewind done, reposition to start of tape, set status
|
||
else, do operation, set done, interrupt
|
||
|
||
Can't be write locked, can only write lock detached unit
|
||
*/
|
||
|
||
t_stat mtc_svc (UNIT *uptr)
|
||
{
|
||
int32 devc, devd;
|
||
t_mtrlnt tbc;
|
||
t_stat st, r = SCPE_OK;
|
||
|
||
devc = mtc_dib.devno; /* get device nos */
|
||
devd = mtd_dib.devno;
|
||
if ((mtc_unit.flags & UNIT_ATT) == 0) { /* offline? */
|
||
mtc_sta = STA_LOCAL | STA_REJ; /* rejected */
|
||
setFLG (devc); /* set cch flg */
|
||
return IORETURN (mtc_stopioe, SCPE_UNATT); }
|
||
|
||
switch (mtc_fnc) { /* case on function */
|
||
|
||
case FNC_REW: /* rewind */
|
||
sim_tape_rewind (uptr); /* BOT */
|
||
mtc_sta = STA_BOT; /* update status */
|
||
break;
|
||
|
||
case FNC_RWS: /* rewind and offline */
|
||
sim_tape_rewind (uptr); /* clear position */
|
||
return sim_tape_detach (uptr); /* don't set cch flg */
|
||
|
||
case FNC_WFM: /* write file mark */
|
||
if (st = sim_tape_wrtmk (uptr)) /* write tmk, err? */
|
||
r = mt_map_err (uptr, st); /* map error */
|
||
mtc_sta = STA_EOF; /* set EOF status */
|
||
break;
|
||
|
||
case FNC_GAP: /* erase gap */
|
||
break;
|
||
|
||
case FNC_FSR: /* space forward */
|
||
if (st = sim_tape_sprecf (uptr, &tbc)) /* space rec fwd, err? */
|
||
r = mt_map_err (uptr, st); /* map error */
|
||
break;
|
||
|
||
case FNC_BSR: /* space reverse */
|
||
if (st = sim_tape_sprecr (uptr, &tbc)) /* space rec rev, err? */
|
||
r = mt_map_err (uptr, st); /* map error */
|
||
break;
|
||
|
||
/* Unit service, continued */
|
||
|
||
case FNC_RC: /* read */
|
||
if (mtc_1st) { /* first svc? */
|
||
mtc_1st = mt_ptr = 0; /* clr 1st flop */
|
||
st = sim_tape_rdrecf (uptr, mtxb, &mt_max, DBSIZE); /* read rec */
|
||
if (st == MTSE_RECE) mtc_sta = mtc_sta | STA_PAR; /* rec in err? */
|
||
else if (st != MTSE_OK) { /* other error? */
|
||
r = mt_map_err (uptr, st); /* map error */
|
||
if (r == SCPE_OK) { /* recoverable? */
|
||
sim_activate (uptr, mtc_gtime); /* sched IRG */
|
||
mtc_fnc = 0; /* NOP func */
|
||
return SCPE_OK; }
|
||
break; } /* non-recov, done */
|
||
if (mt_max < 12) { /* record too short? */
|
||
mtc_sta = mtc_sta | STA_PAR; /* set flag */
|
||
break; }
|
||
}
|
||
if (mt_ptr < mt_max) { /* more chars? */
|
||
if (FLG (devd)) mtc_sta = mtc_sta | STA_TIM;
|
||
mtc_unit.buf = mtxb[mt_ptr++]; /* fetch next */
|
||
setFLG (devd); /* set dch flg */
|
||
sim_activate (uptr, mtc_xtime); /* re-activate */
|
||
return SCPE_OK; }
|
||
sim_activate (uptr, mtc_gtime); /* schedule gap */
|
||
mtc_fnc = 0; /* nop */
|
||
return SCPE_OK;
|
||
|
||
case FNC_WC: /* write */
|
||
if (mtc_1st) mtc_1st = 0; /* no xfr on first */
|
||
else {
|
||
if (mt_ptr < DBSIZE) { /* room in buffer? */
|
||
mtxb[mt_ptr++] = mtc_unit.buf;
|
||
mtc_sta = mtc_sta & ~STA_BOT; } /* clear BOT */
|
||
else mtc_sta = mtc_sta | STA_PAR; }
|
||
if (mtc_dtf) { /* xfer flop set? */
|
||
setFLG (devd); /* set dch flag */
|
||
sim_activate (uptr, mtc_xtime); /* re-activate */
|
||
return SCPE_OK; }
|
||
if (mt_ptr) { /* write buffer */
|
||
if (st = sim_tape_wrrecf (uptr, mtxb, mt_ptr)) { /* write, err? */
|
||
r = mt_map_err (uptr, st); /* map error */
|
||
break; } } /* done */
|
||
sim_activate (uptr, mtc_gtime); /* schedule gap */
|
||
mtc_fnc = 0; /* nop */
|
||
return SCPE_OK;
|
||
|
||
default: /* unknown */
|
||
break; }
|
||
|
||
setFLG (devc); /* set cch flg */
|
||
mtc_sta = mtc_sta & ~STA_BUSY; /* not busy */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Map tape error status */
|
||
|
||
t_stat mt_map_err (UNIT *uptr, t_stat st)
|
||
{
|
||
switch (st) {
|
||
case MTSE_FMT: /* illegal fmt */
|
||
case MTSE_UNATT: /* unattached */
|
||
mtc_sta = mtc_sta | STA_REJ; /* reject */
|
||
case MTSE_OK: /* no error */
|
||
return SCPE_IERR; /* never get here! */
|
||
case MTSE_TMK: /* end of file */
|
||
mtc_sta = mtc_sta | STA_EOF; /* eof */
|
||
break;
|
||
case MTSE_IOERR: /* IO error */
|
||
mtc_sta = mtc_sta | STA_PAR; /* error */
|
||
if (mtc_stopioe) return SCPE_IOERR;
|
||
break;
|
||
case MTSE_INVRL: /* invalid rec lnt */
|
||
mtc_sta = mtc_sta | STA_PAR;
|
||
return SCPE_MTRLNT;
|
||
case MTSE_RECE: /* record in error */
|
||
case MTSE_EOM: /* end of medium */
|
||
mtc_sta = mtc_sta | STA_PAR; /* error */
|
||
break;
|
||
case MTSE_BOT: /* reverse into BOT */
|
||
mtc_sta = mtc_sta | STA_BOT; /* set status */
|
||
break;
|
||
case MTSE_WRP: /* write protect */
|
||
mtc_sta = mtc_sta | STA_REJ; /* reject */
|
||
break; }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Reset routine */
|
||
|
||
t_stat mtc_reset (DEVICE *dptr)
|
||
{
|
||
hp_enbdis_pair (&mtc_dev, &mtd_dev); /* make pair cons */
|
||
mtc_fnc = 0;
|
||
mtc_1st = mtc_dtf = 0;
|
||
mtc_dib.cmd = mtd_dib.cmd = 0; /* clear cmd */
|
||
mtc_dib.ctl = mtd_dib.ctl = 0; /* clear ctl */
|
||
mtc_dib.flg = mtd_dib.flg = 0; /* clear flg */
|
||
mtc_dib.fbf = mtd_dib.fbf = 0; /* clear fbf */
|
||
sim_cancel (&mtc_unit); /* cancel activity */
|
||
sim_tape_reset (&mtc_unit);
|
||
if (mtc_unit.flags & UNIT_ATT) mtc_sta =
|
||
(sim_tape_bot (&mtc_unit)? STA_BOT: 0) |
|
||
(sim_tape_wrp (&mtc_unit)? STA_WLK: 0);
|
||
else mtc_sta = STA_LOCAL | STA_BUSY;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Attach routine */
|
||
|
||
t_stat mtc_attach (UNIT *uptr, char *cptr)
|
||
{
|
||
t_stat r;
|
||
|
||
r = sim_tape_attach (uptr, cptr); /* attach unit */
|
||
if (r != SCPE_OK) return r; /* update status */
|
||
mtc_sta = STA_BOT;
|
||
return r;
|
||
}
|
||
|
||
/* Detach routine */
|
||
|
||
t_stat mtc_detach (UNIT* uptr)
|
||
{
|
||
mtc_sta = 0; /* update status */
|
||
return sim_tape_detach (uptr); /* detach unit */
|
||
}
|