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:
Mark Pizzolato 2013-01-18 09:46:13 -08:00
parent 4f19d08869
commit 19c4ccbf10
4 changed files with 38 additions and 31 deletions

4
scp.c
View file

@ -3115,7 +3115,7 @@ if (dptr == NULL) /* found dev? */
if (uptr == NULL) /* valid unit? */ if (uptr == NULL) /* valid unit? */
return SCPE_NXUN; return SCPE_NXUN;
if ((uptr->flags & UNIT_ATT) && /* already attached? */ 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 */ r = scp_detach_unit (dptr, uptr); /* detach it */
if (r != SCPE_OK) /* error? */ if (r != SCPE_OK) /* error? */
return r; 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->u5); /* [V3.0] more unit */
WRITE_I (uptr->u6); WRITE_I (uptr->u6);
WRITE_I (uptr->flags); /* [V2.10] flags */ WRITE_I (uptr->flags); /* [V2.10] flags */
WRITE_I (uptr->dynflags);
WRITE_I (uptr->capac); /* [V3.5] capacity */ WRITE_I (uptr->capac); /* [V3.5] capacity */
if (uptr->flags & UNIT_ATT) { if (uptr->flags & UNIT_ATT) {
fputs (uptr->filename, sfile); fputs (uptr->filename, sfile);
@ -3673,6 +3674,7 @@ for ( ;; ) { /* device loop */
READ_I (uptr->u5); /* [V3.0+] more dev spec */ READ_I (uptr->u5); /* [V3.0+] more dev spec */
READ_I (uptr->u6); READ_I (uptr->u6);
READ_I (flg); /* [V2.10+] unit flags */ READ_I (flg); /* [V2.10+] unit flags */
READ_I (uptr->dynflags);
old_capac = uptr->capac; /* save current capacity */ old_capac = uptr->capac; /* save current capacity */
if (v35) { /* [V3.5+] capacity */ if (v35) { /* [V3.5+] capacity */
READ_I (uptr->capac); READ_I (uptr->capac);

View file

@ -1032,14 +1032,14 @@ return sim_os_ttinit ();
t_stat sim_ttrun (void) t_stat sim_ttrun (void)
{ {
if (!sim_con_tmxr.ldsc->uptr) { /* If simulator didn't declare its input polling unit */ 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.dynflags &= ~UNIT_TM_POLL; /* we can't poll asynchronously */
sim_con_unit.flags |= TMUF_NOASYNCH; /* disable asynchronous behavior */ sim_con_unit.dynflags |= TMUF_NOASYNCH; /* disable asynchronous behavior */
} }
else { else {
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
if (sim_asynch_enabled) { if (sim_asynch_enabled) {
sim_con_tmxr.ldsc->uptr->flags |= UNIT_TM_POLL;/* flag console input device as a polling unit */ sim_con_tmxr.ldsc->uptr->dynflags |= UNIT_TM_POLL;/* flag console input device as a polling unit */
sim_con_unit.flags |= UNIT_TM_POLL; /* flag as polling unit */ sim_con_unit.dynflags |= UNIT_TM_POLL; /* flag as polling unit */
} }
#endif #endif
} }

View file

@ -373,6 +373,7 @@ struct sim_unit {
uint32 hwmark; /* high water mark */ uint32 hwmark; /* high water mark */
int32 time; /* time out */ int32 time; /* time out */
uint32 flags; /* flags */ uint32 flags; /* flags */
uint32 dynflags; /* dynamic flags */
t_addr capac; /* capacity */ t_addr capac; /* capacity */
t_addr pos; /* file position */ t_addr pos; /* file position */
void (*io_flush)(struct sim_unit *up);/* io flush routine */ 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_RAW 0010000 /* raw mode */
#define UNIT_TEXT 0020000 /* text mode */ #define UNIT_TEXT 0020000 /* text mode */
#define UNIT_IDLE 0040000 /* idle eligible */ #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_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_UFMASK (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF) - 1))
#define UNIT_RFLAGS (UNIT_UFMASK|UNIT_DIS) /* restored flags */ #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 */ /* Register data structure */
struct sim_reg { struct sim_reg {
@ -563,7 +567,7 @@ struct sim_fileref {
/* The following macros define structure contents */ /* 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) #if defined (__STDC__) || defined (_WIN32)
#define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1, NULL #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) \ if ((uptr)->a_cancel) \
(uptr)->a_cancel (uptr); \ (uptr)->a_cancel (uptr); \
else { \ else { \
if (((uptr)->flags & UNIT_TM_POLL) && \ if (((uptr)->dynflags & UNIT_TM_POLL) && \
!((uptr)->next) && !((uptr)->a_next)) { \ !((uptr)->next) && !((uptr)->a_next)) { \
(uptr)->a_polling_now = FALSE; \ (uptr)->a_polling_now = FALSE; \
sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \ sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \
@ -702,7 +706,7 @@ extern int32 sim_asynch_inst_latency;
if ((uptr)->a_cancel) \ if ((uptr)->a_cancel) \
(uptr)->a_cancel (uptr); \ (uptr)->a_cancel (uptr); \
else { \ else { \
if (((uptr)->flags & UNIT_TM_POLL) && \ if (((uptr)->dynflags & UNIT_TM_POLL) && \
!((uptr)->next) && !((uptr)->a_next)) { \ !((uptr)->next) && !((uptr)->a_next)) { \
(uptr)->a_polling_now = FALSE; \ (uptr)->a_polling_now = FALSE; \
sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \ sim_tmxr_poll_count -= (uptr)->a_poll_waiter_count; \
@ -780,7 +784,7 @@ extern int32 sim_asynch_inst_latency;
#endif #endif
#define AIO_EVENT_BEGIN(uptr) \ #define AIO_EVENT_BEGIN(uptr) \
do { \ do { \
int __was_poll = uptr->flags & UNIT_TM_POLL int __was_poll = uptr->dynflags & UNIT_TM_POLL
#define AIO_EVENT_COMPLETE(uptr, reason) \ #define AIO_EVENT_COMPLETE(uptr, reason) \
if (__was_poll) { \ if (__was_poll) { \
pthread_mutex_lock (&sim_tmxr_poll_lock); \ pthread_mutex_lock (&sim_tmxr_poll_lock); \

View file

@ -744,15 +744,15 @@ if (mp->last_poll_time == 0) { /* first poll initializa
if (!uptr) /* Attached ? */ if (!uptr) /* Attached ? */
return -1; /* No connections are possinle! */ return -1; /* No connections are possinle! */
if (!(uptr->flags & TMUF_NOASYNCH)) { /* if asynch not disabled */ if (!(uptr->dynflags & TMUF_NOASYNCH)) { /* if asynch not disabled */
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */ uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
sim_cancel (uptr); sim_cancel (uptr);
} }
for (i=0; i < mp->lines; i++) { for (i=0; i < mp->lines; i++) {
uptr = mp->ldsc[i].uptr ? mp->ldsc[i].uptr : mp->uptr; uptr = mp->ldsc[i].uptr ? mp->ldsc[i].uptr : mp->uptr;
if (!(mp->uptr->flags & TMUF_NOASYNCH)) { /* if asynch not disabled */ if (!(mp->uptr->dynflags & TMUF_NOASYNCH)) { /* if asynch not disabled */
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */ uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
sim_cancel (uptr); 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 (nbytes == 0) { /* buf empty? enab line */
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
UNIT *ruptr = lp->uptr ? lp->uptr : lp->mp->uptr; UNIT *ruptr = lp->uptr ? lp->uptr : lp->mp->uptr;
if ((ruptr->flags & UNIT_TM_POLL) && if ((ruptr->dynflags & UNIT_TM_POLL) &&
sim_asynch_enabled && sim_asynch_enabled &&
tmxr_rqln (lp)) tmxr_rqln (lp))
_sim_activate (ruptr, 0); _sim_activate (ruptr, 0);
@ -1858,8 +1858,8 @@ t_stat tmxr_set_console_input_unit (UNIT *uptr)
extern TMLN sim_con_ldsc; extern TMLN sim_con_ldsc;
sim_con_ldsc.uptr = uptr; sim_con_ldsc.uptr = uptr;
if (!(uptr->flags & UNIT_TM_POLL)) { if (!(uptr->dynflags & UNIT_TM_POLL)) {
uptr->flags |= UNIT_TM_POLL; /* tag as polling unit */ uptr->dynflags |= UNIT_TM_POLL; /* tag as polling unit */
} }
else else
sim_cancel (uptr); sim_cancel (uptr);
@ -1991,7 +1991,7 @@ while (sim_asynch_enabled) {
FD_ZERO (&errorfds); FD_ZERO (&errorfds);
for (i=max_socket_fd=socket_count=0; i<tmxr_open_device_count; ++i) { for (i=max_socket_fd=socket_count=0; i<tmxr_open_device_count; ++i) {
mp = tmxr_open_devices[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; units[socket_count] = mp->uptr;
sockets[socket_count] = mp->master; sockets[socket_count] = mp->master;
FD_SET (mp->master, &readfds); FD_SET (mp->master, &readfds);
@ -2574,13 +2574,13 @@ if ((mp->lines > 1) ||
((mp->master == 0) && ((mp->master == 0) &&
(mp->ldsc[0].connecting == 0) && (mp->ldsc[0].connecting == 0) &&
(mp->ldsc[0].serport == 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 defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
if (!async) /* if asynch disabled */ if (!async || (uptr->flags & TMUF_NOASYNCH)) /* if asynch disabled */
uptr->flags |= TMUF_NOASYNCH; /* tag as no asynch */ uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */
#else #else
uptr->flags |= TMUF_NOASYNCH; /* tag as no asynch */ uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */
#endif #endif
if (mp->dptr == NULL) /* has device been set? */ 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 *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; UNIT *o_uptr = mp->ldsc[i].o_uptr ? mp->ldsc[i].o_uptr : mp->uptr;
uptr->flags &= ~UNIT_TM_POLL; /* no polling */ uptr->dynflags &= ~UNIT_TM_POLL; /* no polling */
o_uptr->flags &= ~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; return SCPE_OK;
} }
@ -2729,7 +2730,7 @@ return SCPE_OK;
t_stat tmxr_activate (UNIT *uptr, int32 interval) t_stat tmxr_activate (UNIT *uptr, int32 interval)
{ {
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
if ((!(uptr->flags & UNIT_TM_POLL)) || if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
(!sim_asynch_enabled)) { (!sim_asynch_enabled)) {
return _sim_activate (uptr, interval); return _sim_activate (uptr, interval);
} }
@ -2742,7 +2743,7 @@ return _sim_activate (uptr, interval);
t_stat tmxr_activate_after (UNIT *uptr, int32 usecs_walltime) t_stat tmxr_activate_after (UNIT *uptr, int32 usecs_walltime)
{ {
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
if ((!(uptr->flags & UNIT_TM_POLL)) || if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
(!sim_asynch_enabled)) { (!sim_asynch_enabled)) {
return _sim_activate_after (uptr, usecs_walltime); 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) t_stat tmxr_clock_coschedule (UNIT *uptr, int32 interval)
{ {
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
if ((!(uptr->flags & UNIT_TM_POLL)) || if ((!(uptr->dynflags & UNIT_TM_POLL)) ||
(!sim_asynch_enabled)) { (!sim_asynch_enabled)) {
return sim_clock_coschedule (uptr, interval); return sim_clock_coschedule (uptr, interval);
} }