PDP1, PDP10, PDP11, ID16, ID32, NOVA, VAX: Open LPT, PTP devices for append

This implements the principle of "least surprise", in that users won't
normally expect to start overwriting an existing file on these devices.
Real hardware didn't behave that way.  A new (empty) file can always
be created with the -N switch on the ATTACH.
This commit is contained in:
Mark Pizzolato 2020-04-28 07:09:20 -07:00
parent 580b388917
commit 4313f9fe3c
12 changed files with 120 additions and 11 deletions

View file

@ -285,6 +285,7 @@ return SCPE_OK;
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
{
lpt_vfup = 0; /* top of form */
sim_switches |= SWMASK ('A'); /* position to EOF */
return attach_unit (uptr, cptr);
}

View file

@ -50,6 +50,7 @@ int32 lpt_stopioe = 0; /* stop on error flag */
int32 lpt (int32 pulse, int32 code, int32 AC);
t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *ptr);
/* LPT data structures
@ -80,7 +81,7 @@ DEVICE lpt_dev = {
"LPT", &lpt_unit, lpt_reg, NULL,
1, 10, 31, 1, 8, 8,
NULL, NULL, &lpt_reset,
NULL, NULL, NULL,
NULL, &lpt_attach, NULL,
&lpt_dib, DEV_DISABLE
};
@ -153,3 +154,9 @@ DEV_UPDATE_INTR ;
sim_cancel (&lpt_unit); /* deactivate unit */
return SCPE_OK;
}
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
{
sim_switches |= SWMASK('A'); /* position to EOF */
return attach_unit (uptr, cptr);
}

View file

@ -59,6 +59,10 @@ extern int32 stop_inst;
t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *ptr);
t_stat lpt_detach (UNIT *uptr);
t_stat lpt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
const char *lpt_description (DEVICE *dptr);
/* LPT data structures
@ -82,7 +86,7 @@ REG lpt_reg[] = {
{ DRDATAD (POS, lpt_unit.pos, T_ADDR_W, "position in the output file"), PV_LEFT },
{ DRDATAD (TIME, lpt_unit.wait, 24, "time from I/O initiation to interrupt"), PV_LEFT },
{ FLDATAD (STOP_IOE, lpt_stopioe, 0, "stop on I/O error") },
{ BRDATAD (LBUF, lpt_buf, 8, 8, LPT_BSIZE, "line buffer") },
{ BRDATAD (LBUF, lpt_buf, 8, 8, LPT_BSIZE, "line buffer") },
{ DRDATA (SBSLVL, lpt_sbs, 4), REG_HRO },
{ NULL }
};
@ -97,8 +101,10 @@ DEVICE lpt_dev = {
"LPT", &lpt_unit, lpt_reg, lpt_mod,
1, 10, 31, 1, 8, 8,
NULL, NULL, &lpt_reset,
NULL, NULL, NULL,
NULL, DEV_DISABLE
NULL, &lpt_attach, &lpt_detach,
NULL, DEV_DISABLE, 0,
NULL, NULL, NULL, &lpt_help, NULL, NULL,
&lpt_description
};
/* Line printer IOT routine */
@ -212,3 +218,41 @@ iosta = iosta & ~(IOS_PNT | IOS_SPC); /* clear flags */
sim_cancel (&lpt_unit); /* deactivate unit */
return SCPE_OK;
}
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
{
t_stat reason;
sim_switches |= SWMASK('A'); /* position to EOF */
reason = attach_unit (uptr, cptr);
return reason;
}
t_stat lpt_detach (UNIT *uptr)
{
return detach_unit (uptr);
}
t_stat lpt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)
{
fprintf (st, "Line Printer (LPT)\n\n");
fprintf (st, "The line printer (LPT) writes data to a disk file. The POS register specifies\n");
fprintf (st, "the number of the next data item to be written. Thus, by changing POS, the\n");
fprintf (st, "user can backspace or advance the printer.\n\n");
fprintf (st, "The default position after ATTACH is to position at the end of an existing file.\n");
fprintf (st, "A new file can be created if you attach with the -N switch.\n\n");
fprint_set_help (st, dptr);
fprint_show_help (st, dptr);
fprint_reg_help (st, dptr);
fprintf (st, "\nError handling is as follows:\n\n");
fprintf (st, " error STOP_IOE processed as\n");
fprintf (st, " not attached 1 out of paper\n");
fprintf (st, " 0 disk not ready\n\n");
fprintf (st, " OS I/O error x report error and stop\n");
return SCPE_OK;
}
const char *lpt_description (DEVICE *dptr)
{
return "Type 62 Line Printer";
}

