mirror of
https://github.com/simh/simh.git
synced 2026-01-11 23:52:58 +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:
parent
52cfa2bba8
commit
700ac6719d
@ -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)
|
||||
|
||||
20
sim_defs.h
20
sim_defs.h
@ -594,11 +594,6 @@ struct UNIT {
|
||||
void (*io_flush)(UNIT *up); /* io flush routine */
|
||||
uint32 iostarttime; /* I/O start time */
|
||||
int32 buf; /* buffer */
|
||||
int32 wait; /* wait */
|
||||
int32 u3; /* device specific */
|
||||
int32 u4; /* device specific */
|
||||
int32 u5; /* device specific */
|
||||
int32 u6; /* device specific */
|
||||
void *up7; /* device specific */
|
||||
void *up8; /* device specific */
|
||||
uint16 us9; /* device specific */
|
||||
@ -631,6 +626,14 @@ struct UNIT {
|
||||
double a_due_gtime; /* due time (in instructions) for timer event */
|
||||
double a_usec_delay; /* time delay for timer event */
|
||||
#endif
|
||||
/* Everything above here in the UNIT structure is within the scope of the UDATA
|
||||
macro initializer, if a simulator developer wants to initialize any of these
|
||||
values, they must be done by explicit code usually in a device reset routine */
|
||||
int32 wait; /* wait */
|
||||
int32 u3; /* device specific */
|
||||
int32 u4; /* device specific */
|
||||
int32 u5; /* device specific */
|
||||
int32 u6; /* device specific */
|
||||
};
|
||||
|
||||
/* Unit flags */
|
||||
@ -911,7 +914,12 @@ struct MEMFILE {
|
||||
|
||||
*/
|
||||
|
||||
#define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,NULL,0,0,(fl),0,(cap),0,NULL,0,0
|
||||
#ifdef SIM_ASYNCH_IO
|
||||
#define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,NULL,0,0,(fl),0,(cap),0,NULL,0,0,NULL,NULL,0,0,NULL,NULL,NULL,0,0,0,NULL,0,NULL,NULL,0,NULL,\
|
||||
NULL,NULL,NULL,0,NULL,0,0,0,0,0
|
||||
#else
|
||||
#define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,NULL,0,0,(fl),0,(cap),0,NULL,0,0,NULL,NULL,0,0,NULL,NULL,NULL,0,0,0,NULL,0,NULL,NULL,0,NULL
|
||||
#endif
|
||||
|
||||
/* Register initialization macros.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user