DISK: Add sim_disk_erase API

This commit is contained in:
Mark Pizzolato 2021-08-17 15:35:51 -07:00
parent bc40d08b94
commit 64b1223468
2 changed files with 27 additions and 7 deletions

View file

@ -867,6 +867,24 @@ switch (DK_GET_FMT (uptr)) { /* case on format */
}
}
t_stat sim_disk_erase (UNIT *uptr)
{
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
uint8 *buf;
t_lba lba;
if (uptr->flags & UNIT_ATT)
return SCPE_UNATT;
buf = (uint8 *)calloc (1, ctx->storage_sector_size);
if (buf == NULL)
return SCPE_MEM;
for (lba = 0; lba < ctx->container_size / ctx->sector_size; lba++)
sim_disk_wrsect (uptr, lba, buf, NULL, 1); /* write sector */
free (buf);
return SCPE_OK;
}
/*
This routine is called when the simulator stops and any time
the asynch mode is changed (enabled or disabled)

View file

@ -69,15 +69,16 @@ typedef void (*DISK_PCALLBACK)(UNIT *unit, t_stat status);
t_stat sim_disk_attach (UNIT *uptr,
const char *cptr,
size_t sector_size, size_t xfer_element_size,
t_bool dontchangecapac,
uint32 debugbit,
const char *drivetype,
uint32 pdp11_tracksize,
int completion_delay);
size_t memory_sector_size, /* memory footprint of sector data */
size_t xfer_element_size,
t_bool dontchangecapac, /* if false just change uptr->capac as needed */
uint32 debugbit, /* debug bit */
const char *drivetype, /* drive type */
uint32 pdp11_tracksize, /* BAD144 track */
int completion_delay); /* Minimum Delay for asynch I/O completion */
t_stat sim_disk_attach_ex (UNIT *uptr,
const char *cptr,
size_t sector_size,
size_t memory_sector_size, /* memory footprint of sector data */
size_t xfer_element_size,
t_bool dontchangecapac, /* if false just change uptr->capac as needed */
uint32 dbit, /* debug bit */
@ -93,6 +94,7 @@ t_stat sim_disk_rdsect_a (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectsread
t_stat sim_disk_wrsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectswritten, t_seccnt sects);
t_stat sim_disk_wrsect_a (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectswritten, t_seccnt sects, DISK_PCALLBACK callback);
t_stat sim_disk_unload (UNIT *uptr);
t_stat sim_disk_erase (UNIT *uptr);
t_stat sim_disk_set_fmt (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat sim_disk_show_fmt (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
t_stat sim_disk_set_capac (UNIT *uptr, int32 val, CONST char *cptr, void *desc);