Previous 199869 Revisions Next

r23904 Monday 24th June, 2013 at 10:24:14 UTC by smf
Uses one timer instead of anonymous timers, so that resetting the device will stop any outstanding work. BSY is always set when waiting for the busy timer to fire. Implemented DASP & PDIAG functionality, device 1 is detected during reset & if device 1 fails diagnostic then device 0 sets bit 7 of it's diagnostic result. Ide cards now default to 1 hard disk, otherwise device 1 without a chd will cause device 0 to report a controller error (AMIBIOS for example doesn't allow booting from device 0 if device 1 fails). Timing of DASP & PDIAG is set very short because of lack of wait states when accessing ATA bus. Improved SRST functionality, which has meant viper needed to be changed to trigger a hard reset instead of a soft reset. Writes to the command register are now ignored with BSY or DRQ is set (packet devices can accept the DEVICE RESET command but they are not supported yet). [smf]
[src/emu/machine]atadev.c atadev.h ataintf.c ataintf.h idehd.c idehd.h
[src/mame/drivers]viper.c
[src/mess/machine]a2cffa.c a2vulcan.c a2zipdrive.c c64_ide64.c isa_ide.c isa_ide8.c kc_d004.c

trunk/src/mame/drivers/viper.c
r23903r23904
14191419               {
14201420                  m_cf_card_ide = 1;
14211421
1422                  // soft reset
1423                  m_ata->write_cs1(space, 6, 0x04, 0xff);
1422                  m_ata->reset();
14241423               }
14251424               break;
14261425            }
trunk/src/emu/machine/idehd.c
r23903r23904
1616
1717#define TIME_PER_SECTOR                     (attotime::from_usec(100))
1818#define TIME_PER_ROTATION                   (attotime::from_hz(5400/60))
19#define TIME_MULTIPLE_SECTORS               (attotime::from_usec(1))
1920
2021#define TIME_SEEK_MULTISECTOR               (attotime::from_msec(13))
2122#define TIME_NO_SEEK_MULTISECTOR            (attotime::from_nsec(16300))
2223
24#define DIAGNOSTIC_TIME                     (attotime::from_msec(2))
25#define DETECT_DEVICE1_TIME                 (attotime::from_msec(2))
26#define DEVICE1_PDIAG_TIME                  (attotime::from_msec(2))
27
2328#define IDE_CS0_DATA_RW              0
2429#define IDE_CS0_ERROR_R              1
2530#define IDE_CS0_FEATURE_W            1
r23903r23904
6368enum
6469{
6570   TID_NULL,
66   TID_DELAYED_INTERRUPT,
67   TID_DELAYED_INTERRUPT_BUFFER_READY,
68   TID_RESET_CALLBACK,
69   TID_READ_SECTOR_DONE_CALLBACK,
70   TID_WRITE_SECTOR_DONE_CALLBACK
71   TID_BUSY,
7172};
7273
74enum
75{
76   PARAM_RESET,
77   PARAM_DETECT_DEVICE1,
78   PARAM_DIAGNOSTIC,
79   PARAM_WAIT_FOR_PDIAG,
80   PARAM_COMMAND
81};
82
7383ata_mass_storage_device::ata_mass_storage_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source)
7484   : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
7585   ata_device_interface(mconfig, *this),
7686   device_slot_card_interface(mconfig, *this),
7787   m_can_identify_device(0),
7888   m_csel(0),
79   m_dasp(0),
89   m_daspin(0),
90   m_daspout(0),
8091   m_dmack(0),
8192   m_dmarq(0),
8293   m_irq(0),
94   m_pdiagin(0),
95   m_pdiagout(0),
8396   m_master_password(NULL),
8497   m_user_password(NULL)
8598{
r23903r23904
118131   }
119132}
120133
134void ata_mass_storage_device::set_dasp(int state)
135{
136   if (m_daspout != state)
137   {
138      m_daspout = state;
139
140      m_dasp_handler(state);
141   }
142}
143
144void ata_mass_storage_device::set_pdiag(int state)
145{
146   if (m_pdiagout != state)
147   {
148      m_pdiagout = state;
149
150      m_pdiag_handler(state);
151   }
152}
153
121154WRITE_LINE_MEMBER( ata_mass_storage_device::write_csel )
122155{
123156   m_csel = state;
r23903r23904
125158
126159WRITE_LINE_MEMBER( ata_mass_storage_device::write_dasp )
127160{
128   m_dasp = state;
161   m_daspin = state;
129162}
130163
131164WRITE_LINE_MEMBER( ata_mass_storage_device::write_dmack )
r23903r23904
133166   m_dmack = state;
134167}
135168
169WRITE_LINE_MEMBER( ata_mass_storage_device::write_pdiag )
170{
171   m_pdiagin = state;
172
173   if (m_pdiagin == ASSERT_LINE && m_busy_timer->param() == PARAM_WAIT_FOR_PDIAG)
174   {
175      stop_busy();
176      finished_diagnostic();
177   }
178}
179
136180/*************************************
137181 *
138182 *  Compute the LBA address
r23903r23904
334378{
335379   m_irq_handler.resolve_safe();
336380   m_dmarq_handler.resolve_safe();
381   m_dasp_handler.resolve_safe();
382   m_pdiag_handler.resolve_safe();
337383
338384   save_item(NAME(m_buffer));
339385   save_item(NAME(m_buffer_offset));
r23903r23904
360406
361407   /* create a timer for timing status */
362408   m_last_status_timer = timer_alloc(TID_NULL);
363   m_reset_timer = timer_alloc(TID_RESET_CALLBACK);
409   m_busy_timer = timer_alloc(TID_BUSY);
364410}
365411
366412void ata_mass_storage_device::device_reset()
367413{
414   /* reset the drive state */
415   set_dasp(CLEAR_LINE);
416   set_dmarq(CLEAR_LINE);
417   set_irq(CLEAR_LINE);
418   set_pdiag(CLEAR_LINE);
419
420   m_status = 0;
421   m_device_control = 0;
422   m_resetting = true;
423
424   if (m_csel == 0)
425   {
426      start_busy(DETECT_DEVICE1_TIME, PARAM_DETECT_DEVICE1);
427   }
428   else
429   {
430      set_dasp(ASSERT_LINE);
431      soft_reset();
432   }
433}
434
435void ata_mass_storage_device::soft_reset()
436{
368437   m_buffer_offset = 0;
369438   m_master_password_enable = (m_master_password != NULL);
370439   m_user_password_enable = (m_user_password != NULL);
r23903r23904
376445      m_status |= IDE_STATUS_DRDY;
377446   }
378447
448   start_busy(DIAGNOSTIC_TIME, PARAM_DIAGNOSTIC);
449}
450
451void ata_mass_storage_device::perform_diagnostic()
452{
379453   if (m_can_identify_device)
454   {
380455      m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
456
457      if (m_csel == 1)
458         set_pdiag(ASSERT_LINE);
459   }
381460   else
382461      m_error = IDE_ERROR_DIAGNOSTIC_FAILED;
383462
463   if (m_csel == 0 && !m_single_device && m_pdiagin == CLEAR_LINE)
464      start_busy(DEVICE1_PDIAG_TIME, PARAM_WAIT_FOR_PDIAG);
465   else
466      finished_diagnostic();
467}
468
469void ata_mass_storage_device::finished_diagnostic()
470{
384471   m_sector_count = 1;
385472   m_sector_number = 1;
386473   m_cylinder_low = 0;
387474   m_cylinder_high = 0;
388475   m_device_head = 0;
389476
390   /* reset the drive state */
391   set_irq(CLEAR_LINE);
392   set_dmarq(CLEAR_LINE);
477   m_resetting = false;
393478}
394479
480
481void ata_mass_storage_device::start_busy(attotime time, int param)
482{
483   m_status |= IDE_STATUS_BSY;
484   m_busy_timer->adjust(time, param);
485}
486
487void ata_mass_storage_device::stop_busy()
488{
489   m_status &= ~IDE_STATUS_BSY;
490   m_busy_timer->adjust(attotime::never);
491}
492
395493void ata_mass_storage_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
396494{
397495   switch(id)
398496   {
399   case TID_DELAYED_INTERRUPT:
497   case TID_BUSY:
400498      m_status &= ~IDE_STATUS_BSY;
401499
402      set_irq(ASSERT_LINE);
500      finished_busy(param);
403501      break;
502   }
503}
404504
405   case TID_DELAYED_INTERRUPT_BUFFER_READY:
406      m_status &= ~IDE_STATUS_BSY;
407      m_status |= IDE_STATUS_DRQ;
408
409      set_irq(ASSERT_LINE);
505void ata_mass_storage_device::finished_busy(int param)
506{
507   switch (param)
508   {
509   case PARAM_DETECT_DEVICE1:
510      m_single_device = (m_daspin == CLEAR_LINE);
511      soft_reset();
410512      break;
411513
412   case TID_RESET_CALLBACK:
413      reset();
514   case PARAM_DIAGNOSTIC:
515      perform_diagnostic();
414516      break;
415517
416   case TID_READ_SECTOR_DONE_CALLBACK:
417      read_sector_done();
518   case PARAM_WAIT_FOR_PDIAG:
519      m_error |= 0x80;
520      finished_diagnostic();
418521      break;
419522
420   case TID_WRITE_SECTOR_DONE_CALLBACK:
421      write_sector_done();
422      break;
523   case PARAM_COMMAND:
524      switch (m_command)
525      {
526      case IDE_COMMAND_DIAGNOSTIC:
527         perform_diagnostic();
528
529         if (m_csel == 0)
530            set_irq(ASSERT_LINE);
531         break;
532
533      case IDE_COMMAND_IDENTIFY_DEVICE:
534         if (m_can_identify_device)
535         {
536            memcpy(m_buffer, m_identify_device, sizeof(m_buffer));
537            m_status |= IDE_STATUS_DRQ;
538         }
539         else
540         {
541            m_status |= IDE_STATUS_ERR;
542            m_error = IDE_ERROR_NONE;
543         }
544
545         set_irq(ASSERT_LINE);
546         break;
547
548      case IDE_COMMAND_SET_CONFIG:
549         set_geometry(m_sector_count,(m_device_head & IDE_DEVICE_HEAD_HS) + 1);
550         set_irq(ASSERT_LINE);
551         break;
552
553      case IDE_COMMAND_READ_SECTORS:
554      case IDE_COMMAND_READ_SECTORS_NORETRY:
555      case IDE_COMMAND_READ_MULTIPLE:
556      case IDE_COMMAND_VERIFY_SECTORS:
557      case IDE_COMMAND_VERIFY_SECTORS_NORETRY:
558      case IDE_COMMAND_READ_DMA:
559         read_sector_done();
560         break;
561
562      case IDE_COMMAND_WRITE_SECTORS:
563      case IDE_COMMAND_WRITE_SECTORS_NORETRY:
564      case IDE_COMMAND_WRITE_MULTIPLE:
565      case IDE_COMMAND_WRITE_DMA:
566         write_sector_done();
567         break;
568
569      case IDE_COMMAND_RECALIBRATE:
570         set_irq(ASSERT_LINE);
571         break;
572
573      case IDE_COMMAND_SET_FEATURES:
574         set_irq(ASSERT_LINE);
575         break;
576
577      default:
578         logerror( "finished_busy(%d) unhandled command %02x\n", param, m_command );
579         break;
580      }
423581   }
424582}
425583
r23903r23904
539697{
540698   int lba = lba_address(), count = 0;
541699
542   m_status &= ~IDE_STATUS_BSY;
700   set_dasp(CLEAR_LINE);
543701
544702   /* now do the read */
545703   count = read_sector(lba, m_buffer);
r23903r23904
589747
590748void ata_mass_storage_device::read_first_sector()
591749{
592   /* mark ourselves busy */
593   m_status |= IDE_STATUS_BSY;
750   set_dasp(ASSERT_LINE);
594751
595752   /* just set a timer */
596753   if (m_command == IDE_COMMAND_READ_MULTIPLE)
r23903r23904
599756      attotime seek_time;
600757
601758      if (new_lba == m_cur_lba || new_lba == m_cur_lba + 1)
602         seek_time = TIME_NO_SEEK_MULTISECTOR;
759         start_busy(TIME_NO_SEEK_MULTISECTOR, PARAM_COMMAND);
603760      else
604         seek_time = TIME_SEEK_MULTISECTOR;
761         start_busy(TIME_SEEK_MULTISECTOR, PARAM_COMMAND);
605762
606763      m_cur_lba = new_lba;
607      timer_set(seek_time, TID_READ_SECTOR_DONE_CALLBACK);
608764   }
609765   else
610      timer_set(TIME_PER_SECTOR, TID_READ_SECTOR_DONE_CALLBACK);
766      start_busy(TIME_PER_SECTOR, PARAM_COMMAND);
611767}
612768
613769
614770void ata_mass_storage_device::read_next_sector()
615771{
616   /* mark ourselves busy */
617   m_status |= IDE_STATUS_BSY;
772   set_dasp(ASSERT_LINE);
618773
619774   if (m_command == IDE_COMMAND_READ_MULTIPLE)
620775   {
r23903r23904
622777         /* make ready now */
623778         read_sector_done();
624779      else
625         /* just set a timer */
626         timer_set(attotime::from_usec(1), TID_READ_SECTOR_DONE_CALLBACK);
780         start_busy(TIME_MULTIPLE_SECTORS, PARAM_COMMAND);
627781   }
628782   else
629      /* just set a timer */
630      timer_set(TIME_PER_SECTOR, TID_READ_SECTOR_DONE_CALLBACK);
783      start_busy(TIME_PER_SECTOR, PARAM_COMMAND);
631784}
632785
633786
r23903r23904
643796   /* reset the totals */
644797   m_buffer_offset = 0;
645798
646   /* clear the buffer ready flag */
647   m_status |= IDE_STATUS_BSY;
799   set_dasp(ASSERT_LINE);
648800
649801   if (m_command == IDE_COMMAND_WRITE_MULTIPLE)
650802   {
r23903r23904
656808      else
657809      {
658810         /* set a timer to do the write */
659         timer_set(TIME_PER_SECTOR, TID_WRITE_SECTOR_DONE_CALLBACK);
811         start_busy(TIME_PER_SECTOR, PARAM_COMMAND);
660812      }
661813   }
662814   else
663815   {
664816      /* set a timer to do the write */
665      timer_set(TIME_PER_SECTOR, TID_WRITE_SECTOR_DONE_CALLBACK);
817      start_busy(TIME_PER_SECTOR, PARAM_COMMAND);
666818   }
667819}
668820
r23903r23904
718870{
719871   int lba = lba_address(), count = 0;
720872
721   m_status &= ~IDE_STATUS_BSY;
873   set_dasp(CLEAR_LINE);
722874
723875   /* now do the write */
724876   count = write_sector(lba, m_buffer);
r23903r23904
8671019   case IDE_COMMAND_IDENTIFY_DEVICE:
8681020      LOGPRINT(("IDE Identify device\n"));
8691021
870      m_status |= IDE_STATUS_BSY;
871      if (m_can_identify_device)
872      {
873         memcpy(m_buffer, m_identify_device, sizeof(m_buffer));
874
875         timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT_BUFFER_READY);
876      }
877      else
878      {
879         m_status |= IDE_STATUS_ERR;
880         m_error = IDE_ERROR_NONE;
881         timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT);
882      }
1022      start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
8831023      return true;
8841024
8851025   case IDE_COMMAND_DIAGNOSTIC:
886      if (m_can_identify_device)
887         m_error = IDE_ERROR_DIAGNOSTIC_PASSED;
888      else
889         m_error = IDE_ERROR_DIAGNOSTIC_FAILED;
890
891      m_status |= IDE_STATUS_BSY;
892      timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT);
1026      start_busy(DIAGNOSTIC_TIME, PARAM_COMMAND);
8931027      return true;
8941028
8951029   case IDE_COMMAND_RECALIBRATE:
896      m_status |= IDE_STATUS_BSY;
897      timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT);
1030      start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
8981031      return true;
8991032
9001033   case IDE_COMMAND_IDLE:
r23903r23904
9041037
9051038   case IDE_COMMAND_SET_CONFIG:
9061039      LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", (m_device_head & IDE_DEVICE_HEAD_HS) + 1, m_sector_count));
907      set_geometry(m_sector_count,(m_device_head & IDE_DEVICE_HEAD_HS) + 1);
9081040
909      m_status |= IDE_STATUS_BSY;
910      timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT);
1041      start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
9111042      return true;
9121043
9131044   case IDE_COMMAND_SET_MAX:
r23903r23904
9201051   case IDE_COMMAND_SET_FEATURES:
9211052      LOGPRINT(("IDE Set features (%02X %02X %02X %02X %02X)\n", m_feature, m_sector_count & 0xff, m_sector_number, m_cylinder_low, m_cylinder_high));
9221053
923      m_status |= IDE_STATUS_BSY;
924      timer_set(MINIMUM_COMMAND_TIME, TID_DELAYED_INTERRUPT);
1054      start_busy(MINIMUM_COMMAND_TIME, PARAM_COMMAND);
9251055      return true;
9261056
9271057   case IDE_COMMAND_SET_BLOCK_COUNT:
r23903r23904
9891119
9901120   UINT16 result = 0xffff;
9911121
992   if (device_selected() || single_device())
1122   if (device_selected() || m_single_device)
9931123   {
9941124      if (m_dmack)
9951125      {
r23903r23904
9971127      }
9981128      else if ((m_status & IDE_STATUS_BSY) && offset != IDE_CS0_STATUS_R)
9991129      {
1130         // ATA5 spec says status reads should also go through here, but this breaks Primal Rage 2.
1131         // Real hardware might work due to read ahead in the vt83c461.
10001132         if (device_selected())
10011133         {
10021134            switch (offset)
r23903r23904
10931225                  }
10941226
10951227                  if (!(m_status & IDE_STATUS_DRDY) && is_ready())
1096                  {
10971228                     m_status |= IDE_STATUS_DRDY;
1098                  }
10991229
11001230                  set_irq(CLEAR_LINE);
11011231               }
r23903r23904
11251255
11261256   UINT16 result = 0xffff;
11271257
1128   if (device_selected() || single_device())
1258   if (device_selected() || m_single_device)
11291259   {
11301260      if (m_dmack)
11311261      {
r23903r23904
12121342   }
12131343   else if ((m_status & IDE_STATUS_BSY) && offset != IDE_CS0_COMMAND_W)
12141344   {
1215      logerror( "%s: dev %d write_cs0 %04x %04x %04x ignored (BSY)\n", machine().describe_context(), dev(), offset, data, mem_mask );
1345      logerror( "%s: dev %d write_cs0 %04x %04x %04x ignored (BSY) command %02x\n", machine().describe_context(), dev(), offset, data, mem_mask, m_command );
12161346   }
12171347   else if ((m_status & IDE_STATUS_DRQ) && offset != IDE_CS0_DATA_RW && offset != IDE_CS0_COMMAND_W)
12181348   {
r23903r23904
12841414
12851415         /* command */
12861416         case IDE_CS0_COMMAND_W:
1287            m_command = data;
1417            // Packet devices can accept DEVICE RESET when BSY or DRQ is set.
1418            if (m_status & IDE_STATUS_BSY)
1419            {
1420               logerror( "%s: dev %d write_cs0 %04x %04x %04x ignored (BSY) command %02x\n", machine().describe_context(), dev(), offset, data, mem_mask, m_command );
1421            }
1422            else if (m_status & IDE_STATUS_DRQ)
1423            {
1424               logerror( "%s: dev %d write_cs0 %04x %04x %04x ignored (DRQ) command %02x\n", machine().describe_context(), dev(), offset, data, mem_mask, m_command );
1425            }
1426            else if (device_selected() || m_command == IDE_COMMAND_DIAGNOSTIC)
1427            {
1428               m_command = data;
12881429
1289            if (device_selected() || m_command == IDE_COMMAND_DIAGNOSTIC)
1290            {
12911430               /* implicitly clear interrupts & dmarq here */
12921431               set_irq(CLEAR_LINE);
12931432               set_dmarq(CLEAR_LINE);
r23903r23904
12951434               m_buffer_offset = 0;
12961435               m_sectors_until_int = 0;
12971436
1298               m_status &= ~IDE_STATUS_BSY;
1437               set_dasp(CLEAR_LINE);
12991438               m_status &= ~IDE_STATUS_DRQ;
13001439               m_status &= ~IDE_STATUS_ERR;
13011440
r23903r23904
13441483            {
13451484               if (m_device_control & IDE_DEVICE_CONTROL_SRST)
13461485               {
1347                  m_status |= IDE_STATUS_BSY;
1348                  set_irq(CLEAR_LINE);
1349                  m_reset_timer->adjust(attotime::from_msec(5));
1486                  if (m_resetting)
1487                  {
1488                     logerror( "%s: dev %d write_cs1 %04x %04x %04x ignored (RESET)\n", machine().describe_context(), dev(), offset, data, mem_mask );
1489                  }
1490                  else
1491                  {
1492                     set_dasp(CLEAR_LINE);
1493                     set_dmarq(CLEAR_LINE);
1494                     set_irq(CLEAR_LINE);
1495                     set_pdiag(CLEAR_LINE);
1496
1497                     start_busy(attotime::never, PARAM_RESET);
1498                  }
13501499               }
1500               else if (m_busy_timer->param() == PARAM_RESET)
1501               {
1502                  soft_reset();
1503               }
13511504            }
13521505            break;
13531506
trunk/src/emu/machine/idehd.h
r23903r23904
6161   virtual DECLARE_WRITE_LINE_MEMBER(write_csel);
6262   virtual DECLARE_WRITE_LINE_MEMBER(write_dasp);
6363   virtual DECLARE_WRITE_LINE_MEMBER(write_dmack);
64   virtual DECLARE_WRITE_LINE_MEMBER(write_pdiag);
6465
6566   UINT8 *identify_device_buffer() { return m_identify_device; }
6667
r23903r23904
8889
8990   int dev() { return (m_device_head & IDE_DEVICE_HEAD_DRV) >> 4; }
9091   bool device_selected() { return m_csel == dev(); }
91   bool single_device() { return m_csel == 0 && m_dasp == 0; }
9292
9393   void set_irq(int state);
9494   void set_dmarq(int state);
95   void set_dasp(int state);
96   void set_pdiag(int state);
9597   void ide_build_identify_device();
9698
9799   virtual bool process_command();
98100   virtual void process_buffer();
99101   virtual void fill_buffer();
102   virtual void finished_busy(int param);
100103
101104   UINT8           m_buffer[IDE_DISK_SECTOR_SIZE];
102105   UINT16          m_buffer_offset;
r23903r23904
131134   void read_buffer_empty();
132135   void write_buffer_full();
133136   void update_irq();
137   void start_busy(attotime time, int param);
138   void stop_busy();
139   void soft_reset();
140   void perform_diagnostic();
141   void finished_diagnostic();
134142
135143   int m_csel;
136   int m_dasp;
144   int m_daspin;
145   int m_daspout;
137146   int m_dmack;
138147   int m_dmarq;
139148   int m_irq;
149   int m_pdiagin;
150   int m_pdiagout;
140151
152   bool m_resetting;
153   bool m_single_device;
154
141155   UINT32          m_cur_lba;
142156   UINT16          m_block_count;
143157   UINT16          m_sectors_until_int;
r23903r23904
148162   const UINT8 *   m_user_password;
149163
150164   emu_timer *     m_last_status_timer;
151   emu_timer *     m_reset_timer;
165   emu_timer *     m_busy_timer;
152166};
153167
154168// ======================> ide_hdd_device
trunk/src/emu/machine/atadev.c
r23903r23904
1212
1313ata_device_interface::ata_device_interface(const machine_config &mconfig, device_t &device) :
1414   m_irq_handler(device),
15   m_dmarq_handler(device)
15   m_dmarq_handler(device),
16   m_dasp_handler(device),
17   m_pdiag_handler(device)
1618{
1719}
trunk/src/emu/machine/atadev.h
r23903r23904
3434   virtual DECLARE_WRITE_LINE_MEMBER(write_dmack) = 0;
3535   virtual DECLARE_WRITE_LINE_MEMBER(write_csel) = 0;
3636   virtual DECLARE_WRITE_LINE_MEMBER(write_dasp) = 0;
37   virtual DECLARE_WRITE_LINE_MEMBER(write_pdiag) = 0;
3738
3839   devcb2_write_line m_irq_handler;
3940   devcb2_write_line m_dmarq_handler;
41   devcb2_write_line m_dasp_handler;
42   devcb2_write_line m_pdiag_handler;
4043};
4144
4245#endif
trunk/src/emu/machine/ataintf.c
r23903r23904
1414#include "debugger.h"
1515#include "idehd.h"
1616
17/***************************************************************************
18    DEBUGGING
19***************************************************************************/
20
21#define VERBOSE                     0
22
23#define LOG(x)  do { if (VERBOSE) logerror x; } while (0)
24
2517void ata_interface_device::set_irq(int state)
2618{
2719//  printf( "irq %d\n", state );
2820
29   if (state == ASSERT_LINE)
30      LOG(("ATA interrupt assert\n"));
31   else
32      LOG(("ATA interrupt clear\n"));
33
34   /* signal an interrupt */
3521   m_irq_handler(state);
3622}
3723
r23903r23904
4228   m_dmarq_handler(state);
4329}
4430
31void ata_interface_device::set_dasp(int state)
32{
33//  printf( "dasp %d\n", state );
34
35   m_dasp_handler(state);
36}
37
4538WRITE_LINE_MEMBER( ata_interface_device::irq0_write_line )
4639{
4740   if (m_irq[0] != state)
r23903r23904
6255   }
6356}
6457
58WRITE_LINE_MEMBER( ata_interface_device::dasp0_write_line )
59{
60   if (m_dasp[0] != state)
61   {
62      m_dasp[0] = state;
63
64      set_dasp(m_dasp[0] == ASSERT_LINE || m_dasp[1] == ASSERT_LINE);
65   }
66}
67
68WRITE_LINE_MEMBER( ata_interface_device::dasp1_write_line )
69{
70   if (m_dasp[1] != state)
71   {
72      m_dasp[1] = state;
73
74      ata_device_interface *dev = m_slot[0]->dev();
75      if (dev != NULL)
76         dev->write_dasp(state);
77
78      set_dasp(m_dasp[0] == ASSERT_LINE || m_dasp[1] == ASSERT_LINE);
79   }
80}
81
6582WRITE_LINE_MEMBER( ata_interface_device::dmarq0_write_line )
6683{
6784   if (m_dmarq[0] != state)
r23903r23904
8299   }
83100}
84101
102WRITE_LINE_MEMBER( ata_interface_device::pdiag0_write_line )
103{
104   m_pdiag[0] = state;
105}
85106
107WRITE_LINE_MEMBER( ata_interface_device::pdiag1_write_line )
108{
109   if (m_pdiag[1] != state)
110   {
111      m_pdiag[1] = state;
112
113      ata_device_interface *dev = m_slot[0]->dev();
114      if (dev != NULL)
115         dev->write_pdiag(state);
116   }
117}
118
86119/*************************************
87120 *
88121 *  ATA interface read
r23903r23904
174207ata_interface_device::ata_interface_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
175208   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
176209   m_irq_handler(*this),
177   m_dmarq_handler(*this)
178{
210   m_dmarq_handler(*this),
211   m_dasp_handler(*this){
179212}
180213
181214
r23903r23904
184217ata_interface_device::ata_interface_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
185218   device_t(mconfig, ATA_INTERFACE, "ATA Interface", tag, owner, clock, "ata_interface", __FILE__),
186219   m_irq_handler(*this),
187   m_dmarq_handler(*this)
220   m_dmarq_handler(*this),
221   m_dasp_handler(*this)
188222{
189223}
190224
r23903r23904
196230{
197231   m_irq_handler.resolve_safe();
198232   m_dmarq_handler.resolve_safe();
233   m_dasp_handler.resolve_safe();
199234
200235   /* set MAME harddisk handle */
201236   m_slot[0] = subdevice<ata_slot_device>("0");
r23903r23904
205240   {
206241      m_irq[i] = 0;
207242      m_dmarq[i] = 0;
243      m_dasp[i] = 0;
244      m_pdiag[i] = 0;
208245
209246      ata_device_interface *dev = m_slot[i]->dev();
210247      if (dev != NULL)
r23903r23904
213250         {
214251            dev->m_irq_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, irq0_write_line));
215252            dev->m_dmarq_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, dmarq0_write_line));
253            dev->m_dasp_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, dasp0_write_line));
254            dev->m_pdiag_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, pdiag0_write_line));
216255         }
217256         else
218257         {
219258            dev->m_irq_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, irq1_write_line));
220259            dev->m_dmarq_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, dmarq1_write_line));
260            dev->m_dasp_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, dasp1_write_line));
261            dev->m_pdiag_handler.set_callback(DEVCB2_DEVWRITELINE("^", ata_interface_device, pdiag1_write_line));
221262         }
222263
223264         dev->write_csel(i);
224         dev->write_dasp(m_slot[1]->dev() != NULL);
225265      }
226266   }
227267}
228268
229//-------------------------------------------------
230//  device_reset - device-specific reset
231//-------------------------------------------------
232
233void ata_interface_device::device_reset()
234{
235   LOG(("ATA interface reset\n"));
236}
237
238
239
240269//**************************************************************************
241270//  ATA SLOT DEVICE
242271//**************************************************************************
trunk/src/emu/machine/ataintf.h
r23903r23904
5151#define MCFG_ATA_INTERFACE_DMARQ_HANDLER(_devcb) \
5252   devcb = &ata_interface_device::set_dmarq_handler(*device, DEVCB2_##_devcb);
5353
54#define MCFG_ATA_INTERFACE_DASP_HANDLER(_devcb) \
55   devcb = &ata_interface_device::set_dasp_handler(*device, DEVCB2_##_devcb);
56
5457SLOT_INTERFACE_EXTERN(ata_devices);
5558
5659/***************************************************************************
r23903r23904
8285   // static configuration helpers
8386   template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_irq_handler.set_callback(object); }
8487   template<class _Object> static devcb2_base &set_dmarq_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_dmarq_handler.set_callback(object); }
85
88   template<class _Object> static devcb2_base &set_dasp_handler(device_t &device, _Object object) { return downcast<ata_interface_device &>(device).m_dasp_handler.set_callback(object); }
8689   UINT16 read_dma();
8790   virtual DECLARE_READ16_MEMBER(read_cs0);
8891   virtual DECLARE_READ16_MEMBER(read_cs1);
r23903r23904
9598protected:
9699   // device-level overrides
97100   virtual void device_start();
98   virtual void device_reset();
99101
100102   virtual void set_irq(int state);
101103   virtual void set_dmarq(int state);
104   virtual void set_dasp(int state);
102105
103106private:
104107   DECLARE_WRITE_LINE_MEMBER(irq0_write_line);
105108   DECLARE_WRITE_LINE_MEMBER(dmarq0_write_line);
109   DECLARE_WRITE_LINE_MEMBER(dasp0_write_line);
110   DECLARE_WRITE_LINE_MEMBER(pdiag0_write_line);
106111
107112   DECLARE_WRITE_LINE_MEMBER(irq1_write_line);
108113   DECLARE_WRITE_LINE_MEMBER(dmarq1_write_line);
114   DECLARE_WRITE_LINE_MEMBER(dasp1_write_line);
115   DECLARE_WRITE_LINE_MEMBER(pdiag1_write_line);
109116
110117   ata_slot_device *m_slot[2];
111118   int m_irq[2];
112119   int m_dmarq[2];
120   int m_dasp[2];
121   int m_pdiag[2];
113122
114123   devcb2_write_line m_irq_handler;
115124   devcb2_write_line m_dmarq_handler;
125   devcb2_write_line m_dasp_handler;
116126};
117127
118128extern const device_type ATA_INTERFACE;
trunk/src/mess/machine/c64_ide64.c
r23903r23904
4949   MCFG_ATMEL_29C010_ADD(AT29C010A_TAG)
5050   MCFG_DS1302_ADD(DS1302_TAG, XTAL_32_768kHz)
5151
52   MCFG_ATA_INTERFACE_ADD(ATA_TAG, ata_devices, "hdd", "hdd", false)
52   MCFG_ATA_INTERFACE_ADD(ATA_TAG, ata_devices, "hdd", NULL, false)
5353MACHINE_CONFIG_END
5454
5555
trunk/src/mess/machine/isa_ide.c
r23903r23904
4040}
4141
4242static MACHINE_CONFIG_FRAGMENT( ide )
43   MCFG_IDE_CONTROLLER_ADD("ide", ata_devices, "hdd", "hdd", false)
43   MCFG_IDE_CONTROLLER_ADD("ide", ata_devices, "hdd", NULL, false)
4444   MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(isa16_ide_device, ide_interrupt))
4545MACHINE_CONFIG_END
4646
trunk/src/mess/machine/a2zipdrive.c
r23903r23904
3232#define ZIPDRIVE_ATA_TAG     "zipdrive_ata"
3333
3434static MACHINE_CONFIG_FRAGMENT( zipdrive )
35   MCFG_ATA_INTERFACE_ADD(ZIPDRIVE_ATA_TAG, ata_devices, "hdd", "hdd", false)
35   MCFG_ATA_INTERFACE_ADD(ZIPDRIVE_ATA_TAG, ata_devices, "hdd", NULL, false)
3636MACHINE_CONFIG_END
3737
3838ROM_START( zipdrive )
trunk/src/mess/machine/a2cffa.c
r23903r23904
3232#define CFFA2_ATA_TAG     "cffa2_ata"
3333
3434MACHINE_CONFIG_FRAGMENT( cffa2 )
35   MCFG_ATA_INTERFACE_ADD(CFFA2_ATA_TAG, ata_devices, "hdd", "hdd", false)
35   MCFG_ATA_INTERFACE_ADD(CFFA2_ATA_TAG, ata_devices, "hdd", NULL, false)
3636MACHINE_CONFIG_END
3737
3838ROM_START( cffa2 )
trunk/src/mess/machine/isa_ide8.c
r23903r23904
114114}
115115
116116static MACHINE_CONFIG_FRAGMENT( ide8_config )
117   MCFG_IDE_CONTROLLER_ADD("ide", ata_devices, "hdd", "hdd", false)
117   MCFG_IDE_CONTROLLER_ADD("ide", ata_devices, "hdd", NULL, false)
118118   MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(isa8_ide_device, ide_interrupt))
119119MACHINE_CONFIG_END
120120
trunk/src/mess/machine/kc_d004.c
r23903r23904
9090   MCFG_CPU_MODIFY(Z80_TAG)
9191   MCFG_CPU_IO_MAP(kc_d004_gide_io)
9292
93   MCFG_ATA_INTERFACE_ADD(ATA_TAG, ata_devices, "hdd", "hdd", false)
93   MCFG_ATA_INTERFACE_ADD(ATA_TAG, ata_devices, "hdd", NULL, false)
9494MACHINE_CONFIG_END
9595
9696
trunk/src/mess/machine/a2vulcan.c
r23903r23904
6666#define VULCAN_ATA_TAG     "vulcan_ata"
6767
6868static MACHINE_CONFIG_FRAGMENT( vulcan )
69   MCFG_ATA_INTERFACE_ADD(VULCAN_ATA_TAG, ata_devices, "hdd", "hdd", false)
69   MCFG_ATA_INTERFACE_ADD(VULCAN_ATA_TAG, ata_devices, "hdd", NULL, false)
7070MACHINE_CONFIG_END
7171
7272ROM_START( vulcan )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team