mirror of
https://github.com/simh/simh.git
synced 2026-04-27 12:28:49 +00:00
SCP: Assure only 5 UNIT fields can be initialized beyond the UDATA macro
The simh v3 UNIT structure only provided UNIT fields wait, u3, u4, u5 and u6 available for static initialization beyond what is provided by the UDATA macro. This change assures that here as well. If a simulator developer needs to initialize UNIT fields beyond what is available here and via the UDATA macro, then explicit code usually in the DEVICE reset routine should be used to initialize those fields. Fix the CDC1700 simulator which statically initialized additional UNIT fields.
This commit is contained in:
@@ -325,30 +325,14 @@ IO_DEVICE CDdev = IODEV(NULL, "1733-2", 1733, 3, 0xFF, 0,
|
||||
*/
|
||||
|
||||
UNIT cd_unit[] = {
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[0], &cd_unit[1]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[0], &cd_unit[0]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[1], &cd_unit[3]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[1], &cd_unit[2]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[2], &cd_unit[5]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[2], &cd_unit[4]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[3], &cd_unit[7]
|
||||
},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE),
|
||||
0, 0, 0, 0, 0, &CDunits[3], &cd_unit[6]
|
||||
}
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)},
|
||||
{ UDATA(&cd_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_856_4, CD856_4_SIZE)}
|
||||
};
|
||||
|
||||
REG cd_reg[] = {
|
||||
@@ -1058,7 +1042,27 @@ static t_stat CDreset(DEVICE *dptr)
|
||||
t_stat cd_reset(DEVICE *dptr)
|
||||
{
|
||||
t_stat r = SCPE_OK;
|
||||
static t_bool Initialized = FALSE;
|
||||
|
||||
if (!Initialized) { /* Initialize additional UNIT state not done by UDATA macro */
|
||||
Initialized = TRUE;
|
||||
cd_unit[0].up7 = &CDunits[0];
|
||||
cd_unit[0].up8 = &cd_unit[1];
|
||||
cd_unit[1].up7 = &CDunits[0];
|
||||
cd_unit[1].up8 = &cd_unit[0];
|
||||
cd_unit[2].up7 = &CDunits[1];
|
||||
cd_unit[2].up8 = &cd_unit[3];
|
||||
cd_unit[3].up7 = &CDunits[1];
|
||||
cd_unit[3].up8 = &cd_unit[2];
|
||||
cd_unit[4].up7 = &CDunits[2];
|
||||
cd_unit[4].up8 = &cd_unit[5];
|
||||
cd_unit[5].up7 = &CDunits[2];
|
||||
cd_unit[5].up8 = &cd_unit[4];
|
||||
cd_unit[6].up7 = &CDunits[3];
|
||||
cd_unit[6].up8 = &cd_unit[7];
|
||||
cd_unit[7].up7 = &CDunits[3];
|
||||
cd_unit[7].up8 = &cd_unit[6];
|
||||
}
|
||||
if (IOFWinitialized)
|
||||
if ((dptr->flags & DEV_DIS) == 0)
|
||||
if ((r = checkReset(dptr, CDdev.iod_equip) == SCPE_OK)) {
|
||||
|
||||
@@ -249,12 +249,8 @@ IO_DEVICE DPdev = IODEV(NULL, "1738-B", 1738, 3, 0xFF, 0,
|
||||
*/
|
||||
|
||||
UNIT dp_unit[] = {
|
||||
{ UDATA(&dp_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_854, DP854_SIZE),
|
||||
0, 0, 0, 0, 0, &DPunits[0]
|
||||
},
|
||||
{ UDATA(&dp_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_854, DP854_SIZE),
|
||||
0, 0, 0, 0, 0, &DPunits[1]
|
||||
},
|
||||
{ UDATA(&dp_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_854, DP854_SIZE)},
|
||||
{ UDATA(&dp_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+UNIT_854, DP854_SIZE)},
|
||||
};
|
||||
|
||||
REG dp_reg[] = {
|
||||
@@ -812,6 +808,8 @@ t_stat dp_reset(DEVICE *dptr)
|
||||
{
|
||||
t_stat r;
|
||||
|
||||
dp_unit[0].up7 = &DPunits[0];
|
||||
dp_unit[1].up7 = &DPunits[1];
|
||||
if (IOFWinitialized)
|
||||
if ((dptr->flags & DEV_DIS) == 0)
|
||||
if ((r = checkReset(dptr, DPdev.iod_equip)) != SCPE_OK)
|
||||
|
||||
Reference in New Issue
Block a user