PDP11: Clarify TC device attach and detach read only & write update messages

As discussed in #1034
This commit is contained in:
Mark Pizzolato 2021-04-16 11:33:42 -07:00
parent 7276dc1f8d
commit af0754f93a

View file

@ -127,7 +127,7 @@
#define STATE u3 /* unit state */
#define LASTT u4 /* last time update */
#define WRITTEN u5 /* device buffer is dirty and needs flushing */
#define UNIT_WPRT (UNIT_WLK | UNIT_RO) /* write protect */
#define UNIT_WPRT (UNIT_WLK) /* write protect */
/* System independent DECtape constants */
@ -313,6 +313,8 @@ void dt_stopunit (UNIT *uptr);
int32 dt_comobv (int32 val);
int32 dt_csum (UNIT *uptr, int32 blk);
int32 dt_gethdr (UNIT *uptr, int32 blk, int32 relpos);
t_stat dt_set_writelock (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat dt_show_writelock (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
t_stat dt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
const char *dt_description (DEVICE *dptr);
@ -381,10 +383,10 @@ REG dt_reg[] = {
};
MTAB dt_mod[] = {
{ UNIT_WLK, 0, "write enabled", "WRITEENABLED",
NULL, NULL, NULL, "Write enable tape drive" },
{ UNIT_WLK, UNIT_WLK, "write locked", "LOCKED",
NULL, NULL, NULL, "Write lock tape drive" },
{ MTAB_XTD|MTAB_VUN, 0, "write enabled", "WRITEENABLED",
&dt_set_writelock, &dt_show_writelock, NULL, "Write enable tape drive" },
{ MTAB_XTD|MTAB_VUN, 1, NULL, "LOCKED",
&dt_set_writelock, NULL, NULL, "Write enable tape drive" },
{ UNIT_8FMT + UNIT_11FMT, 0, "18b", NULL },
{ UNIT_8FMT + UNIT_11FMT, UNIT_8FMT, "12b", NULL },
{ UNIT_8FMT + UNIT_11FMT, UNIT_11FMT, "16b", NULL },
@ -1269,6 +1271,8 @@ uint32 ba, sz, k, *fbuf;
int32 u = uptr - dt_dev.units;
t_stat r;
if (uptr->flags & UNIT_WPRT) /* Write locked drive? */
sim_switches |= SWMASK ('R'); /* Force Read Only Open */
r = attach_unit (uptr, cptr); /* attach */
if (r != SCPE_OK) /* fail? */
return r;
@ -1354,6 +1358,7 @@ int32 k;
uint32 ba, *fbuf;
if (uptr->WRITTEN && uptr->hwmark && ((uptr->flags & UNIT_RO)== 0)) { /* any data? */
sim_printf ("%s: writing buffer to file\n", sim_uname (uptr));
rewind (uptr->fileref); /* start of file */
fbuf = (uint32 *) uptr->filebuf; /* file buffer */
if (uptr->flags & UNIT_8FMT) { /* 12b? */
@ -1405,18 +1410,33 @@ if (sim_is_active (uptr)) { /* active? cancel op */
}
uptr->STATE = 0, uptr->pos = 0;
}
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */
sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u);
dt_flush (uptr);
} /* end if hwmark */
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) /* any data? */
dt_flush (uptr); /* end if hwmark */
free (uptr->filebuf); /* release buf */
uptr->flags = uptr->flags & ~UNIT_BUF; /* clear buf flag */
uptr->flags = uptr->flags & ~(UNIT_BUF | UNIT_RO); /* clear buf & read only flags */
uptr->filebuf = NULL; /* clear buf ptr */
uptr->flags = (uptr->flags | UNIT_11FMT) & ~UNIT_8FMT; /* default fmt */
uptr->capac = DT_CAPAC; /* default size */
return detach_unit (uptr);
}
t_stat dt_set_writelock (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
if ((uptr->flags & UNIT_ATT) != 0)
return sim_messagef (SCPE_ALATT, "%s: Already attached\n", sim_uname (uptr));
if (val)
uptr->flags |= UNIT_WPRT;
else
uptr->flags &= ~UNIT_WPRT;
return SCPE_OK;
}
t_stat dt_show_writelock (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
{
fprintf (st, "write %s", (uptr->flags & (UNIT_WPRT | UNIT_RO)) ? "locked" : "enabled");
return SCPE_OK;
}
t_stat dt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)
{
const char *text2;