1
0
mirror of https://github.com/simh/simh.git synced 2026-02-28 17:20:20 +00:00

SCP: Add a -F option to SET <dev> DISABLE command to force detach and cancel

This commit is contained in:
Mark Pizzolato
2025-09-01 09:55:30 -10:00
parent 0bccaaab66
commit ea37ca9ff5

17
scp.c
View File

@@ -1751,7 +1751,9 @@ static const char simh_help2[] =
" specified device from the configuration. A DISABLED device is invisible\n"
" to running programs. The device can still be RESET, but it cannot be\n"
" ATTAChed, DETACHed, or BOOTed. SET <device> ENABLED restores a disabled\n"
" device to a configuration.\n\n"
" device to a configuration. The SET <device> DISABLED command has an\n"
" optional -F switch which will force units to be detached and removed from\n"
" the event queue.\n\n"
" Most multi-unit devices allow units to be enabled or disabled:\n\n"
"++SET <unit> ENABLED\n"
"++SET <unit> DISABLED\n\n"
@@ -6596,8 +6598,12 @@ else {
return SCPE_OK;
for (i = 0; i < dptr->numunits; i++) { /* check units */
up = (dptr->units) + i; /* att or active? */
if ((up->flags & UNIT_ATT) || sim_is_active (up))
return sim_messagef (SCPE_NOFNC, "%s has attached or busy units\n", sim_dname (dptr)); /* can't do it */
if ((up->flags & UNIT_ATT) || sim_is_active (up)) {
if ((sim_switches & SWMASK ('F')) == 0) /* no forced disable? */
return sim_messagef (SCPE_NOFNC, "%s has attached or busy units\n", sim_dname (dptr)); /* can't do it */
sim_cancel (up);
(void)scp_detach_unit (dptr, up);
}
}
dptr->flags = dptr->flags | DEV_DIS; /* disable */
}
@@ -17799,11 +17805,14 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) {
default:
break;
}
if (was_disabled)
if (was_disabled) {
sim_switches |= SWMASK ('F'); /* force complete disable */
set_dev_enbdis (dptr, NULL, 0, NULL);
}
}
else
tstat = SCPE_OK; /* can't enable, just skip device */
sim_switches = saved_switches;
if (tstat != SCPE_OK) {
stat = tstat;
sim_printf ("%s device tests returned: %d - %s\n", dptr->name, SCPE_BARE_STATUS (tstat), sim_error_text (tstat));