Previous 15994 Revisions Next

r14062 Monday 16th January, 2012 at 12:25:55 UTC by Curt Coder
Hopefully fixed the SCSI hard disk crashes. (nw)
[src/emu/imagedev]harddriv.c
[src/emu/machine]scsihd.c

src/emu/imagedev/harddriv.c
r14061r14062
7676
7777harddisk_image_device::harddisk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
7878    : device_t(mconfig, HARDDISK, "Harddisk", tag, owner, clock),
79     device_image_interface(mconfig, *this)
79     device_image_interface(mconfig, *this),
80     m_chd(NULL),
81     m_hard_disk_handle(NULL)
8082{
8183
8284}
src/emu/machine/scsihd.c
r14061r14062
1515   UINT32 lba;
1616   UINT32 blocks;
1717   int sectorbytes;
18   chd_file       *handle;
1819   hard_disk_file *disk;
19   bool is_file;
20   bool is_image_device;
2021} SCSIHd;
2122
2223
r14061r14062
253254   our_this->blocks = 0;
254255   our_this->sectorbytes = 512;
255256
257   // Attempt to register save state entry after state registration is closed!
256258   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->lba );
257259   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->blocks );
258
259   if (machine.device( diskregion )) {
260      our_this->is_file = TRUE;
261      our_this->disk = machine.device<harddisk_image_device>(diskregion)->get_hard_disk_file();
262   } else {
260   
261   // try to locate the CHD from a DISK_REGION
262   our_this->handle = get_disk_handle(machine, diskregion);
263   our_this->disk = hard_disk_open(our_this->handle);
264   our_this->is_image_device = false;
265   
266   if (our_this->disk == NULL)
267   {
268      // try to locate the CHD from an image device
269      harddisk_image_device *image_device = machine.device<harddisk_image_device>(diskregion);
270     
271      if (image_device != NULL)
272      {
273         our_this->handle = image_device->get_chd_file();
274         our_this->disk = hard_disk_open(our_this->handle);
275         our_this->is_image_device = true;
276      }
277   }
278   
279   if (our_this->disk == NULL)
280   {
281      // try to locate the CHD from an image subdevice
263282      for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
264283      {
265         if (device->subdevice(diskregion)) {
266            our_this->is_file = TRUE;
267            our_this->disk = device->subdevice<harddisk_image_device>(diskregion)->get_hard_disk_file();
284         if (device->subdevice(diskregion) != NULL)
285         {
286            our_this->handle = device->subdevice<harddisk_image_device>(diskregion)->get_chd_file();
287            our_this->disk = hard_disk_open(our_this->handle);
288            our_this->is_image_device = true;
268289         }
269290      }
270
271      if (!our_this->disk)
272      {
273         our_this->is_file = FALSE;
274         our_this->disk = hard_disk_open(get_disk_handle( machine, diskregion ));
275      }
276291   }
277
278   if (!our_this->disk)
292   
293   if (our_this->disk != NULL)
279294   {
280      logerror("SCSIHD: no HD found!\n");
295      // get hard disk sector size from CHD metadata
296      const hard_disk_info *hdinfo = hard_disk_get_info(our_this->disk);
297      our_this->sectorbytes = hdinfo->sectorbytes;
281298   }
282299   else
283300   {
284      const hard_disk_info *hdinfo = hard_disk_get_info(our_this->disk);
285      our_this->sectorbytes = hdinfo->sectorbytes;
301      logerror("SCSIHD: no HD found!\n");
286302   }
287303}
288304
289305static void scsihd_delete_instance( SCSIInstance *scsiInstance )
290306{
291307   SCSIHd *our_this = (SCSIHd *)SCSIThis( &SCSIClassHARDDISK, scsiInstance );
292   if (!our_this->is_file) {
308   if (!our_this->is_image_device) {
293309      if( our_this->disk )
294310      {
295311         hard_disk_close( our_this->disk );

Previous 15994 Revisions Next


© 1998-2018 The MESS Team