Added dynflags to the unit structure to track dynamic flags used by scp & libraries. This avoids expanding the set of unit flags and encroaching on the available user flags .
This commit is contained in:
parent
4f19d08869
commit
19c4ccbf10
4 changed files with 38 additions and 31 deletions
4
scp.c
4
scp.c
|
@ -3115,7 +3115,7 @@ if (dptr == NULL) /* found dev? */
|
|||
if (uptr == NULL) /* valid unit? */
|
||||
return SCPE_NXUN;
|
||||
if ((uptr->flags & UNIT_ATT) && /* already attached? */
|
||||
!(uptr->flags & UNIT_ATTMULT)) { /* and only single attachable */
|
||||
!(uptr->dynflags & UNIT_ATTMULT)) { /* and only single attachable */
|
||||
r = scp_detach_unit (dptr, uptr); /* detach it */
|
||||
if (r != SCPE_OK) /* error? */
|
||||
return r;
|
||||
|
@ -3471,6 +3471,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru devices */
|
|||
WRITE_I (uptr->u5); /* [V3.0] more unit */
|
||||
WRITE_I (uptr->u6);
|
||||
WRITE_I (uptr->flags); /* [V2.10] flags */
|
||||
WRITE_I (uptr->dynflags);
|
||||
WRITE_I (uptr->capac); /* [V3.5] capacity */
|
||||
if (uptr->flags & UNIT_ATT) {
|
||||
fputs (uptr->filename, sfile);
|
||||
|
@ -3673,6 +3674,7 @@ for ( ;; ) { /* device loop */
|
|||
READ_I (uptr->u5); /* [V3.0+] more dev spec */
|
||||
READ_I (uptr->u6);
|
||||
READ_I (flg); /* [V2.10+] unit flags */
|
||||
READ_I (uptr->dynflags);
|
||||
old_capac = uptr->capac; /* save current capacity */
|
||||
if (v35) { /* [V3.5+] capacity */
|
||||
READ_I (uptr->capac);
|
||||
|
|
|
@ -1032,14 +1032,14 @@ return sim_os_ttinit ();
|
|||
t_stat sim_ttrun (void)
|
||||
{
|
||||
if (!sim_con_tmxr.ldsc->uptr) { /* If simulator didn't declare its input polling unit */
|
||||
sim_con_unit.flags &= ~UNIT_TM_POLL; /* we can't poll asynchronously */
|
||||
sim_con_unit.flags |= TMUF_NOASYNCH; /* disable asynchronous behavior */
|
||||
sim_con_unit.dynflags &= ~UNIT_TM_POLL; /* we can't poll asynchronously */
|
||||
sim_con_unit.dynflags |= TMUF_NOASYNCH; /* disable asynchronous behavior */
|
||||
}
|
||||
else {
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
if (sim_asynch_enabled) {
|
||||
sim_con_tmxr.ldsc->uptr->flags |= UNIT_TM_POLL;/* flag console input device as a polling unit */
|
||||
sim_con_unit.flags |= UNIT_TM_POLL; /* flag as polling unit */
|
||||
sim_con_tmxr.ldsc->uptr->dynflags |= UNIT_TM_POLL;/* flag console input device as a polling unit */
|
||||
sim_con_unit.dynflags |= UNIT_TM_POLL; /* flag as polling unit */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
20
sim_defs.h
20
sim_defs.h
|
@ -373,6 +373,7 @@ struct sim_unit {
|
|||
uint32 hwmark; /* high water mark */
|
||||
int32 time; /* time out */
|
||||
uint32 flags; /* flags */
|
||||
uint32 dynflags; /* dynamic flags */
|
||||
t_addr capac; /* capacity */
|
||||
t_addr pos; /* file position */
|
||||
void (*io_flush)(struct sim_unit *up);/* io flush routine */
|
||||
|
@ -426,15 +427,18 @@ struct sim_unit {
|
|||
#define UNIT_RAW 0010000 /* raw mode */
|
||||
#define UNIT_TEXT 0020000 /* text mode */
|
||||
#define UNIT_IDLE 0040000 /* idle eligible */
|
||||
#define UNIT_ATTMULT 0100000 /* Allow multiple attach commands */
|
||||
#define UNIT_TM_POLL 0400000 /* TMXR Polling unit */
|
||||
/* This flag is ONLY set dynamically */
|
||||
/* it should NOT be set via initialization */
|
||||
|
||||
#define UNIT_UFMASK_31 (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF_31) - 1))
|
||||
#define UNIT_UFMASK (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF) - 1))
|
||||
#define UNIT_RFLAGS (UNIT_UFMASK|UNIT_DIS) /* restored flags */
|
||||
|
||||
/* Unit dynamic flags (dynflags) */
|
||||
|
||||
/* These flags are only set dynamically */
|
||||
|
||||
#define UNIT_ATTMULT 0000001 /* Allow multiple attach commands */
|
||||
#define UNIT_TM_POLL 0000002 /* TMXR Polling unit */
|
||||
|
||||
/* Register data structure */
|
||||
|
||||
struct sim_reg {
|
||||
|
@ -563,7 +567,7 @@ struct sim_fileref {
|
|||
|
||||
/* The following macros define structure contents */
|
||||
|
||||
#define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,0,0,(fl),(cap),0,NULL,0,0
|
||||
#define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,0,0,(fl),0,(cap),0,NULL,0,0
|
||||
|
||||
#if defined (__STDC__) || defined (_WIN32)
|
||||
#define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1, NULL
|
||||
|
@ -689,7 +693,7 @@ extern int32 sim_asynch_inst_latency;
|
|||
if ((uptr)->a_cancel) \
|
||||
(uptr)->a_cancel (uptr); \
|
||||
else { \
|
||||
if (((uptr)->flags & UNIT_TM_POLL) && \
|
||||
if (((uptr)->dynflags & UNIT_TM_POLL) && \
|
||||
!((uptr)->next) && !((uptr)->a_next)) { \
|
||||
(uptr)->a_polling_now = FALSE; \
|
||||
sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \
|
||||
|
@ -702,7 +706,7 @@ extern int32 sim_asynch_inst_latency;
|
|||
if ((uptr)->a_cancel) \
|
||||
(uptr)->a_cancel (uptr); \
|
||||
else { \
|
||||
if (((uptr)->flags & UNIT_TM_POLL) && \
|
||||
if (((uptr)->dynflags & UNIT_TM_POLL) && \
|
||||
!((uptr)->next) && !((uptr)->a_next)) { \
|
||||
(uptr)->a_polling_now = FALSE; \
|
||||
sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \
|
||||
|
@ -780,7 +784,7 @@ extern int32 sim_asynch_inst_latency;
|
|||
#endif
|
||||
#define AIO_EVENT_BEGIN(uptr) \
|
||||
do { \
|
||||
int __was_poll = uptr->flags & UNIT_TM_POLL
|
||||
int __was_poll = uptr->dynflags & UNIT_TM_POLL
|
||||
#define AIO_EVENT_COMPLETE(uptr, reason) \
|
||||
if (__was_poll) { \
|
||||
pthread_mutex_lock (&sim_tmxr_poll_lock); \
|
||||
|
|
37
sim_tmxr.c
37
sim_tmxr.c
|
@ -744,15 +744,15 @@ if (mp->last_poll_time == 0) { /* first poll initializa
|
|||
if (!uptr) /* Attached ? */
|
||||
return -1; /* No connections are possinle! */
|
||||
|
||||
if (!(uptr->flags & TMUF_NOASYNCH)) { /* if asynch not disabled */
|
||||
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
if (!(uptr->dynflags & TMUF_NOASYNCH)) { /* if asynch not disabled */
|
||||
uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
sim_cancel (uptr);
|
||||
}
|
||||
for (i=0; i < mp->lines; i++) {
|
||||
uptr = mp->ldsc[i].uptr ? mp->ldsc[i].uptr : mp->uptr;
|
||||
|
||||
if (!(mp->uptr->flags & TMUF_NOASYNCH)) { /* if asynch not disabled */
|
||||
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
if (!(mp->uptr->dynflags & TMUF_NOASYNCH)) { /* if asynch not disabled */
|
||||
uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
sim_cancel (uptr);
|
||||
}
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ for (i = 0; i < mp->lines; i++) { /* loop thru lines */
|
|||
if (nbytes == 0) { /* buf empty? enab line */
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
UNIT *ruptr = lp->uptr ? lp->uptr : lp->mp->uptr;
|
||||
if ((ruptr->flags & UNIT_TM_POLL) &&
|
||||
if ((ruptr->dynflags & UNIT_TM_POLL) &&
|
||||
sim_asynch_enabled &&
|
||||
tmxr_rqln (lp))
|
||||
_sim_activate (ruptr, 0);
|
||||
|
@ -1858,8 +1858,8 @@ t_stat tmxr_set_console_input_unit (UNIT *uptr)
|
|||
extern TMLN sim_con_ldsc;
|
||||
|
||||
sim_con_ldsc.uptr = uptr;
|
||||
if (!(uptr->flags & UNIT_TM_POLL)) {
|
||||
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
if (!(uptr->dynflags & UNIT_TM_POLL)) {
|
||||
uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
|
||||
}
|
||||
else
|
||||
sim_cancel (uptr);
|
||||
|
@ -1991,7 +1991,7 @@ while (sim_asynch_enabled) {
|
|||
FD_ZERO (&errorfds);
|
||||
for (i=max_socket_fd=socket_count=0; i<tmxr_open_device_count; ++i) {
|
||||
mp = tmxr_open_devices[i];
|
||||
if ((mp->master) && (mp->uptr->flags&UNIT_TM_POLL)) {
|
||||
if ((mp->master) && (mp->uptr->dynflags&UNIT_TM_POLL)) {
|
||||
units[socket_count] = mp->uptr;
|
||||
sockets[socket_count] = mp->master;
|
||||
FD_SET (mp->master, &readfds);
|
||||
|
@ -2574,13 +2574,13 @@ if ((mp->lines > 1) ||
|
|||
((mp->master == 0) &&
|
||||
(mp->ldsc[0].connecting == 0) &&
|
||||
(mp->ldsc[0].serport == 0)))
|
||||
uptr->flags = uptr->flags | UNIT_ATTMULT; /* allow multiple attach commands */
|
||||
uptr->flags = uptr->dynflags | UNIT_ATTMULT; /* allow multiple attach commands */
|
||||
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
if (!async) /* if asynch disabled */
|
||||
uptr->flags |= TMUF_NOASYNCH; /* tag as no asynch */
|
||||
if (!async || (uptr->flags & TMUF_NOASYNCH)) /* if asynch disabled */
|
||||
uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */
|
||||
#else
|
||||
uptr->flags |= TMUF_NOASYNCH; /* tag as no asynch */
|
||||
uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */
|
||||
#endif
|
||||
|
||||
if (mp->dptr == NULL) /* has device been set? */
|
||||
|
@ -2718,10 +2718,11 @@ for (i=0; i < mp->lines; i++) {
|
|||
UNIT *uptr = mp->ldsc[i].uptr ? mp->ldsc[i].uptr : mp->uptr;
|
||||
UNIT *o_uptr = mp->ldsc[i].o_uptr ? mp->ldsc[i].o_uptr : mp->uptr;
|
||||
|
||||
uptr->flags &= ~UNIT_TM_POLL; /* no polling */
|
||||
o_uptr->flags &= ~UNIT_TM_POLL; /* no polling */
|
||||
uptr->dynflags &= ~UNIT_TM_POLL; /* no polling */
|
||||
o_uptr->dynflags &= ~UNIT_TM_POLL; /* no polling */
|
||||
}
|
||||
uptr->flags &= ~(UNIT_ATT|UNIT_TM_POLL|TMUF_NOASYNCH); /* not attached, no polling, not asynch disabled */
|
||||
uptr->flags &= ~(UNIT_ATT); /* not attached */
|
||||
uptr->dynflags &= ~(UNIT_TM_POLL|TMUF_NOASYNCH); /* no polling, not asynch disabled */
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
|
@ -2729,7 +2730,7 @@ return SCPE_OK;
|
|||
t_stat tmxr_activate (UNIT *uptr, int32 interval)
|
||||
{
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
if ((!(uptr->flags & UNIT_TM_POLL)) ||
|
||||
if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
|
||||
(!sim_asynch_enabled)) {
|
||||
return _sim_activate (uptr, interval);
|
||||
}
|
||||
|
@ -2742,7 +2743,7 @@ return _sim_activate (uptr, interval);
|
|||
t_stat tmxr_activate_after (UNIT *uptr, int32 usecs_walltime)
|
||||
{
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
if ((!(uptr->flags & UNIT_TM_POLL)) ||
|
||||
if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
|
||||
(!sim_asynch_enabled)) {
|
||||
return _sim_activate_after (uptr, usecs_walltime);
|
||||
}
|
||||
|
@ -2755,7 +2756,7 @@ return _sim_activate_after (uptr, usecs_walltime);
|
|||
t_stat tmxr_clock_coschedule (UNIT *uptr, int32 interval)
|
||||
{
|
||||
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
|
||||
if ((!(uptr->flags & UNIT_TM_POLL)) ||
|
||||
if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
|
||||
(!sim_asynch_enabled)) {
|
||||
return sim_clock_coschedule (uptr, interval);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue