DISK: Add sim_disk_erase API
This commit is contained in:
parent
bc40d08b94
commit
64b1223468
2 changed files with 27 additions and 7 deletions
18
sim_disk.c
18
sim_disk.c
|
@ -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
|
This routine is called when the simulator stops and any time
|
||||||
the asynch mode is changed (enabled or disabled)
|
the asynch mode is changed (enabled or disabled)
|
||||||
|
|
16
sim_disk.h
16
sim_disk.h
|
@ -69,15 +69,16 @@ typedef void (*DISK_PCALLBACK)(UNIT *unit, t_stat status);
|
||||||
|
|
||||||
t_stat sim_disk_attach (UNIT *uptr,
|
t_stat sim_disk_attach (UNIT *uptr,
|
||||||
const char *cptr,
|
const char *cptr,
|
||||||
size_t sector_size, size_t xfer_element_size,
|
size_t memory_sector_size, /* memory footprint of sector data */
|
||||||
t_bool dontchangecapac,
|
size_t xfer_element_size,
|
||||||
uint32 debugbit,
|
t_bool dontchangecapac, /* if false just change uptr->capac as needed */
|
||||||
const char *drivetype,
|
uint32 debugbit, /* debug bit */
|
||||||
uint32 pdp11_tracksize,
|
const char *drivetype, /* drive type */
|
||||||
int completion_delay);
|
uint32 pdp11_tracksize, /* BAD144 track */
|
||||||
|
int completion_delay); /* Minimum Delay for asynch I/O completion */
|
||||||
t_stat sim_disk_attach_ex (UNIT *uptr,
|
t_stat sim_disk_attach_ex (UNIT *uptr,
|
||||||
const char *cptr,
|
const char *cptr,
|
||||||
size_t sector_size,
|
size_t memory_sector_size, /* memory footprint of sector data */
|
||||||
size_t xfer_element_size,
|
size_t xfer_element_size,
|
||||||
t_bool dontchangecapac, /* if false just change uptr->capac as needed */
|
t_bool dontchangecapac, /* if false just change uptr->capac as needed */
|
||||||
uint32 dbit, /* debug bit */
|
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 (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_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_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_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_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);
|
t_stat sim_disk_set_capac (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||||
|
|
Loading…
Add table
Reference in a new issue