Esempio n. 1
0
t_stat dp_attach(UNIT *uptr, CONST char *cptr)
{
  struct dpio_unit *iou = (struct dpio_unit *)uptr->up7;
  const char *drivetype = ((uptr->flags & UNIT_854) != 0) ? "854" : "853";
  t_addr capac = ((uptr->flags & UNIT_854) != 0) ? DP854_SIZE : DP853_SIZE;
  t_stat r;

  uptr->capac = capac;
  r = attach_unit(uptr, cptr);
  if (r != SCPE_OK)
    return r;

  /*
   * If this is a newly created file, set the drive size appropriately.
   */
  if (sim_fsize_ex(uptr->fileref) == 0)
    sim_set_fsize(uptr->fileref, capac);

  if (sim_fsize_ex(uptr->fileref) != capac) {
    if (ExecutionStarted) {
      detach_unit(uptr);
      return sim_messagef(SCPE_OPENERR, "Unable to autosize drive after execution started\n");
    }
    /*
     * This is not the correct size according the drive type but this is the
     * first attach. Force the drive to match the size of the disk.
     */
    switch (sim_fsize_ex(uptr->fileref)) {
      case DP854_SIZE:
        uptr->capac = DP854_SIZE;
        uptr->flags |= UNIT_854;
        break;

      case DP853_SIZE:
        uptr->capac = DP853_SIZE;
        uptr->flags &= ~UNIT_854;
        break;

      default:
        detach_unit(uptr);
        return sim_messagef(SCPE_OPENERR, "Unsupported disk size\n");
    }
  }
  /*
   * Set unit to cylinder 0, head 0, sector 0 and indicate on-cylinder.
   */
  iou->cylinder = 0;
  iou->head = 0;
  iou->sector = 0;
  iou->oncyl = TRUE;

  return SCPE_OK;
}
Esempio n. 2
0
t_offset sim_fsize_name_ex (char *fname)
{
FILE *fp;
t_offset sz;

if ((fp = sim_fopen (fname, "rb")) == NULL)
    return 0;
sz = sim_fsize_ex (fp);
fclose (fp);
return sz;
}
Esempio n. 3
0
uint32 sim_fsize (FILE *fp)
{
return (uint32)(sim_fsize_ex (fp));
}