diff --git a/scp.c b/scp.c index 53dd118c..a83561a6 100644 --- a/scp.c +++ b/scp.c @@ -3656,12 +3656,15 @@ if (dptr == NULL) /* found dev? */ return SCPE_NXDEV; if (uptr == NULL) /* valid unit? */ return SCPE_NXUN; -if ((uptr->flags & UNIT_ATT) && /* already attached? */ - !(uptr->dynflags & UNIT_ATTMULT)) { /* and only single attachable */ - r = scp_detach_unit (dptr, uptr); /* detach it */ - if (r != SCPE_OK) /* error? */ - return r; - } +if (uptr->flags & UNIT_ATT) /* already attached? */ + if (!(uptr->dynflags & UNIT_ATTMULT) && /* and only single attachable */ + !(dptr->flags & DEV_DONTAUTO)) { /* and auto detachable */ + r = scp_detach_unit (dptr, uptr); /* detach it */ + if (r != SCPE_OK) /* error? */ + return r; + } + else + return SCPE_ALATT; /* Already attached */ sim_trim_endspc (cptr); /* trim trailing spc */ return scp_attach_unit (dptr, uptr, cptr); /* attach */ } diff --git a/sim_defs.h b/sim_defs.h index 48503a3f..b2e25b81 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -384,6 +384,7 @@ struct sim_device { #define DEV_V_TYPE 4 /* Attach type */ #define DEV_S_TYPE 3 /* Width of Type Field */ #define DEV_V_SECTORS 7 /* Unit Capacity is in 512byte sectors */ +#define DEV_V_DONTAUTO 8 /* Do not auto detach already attached units */ #define DEV_V_UF_31 12 /* user flags, V3.1 */ #define DEV_V_UF 16 /* user flags */ #define DEV_V_RSV 31 /* reserved */ @@ -393,6 +394,7 @@ struct sim_device { #define DEV_DYNM (1 << DEV_V_DYNM) /* device requires call on msize routine to change memory size */ #define DEV_DEBUG (1 << DEV_V_DEBUG) /* device supports SET DEBUG command */ #define DEV_SECTORS (1 << DEV_V_SECTORS) /* capacity is 512 byte sectors */ +#define DEV_DONTAUTO (1 << DEV_V_DONTAUTO) /* Do not auto detach already attached units */ #define DEV_NET 0 /* Deprecated - meaningless */