View file

@ -106,6 +106,10 @@ t_stat tty_reset (DEVICE *dptr);
t_stat ptr_boot (int32 unitno, DEVICE *dptr);
t_stat ptr_attach (UNIT *uptr, CONST char *cptr);
t_stat ptp_attach (UNIT *uptr, CONST char *cptr);
t_stat ptr_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
t_stat ptp_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
const char *ptr_description (DEVICE *dptr);
const char *ptp_description (DEVICE *dptr);
/* Character translation tables */
@ -161,7 +165,7 @@ UNIT ptr_unit = {
REG ptr_reg[] = {
{ ORDATAD (BUF, ptr_unit.buf, 18, "last data item processed") },
{ FLDATA (UC, ptr_uc, UC_V) },
{ FLDATAD (UC, ptr_uc, UC_V, "upper case/lower case state (shared)") },
{ FLDATAD (DONE, iosta, IOS_V_PTR, "device done flag") },
{ FLDATAD (RPLS, cpls, CPLS_V_PTR, "return restart pulse flag") },
{ ORDATA (HOLD, ptr_hold, 9), REG_HRO },
@ -188,7 +192,8 @@ DEVICE ptr_dev = {
1, 10, 31, 1, 8, 8,
NULL, NULL, &ptr_reset,
&ptr_boot, &ptr_attach, NULL,
NULL, 0
NULL, 0, 0, NULL,
NULL, NULL, &ptr_help, NULL, NULL, &ptr_description
};
/* PTP data structures
@ -226,7 +231,8 @@ DEVICE ptp_dev = {
1, 10, 31, 1, 8, 8,
NULL, NULL, &ptp_reset,
NULL, &ptp_attach, NULL,
NULL, 0
NULL, 0, 0, NULL,
NULL, NULL, &ptp_help, NULL, NULL, &ptp_description
};
/* TTI data structures
@ -458,7 +464,7 @@ ptr_leader = PTR_LEADER; /* set up leader */
if (sim_switches & SWMASK ('A'))
uptr->flags = uptr->flags | UNIT_ASCII;
else uptr->flags = uptr->flags & ~UNIT_ASCII;
sim_switches |= SWMASK ('R');
sim_switches &= ~SWMASK ('A'); /* Turn off A switch to avoid Append mode ambiguity */
return attach_unit (uptr, cptr);
}
@ -504,6 +510,29 @@ for (;;) {
return SCPE_OK; /* done */
}
t_stat ptr_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)
{
fprintf (st, "Paper Tape Reader (PTR)\n\n");
fprintf (st, "The paper tape reader (PTR) reads data from a disk file. The POS register\n");
fprintf (st, "specifies the number of the next data item to be read. Thus, by changing\n");
fprintf (st, "The paper tape reader supports the BOOT command. BOOT PTR copies the RIM\n");
fprintf (st, "loader into memory and starts it running. BOOT PTR loads into the field\n");
fprintf (st, "selected by TA<0:3> (the high order four bits of the address switches).\n\n");
fprintf (st, "The paper tape reader recognizes one switch at ATTACH time:\n\n");
fprintf (st, " ATT -A PTP <file> convert input characters from ASCII\n\n");
fprintf (st, "By default, the paper tape reader does no conversions on input characters.\n\n");
fprint_set_help (st, dptr);
fprint_show_help (st, dptr);
fprint_reg_help (st, dptr);
return SCPE_OK;
}
const char *ptr_description (DEVICE *dptr)
{
return "Paper Tape Reader";
}
/* Paper tape punch: IOT routine */
int32 ptp (int32 inst, int32 dev, int32 dat)
@ -582,9 +611,31 @@ t_stat ptp_attach (UNIT *uptr, CONST char *cptr)
if (sim_switches & SWMASK ('A'))
uptr->flags = uptr->flags | UNIT_ASCII;
else uptr->flags = uptr->flags & ~UNIT_ASCII;
sim_switches |= SWMASK ('A'); /* Default to Append to existing file */
return attach_unit (uptr, cptr);
}
t_stat ptp_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)
{
fprintf (st, "Paper Tape Punch (PTP)\n\n");
fprintf (st, "The paper tape punch (PTP) writes data to a disk file. The POS register\n");
fprintf (st, "specifies the number of the next data item to be written. Thus, by changing\n");
fprintf (st, "POS, the user can backspace or advance the punch.\n\n");
fprintf (st, "The paper tape punch recognizes two switches at ATTACH time:\n\n");
fprintf (st, " ATT -A PTP <file> output characters as ASCII text\n");
fprintf (st, " ATT -N PTP <file> create a new (empty) output file\n\n");
fprintf (st, "By default, the paper tape punch punches files with no conversions.\n\n");
fprint_set_help (st, dptr);
fprint_show_help (st, dptr);
fprint_reg_help (st, dptr);
return SCPE_OK;
}
const char *ptp_description (DEVICE *dptr)
{
return "Paper Tape Punch";
}
/* Typewriter IOT routines */
int32 tti (int32 inst, int32 dev, int32 dat)

