Previous 199869 Revisions Next

r23652 Wednesday 12th June, 2013 at 17:28:00 UTC by smf
moved more state from idectrl.h (nw)
[src/emu/machine]idectrl.c idectrl.h idehd.c idehd.h

trunk/src/emu/machine/idehd.c
r23651r23652
250250
251251   save_item(NAME(buffer));
252252   save_item(NAME(buffer_offset));
253
254   save_item(NAME(adapter_control));
255   save_item(NAME(precomp_offset));
256
257   save_item(NAME(sector_count));
253258}
254259
255260//-------------------------------------------------
trunk/src/emu/machine/idehd.h
r23651r23652
3131   UINT8           buffer[IDE_DISK_SECTOR_SIZE];
3232   UINT16          buffer_offset;
3333
34   UINT8           adapter_control;
35   UINT8           precomp_offset;
36   UINT16          sector_count;
37
3438protected:
3539   UINT8           m_features[IDE_DISK_SECTOR_SIZE];
3640   UINT16          m_num_cylinders;
trunk/src/emu/machine/idectrl.c
r23651r23652
283283   {
284284      security_error();
285285
286      sector_count = 0;
286      dev->sector_count = 0;
287287
288288      return;
289289   }
290290
291291   /* if there is more data to read, keep going */
292   if (sector_count > 0)
293      sector_count--;
294   if (sector_count > 0)
292   if (dev->sector_count > 0)
293      dev->sector_count--;
294   if (dev->sector_count > 0)
295295      read_next_sector();
296296}
297297
r23651r23652
325325   {
326326      /* advance the pointers, unless this is the last sector */
327327      /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */
328      if (sector_count != 1)
328      if (dev->sector_count != 1)
329329         next_sector();
330330
331331      /* clear the error value */
r23651r23652
334334      /* signal an interrupt */
335335      if (!verify_only)
336336         sectors_until_int--;
337      if (sectors_until_int == 0 || sector_count == 1)
337      if (sectors_until_int == 0 || dev->sector_count == 1)
338338      {
339339         sectors_until_int = ((command == IDE_COMMAND_READ_MULTIPLE_BLOCK) ? block_count : 1);
340340         set_irq(ASSERT_LINE);
r23651r23652
534534   {
535535      /* advance the pointers, unless this is the last sector */
536536      /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */
537      if (sector_count != 1)
537      if (dev->sector_count != 1)
538538         next_sector();
539539
540540      /* clear the error value */
541541      error = IDE_ERROR_NONE;
542542
543543      /* signal an interrupt */
544      if (--sectors_until_int == 0 || sector_count == 1)
544      if (--sectors_until_int == 0 || dev->sector_count == 1)
545545      {
546546         sectors_until_int = ((command == IDE_COMMAND_WRITE_MULTIPLE_BLOCK) ? block_count : 1);
547547         set_irq(ASSERT_LINE);
548548      }
549549
550550      /* signal an interrupt if there's more data needed */
551      if (sector_count > 0)
552         sector_count--;
553      if (sector_count == 0)
551      if (dev->sector_count > 0)
552         dev->sector_count--;
553      if (dev->sector_count == 0)
554554         status &= ~IDE_STATUS_BUFFER_READY;
555555
556556      /* keep going for DMA */
557      if (dma_active && sector_count != 0)
557      if (dma_active && dev->sector_count != 0)
558558      {
559559         set_dmarq(1);
560560      }
r23651r23652
594594      case IDE_COMMAND_READ_MULTIPLE:
595595      case IDE_COMMAND_READ_MULTIPLE_NORETRY:
596596         LOGPRINT(("IDE Read multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
597            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
597            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
598598
599599         /* reset the buffer */
600600         dev->buffer_offset = 0;
r23651r23652
608608
609609      case IDE_COMMAND_READ_MULTIPLE_BLOCK:
610610         LOGPRINT(("IDE Read multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
611            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
611            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
612612
613613         /* reset the buffer */
614614         dev->buffer_offset = 0;
r23651r23652
623623      case IDE_COMMAND_VERIFY_MULTIPLE:
624624      case IDE_COMMAND_VERIFY_NORETRY:
625625         LOGPRINT(("IDE Read verify multiple with/without retries: C=%d H=%d S=%d LBA=%d count=%d\n",
626            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
626            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
627627
628628         /* reset the buffer */
629629         dev->buffer_offset = 0;
r23651r23652
637637
638638      case IDE_COMMAND_READ_DMA:
639639         LOGPRINT(("IDE Read multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
640            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
640            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
641641
642642         /* reset the buffer */
643643         dev->buffer_offset = 0;
644         sectors_until_int = sector_count;
644         sectors_until_int = dev->sector_count;
645645         dma_active = 1;
646646         verify_only = 0;
647647
r23651r23652
652652      case IDE_COMMAND_WRITE_MULTIPLE:
653653      case IDE_COMMAND_WRITE_MULTIPLE_NORETRY:
654654         LOGPRINT(("IDE Write multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
655            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
655            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
656656
657657         /* reset the buffer */
658658         dev->buffer_offset = 0;
r23651r23652
665665
666666      case IDE_COMMAND_WRITE_MULTIPLE_BLOCK:
667667         LOGPRINT(("IDE Write multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
668            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
668            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
669669
670670         /* reset the buffer */
671671         dev->buffer_offset = 0;
r23651r23652
678678
679679      case IDE_COMMAND_WRITE_DMA:
680680         LOGPRINT(("IDE Write multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
681            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), sector_count));
681            dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count));
682682
683683         /* reset the buffer */
684684         dev->buffer_offset = 0;
685         sectors_until_int = sector_count;
685         sectors_until_int = dev->sector_count;
686686         dma_active = 1;
687687
688688         /* start the read going */
r23651r23652
707707
708708         /* reset the buffer */
709709         dev->buffer_offset = 0;
710         sector_count = 1;
710         dev->sector_count = 1;
711711
712712         /* build the features page */
713713         memcpy(dev->buffer, slot[cur_drive]->dev()->get_features(), sizeof(dev->buffer));
r23651r23652
747747         error = IDE_ERROR_NONE;
748748
749749         /* for timeout disabled value is 0 */
750         sector_count = 0;
750         dev->sector_count = 0;
751751         /* signal an interrupt */
752752         set_irq(ASSERT_LINE);
753753         break;
754754
755755      case IDE_COMMAND_SET_CONFIG:
756         LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", dev->cur_head + 1, sector_count));
756         LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", dev->cur_head + 1, dev->sector_count));
757757         status &= ~IDE_STATUS_ERROR;
758758         error = IDE_ERROR_NONE;
759         dev->set_geometry(sector_count,dev->cur_head + 1);
759         dev->set_geometry(dev->sector_count,dev->cur_head + 1);
760760
761761         /* signal an interrupt */
762762         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
r23651r23652
771771         break;
772772
773773      case IDE_COMMAND_SET_FEATURES:
774         LOGPRINT(("IDE Set features (%02X %02X %02X %02X %02X)\n", precomp_offset, sector_count & 0xff, dev->cur_sector, dev->cur_cylinder & 0xff, dev->cur_cylinder >> 8));
774         LOGPRINT(("IDE Set features (%02X %02X %02X %02X %02X)\n", dev->precomp_offset, dev->sector_count & 0xff, dev->cur_sector, dev->cur_cylinder & 0xff, dev->cur_cylinder >> 8));
775775
776776         /* signal an interrupt */
777777         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
778778         break;
779779
780780      case IDE_COMMAND_SET_BLOCK_COUNT:
781         LOGPRINT(("IDE Set block count (%02X)\n", sector_count));
781         LOGPRINT(("IDE Set block count (%02X)\n", dev->sector_count));
782782
783         block_count = sector_count;
783         block_count = dev->sector_count;
784784         // judge dredd wants 'drive ready' on this command
785785         status |= IDE_STATUS_DRIVE_READY;
786786
r23651r23652
791791      case IDE_COMMAND_TAITO_GNET_UNLOCK_1:
792792         LOGPRINT(("IDE GNET Unlock 1\n"));
793793
794         sector_count = 1;
794         dev->sector_count = 1;
795795         status |= IDE_STATUS_DRIVE_READY;
796796         status &= ~IDE_STATUS_ERROR;
797797         set_irq(ASSERT_LINE);
r23651r23652
815815
816816         /* key check */
817817         dev->read_key(key);
818         if ((precomp_offset == key[0]) && (sector_count == key[1]) && (dev->cur_sector == key[2]) && (dev->cur_cylinder == (((UINT16)key[4]<<8)|key[3])))
818         if ((dev->precomp_offset == key[0]) && (dev->sector_count == key[1]) && (dev->cur_sector == key[2]) && (dev->cur_cylinder == (((UINT16)key[4]<<8)|key[3])))
819819         {
820820            gnetreadlock= 0;
821821         }
r23651r23652
836836         error = IDE_ERROR_NONE;
837837
838838         /* for timeout disabled value is 0 */
839         sector_count = 0;
839         dev->sector_count = 0;
840840         /* signal an interrupt */
841841         set_irq(ASSERT_LINE);
842842         break;
r23651r23652
975975
976976      /* return the current sector count */
977977      case IDE_BANK0_SECTOR_COUNT:
978         result = sector_count;
978         result = dev->sector_count;
979979         break;
980980
981981      /* return the current sector */
r23651r23652
11841184
11851185      /* precompensation offset?? */
11861186      case IDE_BANK0_ERROR:
1187         precomp_offset = data;
1187         dev->precomp_offset = data;
11881188         break;
11891189
11901190      /* sector count */
11911191      case IDE_BANK0_SECTOR_COUNT:
1192         sector_count = data ? data : 256;
1192         dev->sector_count = data ? data : 256;
11931193         break;
11941194
11951195      /* current sector */
r23651r23652
12351235
12361236WRITE16_MEMBER( ide_controller_device::write_cs1 )
12371237{
1238   ide_device_interface *dev = slot[cur_drive]->dev();
1239
1240   if (dev == NULL)
1241      return;
1242
12381243//  printf( "write cs1 %04x %04x %04x\n", offset, data, mem_mask );
12391244
12401245   /* logit */
r23651r23652
12441249   {
12451250      /* adapter control */
12461251      case IDE_BANK1_STATUS_CONTROL:
1247         adapter_control = data;
1252         dev->adapter_control = data;
12481253
12491254         /* handle controller reset */
12501255         //if (data == 0x04)
r23651r23652
12661271ide_controller_device::ide_controller_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
12671272   device_t(mconfig, type, name, tag, owner, clock),
12681273   status(0),
1269   adapter_control(0),
12701274   error(0),
12711275   command(0),
12721276   interrupt_pending(0),
1273   precomp_offset(0),
1274   sector_count(0),
12751277   block_count(0),
12761278   sectors_until_int(0),
12771279   verify_only(0),
r23651r23652
12921294
12931295ide_controller_device::ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
12941296   device_t(mconfig, IDE_CONTROLLER, "IDE Controller", tag, owner, clock),
1295   adapter_control(0),
12961297   error(0),
12971298   command(0),
12981299   interrupt_pending(0),
1299   precomp_offset(0),
1300   sector_count(0),
13011300   block_count(0),
13021301   sectors_until_int(0),
13031302   verify_only(0),
r23651r23652
13301329   reset_timer = timer_alloc(TID_RESET_CALLBACK);
13311330
13321331   /* register ide states */
1333   save_item(NAME(adapter_control));
13341332   save_item(NAME(status));
13351333   save_item(NAME(error));
13361334   save_item(NAME(command));
13371335   save_item(NAME(interrupt_pending));
1338   save_item(NAME(precomp_offset));
13391336
1340   save_item(NAME(sector_count));
1341
13421337   save_item(NAME(block_count));
13431338   save_item(NAME(sectors_until_int));
13441339
trunk/src/emu/machine/idectrl.h
r23651r23652
106106   void read_sector_done();
107107   void write_sector_done();
108108
109   UINT8           status;
110
111109protected:
112110   // device-level overrides
113111   virtual void device_start();
r23651r23652
127125   void read_buffer_empty();
128126   void write_buffer_full();
129127
130   UINT8           dma_active;
131   UINT8           adapter_control;
128   UINT8           status;
132129   UINT8           error;
133130   UINT8           command;
131
132   UINT8           dma_active;
134133   UINT8           interrupt_pending;
135   UINT8           precomp_offset;
136134
137   UINT16          sector_count;
138
139135   UINT16          block_count;
140136   UINT16          sectors_until_int;
141137   UINT8           verify_only;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team