Previous 199869 Revisions Next

r34778 Sunday 1st February, 2015 at 03:28:22 UTC by R. Belmont
(MESS) apple2 updates: [R. Belmont]
- Provide centralized DMA mechanism for slot cards
- Fixed 0.156 regressions for Z80 SoftCard, The Mill 6809, and Mountain Computer Music System
- Provide debugger protection for slot-based foreign CPUs executing from Apple II DMA
[src/emu/bus/a2bus]a2bus.c a2bus.h a2mcms.c a2mcms.h a2softcard.c a2softcard.h a2themill.c a2themill.h

trunk/src/emu/bus/a2bus/a2bus.c
r243289r243290
160160void a2bus_device::device_start()
161161{
162162   m_maincpu = machine().device<cpu_device>(m_cputag);
163   m_maincpu_space = &machine().device<cpu_device>(m_cputag)->space(AS_PROGRAM);
163164
164165   // resolve callbacks
165166   m_out_irq_cb.resolve_safe();
r243289r243290
246247   m_maincpu->set_input_line(INPUT_LINE_HALT, state);
247248}
248249
250UINT8 a2bus_device::dma_r(address_space &space, UINT16 offset)
251{
252   m_maincpu_space->set_debugger_access(space.debugger_access());
253
254   return m_maincpu_space->read_byte(offset);
255}
256
257void a2bus_device::dma_w(address_space &space, UINT16 offset, UINT8 data)
258{
259   m_maincpu_space->set_debugger_access(space.debugger_access());
260
261   m_maincpu_space->write_byte(offset, data);
262}
263
264UINT8 a2bus_device::dma_nospace_r(UINT16 offset)
265{
266   return m_maincpu_space->read_byte(offset);
267}
268
269void a2bus_device::dma_nospace_w(UINT16 offset, UINT8 data)
270{
271   m_maincpu_space->write_byte(offset, data);
272}
273
249274void a2bus_device::recalc_inh(int slot)
250275{
251276   m_out_inh_cb(ASSERT_LINE);
trunk/src/emu/bus/a2bus/a2bus.h
r243289r243290
106106   void set_nmi_line(int state, int slot);
107107   void set_maincpu_halt(int state);
108108   void recalc_inh(int slot);
109   UINT8 dma_r(address_space &space, UINT16 offset);
110   void dma_w(address_space &space, UINT16 offset, UINT8 data);
111   UINT8 dma_nospace_r(UINT16 offset);
112   void dma_nospace_w(UINT16 offset, UINT8 data);
109113
110114   DECLARE_WRITE_LINE_MEMBER( irq_w );
111115   DECLARE_WRITE_LINE_MEMBER( nmi_w );
r243289r243290
117121
118122   // internal state
119123   cpu_device   *m_maincpu;
124   address_space *m_maincpu_space;
120125
121126   devcb_write_line    m_out_irq_cb;
122127   devcb_write_line    m_out_nmi_cb;
r243289r243290
144149   device_a2bus_card_interface(const machine_config &mconfig, device_t &device);
145150   virtual ~device_a2bus_card_interface();
146151
147   virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { printf("a2bus: unhandled read at C0n%x\n", offset); return 0; }       // C0nX - /DEVSEL
148   virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to C0n%x\n", data, offset); }
152   virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { logerror("a2bus: unhandled read at C0n%x\n", offset); return 0; }       // C0nX - /DEVSEL
153   virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset); }
149154   virtual UINT8 read_cnxx(address_space &space, UINT8 offset) { return 0; }       // CnXX - /IOSEL
150   virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to Cn%02x\n", data, offset); }
155   virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset); }
151156   virtual UINT8 read_c800(address_space &space, UINT16 offset) { return 0; }      // C800 - /IOSTB
152   virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { printf("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); }
157   virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); }
153158   virtual bool take_c800() { return true; }   // override and return false if your card doesn't take over the c800 space
154159   virtual UINT8 read_inh_rom(address_space &space, UINT16 offset) { return 0; }
155160   virtual void write_inh_rom(address_space &space, UINT16 offset, UINT8 data) { }
r243289r243290
171176   void recalc_slot_inh() { m_a2bus->recalc_inh(m_slot); }
172177   void set_maincpu_halt(int state) { m_a2bus->set_maincpu_halt(state); }
173178
179   // pass through the original address space if any for debugger protection
180   // when debugging e.g. coprocessor cards (Z80 SoftCard etc).
181   UINT8 slot_dma_read(address_space &space, UINT16 offset) { return m_a2bus->dma_r(space, offset); }
182   void slot_dma_write(address_space &space, UINT16 offset, UINT8 data) { m_a2bus->dma_w(space, offset, data); }
183
184   // these versions forego that protection for when the DMA isn't coming from a debuggable CPU device
185   UINT8 slot_dma_read_no_space(UINT16 offset) { return m_a2bus->dma_nospace_r(offset); }
186   void slot_dma_write_no_space(UINT16 offset, UINT8 data) { m_a2bus->dma_nospace_w(offset, data); }
187
174188   // inline configuration
175189   static void static_set_a2bus_tag(device_t &device, const char *tag, const char *slottag);
176190public:
trunk/src/emu/bus/a2bus/a2mcms.c
r243289r243290
9494
9595void a2bus_mcms1_device::device_reset()
9696{
97   m_mcms->set_bus_device(this);
9798}
9899
99100// read once at c0n0 to disable 125 Hz IRQs
r243289r243290
290291            wptr = (m_table[v]<<8) | (m_acc[v]>>8);
291292            m_rand = (m_acc[v]>>8) & 0x1f;
292293
293            sample = (m_6502space->read_byte(wptr) ^ 0x80);
294            sample = (m_pBusDevice->slot_dma_read_no_space(wptr) ^ 0x80);
294295            if (v & 1)
295296            {
296297               mixL += sample * m_vols[v];
r243289r243290
355356
356357WRITE8_MEMBER(mcms_device::control_w)
357358{
358   // keep the space (TODO: we need to define a formal DMA mechanism from machine/apple2 out to the slots)
359   m_6502space = &space;
360
361359   m_stream->update();
362360
363361   switch (offset)
trunk/src/emu/bus/a2bus/a2mcms.h
r243289r243290
2020//  TYPE DEFINITIONS
2121//**************************************************************************
2222
23class a2bus_mcms1_device;
24
2325class mcms_device : public device_t, public device_sound_interface
2426{
2527public:
r243289r243290
3032   DECLARE_WRITE8_MEMBER(control_w);
3133   UINT8 get_pen_rand(void) { m_stream->update(); return m_rand; }
3234
35   void set_bus_device(a2bus_mcms1_device *pDev) { m_pBusDevice = pDev; }
36
3337   template<class _Object> static devcb_base &set_irq_cb(device_t &device, _Object wr) { return downcast<mcms_device &>(device).m_write_irq.set_callback(wr); }
3438   devcb_write_line m_write_irq;
3539
r243289r243290
4347
4448private:
4549   sound_stream *m_stream;
46   address_space *m_6502space;
4750   emu_timer *m_timer, *m_clrtimer;
51   a2bus_mcms1_device *m_pBusDevice;
4852   bool m_enabled;
4953   UINT8 m_vols[16];
5054   UINT8 m_table[16];
trunk/src/emu/bus/a2bus/a2softcard.c
r243289r243290
5252a2bus_softcard_device::a2bus_softcard_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) :
5353   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
5454   device_a2bus_card_interface(mconfig, *this),
55   m_z80(*this, Z80_TAG),
56   m_6502space(NULL)
55   m_z80(*this, Z80_TAG)
5756{
5857}
5958
6059a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6160   device_t(mconfig, A2BUS_SOFTCARD, "Microsoft SoftCard", tag, owner, clock, "a2softcard", __FILE__),
6261   device_a2bus_card_interface(mconfig, *this),
63   m_z80(*this, Z80_TAG),
64   m_6502space(NULL)
62   m_z80(*this, Z80_TAG)
6563{
6664}
6765
r243289r243290
8280{
8381   m_bEnabled = false;
8482
85   m_6502space = NULL;
8683   m_FirstZ80Boot = true;
8784   m_z80->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
8885}
r243289r243290
9188{
9289   if (!m_bEnabled)
9390   {
94      // steal the 6502's address space
95      m_6502space = &space;
96
9791      m_z80->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
9892      set_maincpu_halt(ASSERT_LINE);
9993
r243289r243290
115109
116110READ8_MEMBER( a2bus_softcard_device::dma_r )
117111{
118   if (m_6502space)
112   if (m_bEnabled)
119113   {
120114      if (offset <= 0xafff)
121115      {
122         return m_6502space->read_byte(offset+0x1000);
116         return slot_dma_read(space, offset+0x1000);
123117      }
124118      else if (offset <= 0xbfff)  // LC bank 2 d000-dfff
125119      {
126         return m_6502space->read_byte((offset&0xfff) + 0xd000);
120         return slot_dma_read(space, (offset&0xfff) + 0xd000);
127121      }
128122      else if (offset <= 0xcfff)  // LC e000-efff
129123      {
130         return m_6502space->read_byte((offset&0xfff) + 0xe000);
124         return slot_dma_read(space, (offset&0xfff) + 0xe000);
131125      }
132126      else if (offset <= 0xdfff)  // LC f000-ffff (or ROM?)
133127      {
134         return m_6502space->read_byte((offset&0xfff) + 0xf000);
128         return slot_dma_read(space, (offset&0xfff) + 0xf000);
135129      }
136130      else if (offset <= 0xefff)  // I/O space c000-cfff
137131      {
138         return m_6502space->read_byte((offset&0xfff) + 0xc000);
132         return slot_dma_read(space, (offset&0xfff) + 0xc000);
139133      }
140134      else    // zero page
141135      {
142         return m_6502space->read_byte(offset&0xfff);
136         return slot_dma_read(space, offset&0xfff);
143137      }
144138   }
145139
r243289r243290
153147
154148WRITE8_MEMBER( a2bus_softcard_device::dma_w )
155149{
156   if (m_6502space)
150   if (m_bEnabled)
157151   {
158152      if (offset <= 0xafff)
159153      {
160         m_6502space->write_byte(offset+0x1000, data);
154         slot_dma_write(space, offset+0x1000, data);
161155      }
162156      else if (offset <= 0xbfff)  // LC bank 2 d000-dfff
163157      {
164         m_6502space->write_byte((offset&0xfff) + 0xd000, data);
158         slot_dma_write(space, (offset&0xfff) + 0xd000, data);
165159      }
166160      else if (offset <= 0xcfff)  // LC e000-efff
167161      {
168         m_6502space->write_byte((offset&0xfff) + 0xe000, data);
162         slot_dma_write(space, (offset&0xfff) + 0xe000, data);
169163      }
170164      else if (offset <= 0xdfff)  // LC f000-ffff (or ROM?)
171165      {
172         m_6502space->write_byte((offset&0xfff) + 0xf000, data);
166         slot_dma_write(space, (offset&0xfff) + 0xf000, data);
173167      }
174168      else if (offset <= 0xefff)  // I/O space c000-cfff
175169      {
176         m_6502space->write_byte((offset&0xfff) + 0xc000, data);
170         slot_dma_write(space, (offset&0xfff) + 0xc000, data);
177171      }
178172      else    // zero page
179173      {
180         m_6502space->write_byte(offset&0xfff, data);
174         slot_dma_write(space, offset&0xfff, data);
181175      }
182176   }
183177}
trunk/src/emu/bus/a2bus/a2softcard.h
r243289r243290
4444private:
4545   bool m_bEnabled;
4646   bool m_FirstZ80Boot;
47   address_space *m_6502space;
4847};
4948
5049// device type definition
trunk/src/emu/bus/a2bus/a2themill.c
r243289r243290
7171a2bus_themill_device::a2bus_themill_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) :
7272   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
7373   device_a2bus_card_interface(mconfig, *this),
74   m_6809(*this, M6809_TAG),
75   m_6502space(NULL)
74   m_6809(*this, M6809_TAG)
7675{
7776}
7877
7978a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
8079   device_t(mconfig, A2BUS_THEMILL, "Stellation Two The Mill", tag, owner, clock, "a2themill", __FILE__),
8180   device_a2bus_card_interface(mconfig, *this),
82   m_6809(*this, M6809_TAG),
83   m_6502space(NULL)
81   m_6809(*this, M6809_TAG)
8482{
8583}
8684
r243289r243290
102100void a2bus_themill_device::device_reset()
103101{
104102   m_bEnabled = false;
105   m_6502space = NULL;
106103   m_flipAddrSpace = false;
107104   m_6809Mode = false;
108105   m_status = 0xc0;    // OS9 loader relies on this
r243289r243290
135132      case 2: // 6809 reset
136133         if (data & 0x80)
137134         {
138            // steal the 6502's address space
139            m_6502space = &space;
140135            m_6809->reset();
141136
142137            m_6809->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
r243289r243290
241236
242237READ8_MEMBER( a2bus_themill_device::dma_r )
243238{
244   if (m_6502space)
239   if (m_6809Mode)
245240   {
246      if (m_6809Mode)
241      if (offset <= 0xafff)
247242      {
248         if (offset <= 0xafff)
249         {
250            return m_6502space->read_byte(offset+0x1000);
251         }
252         else if (offset <= 0xbfff)
253         {
254            return m_6502space->read_byte((offset&0xfff) + 0xd000);
255         }
256         else if (offset <= 0xcfff)
257         {
258            return m_6502space->read_byte((offset&0xfff) + 0xe000);
259         }
260         else if (offset <= 0xdfff)
261         {
262            return m_6502space->read_byte((offset&0xfff) + 0xf000);
263         }
264         else if (offset <= 0xefff)
265         {
266            return m_6502space->read_byte((offset&0xfff) + 0xc000);
267         }
268         else    // 6809 Fxxx -> 6502 ZP
269         {
270            return m_6502space->read_byte(offset&0xfff);
271         }
243         return slot_dma_read(space, offset+0x1000);
272244      }
245      else if (offset <= 0xbfff)
246      {
247         return slot_dma_read(space, (offset&0xfff) + 0xd000);
248      }
249      else if (offset <= 0xcfff)
250      {
251         return slot_dma_read(space, (offset&0xfff) + 0xe000);
252      }
253      else if (offset <= 0xdfff)
254      {
255         return slot_dma_read(space, (offset&0xfff) + 0xf000);
256      }
257      else if (offset <= 0xefff)
258      {
259         return slot_dma_read(space, (offset&0xfff) + 0xc000);
260      }
261      else    // 6809 Fxxx -> 6502 ZP
262      {
263         return slot_dma_read(space, offset&0xfff);
264      }
265   }
266   else
267   {
268      if (m_flipAddrSpace)
269      {
270         return slot_dma_read(space, offset^0x8000);
271      }
273272      else
274273      {
275         if (m_flipAddrSpace)
276         {
277            return m_6502space->read_byte(offset^0x8000);
278         }
279         else
280         {
281            return m_6502space->read_byte(offset);
282         }
274         return slot_dma_read(space, offset);
283275      }
284276   }
285277
r243289r243290
293285
294286WRITE8_MEMBER( a2bus_themill_device::dma_w )
295287{
296   if (m_6502space)
288   if (m_6809Mode)
297289   {
298      if (m_6809Mode)
290      if (offset <= 0xafff)
299291      {
300         if (offset <= 0xafff)
301         {
302            m_6502space->write_byte(offset+0x1000, data);
303         }
304         else if (offset <= 0xbfff)
305         {
306            m_6502space->write_byte((offset&0xfff) + 0xd000, data);
307         }
308         else if (offset <= 0xcfff)
309         {
310            m_6502space->write_byte((offset&0xfff) + 0xe000, data);
311         }
312         else if (offset <= 0xdfff)
313         {
314            m_6502space->write_byte((offset&0xfff) + 0xf000, data);
315         }
316         else if (offset <= 0xefff)
317         {
318            m_6502space->write_byte((offset&0xfff) + 0xc000, data);
319         }
320         else    // 6809 Fxxx -> 6502 ZP
321         {
322            m_6502space->write_byte(offset&0xfff, data);
323         }
292         slot_dma_write(space, offset+0x1000, data);
324293      }
294      else if (offset <= 0xbfff)
295      {
296         slot_dma_write(space, (offset&0xfff) + 0xd000, data);
297      }
298      else if (offset <= 0xcfff)
299      {
300         slot_dma_write(space, (offset&0xfff) + 0xe000, data);
301      }
302      else if (offset <= 0xdfff)
303      {
304         slot_dma_write(space, (offset&0xfff) + 0xf000, data);
305      }
306      else if (offset <= 0xefff)
307      {
308         slot_dma_write(space, (offset&0xfff) + 0xc000, data);
309      }
310      else    // 6809 Fxxx -> 6502 ZP
311      {
312         slot_dma_write(space, offset&0xfff, data);
313      }
314   }
315   else
316   {
317      if (m_flipAddrSpace)
318      {
319         slot_dma_write(space, offset^0x8000, data);
320      }
325321      else
326322      {
327         if (m_flipAddrSpace)
328         {
329            m_6502space->write_byte(offset^0x8000, data);
330         }
331         else
332         {
333            m_6502space->write_byte(offset, data);
334         }
323         slot_dma_write(space, offset, data);
335324      }
336325   }
337326}
trunk/src/emu/bus/a2bus/a2themill.h
r243289r243290
4646   bool m_bEnabled;
4747   bool m_flipAddrSpace;
4848   bool m_6809Mode;
49   address_space *m_6502space;
5049   UINT8 m_status;
5150};
5251


Previous 199869 Revisions Next


© 1997-2024 The MAME Team