@@ -1649,7 +1649,9 @@ static const char simh_help2[] =
16491649 " specified device from the configuration. A DISABLED device is invisible\n"
16501650 " to running programs. The device can still be RESET, but it cannot be\n"
16511651 " ATTAChed, DETACHed, or BOOTed. SET <device> ENABLED restores a disabled\n"
1652- " device to a configuration.\n\n"
1652+ " device to a configuration. The SET <device> DISABLED command has an\n"
1653+ " optional -F switch which will force units to be detached and removed from\n"
1654+ " the event queue.\n\n"
16531655 " Most multi-unit devices allow units to be enabled or disabled:\n\n"
16541656 "++SET <unit> ENABLED\n"
16551657 "++SET <unit> DISABLED\n\n"
@@ -6108,8 +6110,12 @@ else {
61086110 return SCPE_OK;
61096111 for (i = 0; i < dptr->numunits; i++) { /* check units */
61106112 up = (dptr->units) + i; /* att or active? */
6111- if ((up->flags & UNIT_ATT) || sim_is_active (up))
6112- return sim_messagef (SCPE_NOFNC, "%s has attached or busy units\n", sim_dname (dptr)); /* can't do it */
6113+ if ((up->flags & UNIT_ATT) || sim_is_active (up)) {
6114+ if ((sim_switches & SWMASK ('F')) == 0) /* no forced disable? */
6115+ return sim_messagef (SCPE_NOFNC, "%s has attached or busy units\n", sim_dname (dptr)); /* can't do it */
6116+ sim_cancel (up);
6117+ (void)scp_detach_unit (dptr, up);
6118+ }
61136119 }
61146120 dptr->flags = dptr->flags | DEV_DIS; /* disable */
61156121 }
@@ -16608,11 +16614,14 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) {
1660816614 default:
1660916615 break;
1661016616 }
16611- if (was_disabled)
16617+ if (was_disabled) {
16618+ sim_switches |= SWMASK ('F'); /* force complete disable */
1661216619 set_dev_enbdis (dptr, NULL, 0, NULL);
16620+ }
1661316621 }
1661416622 else
1661516623 tstat = SCPE_OK; /* can't enable, just skip device */
16624+ sim_switches = saved_switches;
1661616625 if (tstat != SCPE_OK) {
1661716626 stat = tstat;
1661816627 sim_printf ("%s device tests returned: %d - %s\n", dptr->name, SCPE_BARE_STATUS (tstat), sim_error_text (tstat));
0 commit comments