Previous 199869 Revisions Next

r29450 Tuesday 8th April, 2014 at 15:03:52 UTC by Osso
ncr539x.device: converted to devcb2 (nw)
[src/emu/machine]ncr539x.c ncr539x.h
[src/mess/drivers]mac.c

trunk/src/emu/machine/ncr539x.c
r29449r29450
104104   return 6;
105105}
106106
107//-------------------------------------------------
108//  device_config_complete - perform any
109//  operations now that the configuration is
110//  complete
111//-------------------------------------------------
112
113void ncr539x_device::device_config_complete()
114{
115   // inherit a copy of the static data
116   const NCR539Xinterface *intf = reinterpret_cast<const NCR539Xinterface *>(static_config());
117   if (intf != NULL)
118   {
119      *static_cast<NCR539Xinterface *>(this) = *intf;
120   }
121
122   // or initialize to defaults if none provided
123   else
124   {
125      memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
126      memset(&m_out_drq_cb, 0, sizeof(m_out_drq_cb));
127   }
128}
129
130107//**************************************************************************
131108//  LIVE DEVICE
132109//**************************************************************************
r29449r29450
138115//-------------------------------------------------
139116
140117ncr539x_device::ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
141   : device_t(mconfig, NCR539X, "539x SCSI", tag, owner, clock, "ncr539x", __FILE__)
118   : device_t(mconfig, NCR539X, "539x SCSI", tag, owner, clock, "ncr539x", __FILE__),
119   m_out_irq_cb(*this),
120   m_out_drq_cb(*this)
142121{
143122}
144123
r29449r29450
151130   memset(m_scsi_devices, 0, sizeof(m_scsi_devices));
152131
153132   // resolve line callbacks
154   m_out_irq_func.resolve(m_out_irq_cb, *this);
155   m_out_drq_func.resolve(m_out_drq_cb, *this);
133   m_out_irq_cb.resolve_safe();
134   m_out_drq_cb.resolve_safe();
156135
157136   // try to open the devices
158137   for( device_t *device = owner()->first_subdevice(); device != NULL; device = device->next() )
r29449r29450
189168   m_chipid_available = false;
190169   m_chipid_lock = false;
191170
192   m_out_irq_func(CLEAR_LINE);
193   m_out_drq_func(CLEAR_LINE);
171   m_out_irq_cb(CLEAR_LINE);
172   m_out_drq_cb(CLEAR_LINE);
194173}
195174
196175void ncr539x_device::dma_read_data(int bytes, UINT8 *pData)
r29449r29450
233212         // if this is a DMA command, raise DRQ now
234213         if (m_command & 0x80)
235214         {
236            m_out_drq_func(ASSERT_LINE);
215            m_out_drq_cb(ASSERT_LINE);
237216         }
238217
239218         switch (m_command & 0x7f)
r29449r29450
267246                  m_status |= MAIN_STATUS_INTERRUPT;
268247                  m_irq_status |= IRQ_STATUS_DISCONNECTED;
269248               }
270               m_out_irq_func(ASSERT_LINE);
249               m_out_irq_cb(ASSERT_LINE);
271250               break;
272251
273252            case 0x42:  // Select with ATN steps
r29449r29450
298277                  m_status |= MAIN_STATUS_INTERRUPT;
299278                  m_irq_status |= IRQ_STATUS_DISCONNECTED;
300279               }
301               m_out_irq_func(ASSERT_LINE);
280               m_out_irq_cb(ASSERT_LINE);
302281               break;
303282
304283            case 0x11:  // initiator command complete
r29449r29450
308287               m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
309288               m_status &= ~7; // clear phase bits
310289               m_status |= MAIN_STATUS_INTERRUPT | SCSI_PHASE_DATAIN;  // go to data in phase (?)
311               m_out_irq_func(ASSERT_LINE);
290               m_out_irq_cb(ASSERT_LINE);
312291
313292               // this puts status and message bytes into the FIFO (todo: what are these?)
314293               m_fifo_ptr = 0;
r29449r29450
326305               #endif
327306               m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
328307               m_status |= MAIN_STATUS_INTERRUPT;
329               m_out_irq_func(ASSERT_LINE);
308               m_out_irq_cb(ASSERT_LINE);
330309               break;
331310
332311            default:
r29449r29450
407386                     m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
408387                     m_status &= 0x7;    // clear everything but the phase bits
409388                     m_status |= MAIN_STATUS_INTERRUPT | MAIN_STATUS_COUNT_TO_ZERO;
410                     m_out_irq_func(ASSERT_LINE);
389                     m_out_irq_cb(ASSERT_LINE);
411390
412391                     // if no data at all, drop the phase
413392                     if ((m_buffer_remaining + m_total_data) == 0)
r29449r29450
436415         rv = m_irq_status;
437416         // clear the interrupt state
438417         m_status &= ~MAIN_STATUS_INTERRUPT;
439         m_out_irq_func(CLEAR_LINE);
418         m_out_irq_cb(CLEAR_LINE);
440419         break;
441420
442421      case 6:
r29449r29450
515494            case 0x00:  // NOP
516495               m_irq_status = IRQ_STATUS_SUCCESS;
517496               m_status |= MAIN_STATUS_INTERRUPT;
518               m_out_irq_func(ASSERT_LINE);
497               m_out_irq_cb(ASSERT_LINE);
519498
520499               // DMA NOP?  allow chip ID
521500               if ((m_command == 0x80) && (!m_chipid_lock))
r29449r29450
529508               update_fifo_internal_state(0);
530509               m_irq_status = IRQ_STATUS_SUCCESS;
531510               m_status |= MAIN_STATUS_INTERRUPT;
532               m_out_irq_func(ASSERT_LINE);
511               m_out_irq_cb(ASSERT_LINE);
533512               break;
534513
535514            case 0x02:  // Reset device
r29449r29450
537516
538517               m_irq_status = IRQ_STATUS_SUCCESS;
539518               m_status |= MAIN_STATUS_INTERRUPT;
540               m_out_irq_func(ASSERT_LINE);
519               m_out_irq_cb(ASSERT_LINE);
541520               break;
542521
543522            case 0x03:  // Reset SCSI bus
544523               m_status = 0;
545524               m_irq_status = IRQ_STATUS_SUCCESS;
546525               m_status |= MAIN_STATUS_INTERRUPT;
547               m_out_irq_func(ASSERT_LINE);
526               m_out_irq_cb(ASSERT_LINE);
548527               break;
549528
550529            case 0x10:  // information transfer (must happen immediately)
r29449r29450
611590                     m_xfer_count = m_dma_size;
612591                     m_fifo_ptr = 0;
613592                     update_fifo_internal_state(fifo_fill_size);
614                     m_out_drq_func(ASSERT_LINE);
593                     m_out_drq_cb(ASSERT_LINE);
615594                  }
616595
617596                  m_status |= MAIN_STATUS_COUNT_TO_ZERO;
r29449r29450
635614                  m_buffer_offset = 0;
636615                  m_buffer_remaining = 0;
637616               }
638               m_out_irq_func(ASSERT_LINE);
617               m_out_irq_cb(ASSERT_LINE);
639618               break;
640619
641620            case 0x24:  // Terminate steps
r29449r29450
644623               #endif
645624               m_irq_status = IRQ_STATUS_SUCCESS | IRQ_STATUS_DISCONNECTED;
646625               m_status |= MAIN_STATUS_INTERRUPT;
647               m_out_irq_func(ASSERT_LINE);
626               m_out_irq_cb(ASSERT_LINE);
648627               m_fifo_ptr = 0;
649628               update_fifo_internal_state(0);
650629               break;
r29449r29450
655634               #endif
656635               m_irq_status = IRQ_STATUS_SUCCESS;
657636               m_status |= MAIN_STATUS_INTERRUPT;
658               m_out_irq_func(ASSERT_LINE);
637               m_out_irq_cb(ASSERT_LINE);
659638               break;
660639
661640            case 0x44:  // Enable selection/reselection
r29449r29450
664643               #endif
665644               m_irq_status = IRQ_STATUS_SUCCESS;
666645               m_status |= MAIN_STATUS_INTERRUPT;
667               m_out_irq_func(ASSERT_LINE);
646               m_out_irq_cb(ASSERT_LINE);
668647               break;
669648
670649            case 0x47:  // Reselect with ATN3 steps
r29449r29450
695674                  m_status |= MAIN_STATUS_INTERRUPT;
696675                  m_irq_status |= IRQ_STATUS_DISCONNECTED;
697676               }
698               m_out_irq_func(ASSERT_LINE);
677               m_out_irq_cb(ASSERT_LINE);
699678               break;
700679
701680            default:    // other commands are not instantaneous
r29449r29450
846825         m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
847826         m_status &= 7;
848827         m_status |= MAIN_STATUS_INTERRUPT;
849         m_out_irq_func(ASSERT_LINE);
828         m_out_irq_cb(ASSERT_LINE);
850829      }
851830
852831      if ((m_xfer_count == 0) && (m_total_data == 0))
r29449r29450
858837         m_buffer_offset = 0;
859838         m_irq_status = IRQ_STATUS_SERVICE_REQUEST;
860839         m_status = MAIN_STATUS_INTERRUPT | SCSI_PHASE_STATUS;
861         m_out_irq_func(ASSERT_LINE);
840         m_out_irq_cb(ASSERT_LINE);
862841      }
863842   }
864843}
trunk/src/emu/machine/ncr539x.h
r29449r29450
88
99#include "machine/scsihle.h"
1010
11struct NCR539Xinterface
12{
13   devcb_write_line m_out_irq_cb;          /* IRQ line */
14   devcb_write_line m_out_drq_cb;          /* DRQ line */
15};
16
1711//// 539x registers
1812//enum
1913//{
2014//};
2115
2216// device stuff
23#define MCFG_NCR539X_ADD(_tag, _clock, _intrf) \
24   MCFG_DEVICE_ADD(_tag, NCR539X, _clock) \
25   MCFG_DEVICE_CONFIG(_intrf)
2617
27class ncr539x_device : public device_t,
28                  public NCR539Xinterface
18#define MCFG_NCR539X_OUT_IRQ_CB(_devcb) \
19   devcb = &ncr539x_device::set_out_irq_callback(*device, DEVCB2_##_devcb);
20   
21#define MCFG_NCR539X_OUT_DRQ_CB(_devcb) \
22   devcb = &ncr539x_device::set_out_drq_callback(*device, DEVCB2_##_devcb);
23   
24
25class ncr539x_device : public device_t
2926{
3027public:
3128   // construction/destruction
3229   ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
30   
31   template<class _Object> static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_irq_cb.set_callback(object); }
32   template<class _Object> static devcb2_base &set_out_drq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_drq_cb.set_callback(object); }
3333
3434   // our API
3535   DECLARE_READ8_MEMBER(read);
r29449r29450
4242   // device-level overrides
4343   virtual void device_start();
4444   virtual void device_reset();
45   virtual void device_config_complete();
4645   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
4746
4847private:
r29449r29450
8382
8483   emu_timer *m_operation_timer;
8584
86   devcb_resolved_write_line   m_out_irq_func;
87   devcb_resolved_write_line   m_out_drq_func;
85   devcb2_write_line m_out_irq_cb;          /* IRQ line */
86   devcb2_write_line m_out_drq_cb;          /* DRQ line */
8887};
8988
9089// device type definition
trunk/src/mess/drivers/mac.c
r29449r29450
841841   sony_read_status
842842};
843843
844static const struct NCR539Xinterface mac_539x_intf =
845{
846   DEVCB_DRIVER_LINE_MEMBER(mac_state, irq_539x_1_w),
847   DEVCB_DRIVER_LINE_MEMBER(mac_state, drq_539x_1_w)
848};
849
850844static const struct nbbus_interface nubus_intf =
851845{
852846   // interrupt lines
r29449r29450
18681862   MCFG_SCSIBUS_ADD("scsi")
18691863   MCFG_SCSIDEV_ADD("scsi:harddisk1", SCSIHD, SCSI_ID_6)
18701864   MCFG_SCSIDEV_ADD("scsi:harddisk2", SCSIHD, SCSI_ID_5)
1871   MCFG_NCR539X_ADD(MAC_539X_1_TAG, C7M, mac_539x_intf)
1872
1865   MCFG_DEVICE_ADD(MAC_539X_1_TAG, NCR539X, C7M)
1866   MCFG_NCR539X_OUT_IRQ_CB(DEVWRITELINE(DEVICE_SELF_OWNER, mac_state, irq_539x_1_w))
1867   MCFG_NCR539X_OUT_DRQ_CB(DEVWRITELINE(DEVICE_SELF_OWNER, mac_state, drq_539x_1_w))
1868   
18731869   /* internal ram */
18741870   MCFG_RAM_ADD(RAM_TAG)
18751871   MCFG_RAM_DEFAULT_SIZE("4M")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team