View file

@ -949,7 +949,8 @@ return SCPE_OK;
static t_stat lp20_attach (UNIT *uptr, CONST char *cptr)
{
t_stat reason;
sim_switches |= SWMASK ('A'); /* position to EOF */
reason = attach_unit (uptr, cptr); /* attach file */
if (reason == SCPE_OK) {
sim_fseek (uptr->fileref, 0, SEEK_END);

View file

@ -189,6 +189,7 @@ t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
t_stat reason;
lpt_csr = lpt_csr & ~CSR_ERR;
sim_switches |= SWMASK('A');
reason = attach_unit (uptr, cptr);
if ((lpt_unit.flags & UNIT_ATT) == 0)
lpt_csr = lpt_csr | CSR_ERR;
@ -206,7 +207,9 @@ t_stat lpt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cpt
fprintf (st, "Line Printer (LPT)\n\n");
fprintf (st, "The line printer (LPT) writes data to a disk file. The POS register specifies\n");
fprintf (st, "the number of the next data item to be written. Thus, by changing POS, the\n");
fprintf (st, "user can backspace or advance the printer.\n");
fprintf (st, "user can backspace or advance the printer.\n\n");
fprintf (st, "The default position after ATTACH is to position at the end of an existing file.\n");
fprintf (st, "A new file can be created if you attach with the -N switch.\n\n");
fprint_set_help (st, dptr);
fprint_show_help (st, dptr);
fprint_reg_help (st, dptr);

View file

@ -406,7 +406,9 @@ t_stat ptp_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cpt
fprintf (st, "PC11 Paper Tape Punch (PTP)\n\n");
fprintf (st, "The paper tape punch (PTP) writes data to a disk file. The POS register\n");
fprintf (st, "specifies the number of the next data item to be written. Thus, by changing\n");
fprintf (st, "POS, the user can backspace or advance the punch.\n");
fprintf (st, "POS, the user can backspace or advance the punch.\n\n");
fprintf (st, "The default position after ATTACH is to position at the end of an existing file.\n");
fprintf (st, "A new file can be created if you attach with the -N switch.\n\n");
fprint_set_help (st, dptr);
fprint_show_help (st, dptr);
fprint_reg_help (st, dptr);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.