PDP4, PDP7, PDP9, PDP15: 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:35:09 -07:00
parent 7ebd22edaa
commit 3a38d38ce7
3 changed files with 28 additions and 3 deletions

View file

@ -91,6 +91,7 @@ int32 lp62_66 (int32 dev, int32 pulse, int32 dat);
int32 lp62_iors (void); int32 lp62_iors (void);
t_stat lp62_svc (UNIT *uptr); t_stat lp62_svc (UNIT *uptr);
t_stat lp62_reset (DEVICE *dptr); t_stat lp62_reset (DEVICE *dptr);
t_stat lp62_attach (UNIT *uptr, CONST char *cptr);
/* Type 62 LPT data structures /* Type 62 LPT data structures
@ -130,7 +131,7 @@ DEVICE lp62_dev = {
"LPT", &lp62_unit, lp62_reg, lp62_mod, "LPT", &lp62_unit, lp62_reg, lp62_mod,
1, 10, 31, 1, 8, 8, 1, 10, 31, 1, 8, 8,
NULL, NULL, &lp62_reset, NULL, NULL, &lp62_reset,
NULL, NULL, NULL, NULL, &lp62_attach, NULL,
&lp62_dib, DEV_DISABLE &lp62_dib, DEV_DISABLE
}; };
@ -235,6 +236,14 @@ lp62_ovrpr = 0; /* clear overprint */
return SCPE_OK; return SCPE_OK;
} }
/* Attach routine */
t_stat lp62_attach (UNIT *uptr, CONST char *cptr)
{
sim_switches |= SWMASK ('A');
return attach_unit (uptr, cptr);
}
/* IORS routine */ /* IORS routine */
int32 lp62_iors (void) int32 lp62_iors (void)
@ -482,6 +491,7 @@ t_stat lp647_attach (UNIT *uptr, CONST char *cptr)
{ {
t_stat reason; t_stat reason;
sim_switches |= SWMASK ('A');
reason = attach_unit (uptr, cptr); reason = attach_unit (uptr, cptr);
lp647_err = (lp647_unit.flags & UNIT_ATT)? 0: 1; /* clr/set error */ lp647_err = (lp647_unit.flags & UNIT_ATT)? 0: 1; /* clr/set error */
return reason; return reason;
@ -646,6 +656,7 @@ t_stat lp09_attach (UNIT *uptr, CONST char *cptr)
{ {
t_stat reason; t_stat reason;
sim_switches |= SWMASK ('A');
reason = attach_unit (uptr, cptr); reason = attach_unit (uptr, cptr);
lp09_err = (lp09_unit.flags & UNIT_ATT)? 0: 1; /* clr/set error */ lp09_err = (lp09_unit.flags & UNIT_ATT)? 0: 1; /* clr/set error */
return reason; return reason;
@ -694,6 +705,7 @@ int32 lp15_66 (int32 dev, int32 pulse, int32 dat);
int32 lp15_iors (void); int32 lp15_iors (void);
t_stat lp15_svc (UNIT *uptr); t_stat lp15_svc (UNIT *uptr);
t_stat lp15_reset (DEVICE *dptr); t_stat lp15_reset (DEVICE *dptr);
t_stat lp15_attach (UNIT *uptr, CONST char *cptr);
int32 lp15_updsta (int32 New); int32 lp15_updsta (int32 New);
@ -736,7 +748,7 @@ DEVICE lp15_dev = {
"LPT", &lp15_unit, lp15_reg, lp15_mod, "LPT", &lp15_unit, lp15_reg, lp15_mod,
1, 10, 31, 1, 8, 8, 1, 10, 31, 1, 8, 8,
NULL, NULL, &lp15_reset, NULL, NULL, &lp15_reset,
NULL, NULL, NULL, NULL, &lp15_attach, NULL,
&lp15_dib, DEV_DISABLE &lp15_dib, DEV_DISABLE
}; };
@ -878,6 +890,14 @@ lp15_updsta (0); /* update status */
return SCPE_OK; return SCPE_OK;
} }
/* Attach routine */
t_stat lp15_attach (UNIT *uptr, CONST char *cptr)
{
sim_switches |= SWMASK ('A');
return attach_unit (uptr, cptr);
}
/* IORS routine */ /* IORS routine */
int32 lp15_iors (void) int32 lp15_iors (void)

View file

@ -650,9 +650,11 @@ return ((TST_INT (PTR)? IOS_PTR: 0)
t_stat ptr_attach (UNIT *uptr, CONST char *cptr) t_stat ptr_attach (UNIT *uptr, CONST char *cptr)
{ {
t_stat reason; t_stat reason;
int32 saved_switches = sim_switches;
sim_switches |= SWMASK ('R'); sim_switches &= ~SWMASK ('A');
reason = attach_unit (uptr, cptr); reason = attach_unit (uptr, cptr);
sim_switches = saved_switches;
if (reason != SCPE_OK) if (reason != SCPE_OK)
return reason; return reason;
ptr_err = 0; /* attach clrs error */ ptr_err = 0; /* attach clrs error */
@ -969,10 +971,13 @@ return SCPE_OK;
t_stat ptp_attach (UNIT *uptr, CONST char *cptr) t_stat ptp_attach (UNIT *uptr, CONST char *cptr)
{ {
t_stat reason; t_stat reason;
int32 saved_switches = sim_switches;
sim_switches |= SWMASK ('A'); /* Default to Append to existing file */
reason = attach_unit (uptr, cptr); reason = attach_unit (uptr, cptr);
if (reason != SCPE_OK) if (reason != SCPE_OK)
return reason; return reason;
sim_switches = saved_switches;
ptp_err = 0; ptp_err = 0;
ptp_unit.flags = ptp_unit.flags & ~UNIT_PASCII; ptp_unit.flags = ptp_unit.flags & ~UNIT_PASCII;
if (sim_switches & SWMASK ('A')) if (sim_switches & SWMASK ('A'))

Binary file not shown.