1
0
mirror of https://github.com/simh/simh.git synced 2026-01-26 04:01:38 +00:00

ALL: Standardize writelock behavior adding global UNIT_WLK & UNIT_WPRT

Historically this functionality was reimplemented within each
DEVICE simulator often with slightly different implementations
and inconsistencies.  Solving this globally within SCP required
changes in many places, but should henceforth be reasonably
managed.

As discussed in #1034
This commit is contained in:
Mark Pizzolato
2021-04-19 10:58:51 -07:00
parent 587b81bed4
commit a015e44c10
81 changed files with 413 additions and 467 deletions

View File

@@ -119,10 +119,8 @@
#include "pdp18b_defs.h"
#define DT_NUMDR 8 /* #drives */
#define UNIT_V_WLK (UNIT_V_UF + 0) /* write locked */
#define UNIT_V_8FMT (UNIT_V_UF + 1) /* 12b format */
#define UNIT_V_11FMT (UNIT_V_UF + 2) /* 16b format */
#define UNIT_WLK (1 << UNIT_V_WLK)
#define UNIT_V_8FMT (UNIT_V_UF + 0) /* 12b format */
#define UNIT_V_11FMT (UNIT_V_UF + 1) /* 16b format */
#define UNIT_8FMT (1 << UNIT_V_8FMT)
#define UNIT_11FMT (1 << UNIT_V_11FMT)
#define STATE u3 /* unit state */
@@ -130,7 +128,6 @@
#define WRITTEN u5 /* device buffer is dirty and needs flushing */
#define DT_WC 030 /* word count */
#define DT_CA 031 /* current addr */
#define UNIT_WPRT (UNIT_WLK | UNIT_RO) /* write protect */
/* System independent DECtape constants */
@@ -430,8 +427,10 @@ REG dt_reg[] = {
};
MTAB dt_mod[] = {
{ UNIT_WLK, 0, "write enabled", "WRITEENABLED", NULL },
{ UNIT_WLK, UNIT_WLK, "write locked", "LOCKED", NULL },
{ MTAB_XTD|MTAB_VUN, 0, "write enabled", "WRITEENABLED",
&set_writelock, &show_writelock, NULL, "Write enable drive" },
{ MTAB_XTD|MTAB_VUN, 1, NULL, "LOCKED",
&set_writelock, NULL, NULL, "Write enable drive" },
{ UNIT_8FMT + UNIT_11FMT, 0, "18b", NULL, NULL },
{ UNIT_8FMT + UNIT_11FMT, UNIT_8FMT, "12b", NULL, NULL },
{ UNIT_8FMT + UNIT_11FMT, UNIT_11FMT, "16b", NULL, NULL },
@@ -564,8 +563,8 @@ else if ((pulse & 044) == 004) { /* MMLC */
if ((uptr == NULL) || /* invalid? */
((uptr->flags) & UNIT_DIS) || /* disabled? */
(fnc >= FNC_WMRK) || /* write mark? */
((fnc == FNC_WRIT) && (uptr->flags & UNIT_WLK)) ||
((fnc == FNC_WALL) && (uptr->flags & UNIT_WLK)))
((fnc == FNC_WRIT) && (uptr->flags & UNIT_WPRT)) ||
((fnc == FNC_WALL) && (uptr->flags & UNIT_WPRT)))
dt_seterr (uptr, DTB_SEL); /* select err */
else dt_newsa (dtsa);
}
@@ -1515,6 +1514,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: %s\n", sim_uname (uptr), uptr->filename);
rewind (uptr->fileref); /* start of file */
fbuf = (uint32 *) uptr->filebuf; /* file buffer */
if (uptr->flags & UNIT_8FMT) { /* 12b? */
@@ -1564,10 +1564,8 @@ if (sim_is_active (uptr)) {
}
uptr->STATE = 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->filebuf = NULL; /* clear buf ptr */

View File

@@ -184,8 +184,10 @@ REG mt_reg[] = {
};
MTAB mt_mod[] = {
{ MTUF_WLK, 0, "write enabled", "WRITEENABLED", NULL },
{ MTUF_WLK, MTUF_WLK, "write locked", "LOCKED", NULL },
{ MTAB_XTD|MTAB_VUN, 0, "write enabled", "WRITEENABLED",
&set_writelock, &show_writelock, NULL, "Write ring in place" },
{ MTAB_XTD|MTAB_VUN, 1, NULL, "LOCKED",
&set_writelock, NULL, NULL, "no Write ring in place" },
{ MTAB_XTD|MTAB_VUN, 0, "FORMAT", "FORMAT",
&sim_tape_set_fmt, &sim_tape_show_fmt, NULL },
{ MTAB_XTD|MTAB_VUN, 0, "TCAPACITY", "TCAPACITY",

View File

@@ -59,11 +59,8 @@
/* Unit specific flags */
#define UNIT_V_WLK (UNIT_V_UF + 0) /* hwre write lock */
#define UNIT_V_RP03 (UNIT_V_UF + 1) /* RP03 */
#define UNIT_WLK (1u << UNIT_V_WLK)
#define UNIT_V_RP03 (UNIT_V_UF + 0) /* RP03 */
#define UNIT_RP03 (1u << UNIT_V_RP03)
#define UNIT_WPRT (UNIT_WLK | UNIT_RO) /* write protect */
/* Parameters in the unit descriptor */
@@ -214,8 +211,10 @@ REG rp_reg[] = {
MTAB rp_mod[] = {
{ UNIT_RP03, 0, "RP02", "RP02", &rp_set_size },
{ UNIT_RP03, UNIT_RP03, "RP03", "RP03", &rp_set_size },
{ UNIT_WLK, 0, "write enabled", "WRITEENABLED", NULL },
{ UNIT_WLK, UNIT_WLK, "write locked", "LOCKED", NULL },
{ MTAB_XTD|MTAB_VUN, 0, "write enabled", "WRITEENABLED",
&set_writelock, &show_writelock, NULL, "Write enable disk drive" },
{ MTAB_XTD|MTAB_VUN, 1, NULL, "LOCKED",
&set_writelock, NULL, NULL, "Write enable disk drive" },
{ MTAB_XTD|MTAB_VDV, 0, "DEVNO", "DEVNO", &set_devno, &show_devno },
{ 0 }
};