DISK, TAPE: Make an -F switch specified on a disk/tape attach only change the device format until the unit is detached at which time the unit format will revert to the default format. Fix #219
This commit is contained in:
parent
133572908f
commit
435ea69b20
2 changed files with 17 additions and 9 deletions
12
sim_disk.c
12
sim_disk.c
|
@ -836,8 +836,9 @@ if (sim_switches & SWMASK ('F')) { /* format spec? */
|
||||||
if (*cptr == 0) /* must be more */
|
if (*cptr == 0) /* must be more */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
if (sim_disk_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
if (sim_disk_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
||||||
return SCPE_ARG;
|
return sim_messagef (SCPE_ARG, "Invalid Disk Format: %s\n", gbuf);
|
||||||
sim_switches = sim_switches & ~(SWMASK ('F')); /* Record Format specifier already processed */
|
sim_switches = sim_switches & ~(SWMASK ('F')); /* Record Format specifier already processed */
|
||||||
|
auto_format = TRUE;
|
||||||
}
|
}
|
||||||
if (sim_switches & SWMASK ('D')) { /* create difference disk? */
|
if (sim_switches & SWMASK ('D')) { /* create difference disk? */
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
|
@ -852,7 +853,7 @@ if (sim_switches & SWMASK ('D')) { /* create difference dis
|
||||||
sim_vhd_disk_close (vhd);
|
sim_vhd_disk_close (vhd);
|
||||||
return sim_disk_attach (uptr, gbuf, sector_size, xfer_element_size, dontautosize, dbit, dtype, pdp11tracksize, completion_delay);
|
return sim_disk_attach (uptr, gbuf, sector_size, xfer_element_size, dontautosize, dbit, dtype, pdp11tracksize, completion_delay);
|
||||||
}
|
}
|
||||||
return SCPE_ARG;
|
return sim_messagef (SCPE_ARG, "Unable to create differencing VHD: %s\n", gbuf);
|
||||||
}
|
}
|
||||||
if (sim_switches & SWMASK ('C')) { /* create vhd disk & copy contents? */
|
if (sim_switches & SWMASK ('C')) { /* create vhd disk & copy contents? */
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
|
@ -873,7 +874,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
||||||
sim_quiet = saved_sim_quiet;
|
sim_quiet = saved_sim_quiet;
|
||||||
if (r != SCPE_OK) {
|
if (r != SCPE_OK) {
|
||||||
sim_switches = saved_sim_switches;
|
sim_switches = saved_sim_switches;
|
||||||
return r;
|
return sim_messagef (r, "Can't open source VHD: %s\n", cptr);
|
||||||
}
|
}
|
||||||
if (!sim_quiet) {
|
if (!sim_quiet) {
|
||||||
sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
||||||
|
@ -881,10 +882,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
||||||
capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */
|
capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */
|
||||||
vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1));
|
vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1));
|
||||||
if (!vhd) {
|
if (!vhd) {
|
||||||
if (!sim_quiet) {
|
return sim_messagef (r, "%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
||||||
sim_printf ("%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
|
||||||
}
|
|
||||||
return SCPE_OPENERR;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint8 *copy_buf = (uint8*) malloc (1024*1024);
|
uint8 *copy_buf = (uint8*) malloc (1024*1024);
|
||||||
|
|
14
sim_tape.c
14
sim_tape.c
|
@ -134,6 +134,7 @@ static void sim_tape_data_trace (UNIT *uptr, const uint8 *data, size_t len, cons
|
||||||
struct tape_context {
|
struct tape_context {
|
||||||
DEVICE *dptr; /* Device for unit (access to debug flags) */
|
DEVICE *dptr; /* Device for unit (access to debug flags) */
|
||||||
uint32 dbit; /* debugging bit */
|
uint32 dbit; /* debugging bit */
|
||||||
|
uint32 auto_format; /* Format determined dynamically */
|
||||||
#if defined SIM_ASYNCH_IO
|
#if defined SIM_ASYNCH_IO
|
||||||
int asynch_io; /* Asynchronous Interrupt scheduling enabled */
|
int asynch_io; /* Asynchronous Interrupt scheduling enabled */
|
||||||
int asynch_io_latency; /* instructions to delay pending interrupt */
|
int asynch_io_latency; /* instructions to delay pending interrupt */
|
||||||
|
@ -449,6 +450,7 @@ uint32 objc;
|
||||||
DEVICE *dptr;
|
DEVICE *dptr;
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
t_stat r;
|
t_stat r;
|
||||||
|
t_bool auto_format = FALSE;
|
||||||
|
|
||||||
if ((dptr = find_dev_from_unit (uptr)) == NULL)
|
if ((dptr = find_dev_from_unit (uptr)) == NULL)
|
||||||
return SCPE_NOATT;
|
return SCPE_NOATT;
|
||||||
|
@ -457,13 +459,15 @@ if (sim_switches & SWMASK ('F')) { /* format spec? */
|
||||||
if (*cptr == 0) /* must be more */
|
if (*cptr == 0) /* must be more */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
if (sim_tape_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
if (sim_tape_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
||||||
return SCPE_ARG;
|
return sim_messagef (SCPE_ARG, "Invalid Tape Format: %s\n", gbuf);
|
||||||
|
sim_switches = sim_switches & ~(SWMASK ('F')); /* Record Format specifier already processed */
|
||||||
|
auto_format = TRUE;
|
||||||
}
|
}
|
||||||
if (MT_GET_FMT (uptr) == MTUF_F_TPC)
|
if (MT_GET_FMT (uptr) == MTUF_F_TPC)
|
||||||
sim_switches |= SWMASK ('R'); /* Force ReadOnly attach for TPC tapes */
|
sim_switches |= SWMASK ('R'); /* Force ReadOnly attach for TPC tapes */
|
||||||
r = attach_unit (uptr, cptr); /* attach unit */
|
r = attach_unit (uptr, cptr); /* attach unit */
|
||||||
if (r != SCPE_OK) /* error? */
|
if (r != SCPE_OK) /* error? */
|
||||||
return r;
|
return sim_messagef (r, "Can't open tape image: %s\n", cptr);
|
||||||
switch (MT_GET_FMT (uptr)) { /* case on format */
|
switch (MT_GET_FMT (uptr)) { /* case on format */
|
||||||
|
|
||||||
case MTUF_F_STD: /* SIMH */
|
case MTUF_F_STD: /* SIMH */
|
||||||
|
@ -502,6 +506,7 @@ switch (MT_GET_FMT (uptr)) { /* case on format */
|
||||||
uptr->tape_ctx = ctx = (struct tape_context *)calloc(1, sizeof(struct tape_context));
|
uptr->tape_ctx = ctx = (struct tape_context *)calloc(1, sizeof(struct tape_context));
|
||||||
ctx->dptr = dptr; /* save DEVICE pointer */
|
ctx->dptr = dptr; /* save DEVICE pointer */
|
||||||
ctx->dbit = dbit; /* save debug bit */
|
ctx->dbit = dbit; /* save debug bit */
|
||||||
|
ctx->auto_format = auto_format; /* save that we auto selected format */
|
||||||
|
|
||||||
sim_tape_rewind (uptr);
|
sim_tape_rewind (uptr);
|
||||||
|
|
||||||
|
@ -517,14 +522,17 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_stat sim_tape_detach (UNIT *uptr)
|
t_stat sim_tape_detach (UNIT *uptr)
|
||||||
{
|
{
|
||||||
|
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;
|
||||||
uint32 f = MT_GET_FMT (uptr);
|
uint32 f = MT_GET_FMT (uptr);
|
||||||
t_stat r;
|
t_stat r;
|
||||||
|
t_bool auto_format;
|
||||||
|
|
||||||
if ((uptr == NULL) || !(uptr->flags & UNIT_ATT))
|
if ((uptr == NULL) || !(uptr->flags & UNIT_ATT))
|
||||||
return SCPE_IERR;
|
return SCPE_IERR;
|
||||||
|
|
||||||
if (uptr->io_flush)
|
if (uptr->io_flush)
|
||||||
uptr->io_flush (uptr); /* flush buffered data */
|
uptr->io_flush (uptr); /* flush buffered data */
|
||||||
|
auto_format = ctx->auto_format;
|
||||||
|
|
||||||
sim_tape_clr_async (uptr);
|
sim_tape_clr_async (uptr);
|
||||||
|
|
||||||
|
@ -548,6 +556,8 @@ sim_tape_rewind (uptr);
|
||||||
free (uptr->tape_ctx);
|
free (uptr->tape_ctx);
|
||||||
uptr->tape_ctx = NULL;
|
uptr->tape_ctx = NULL;
|
||||||
uptr->io_flush = NULL;
|
uptr->io_flush = NULL;
|
||||||
|
if (auto_format) /* format was determined or specified at attach time? */
|
||||||
|
sim_tape_set_fmt (uptr, 0, "SIMH", NULL); /* restore default format */
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue