Previous 199869 Revisions Next

r23718 Saturday 15th June, 2013 at 12:23:32 UTC by smf
simplified status flags & fixed ct486 booting in mess (nw)
[src/emu/machine]ataflash.c idectrl.c idehd.c idehd.h
[src/mame/drivers]chihiro.c

trunk/src/mame/drivers/chihiro.c
r23717r23718
26642664
26652665   virtual int  read_sector(UINT32 lba, void *buffer);
26662666   virtual int  write_sector(UINT32 lba, const void *buffer);
2667   virtual bool is_ready() { return true; }
2667   virtual bool device_present() { return true; }
26682668   virtual void read_key(UINT8 key[]) { }
26692669protected:
26702670   // device-level overrides
trunk/src/emu/machine/idehd.c
r23717r23718
1616
1717#define TIME_PER_SECTOR                     (attotime::from_usec(100))
1818#define TIME_PER_ROTATION                   (attotime::from_hz(5400/60))
19#define TIME_SECURITY_ERROR                 (attotime::from_msec(1000))
2019
2120#define TIME_SEEK_MULTISECTOR               (attotime::from_msec(13))
2221#define TIME_NO_SEEK_MULTISECTOR            (attotime::from_nsec(16300))
r23717r23718
6766   TID_DELAYED_INTERRUPT,
6867   TID_DELAYED_INTERRUPT_BUFFER_READY,
6968   TID_RESET_CALLBACK,
70   TID_SECURITY_ERROR_DONE,
7169   TID_READ_SECTOR_DONE_CALLBACK,
7270   TID_WRITE_SECTOR_DONE_CALLBACK
7371};
r23717r23718
387385   m_gnetreadlock = 0;
388386   m_master_password_enable = (m_master_password != NULL);
389387   m_user_password_enable = (m_user_password != NULL);
390   m_error = IDE_ERROR_DEFAULT;
388   m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
391389
392390   m_status = IDE_STATUS_DSC;
393   if (is_ready())
394   {
391
392   if (!m_gnetreadlock)
395393      m_status |= IDE_STATUS_DRDY;
396   }
397394
398395   m_cur_drive = 0;
399396
r23717r23718
422419      reset();
423420      break;
424421
425   case TID_SECURITY_ERROR_DONE:
426      /* clear error state */
427      m_status &= ~IDE_STATUS_ERR;
428      m_status |= IDE_STATUS_DRDY;
429      break;
430
431422   case TID_READ_SECTOR_DONE_CALLBACK:
432423      read_sector_done();
433424      break;
r23717r23718
504495{
505496   /* set error state */
506497   m_status |= IDE_STATUS_ERR;
498   m_error = IDE_ERROR_NONE;
507499   m_status &= ~IDE_STATUS_DRDY;
508
509   /* just set a timer and mark ourselves error */
510   timer_set(TIME_SECURITY_ERROR, TID_SECURITY_ERROR_DONE);
511500}
512501
513502
r23717r23718
523512   /* reset the totals */
524513   m_buffer_offset = 0;
525514
526   /* clear the buffer ready and busy flag */
527515   m_status &= ~IDE_STATUS_DRQ;
528   m_status &= ~IDE_STATUS_BSY;
529   m_error = IDE_ERROR_DEFAULT;
530516   set_dmarq(CLEAR_LINE);
531517
532518   if (m_master_password_enable || m_user_password_enable)
533519   {
534520      security_error();
535
536521      m_sector_count = 0;
537
538522      return;
539523   }
540524
541525   /* if there is more data to read, keep going */
542526   if (m_sector_count > 0)
543527      m_sector_count--;
528
544529   if (m_sector_count > 0)
545530      read_next_sector();
546531}
r23717r23718
550535{
551536   int lba = lba_address(), count = 0;
552537
538   m_status &= ~IDE_STATUS_BSY;
539
553540   /* GNET readlock check */
554   if (m_gnetreadlock) {
555      m_status &= ~IDE_STATUS_ERR;
556      m_status &= ~IDE_STATUS_BSY;
541   if (m_gnetreadlock)
542   {
557543      return;
558544   }
559545
560546   /* now do the read */
561547   count = read_sector(lba, m_buffer);
562548
563   /* by default, mark the buffer ready and the seek complete */
564   if (!m_verify_only)
565      m_status |= IDE_STATUS_DRQ;
566
567   m_status |= IDE_STATUS_DSC;
568
569   /* and clear the busy and error flags */
570   m_status &= ~IDE_STATUS_ERR;
571   m_status &= ~IDE_STATUS_BSY;
572
573549   /* if we succeeded, advance to the next sector and set the nice bits */
574550   if (count == 1)
575551   {
r23717r23718
578554      if (m_sector_count != 1)
579555         next_sector();
580556
581      /* clear the error value */
582      m_error = IDE_ERROR_NONE;
583
584557      /* signal an interrupt */
585558      if (!m_verify_only)
586559         m_sectors_until_int--;
r23717r23718
590563         set_irq(ASSERT_LINE);
591564      }
592565
593      /* handle DMA */
594      if (m_dma_active)
595         set_dmarq(ASSERT_LINE);
596
597566      /* if we're just verifying we can read the next sector */
598567      if (m_verify_only)
568      {
599569         read_buffer_empty();
570      }
571      else
572      {
573         m_status |= IDE_STATUS_DRQ;
574
575         if (m_dma_active)
576            set_dmarq(ASSERT_LINE);
577      }
600578   }
601579
602580   /* if we got an error, we need to report it */
r23717r23718
669647   m_buffer_offset = 0;
670648
671649   /* clear the buffer ready flag */
672   m_status &= ~IDE_STATUS_DRQ;
673650   m_status |= IDE_STATUS_BSY;
674651
675652   if (m_command == IDE_COMMAND_WRITE_MULTIPLE)
r23717r23718
695672
696673void ide_mass_storage_device::write_buffer_full()
697674{
675   m_status &= ~IDE_STATUS_DRQ;
698676   set_dmarq(CLEAR_LINE);
699677
700678   if (m_command == IDE_COMMAND_SECURITY_UNLOCK)
r23717r23718
724702         mame_printf_debug("\n");
725703      }
726704
727      /* clear the busy and error flags */
728      m_status &= ~IDE_STATUS_ERR;
729      m_status &= ~IDE_STATUS_BSY;
730      m_status &= ~IDE_STATUS_DRQ;
731
732705      if (m_master_password_enable || m_user_password_enable)
733706         security_error();
734      else
735         m_status |= IDE_STATUS_DRDY;
736707   }
737708   else if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2)
738709   {
r23717r23718
743714      for (i=0; !bad && i<512; i++)
744715         bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != key[i-2]);
745716
746      m_status &= ~IDE_STATUS_BSY;
747      m_status &= ~IDE_STATUS_DRQ;
748717      if (bad)
718      {
749719         m_status |= IDE_STATUS_ERR;
750      else {
751         m_status &= ~IDE_STATUS_ERR;
720         m_error = IDE_ERROR_NONE;
721      }
722      else
723      {
752724         m_gnetreadlock= 0;
753725      }
754726   }
r23717r23718
763735{
764736   int lba = lba_address(), count = 0;
765737
738   m_status &= ~IDE_STATUS_BSY;
739
766740   /* now do the write */
767741   count = write_sector(lba, m_buffer);
768742
769   /* by default, mark the buffer ready and the seek complete */
770   m_status |= IDE_STATUS_DRQ;
771   m_status |= IDE_STATUS_DSC;
772
773   /* and clear the busy adn error flags */
774   m_status &= ~IDE_STATUS_ERR;
775   m_status &= ~IDE_STATUS_BSY;
776
777743   /* if we succeeded, advance to the next sector and set the nice bits */
778744   if (count == 1)
779745   {
r23717r23718
782748      if (m_sector_count != 1)
783749         next_sector();
784750
785      /* clear the error value */
786      m_error = IDE_ERROR_NONE;
787
788751      /* signal an interrupt */
789752      if (--m_sectors_until_int == 0 || m_sector_count == 1)
790753      {
r23717r23718
795758      /* signal an interrupt if there's more data needed */
796759      if (m_sector_count > 0)
797760         m_sector_count--;
798      if (m_sector_count == 0)
799         m_status &= ~IDE_STATUS_DRQ;
800761
801      /* keep going for DMA */
802      if (m_dma_active && m_sector_count != 0)
762      if (m_sector_count > 0)
803763      {
804         set_dmarq(ASSERT_LINE);
764         m_status |= IDE_STATUS_DRQ;
765
766         if (m_dma_active)
767         {
768            set_dmarq(ASSERT_LINE);
769         }
805770      }
806771   }
807772
r23717r23718
833798   set_irq(CLEAR_LINE);
834799   set_dmarq(CLEAR_LINE);
835800
801   m_status &= ~IDE_STATUS_ERR;
802
836803   switch (m_command)
837804   {
838805      case IDE_COMMAND_READ_SECTORS:
r23717r23718
962929
963930         /* indicate everything is ready */
964931         m_status |= IDE_STATUS_DRQ;
965         m_status |= IDE_STATUS_DSC;
966         m_status |= IDE_STATUS_DRDY;
967
968         /* and clear the busy adn error flags */
969         m_status &= ~IDE_STATUS_ERR;
970932         m_status &= ~IDE_STATUS_BSY;
971933
972         /* clear the error too */
973         m_error = IDE_ERROR_NONE;
974
975934         /* signal an interrupt */
976935         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 1);
977936         break;
978937
979938      case IDE_COMMAND_DIAGNOSTIC:
980         m_error = IDE_ERROR_DEFAULT;
939         m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
981940
982941         /* signal an interrupt */
983942         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
984943         break;
985944
986945      case IDE_COMMAND_RECALIBRATE:
987         /* clear the error too */
988         m_error = IDE_ERROR_NONE;
989946         /* signal an interrupt */
990947         signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0);
991948         break;
992949
993950      case IDE_COMMAND_IDLE:
994         /* clear the error too */
995         m_error = IDE_ERROR_NONE;
996
997951         /* for timeout disabled value is 0 */
998952         m_sector_count = 0;
999953         /* signal an interrupt */
r23717r23718
1002956
1003957      case IDE_COMMAND_SET_CONFIG:
1004958         LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", m_cur_head + 1, m_sector_count));
1005         m_status &= ~IDE_STATUS_ERR;
1006         m_error = IDE_ERROR_NONE;
1007959         set_geometry(m_sector_count,m_cur_head + 1);
1008960
1009961         /* signal an interrupt */
r23717r23718
1029981         LOGPRINT(("IDE Set block count (%02X)\n", m_sector_count));
1030982
1031983         m_block_count = m_sector_count;
1032         // judge dredd wants 'drive ready' on this command
1033         m_status |= IDE_STATUS_DRDY;
1034984
1035985         /* signal an interrupt */
1036986         set_irq(ASSERT_LINE);
r23717r23718
1041991
1042992         m_sector_count = 1;
1043993         m_status |= IDE_STATUS_DRDY;
1044         m_status &= ~IDE_STATUS_ERR;
994
1045995         set_irq(ASSERT_LINE);
1046996         break;
1047997
r23717r23718
10681018         {
10691019            m_gnetreadlock= 0;
10701020         }
1021         else
1022         {
1023            m_status &= ~IDE_STATUS_DRDY;
1024         }
10711025
1072         /* update flags */
1073         m_status |= IDE_STATUS_DRDY;
1074         m_status &= ~IDE_STATUS_ERR;
10751026         set_irq(ASSERT_LINE);
10761027         break;
10771028
r23717r23718
10811032             are all already set in this case so no need
10821033             so that implements actual seek
10831034         */
1084         /* clear the error too */
1085         m_error = IDE_ERROR_NONE;
10861035
10871036         /* for timeout disabled value is 0 */
10881037         m_sector_count = 0;
r23717r23718
12501199                     m_last_status_timer->adjust(attotime::never);
12511200                  }
12521201
1202                  if (!(m_status & IDE_STATUS_DRDY) && !m_gnetreadlock)
1203                  {
1204                     m_status |= IDE_STATUS_DRDY;
1205                  }
1206
12531207                  set_irq(CLEAR_LINE);
12541208               }
12551209               else
12561210               {
12571211                  result = 0;
12581212               }
1213
12591214               break;
12601215
12611216            /* log anything else */
r23717r23718
13541309
13551310WRITE16_MEMBER( ide_mass_storage_device::write_cs0 )
13561311{
1312   if (!device_present())
1313      return;
1314
13571315   /* logit */
13581316   if (offset != IDE_CS0_DATA_RW)
13591317      LOG(("%s:IDE cs0 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
r23717r23718
14451403
14461404WRITE16_MEMBER( ide_mass_storage_device::write_cs1 )
14471405{
1406   if (!device_present())
1407      return;
1408
14481409   /* logit */
14491410   LOG(("%s:IDE cs1 write to %X = %08X, mem_mask=%d\n", machine().describe_context(), offset, data, mem_mask));
14501411
trunk/src/emu/machine/idehd.h
r23717r23718
2828#define IDE_STATUS_BSY  (0x80)
2929
3030#define IDE_ERROR_NONE                      0x00
31#define IDE_ERROR_DEFAULT                   0x01
31#define IDE_ERROR_DIAGNOSTIC_OK             0x01
3232#define IDE_ERROR_TRACK0_NOT_FOUND          0x02
3333#define IDE_ERROR_UNKNOWN_COMMAND           0x04
3434#define IDE_ERROR_BAD_LOCATION              0x10
3535#define IDE_ERROR_BAD_SECTOR                0x80
3636
37#define IDE_ERROR_DIAGNOSTIC_FAILED 0x00
38#define IDE_ERROR_DIAGNOSTIC_PASSED 0x01
39#define IDE_ERROR_DIAGNOSTIC_DEVICE1_FAILED 0x81
40
3741// ======================> ide_device_interface
3842
3943class ide_device_interface
r23717r23718
5357   virtual DECLARE_WRITE_LINE_MEMBER(write_csel) = 0;
5458   virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0;
5559
60   virtual bool device_present() = 0;
5661   virtual UINT8 *get_features() = 0;
5762
5863   UINT8           m_master_password_enable;
r23717r23718
9196
9297   virtual int read_sector(UINT32 lba, void *buffer) = 0;
9398   virtual int write_sector(UINT32 lba, const void *buffer) = 0;
94   virtual bool is_ready() = 0;
9599   virtual void read_key(UINT8 key[]) = 0;
96100
97   bool device_selected() { return m_cur_drive == m_csel; }
98   bool single_device() { return m_csel == 0 && m_dasp == 0; }
101   bool device_selected() { return m_csel == m_cur_drive && device_present(); }
102   bool single_device() { return m_csel == 0 && m_dasp == 0 && device_present(); }
99103
100104   void set_irq(int state);
101105   void set_dmarq(int state);
r23717r23718
177181   // optional information overrides
178182   virtual machine_config_constructor device_mconfig_additions() const;
179183
180   virtual bool is_ready() { return (m_disk != NULL); }
184   virtual bool device_present() { return (m_disk != NULL); }
181185   virtual void read_key(UINT8 key[]);
182186
183187   chd_file       *m_handle;
trunk/src/emu/machine/ataflash.c
r23717r23718
99
1010void ata_flash_pccard_device::device_reset()
1111{
12   m_locked = 0x1ff;
13   m_gnetreadlock = 1;
14
1215   ide_hdd_device::device_reset();
1316
1417   UINT32 metalength;
r23717r23718
1619
1720   if (m_handle != NULL)
1821      m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength);
19
20   m_locked = 0x1ff;
21   m_gnetreadlock = 1;
2222}
2323
2424READ16_MEMBER( ata_flash_pccard_device::read_memory )
trunk/src/emu/machine/idectrl.c
r23717r23718
351351         }
352352
353353         dev->write_csel(i);
354         dev->write_dasp(m_slot[1]->dev() != NULL);
354         dev->write_dasp(m_slot[1]->dev() != NULL && m_slot[1]->dev()->device_present());
355355      }
356356   }
357357

Previous 199869 Revisions Next


© 1997-2024 The MAME Team