/* * Shut down SCSI layer */ static void dev_exit (void) { int i, j; struct devstruct *dev; for (i = 0; i < MAX_TOTAL_DEVICES; i++) { dev = &devst[i]; if (dev->opencnt > 0) { /* Abort any outstanding requests */ for (j = 0; j < MAX_ASYNC_REQUESTS; j++) { uaecptr request; if ((request = dev->d_request[i])) abort_async (dev, request, 0, 0); } /* Kill dev thread and wait for it to die */ write_comm_pipe_u32 (&dev->requests, 0, 1); uae_sem_wait (&dev->sync_sem); /* Close device */ dev->opencnt = 0; sys_command_close (DF_SCSI, dev->unitnum); sys_command_close (DF_IOCTL, dev->unitnum); } memset (dev, 0, sizeof (struct devstruct)); dev->unitnum = dev->aunit = -1; } }
static void dev_close_3 (struct devstruct *dev, struct priv_devstruct *pdev) { if (!dev->opencnt) return; dev->opencnt--; if (!dev->opencnt) { if (pdev->scsi) sys_command_close (DF_SCSI, dev->unitnum); if (pdev->ioctl) sys_command_close (DF_IOCTL, dev->unitnum); pdev->inuse = 0; write_comm_pipe_u32 (&dev->requests, 0, 1); } }
void scsi_free(struct scsi_data *sd) { if (!sd) return; if (sd->nativescsiunit >= 0) { sys_command_close (sd->nativescsiunit); sd->nativescsiunit = -1; } if (sd->cd_emu_unit >= 0) { sys_command_close (sd->cd_emu_unit); sd->cd_emu_unit = -1; } xfree(sd); }
static void dev_reset (void) { int i, j; struct devstruct *dev; struct device_info *discsi, discsi2; int unitnum = 0; device_func_init (DEVICE_TYPE_SCSI); dev_exit(); for (i = 0; i < MAX_OPEN_DEVICES; i++) memset (&pdevst[i], 0, sizeof (struct priv_devstruct)); i = j = 0; while (i < MAX_TOTAL_DEVICES) { dev = &devst[i]; discsi = 0; if (sys_command_open (DF_SCSI, j)) { discsi = sys_command_info (DF_SCSI, j, &discsi2); sys_command_close (DF_SCSI, j); } if (discsi) { dev->unitnum = j; dev->allow_scsi = 1; dev->drivetype = discsi->type; memcpy (&dev->di, discsi, sizeof (struct device_info)); if (discsi->type == INQ_ROMD) dev->iscd = 1; } i++; j++; } unitnum = 0; for (i = 0; i < MAX_TOTAL_DEVICES; i++) { dev = &devst[i]; if (dev->unitnum >= 0 && dev->iscd) { dev->aunit = unitnum; unitnum++; } } if (unitnum == 0) unitnum = 1; for (i = 0; i < MAX_TOTAL_DEVICES; i++) { dev = &devst[i]; if (dev->unitnum >= 0) { if (!dev->iscd) { dev->aunit = unitnum; unitnum++; } write_log ("%s = %s:%d\n", dev->di.label, UAEDEV_SCSI, dev->aunit); } } }