Previous 199869 Revisions Next

r23921 Tuesday 25th June, 2013 at 04:03:40 UTC by David Haywood
legacy_cpu--

this is a first pass at converting to a modern device, I'd be surprised if there are no issue but it's already a weeks worth of updating + testing.
[src/emu/cpu/m68000]68307bus.c 68307bus.h 68307ser.c 68307ser.h 68307sim.c 68307sim.h 68307tmu.c 68307tmu.h 68340dma.c 68340dma.h 68340ser.c 68340ser.h 68340sim.c 68340sim.h 68340tmu.c 68340tmu.h m68000.h m68k_in.c m68kcpu.c m68kcpu.h m68kfpu.c m68kmake.c m68kmmu.h
[src/mame/drivers]astrafr.c bfm_sc4h.c bfm_swp.c cd32.c mpu4vid.c mpu5hw.c pluto5.c segahang.c segaorun.c segas16a.c segaxbd.c
[src/mame/includes]amiga.h atarig1.h atarig42.h bfm_sc45.h cps1.h cyberbal.h megadriv.h stv.h tatsumi.h toaplan2.h
[src/mame/machine]cps2crpt.c deco102.c fd1089.c fd1094.c megadriv.c
[src/mess/drivers]apollo.c dectalk.c
[src/mess/includes]abc1600.h apollo.h mac.h
[src/mess/machine]apollo.c apollo_dbg.c mac.c

trunk/src/mame/drivers/pluto5.c
r23920r23921
195195protected:
196196
197197   // devices
198   required_device<cpu_device> m_maincpu;
198   required_device<m68000_base_device> m_maincpu;
199199public:
200200   DECLARE_DRIVER_INIT(hb);
201201   virtual void machine_start();
trunk/src/mame/drivers/segaxbd.c
r23920r23921
601601
602602READ16_MEMBER( segaxbd_state::rascot_excs_r )
603603{
604   logerror("%06X:rascot_excs_r(%04X)\n", m_maincpu->pc(), offset*2);
604   //logerror("%06X:rascot_excs_r(%04X)\n", m_maincpu->pc(), offset*2);
605605
606606   // probably receives commands from the server here
607607   //return space.machine().rand() & 0xff;
r23920r23921
616616
617617WRITE16_MEMBER( segaxbd_state::rascot_excs_w )
618618{
619   logerror("%06X:rascot_excs_w(%04X) = %04X & %04X\n", m_maincpu->pc(), offset*2, data, mem_mask);
619   //logerror("%06X:rascot_excs_w(%04X) = %04X & %04X\n", m_maincpu->pc(), offset*2, data, mem_mask);
620620}
621621
622622
r23920r23921
627627
628628READ16_MEMBER( segaxbd_state::smgp_excs_r )
629629{
630   logerror("%06X:smgp_excs_r(%04X)\n", m_maincpu->pc(), offset*2);
630   //logerror("%06X:smgp_excs_r(%04X)\n", m_maincpu->pc(), offset*2);
631631   return 0xffff;
632632}
633633
r23920r23921
639639
640640WRITE16_MEMBER( segaxbd_state::smgp_excs_w )
641641{
642   logerror("%06X:smgp_excs_w(%04X) = %04X & %04X\n", m_maincpu->pc(), offset*2, data, mem_mask);
642   //logerror("%06X:smgp_excs_w(%04X) = %04X & %04X\n", m_maincpu->pc(), offset*2, data, mem_mask);
643643}
644644
645645
trunk/src/mame/drivers/bfm_sc4h.c
r23920r23921
551551//  if (dedicated == false)
552552   {
553553      int pc = space.device().safe_pc();
554      //m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
554      //_m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
555555      // serial output to the VFD at least..
556556      logerror("%08x bfm_sc4_68307_portb_w %04x %04x\n", pc, data, line_mask);
557557
r23920r23921
603603{
604604   m_nvram->set_base(m_mainram, sizeof(m_mainram));
605605
606
606607   m68307_set_port_callbacks(m_maincpu,
607608      bfm_sc4_68307_porta_r,
608609      bfm_sc4_68307_porta_w,
r23920r23921
610611      bfm_sc4_68307_portb_w );
611612   m68307_set_duart68681(m_maincpu,machine().device("m68307_68681"));
612613
614   
615
613616   int reels = 6;
614617   m_reels=reels;
615618
trunk/src/mame/drivers/segas16a.c
r23920r23921
300300      case 0x2000/2:
301301         return ioport((offset & 1) ? "DSW2" : "DSW1")->read();
302302   }
303   logerror("%06X:standard_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
303   //logerror("%06X:standard_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
304304   return 0xffff;
305305}
306306
r23920r23921
321321            synchronize(TID_PPI_WRITE, ((offset & 3) << 8) | (data & 0xff));
322322         return;
323323   }
324   logerror("%06X:standard_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
324   //logerror("%06X:standard_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
325325}
326326
327327
trunk/src/mame/drivers/segahang.c
r23920r23921
243243      }
244244   }
245245
246   logerror("%06X:hangon_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
246   //logerror("%06X:hangon_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
247247   return open_bus_r(space, 0, mem_mask);
248248}
249249
r23920r23921
271271            return;
272272      }
273273
274   logerror("%06X:hangon_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
274   //logerror("%06X:hangon_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
275275}
276276
277277
r23920r23921
304304      }
305305   }
306306
307   logerror("%06X:sharrier_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
307   //logerror("%06X:sharrier_io_r - unknown read access to address %04X\n", m_maincpu->pc(), offset * 2);
308308   return open_bus_r(space, 0, mem_mask);
309309}
310310
r23920r23921
333333            return;
334334      }
335335
336   logerror("%06X:sharrier_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
336   //logerror("%06X:sharrier_io_w - unknown write access to address %04X = %04X & %04X\n", m_maincpu->pc(), offset * 2, data, mem_mask);
337337}
338338
339339
trunk/src/mame/drivers/mpu4vid.c
r23920r23921
195195#include "crmaze2p.lh"
196196#include "crmaze4p.lh"
197197#include "includes/mpu4.h"
198 #include "cpu/m68000/m68000.h"
198199
199200
200201struct ef9369_t
r23920r23921
230231   {
231232   }
232233
233   required_device<cpu_device> m_videocpu;
234   required_device<m68000_base_device> m_videocpu;
234235   optional_device<scn2674_device> m_scn2674;
235236   optional_shared_ptr<UINT16> m_vid_vidram;
236237   optional_shared_ptr<UINT16> m_vid_mainram;
trunk/src/mame/drivers/cd32.c
r23920r23921
12451245static void cndypuzl_input_hack(running_machine &machine)
12461246{
12471247   cd32_state *state = machine.driver_data<cd32_state>();
1248   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
12481249
1249   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1250   if (thiscpu->pc() < state->m_chip_ram.bytes())
12501251   {
12511252      //(*state->m_chip_ram_w)(0x051c02, 0x0000);
12521253
r23920r23921
12641265static void haremchl_input_hack(running_machine &machine)
12651266{
12661267   cd32_state *state = machine.driver_data<cd32_state>();
1268   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
12671269
1268   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1270   if (thiscpu->pc() < state->m_chip_ram.bytes())
12691271   {
12701272      //amiga_chip_ram_w8(state, 0x002907, 0x00);
12711273
r23920r23921
12841286static void lsrquiz_input_hack(running_machine &machine)
12851287{
12861288   cd32_state *state = machine.driver_data<cd32_state>();
1289   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
12871290
1288   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1291   if (thiscpu->pc() < state->m_chip_ram.bytes())
12891292   {
12901293      //amiga_chip_ram_w8(state, 0x001e1b, 0x00);
12911294
r23920r23921
13051308static void lsrquiz2_input_hack(running_machine &machine)
13061309{
13071310   cd32_state *state = machine.driver_data<cd32_state>();
1311   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
13081312
1309   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1313   if (thiscpu->pc() < state->m_chip_ram.bytes())
13101314   {
13111315      //amiga_chip_ram_w8(state, 0x046107, 0x00);
13121316
r23920r23921
13251329static void lasstixx_input_hack(running_machine &machine)
13261330{
13271331   cd32_state *state = machine.driver_data<cd32_state>();
1332   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
13281333
1329   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1334   if (thiscpu->pc() < state->m_chip_ram.bytes())
13301335   {
13311336      //amiga_chip_ram_w8(state, 0x00281c, 0x00);
13321337
r23920r23921
13451350static void mgnumber_input_hack(running_machine &machine)
13461351{
13471352   cd32_state *state = machine.driver_data<cd32_state>();
1353   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
13481354
1349   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1355   if (thiscpu->pc() < state->m_chip_ram.bytes())
13501356   {
13511357      //(*state->m_chip_ram_w)(0x04bfa0, 0x0000);
13521358
r23920r23921
13641370static void mgprem11_input_hack(running_machine &machine)
13651371{
13661372   cd32_state *state = machine.driver_data<cd32_state>();
1373   cpu_device* thiscpu = (cpu_device*)state->m_maincpu;
13671374
1368   if (state->m_maincpu->pc() < state->m_chip_ram.bytes())
1375   if (thiscpu->pc() < state->m_chip_ram.bytes())
13691376   {
13701377      //amiga_chip_ram_w8(state, 0x044f7e, 0x00);
13711378
trunk/src/mame/drivers/bfm_swp.c
r23920r23921
127127protected:
128128
129129   // devices
130   required_device<cpu_device> m_maincpu;
130   required_device<m68000_base_device> m_maincpu;
131131
132132   virtual void machine_start();
133133};
trunk/src/mame/drivers/astrafr.c
r23920r23921
113113   }
114114
115115   // devices
116   required_device<cpu_device> m_maincpu;
117   optional_device<cpu_device> m_slavecpu;
116   required_device<m68000_base_device> m_maincpu;
117   optional_device<m68000_base_device> m_slavecpu;
118118
119119   DECLARE_DRIVER_INIT(astradec_sml);
120120   DECLARE_DRIVER_INIT(astradec);
trunk/src/mame/drivers/segaorun.c
r23920r23921
348348
349349READ8_MEMBER( segaorun_state::unknown_porta_r )
350350{
351   logerror("%06X:read from 8255 port A\n", m_maincpu->pc());
351   //logerror("%06X:read from 8255 port A\n", m_maincpu->pc());
352352   return 0;
353353}
354354
355355READ8_MEMBER( segaorun_state::unknown_portb_r )
356356{
357   logerror("%06X:read from 8255 port B\n", m_maincpu->pc());
357   //logerror("%06X:read from 8255 port B\n", m_maincpu->pc());
358358   return 0;
359359}
360360
361361READ8_MEMBER( segaorun_state::unknown_portc_r )
362362{
363   logerror("%06X:read from 8255 port C\n", m_maincpu->pc());
363   //logerror("%06X:read from 8255 port C\n", m_maincpu->pc());
364364   return 0;
365365}
366366
r23920r23921
372372
373373WRITE8_MEMBER( segaorun_state::unknown_porta_w )
374374{
375   logerror("%06X:write %02X to 8255 port A\n", m_maincpu->pc(), data);
375   //logerror("%06X:write %02X to 8255 port A\n", m_maincpu->pc(), data);
376376}
377377
378378WRITE8_MEMBER( segaorun_state::unknown_portb_w )
379379{
380   logerror("%06X:write %02X to 8255 port B\n", m_maincpu->pc(), data);
380   //logerror("%06X:write %02X to 8255 port B\n", m_maincpu->pc(), data);
381381}
382382
383383
trunk/src/mame/drivers/mpu5hw.c
r23920r23921
5858protected:
5959
6060   // devices
61   required_device<cpu_device> m_maincpu;
61   required_device<m68000_base_device> m_maincpu;
6262   virtual void machine_start();
6363};
6464
trunk/src/mame/machine/fd1094.c
r23920r23921
605605//  fd1094_device - constructor
606606//-------------------------------------------------
607607
608
608609fd1094_device::fd1094_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
609   : m68000_device(mconfig, M68000, tag, owner, clock),
610   : m68000_device(mconfig, tag, owner, clock),
610611      m_state(0x00),
611612      m_irqmode(false),
612613      m_cache(*this),
trunk/src/mame/machine/deco102.c
r23920r23921
5959   memcpy(buf, rom, size);
6060
6161   space.set_decrypted_region(0, size - 1, opcodes);
62   m68k_set_encrypted_opcode_range(machine.device(cputag), 0, size);
62   m68k_set_encrypted_opcode_range((m68000_base_device*)machine.device(cputag), 0, size);
6363
6464   for (i = 0; i < size / 2; i++)
6565   {
trunk/src/mame/machine/megadriv.c
r23920r23921
11441144   }
11451145
11461146   m68k_set_tas_callback(m_maincpu, megadriv_tas_callback);
1147
1147   
11481148   m_megadrive_io_read_data_port_ptr = read8_delegate(FUNC(md_base_state::megadrive_io_read_data_port_3button),this);
11491149   m_megadrive_io_write_data_port_ptr = write16_delegate(FUNC(md_base_state::megadrive_io_write_data_port_3button),this);
11501150
trunk/src/mame/machine/fd1089.c
r23920r23921
215215//-------------------------------------------------
216216
217217fd1089_base_device::fd1089_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
218   : m68000_device(mconfig, M68000, tag, owner, clock)
218   : m68000_device(mconfig, tag, owner, clock)
219219{
220220   // override the name after the m68000 initializes
221221   m_name.cpy(name);
trunk/src/mame/machine/cps2crpt.c
r23920r23921
721721   }
722722
723723   space.set_decrypted_region(0x000000, length - 1, dec);
724   m68k_set_encrypted_opcode_range(machine.device("maincpu"), 0, length);
724   m68k_set_encrypted_opcode_range((m68000_base_device*)machine.device("maincpu"), 0, length);
725725}
726726
727727
trunk/src/mame/includes/megadriv.h
r23920r23921
1818#include "machine/mega32x.h"
1919#include "machine/megacd.h"
2020#include "video/315_5124.h"
21#include "cpu/m68000/m68000.h"
2122
2223#define MASTER_CLOCK_NTSC 53693175
2324#define MASTER_CLOCK_PAL  53203424
r23920r23921
6869      m_segacd(*this,"segacd"),
6970      m_megadrive_ram(*this,"megadrive_ram")
7071   { }
71   required_device<cpu_device> m_maincpu;
72   required_device<m68000_base_device> m_maincpu;
7273   optional_device<cpu_device> m_z80snd;
7374   optional_device<ym2612_device> m_ymsnd;
7475   required_device<sega_genesis_vdp_device> m_vdp;
trunk/src/mame/includes/cps1.h
r23920r23921
55#include "sound/qsound.h"
66#include "sound/okim6295.h"
77#include "machine/timekpr.h"
8#include "cpu/m68000/m68000.h"
89
910struct gfx_range
1011{
r23920r23921
166167   UINT16       *m_bootleg_work_ram;
167168
168169   /* devices */
169   required_device<cpu_device> m_maincpu;
170   required_device<m68000_base_device> m_maincpu;
170171   optional_device<cpu_device> m_audiocpu;
171172   optional_device<okim6295_device> m_oki;
172173   optional_device<m48t35_device> m_m48t35;
trunk/src/mame/includes/tatsumi.h
r23920r23921
11#include "sound/okim6295.h"
2#include "cpu/m68000/m68000.h"
23
34class tatsumi_state : public driver_device
45{
r23920r23921
136137   DECLARE_READ8_MEMBER(tatsumi_hack_oki_r);
137138   required_device<cpu_device> m_maincpu;
138139   required_device<cpu_device> m_audiocpu;
139   required_device<cpu_device> m_subcpu;
140   required_device<m68000_base_device> m_subcpu;
140141   optional_device<cpu_device> m_subcpu2;
141142   required_device<okim6295_device> m_oki;
142143};
trunk/src/mame/includes/atarig1.h
r23920r23921
1515         m_maincpu(*this, "maincpu"),
1616         m_mo_command(*this, "mo_command") { }
1717
18   required_device<m68000_device> m_maincpu;
18   required_device<cpu_device> m_maincpu;
1919
2020   bool            m_is_pitfight;
2121
trunk/src/mame/includes/toaplan2.h
r23920r23921
1111// VDP related
1212#include "video/gp9001.h"
1313#include "sound/okim6295.h"
14#include "cpu/m68000/m68000.h"
1415// Cache the CPUs and VDPs for faster access
1516class toaplan2_state : public driver_device
1617{
r23920r23921
148149   void toaplan2_vblank_irq(int irq_line);
149150   DECLARE_WRITE_LINE_MEMBER(irqhandler);
150151   DECLARE_WRITE_LINE_MEMBER(bbakraid_irqhandler);
151   required_device<cpu_device> m_maincpu;
152   required_device<m68000_base_device> m_maincpu;
152153   optional_device<cpu_device> m_audiocpu;
153154   optional_device<nmk112_device> m_nmk112;
154155   optional_device<okim6295_device> m_oki;
trunk/src/mame/includes/atarig42.h
r23920r23921
1515         m_maincpu(*this, "maincpu"),
1616         m_mo_command(*this, "mo_command") { }
1717
18   required_device<m68000_device> m_maincpu;
18   required_device<cpu_device> m_maincpu;
1919
2020   UINT16          m_playfield_base;
2121
trunk/src/mame/includes/bfm_sc45.h
r23920r23921
99#include "sound/ymz280b.h"
1010#include "machine/68681.h"
1111#include "machine/nvram.h"
12#include "cpu/m68000/m68000.h"
1213
1314// common base class for things shared between sc4 and sc5
1415class bfm_sc45_state : public driver_device
r23920r23921
2425   }
2526
2627public:
27   required_device<legacy_cpu_device> m_maincpu;
28   required_device<m68000_base_device> m_maincpu;
2829   required_device<duart68681_device> m_duart;
2930   optional_device<bfm_bda_t> m_vfd0;
3031   required_device<ymz280b_device> m_ymz;
r23920r23921
547548   DECLARE_MACHINE_START(adder4);
548549
549550   // devices
550   required_device<cpu_device> m_adder4cpu;
551   required_device<m68000_base_device> m_adder4cpu;
551552};
552553
553554
trunk/src/mame/includes/amiga.h
r23920r23921
1414
1515#include "machine/6526cia.h"
1616#include "machine/amigafdc.h"
17#include "cpu/m68000/m68000.h"
1718
19
1820/*************************************
1921 *
2022 *  Debugging
r23920r23921
400402
401403   { }
402404
403   required_device<cpu_device> m_maincpu;
405   required_device<m68000_base_device> m_maincpu;
404406   required_device<legacy_mos6526_device> m_cia_0;
405407   required_device<legacy_mos6526_device> m_cia_1;
406408   optional_device<amiga_fdc> m_fdc;
trunk/src/mame/includes/cyberbal.h
r23920r23921
2323         m_paletteram_0(*this, "paletteram_0"),
2424         m_paletteram_1(*this, "paletteram_1") { }
2525
26   required_device<m68000_device> m_maincpu;
26   required_device<cpu_device> m_maincpu;
2727   optional_device<m6502_device> m_audiocpu;
28   optional_device<m68000_device> m_extracpu;
29   optional_device<m68000_device> m_daccpu;
28   optional_device<cpu_device> m_extracpu;
29   optional_device<cpu_device> m_daccpu;
3030   optional_device<dac_device> m_dac1;
3131   optional_device<dac_device> m_dac2;
3232   optional_shared_ptr<UINT16> m_paletteram_0;
trunk/src/mame/includes/stv.h
r23920r23921
11/*----------- defined in drivers/stv.c -----------*/
22#include "cdrom.h"
33#include "machine/eeprom.h"
4#include "cpu/m68000/m68000.h"
45
56#define MAX_FILTERS (24)
67#define MAX_BLOCKS  (200)
r23920r23921
141142
142143   required_device<cpu_device> m_maincpu;
143144   required_device<cpu_device> m_slave;
144   required_device<cpu_device> m_audiocpu;
145   required_device<m68000_base_device> m_audiocpu;
145146   optional_device<eeprom_device> m_eeprom;
146147
147148   bitmap_rgb32 m_tmpbitmap;
trunk/src/emu/cpu/m68000/68340sim.c
r23920r23921
44#include "m68kcpu.h"
55
66
7READ16_HANDLER( m68340_internal_sim_r )
7READ16_MEMBER( m68000_base_device::m68340_internal_sim_r )
88{
9   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
9   m68000_base_device *m68k = this;
1010   m68340_sim* sim = m68k->m68340SIM;
1111   assert(sim != NULL);
1212
r23920r23921
5454   return 0x0000;
5555}
5656
57READ8_HANDLER( m68340_internal_sim_ports_r )
57READ8_MEMBER( m68000_base_device::m68340_internal_sim_ports_r )
5858{
5959   offset += 0x10;
60   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
60   m68000_base_device *m68k = this;
6161   m68340_sim* sim = m68k->m68340SIM;
6262   assert(sim != NULL);
6363
r23920r23921
109109   return 0x00;
110110}
111111
112READ32_HANDLER( m68340_internal_sim_cs_r )
112READ32_MEMBER( m68000_base_device::m68340_internal_sim_cs_r )
113113{
114114   offset += m68340SIM_AM_CS0>>2;
115115
116   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
116   m68000_base_device *m68k = this;
117117   m68340_sim* sim = m68k->m68340SIM;
118118   assert(sim != NULL);
119119
r23920r23921
141141   return 0x00000000;
142142}
143143
144WRITE16_HANDLER( m68340_internal_sim_w )
144WRITE16_MEMBER( m68000_base_device::m68340_internal_sim_w )
145145{
146   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
146   m68000_base_device *m68k = this;
147147   m68340_sim* sim = m68k->m68340SIM;
148148   assert(sim != NULL);
149149
r23920r23921
190190   }
191191}
192192
193WRITE8_HANDLER( m68340_internal_sim_ports_w )
193WRITE8_MEMBER( m68000_base_device::m68340_internal_sim_ports_w )
194194{
195195   offset += 0x10;
196   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
196   m68000_base_device *m68k = this;
197197   m68340_sim* sim = m68k->m68340SIM;
198198   assert(sim != NULL);
199199
r23920r23921
243243   }
244244}
245245
246WRITE32_HANDLER( m68340_internal_sim_cs_w )
246WRITE32_MEMBER( m68000_base_device::m68340_internal_sim_cs_w )
247247{
248248   offset += m68340SIM_AM_CS0>>2;
249   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
249   m68000_base_device *m68k = this;
250250   m68340_sim* sim = m68k->m68340SIM;
251251   assert(sim != NULL);
252252
trunk/src/emu/cpu/m68000/m68kcpu.c
r23920r23921
3737#include <setjmp.h>
3838#include "m68kcpu.h"
3939#include "m68kops.h"
40
4041#include "m68kfpu.c"
41
4242#include "m68kmmu.h"
4343
44extern void m68040_fpu_op0(m68ki_cpu_core *m68k);
45extern void m68040_fpu_op1(m68ki_cpu_core *m68k);
46extern void m68881_mmu_ops(m68ki_cpu_core *m68k);
44extern void m68040_fpu_op0(m68000_base_device *m68k);
45extern void m68040_fpu_op1(m68000_base_device *m68k);
46extern void m68881_mmu_ops(m68000_base_device *m68k);
4747
4848/* ======================================================================== */
4949/* ================================= DATA ================================= */
r23920r23921
644644/* ================================= API ================================== */
645645/* ======================================================================== */
646646
647static void set_irq_line(m68ki_cpu_core *m68k, int irqline, int state)
647static void set_irq_line(m68000_base_device *m68k, int irqline, int state)
648648{
649649   UINT32 old_level = m68k->int_level;
650650   UINT32 vstate = m68k->virq_state;
r23920r23921
668668      m68k->nmi_pending = TRUE;
669669}
670670
671static void m68k_presave(m68ki_cpu_core *m68k)
671static void m68k_presave(m68000_base_device *m68k)
672672{
673673   m68k->save_sr = m68ki_get_sr(m68k);
674674   m68k->save_stopped = (m68k->stopped & STOP_LEVEL_STOP) != 0;
675675   m68k->save_halted  = (m68k->stopped & STOP_LEVEL_HALT) != 0;
676676}
677677
678static void m68k_postload(m68ki_cpu_core *m68k)
678static void m68k_postload(m68000_base_device *m68k)
679679{
680680   m68ki_set_sr_noint_nosp(m68k, m68k->save_sr);
681681   m68k->stopped = m68k->save_stopped ? STOP_LEVEL_STOP : 0
r23920r23921
683683   m68ki_jump(m68k, REG_PC(m68k));
684684}
685685
686static void m68k_cause_bus_error(m68ki_cpu_core *m68k)
686static void m68k_cause_bus_error(m68000_base_device *m68k)
687687{
688688   UINT32 sr;
689689
r23920r23921
708708   m68ki_jump_vector(m68k, EXCEPTION_BUS_ERROR);
709709}
710710
711/* translate logical to physical addresses */
712static CPU_TRANSLATE( m68k )
711bool m68000_base_device::memory_translate(address_spacenum space, int intention, offs_t &address)
713712{
714   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
715
716713   /* only applies to the program address space and only does something if the MMU's enabled */
717   if (m68k)
714   if (this)
718715   {
719716      /* 68040 needs to call the MMU even when disabled so transparent translation works */
720      if ((space == AS_PROGRAM) && ((m68k->pmmu_enabled) || (CPU_TYPE_IS_040_PLUS(m68k->cpu_type))))
717      if ((space == AS_PROGRAM) && ((pmmu_enabled) || (CPU_TYPE_IS_040_PLUS(cpu_type))))
721718      {
722719         // FIXME: mmu_tmp_sr will be overwritten in pmmu_translate_addr_with_fc
723         UINT16 mmu_tmp_sr = m68k->mmu_tmp_sr;
724         int mode = m68k->s_flag ? FUNCTION_CODE_SUPERVISOR_PROGRAM : FUNCTION_CODE_USER_PROGRAM;
725//          UINT32 va=*address;
720         UINT16 temp_mmu_tmp_sr = mmu_tmp_sr;
721         int mode = s_flag ? FUNCTION_CODE_SUPERVISOR_PROGRAM : FUNCTION_CODE_USER_PROGRAM;
722//          UINT32 va=address;
726723
727         if (CPU_TYPE_IS_040_PLUS(m68k->cpu_type))
724         if (CPU_TYPE_IS_040_PLUS(cpu_type))
728725         {
729            *address = pmmu_translate_addr_with_fc_040(m68k, *address, mode, 1);
726            address = pmmu_translate_addr_with_fc_040(this, address, mode, 1);
730727         }
731728         else
732729         {
733            *address = pmmu_translate_addr_with_fc(m68k, *address, mode, 1);
730            address = pmmu_translate_addr_with_fc(this, address, mode, 1);
734731         }
735732
736         if ((m68k->mmu_tmp_sr & M68K_MMU_SR_INVALID) != 0) {
737//              logerror("cpu_translate_m68k failed with mmu_sr=%04x va=%08x pa=%08x\n",m68k->mmu_tmp_sr,va ,*address);
738            *address = 0;
733         if ((mmu_tmp_sr & M68K_MMU_SR_INVALID) != 0) {
734//              logerror("cpu_translate_m68k failed with mmu_sr=%04x va=%08x pa=%08x\n",mmu_tmp_sr,va ,address);
735            address = 0;
739736         }
740737
741         m68k->mmu_tmp_sr = mmu_tmp_sr;
738         mmu_tmp_sr = temp_mmu_tmp_sr;
742739      }
743740   }
744741   return TRUE;
745742}
746743
747/* translate logical to physical addresses for Apple HMMU */
748static CPU_TRANSLATE( m68khmmu )
749{
750   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
751744
752   /* only applies to the program address space and only does something if the MMU's enabled */
753   if (m68k)
754   {
755      if ((space == AS_PROGRAM) && (m68k->hmmu_enabled))
756      {
757         *address = hmmu_translate_addr(m68k, *address);
758      }
759   }
760   return TRUE;
761}
762745
763/* Execute some instructions until we use up cycles clock cycles */
764static CPU_EXECUTE( m68k )
746
747
748
749
750
751
752inline void m68000_base_device::cpu_execute(void)
765753{
766   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
754   initial_cycles = remaining_cycles;
767755
768   m68k->initial_cycles = m68k->remaining_cycles;
769
770756   /* eat up any reset cycles */
771   if (m68k->reset_cycles) {
772      int rc = m68k->reset_cycles;
773      m68k->reset_cycles = 0;
774      m68k->remaining_cycles -= rc;
757   if (reset_cycles) {
758      int rc = reset_cycles;
759      reset_cycles = 0;
760      remaining_cycles -= rc;
775761
776      if (m68k->remaining_cycles <= 0) return;
762      if (remaining_cycles <= 0) return;
777763   }
778764
779765   /* See if interrupts came in */
780   m68ki_check_interrupts(m68k);
766   m68ki_check_interrupts(this);
781767
782768   /* Make sure we're not stopped */
783   if(!m68k->stopped)
769   if(!stopped)
784770   {
785771      /* Return point if we had an address error */
786      m68ki_set_address_error_trap(m68k); /* auto-disable (see m68kcpu.h) */
772      m68ki_set_address_error_trap(this); /* auto-disable (see m68kcpu.h) */
787773
788774      /* Main loop.  Keep going until we run out of clock cycles */
789      while (m68k->remaining_cycles > 0)
775      while (remaining_cycles > 0)
790776      {
791777         /* Set tracing accodring to T1. (T0 is done inside instruction) */
792         m68ki_trace_t1(m68k); /* auto-disable (see m68kcpu.h) */
778         m68ki_trace_t1(this); /* auto-disable (see m68kcpu.h) */
793779
794780         /* Call external hook to peek at CPU */
795         debugger_instruction_hook(device, REG_PC(m68k));
781         debugger_instruction_hook(this, REG_PC(this));
796782
797783         /* call external instruction hook (independent of debug mode) */
798         if (m68k->instruction_hook != NULL)
799            m68k->instruction_hook(device, REG_PC(m68k));
784         if (instruction_hook != NULL)
785            instruction_hook(this, REG_PC(this));
800786
801787         /* Record previous program counter */
802         REG_PPC(m68k) = REG_PC(m68k);
788         REG_PPC(this) = REG_PC(this);
803789
804         if (!m68k->pmmu_enabled)
790         if (!pmmu_enabled)
805791         {
806            m68k->run_mode = RUN_MODE_NORMAL;
792            run_mode = RUN_MODE_NORMAL;
807793            /* Read an instruction and call its handler */
808            m68k->ir = m68ki_read_imm_16(m68k);
809            m68k->jump_table[m68k->ir](m68k);
810            m68k->remaining_cycles -= m68k->cyc_instruction[m68k->ir];
794            ir = m68ki_read_imm_16(this);
795            jump_table[ir](this);
796            remaining_cycles -= cyc_instruction[ir];
811797         }
812798         else
813799         {
814            m68k->run_mode = RUN_MODE_NORMAL;
800            run_mode = RUN_MODE_NORMAL;
815801            // save CPU address registers values at start of instruction
816802            int i;
817803            UINT32 tmp_dar[16];
818804
819805            for (i = 15; i >= 0; i--)
820806            {
821               tmp_dar[i] = REG_DA(m68k)[i];
807               tmp_dar[i] = REG_DA(this)[i];
822808            }
823809
824            m68k->mmu_tmp_buserror_occurred = 0;
810            mmu_tmp_buserror_occurred = 0;
825811
826812            /* Read an instruction and call its handler */
827            m68k->ir = m68ki_read_imm_16(m68k);
813            ir = m68ki_read_imm_16(this);
828814
829            if (!m68k->mmu_tmp_buserror_occurred)
815            if (!mmu_tmp_buserror_occurred)
830816            {
831               m68k->jump_table[m68k->ir](m68k);
832               m68k->remaining_cycles -= m68k->cyc_instruction[m68k->ir];
817               jump_table[ir](this);
818               remaining_cycles -= cyc_instruction[ir];
833819            }
834820
835            if (m68k->mmu_tmp_buserror_occurred)
821            if (mmu_tmp_buserror_occurred)
836822            {
837823               UINT32 sr;
838824
839               m68k->mmu_tmp_buserror_occurred = 0;
825               mmu_tmp_buserror_occurred = 0;
840826
841827               // restore cpu address registers to value at start of instruction
842828               for (i = 15; i >= 0; i--)
843829               {
844                  if (REG_DA(m68k)[i] != tmp_dar[i])
830                  if (REG_DA(this)[i] != tmp_dar[i])
845831                  {
846832//                          logerror("PMMU: pc=%08x sp=%08x bus error: fixed %s[%d]: %08x -> %08x\n",
847//                                  REG_PPC(m68k), REG_A(m68k)[7], i < 8 ? "D" : "A", i & 7, REG_DA(m68k)[i], tmp_dar[i]);
848                     REG_DA(m68k)[i] = tmp_dar[i];
833//                                  REG_PPC(this), REG_A(this)[7], i < 8 ? "D" : "A", i & 7, REG_DA(this)[i], tmp_dar[i]);
834                     REG_DA(this)[i] = tmp_dar[i];
849835                  }
850836               }
851837
852               sr = m68ki_init_exception(m68k);
838               sr = m68ki_init_exception(this);
853839
854               m68k->run_mode = RUN_MODE_BERR_AERR_RESET;
840               run_mode = RUN_MODE_BERR_AERR_RESET;
855841
856               if (!CPU_TYPE_IS_020_PLUS(m68k->cpu_type))
842               if (!CPU_TYPE_IS_020_PLUS(cpu_type))
857843               {
858844                  /* Note: This is implemented for 68000 only! */
859                  m68ki_stack_frame_buserr(m68k, sr);
845                  m68ki_stack_frame_buserr(this, sr);
860846               }
861               else if(!CPU_TYPE_IS_040_PLUS(m68k->cpu_type)) {
862                  if (m68k->mmu_tmp_buserror_address == REG_PPC(m68k))
847               else if(!CPU_TYPE_IS_040_PLUS(cpu_type)) {
848                  if (mmu_tmp_buserror_address == REG_PPC(this))
863849                  {
864                     m68ki_stack_frame_1010(m68k, sr, EXCEPTION_BUS_ERROR, REG_PPC(m68k), m68k->mmu_tmp_buserror_address);
850                     m68ki_stack_frame_1010(this, sr, EXCEPTION_BUS_ERROR, REG_PPC(this), mmu_tmp_buserror_address);
865851                  }
866852                  else
867853                  {
868                     m68ki_stack_frame_1011(m68k, sr, EXCEPTION_BUS_ERROR, REG_PPC(m68k), m68k->mmu_tmp_buserror_address);
854                     m68ki_stack_frame_1011(this, sr, EXCEPTION_BUS_ERROR, REG_PPC(this), mmu_tmp_buserror_address);
869855                  }
870856               }
871857               else
872858               {
873                  m68ki_stack_frame_0111(m68k, sr, EXCEPTION_BUS_ERROR, REG_PPC(m68k), m68k->mmu_tmp_buserror_address, true);
859                  m68ki_stack_frame_0111(this, sr, EXCEPTION_BUS_ERROR, REG_PPC(this), mmu_tmp_buserror_address, true);
874860               }
875861
876               m68ki_jump_vector(m68k, EXCEPTION_BUS_ERROR);
862               m68ki_jump_vector(this, EXCEPTION_BUS_ERROR);
877863
878864               // TODO:
879865               /* Use up some clock cycles and undo the instruction's cycles */
880               // m68k->remaining_cycles -= m68k->cyc_exception[EXCEPTION_BUS_ERROR] - m68k->cyc_instruction[m68k->ir];
866               // remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir];
881867            }
882868         }
883869
884870         /* Trace m68k_exception, if necessary */
885         m68ki_exception_if_trace(m68k); /* auto-disable (see m68kcpu.h) */
871         m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */
886872      }
887873
888874      /* set previous PC to current PC for the next entry into the loop */
889      REG_PPC(m68k) = REG_PC(m68k);
875      REG_PPC(this) = REG_PC(this);
890876   }
891   else if (m68k->remaining_cycles > 0)
892      m68k->remaining_cycles = 0;
877   else if (remaining_cycles > 0)
878      remaining_cycles = 0;
893879}
894880
895static CPU_INIT( m68k )
881
882
883void m68000_base_device::init_cpu_common(void)
896884{
897885   static UINT32 emulation_initialized = 0;
898   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
899886
900   m68k->device = device;
901   m68k->program = &device->space(AS_PROGRAM);
902   m68k->int_ack_callback = irqcallback;
887   //this = device;//deviceparam;
888   program = &space(AS_PROGRAM);
889   int_ack_callback = static_standard_irq_callback;
903890
904891   /* disable all MMUs */
905   m68k->has_pmmu         = 0;
906   m68k->has_hmmu         = 0;
907   m68k->pmmu_enabled     = 0;
908   m68k->hmmu_enabled     = 0;
892   has_pmmu         = 0;
893   has_hmmu         = 0;
894   pmmu_enabled     = 0;
895   hmmu_enabled     = 0;
909896
910897   /* The first call to this function initializes the opcode handler jump table */
911898   if(!emulation_initialized)
r23920r23921
915902   }
916903
917904   /* Note, D covers A because the dar array is common, REG_A(m68k)=REG_D(m68k)+8 */
918   device->save_item(NAME(REG_D(m68k)));
919   device->save_item(NAME(REG_PPC(m68k)));
920   device->save_item(NAME(REG_PC(m68k)));
921   device->save_item(NAME(REG_USP(m68k)));
922   device->save_item(NAME(REG_ISP(m68k)));
923   device->save_item(NAME(REG_MSP(m68k)));
924   device->save_item(NAME(m68k->vbr));
925   device->save_item(NAME(m68k->sfc));
926   device->save_item(NAME(m68k->dfc));
927   device->save_item(NAME(m68k->cacr));
928   device->save_item(NAME(m68k->caar));
929   device->save_item(NAME(m68k->save_sr));
930   device->save_item(NAME(m68k->int_level));
931   device->save_item(NAME(m68k->save_stopped));
932   device->save_item(NAME(m68k->save_halted));
933   device->save_item(NAME(m68k->pref_addr));
934   device->save_item(NAME(m68k->pref_data));
935   device->machine().save().register_presave(save_prepost_delegate(FUNC(m68k_presave), m68k));
936   device->machine().save().register_postload(save_prepost_delegate(FUNC(m68k_postload), m68k));
905   save_item(NAME(REG_D(this)));
906   save_item(NAME(REG_PPC(this)));
907   save_item(NAME(REG_PC(this)));
908   save_item(NAME(REG_USP(this)));
909   save_item(NAME(REG_ISP(this)));
910   save_item(NAME(REG_MSP(this)));
911   save_item(NAME(vbr));
912   save_item(NAME(sfc));
913   save_item(NAME(dfc));
914   save_item(NAME(cacr));
915   save_item(NAME(caar));
916   save_item(NAME(save_sr));
917   save_item(NAME(int_level));
918   save_item(NAME(save_stopped));
919   save_item(NAME(save_halted));
920   save_item(NAME(pref_addr));
921   save_item(NAME(pref_data));
922   machine().save().register_presave(save_prepost_delegate(FUNC(m68k_presave), this));
923   machine().save().register_postload(save_prepost_delegate(FUNC(m68k_postload), this));
924
925   m_icountptr = &remaining_cycles;
926   remaining_cycles = 0;
927
937928}
938929
939/* Pulse the RESET line on the CPU */
940static CPU_RESET( m68k )
930void m68000_base_device::reset_cpu(void)
941931{
942   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
943
944932   /* Disable the PMMU/HMMU on reset, if any */
945   m68k->pmmu_enabled = 0;
946   m68k->hmmu_enabled = 0;
933   pmmu_enabled = 0;
934   hmmu_enabled = 0;
947935
948   m68k->mmu_tc = 0;
949   m68k->mmu_tt0 = 0;
950   m68k->mmu_tt1 = 0;
936   mmu_tc = 0;
937   mmu_tt0 = 0;
938   mmu_tt1 = 0;
951939
952940   /* Clear all stop levels and eat up all remaining cycles */
953   m68k->stopped = 0;
954   if (m68k->remaining_cycles > 0)
955      m68k->remaining_cycles = 0;
941   stopped = 0;
942   if (remaining_cycles > 0)
943      remaining_cycles = 0;
956944
957   m68k->run_mode = RUN_MODE_BERR_AERR_RESET;
945   run_mode = RUN_MODE_BERR_AERR_RESET;
958946
959947   /* Turn off tracing */
960   m68k->t1_flag = m68k->t0_flag = 0;
961   m68ki_clear_trace(m68k);
948   t1_flag = t0_flag = 0;
949   m68ki_clear_trace(this);
962950   /* Interrupt mask to level 7 */
963   m68k->int_mask = 0x0700;
964   m68k->int_level = 0;
965   m68k->virq_state = 0;
951   int_mask = 0x0700;
952   int_level = 0;
953   virq_state = 0;
966954   /* Reset VBR */
967   m68k->vbr = 0;
955   vbr = 0;
968956   /* Go to supervisor mode */
969   m68ki_set_sm_flag(m68k, SFLAG_SET | MFLAG_CLEAR);
957   m68ki_set_sm_flag(this, SFLAG_SET | MFLAG_CLEAR);
970958
971959   /* Invalidate the prefetch queue */
972960   /* Set to arbitrary number since our first fetch is from 0 */
973   m68k->pref_addr = 0x1000;
961   pref_addr = 0x1000;
974962
975963   /* Read the initial stack pointer and program counter */
976   m68ki_jump(m68k, 0);
977   REG_SP(m68k) = m68ki_read_imm_32(m68k);
978   REG_PC(m68k) = m68ki_read_imm_32(m68k);
979   m68ki_jump(m68k, REG_PC(m68k));
964   m68ki_jump(this, 0);
965   REG_SP(this) = m68ki_read_imm_32(this);
966   REG_PC(this) = m68ki_read_imm_32(this);
967   m68ki_jump(this, REG_PC(this));
980968
981   m68k->run_mode = RUN_MODE_NORMAL;
969   run_mode = RUN_MODE_NORMAL;
982970
983   m68k->reset_cycles = m68k->cyc_exception[EXCEPTION_RESET];
971   reset_cycles = cyc_exception[EXCEPTION_RESET];
984972
985973   /* flush the MMU's cache */
986   pmmu_atc_flush(m68k);
974   pmmu_atc_flush(this);
987975
988   if(CPU_TYPE_IS_EC020_PLUS(m68k->cpu_type))
976   if(CPU_TYPE_IS_EC020_PLUS(cpu_type))
989977   {
990978      // clear instruction cache
991      m68ki_ic_clear(m68k);
979      m68ki_ic_clear(this);
992980   }
993981
994982   // disable instruction hook
995   m68k->instruction_hook = NULL;
983   instruction_hook = NULL;
996984
997   if (m68k->m68307SIM) m68k->m68307SIM->reset();
998   if (m68k->m68307MBUS) m68k->m68307MBUS->reset();
999   if (m68k->m68307SERIAL) m68k->m68307SERIAL->reset();
1000   if (m68k->m68307TIMER) m68k->m68307TIMER->reset();
985   if (m68307SIM) m68307SIM->reset();
986   if (m68307MBUS) m68307MBUS->reset();
987   if (m68307SERIAL) m68307SERIAL->reset();
988   if (m68307TIMER) m68307TIMER->reset();
1001989
1002   m68k->m68307_base = 0xbfff;
1003   m68k->m68307_scrhigh = 0x0007;
1004   m68k->m68307_scrlow = 0xf010;
1005
1006
990   m68307_base = 0xbfff;
991   m68307_scrhigh = 0x0007;
992   m68307_scrlow = 0xf010;
1007993}
1008994
1009static CPU_DISASSEMBLE( m68k )
1010{
1011   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1012   return m68k_disassemble_raw(buffer, pc, oprom, opram, m68k->dasm_type);
1013}
1014995
1015996
1016
1017997/**************************************************************************
1018998 * STATE IMPORT/EXPORT
1019999 **************************************************************************/
10201000
1021static CPU_IMPORT_STATE( m68k )
1001void m68000_base_device::state_import(const device_state_entry &entry)
10221002{
1023   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1024
10251003   switch (entry.index())
10261004   {
10271005      case M68K_SR:
10281006      case STATE_GENFLAGS:
1029         m68ki_set_sr(m68k, m68k->iotemp);
1007         m68ki_set_sr(this, iotemp);
10301008         break;
10311009
10321010      case M68K_ISP:
1033         if (m68k->s_flag && !m68k->m_flag)
1034            REG_SP(m68k) = m68k->iotemp;
1011         if (s_flag && !m_flag)
1012            REG_SP(this) = iotemp;
10351013         else
1036            REG_ISP(m68k) = m68k->iotemp;
1014            REG_ISP(this) = iotemp;
10371015         break;
10381016
10391017      case M68K_USP:
1040         if (!m68k->s_flag)
1041            REG_SP(m68k) = m68k->iotemp;
1018         if (!s_flag)
1019            REG_SP(this) = iotemp;
10421020         else
1043            REG_USP(m68k) = m68k->iotemp;
1021            REG_USP(this) = iotemp;
10441022         break;
10451023
10461024      case M68K_MSP:
1047         if (m68k->s_flag && m68k->m_flag)
1048            REG_SP(m68k) = m68k->iotemp;
1025         if (s_flag && m_flag)
1026            REG_SP(this) = iotemp;
10491027         else
1050            REG_MSP(m68k) = m68k->iotemp;
1028            REG_MSP(this) = iotemp;
10511029         break;
10521030
10531031      default:
1054         fatalerror("CPU_IMPORT_STATE(m68k) called for unexpected value\n");
1032         fatalerror("CPU_IMPORT_STATE(this) called for unexpected value\n");
10551033         break;
10561034   }
1035
10571036}
10581037
10591038
1060static CPU_EXPORT_STATE( m68k )
1039
1040void m68000_base_device::state_export(const device_state_entry &entry)
10611041{
1062   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1063
10641042   switch (entry.index())
10651043   {
10661044      case M68K_SR:
10671045      case STATE_GENFLAGS:
1068         m68k->iotemp = m68ki_get_sr(m68k);
1046         iotemp = m68ki_get_sr(this);
10691047         break;
10701048
10711049      case M68K_ISP:
1072         m68k->iotemp = (m68k->s_flag && !m68k->m_flag) ? REG_SP(m68k) : REG_ISP(m68k);
1050         iotemp = (s_flag && !m_flag) ? REG_SP(this) : REG_ISP(this);
10731051         break;
10741052
10751053      case M68K_USP:
1076         m68k->iotemp = (!m68k->s_flag) ? REG_SP(m68k) : REG_USP(m68k);
1054         iotemp = (!s_flag) ? REG_SP(this) : REG_USP(this);
10771055         break;
10781056
10791057      case M68K_MSP:
1080         m68k->iotemp = (m68k->s_flag && m68k->m_flag) ? REG_SP(m68k) : REG_MSP(m68k);
1058         iotemp = (s_flag && m_flag) ? REG_SP(this) : REG_MSP(this);
10811059         break;
10821060
10831061      case M68K_FP0:
r23920r23921
10911069         break;
10921070
10931071      default:
1094         fatalerror("CPU_EXPORT_STATE(m68k) called for unexpected value\n");
1072         fatalerror("CPU_EXPORT_STATE(this) called for unexpected value\n");
10951073         break;
10961074   }
10971075}
10981076
1099static CPU_SET_INFO( m68k )
1077void m68000_base_device::state_string_export(const device_state_entry &entry, astring &string)
11001078{
1101   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1102   switch (state)
1103   {
1104      /* --- the following bits of info are set as 64-bit signed integers --- */
1105      case CPUINFO_INT_INPUT_STATE + 0:
1106      case CPUINFO_INT_INPUT_STATE + 1:
1107      case CPUINFO_INT_INPUT_STATE + 2:
1108      case CPUINFO_INT_INPUT_STATE + 3:
1109      case CPUINFO_INT_INPUT_STATE + 4:
1110      case CPUINFO_INT_INPUT_STATE + 5:
1111      case CPUINFO_INT_INPUT_STATE + 6:
1112      case CPUINFO_INT_INPUT_STATE + 7:
1113      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI:
1114         set_irq_line(m68k, state - CPUINFO_INT_INPUT_STATE, info->i);
1115         break;
1116
1117      case CPUINFO_INT_INPUT_STATE + M68K_LINE_BUSERROR:
1118         if (info->i == ASSERT_LINE)
1119         {
1120            m68k_cause_bus_error(m68k);
1121         }
1122         break;
1123   }
1124}
1125
1126static CPU_EXPORT_STRING( m68k )
1127{
1128   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
11291079   UINT16 sr;
11301080
11311081   switch (entry.index())
11321082   {
11331083      case M68K_FP0:
1134         string.printf("%f", fx80_to_double(REG_FP(m68k)[0]));
1084         string.printf("%f", fx80_to_double(REG_FP(this)[0]));
11351085         break;
11361086
11371087      case M68K_FP1:
1138         string.printf("%f", fx80_to_double(REG_FP(m68k)[1]));
1088         string.printf("%f", fx80_to_double(REG_FP(this)[1]));
11391089         break;
11401090
11411091      case M68K_FP2:
1142         string.printf("%f", fx80_to_double(REG_FP(m68k)[2]));
1092         string.printf("%f", fx80_to_double(REG_FP(this)[2]));
11431093         break;
11441094
11451095      case M68K_FP3:
1146         string.printf("%f", fx80_to_double(REG_FP(m68k)[3]));
1096         string.printf("%f", fx80_to_double(REG_FP(this)[3]));
11471097         break;
11481098
11491099      case M68K_FP4:
1150         string.printf("%f", fx80_to_double(REG_FP(m68k)[4]));
1100         string.printf("%f", fx80_to_double(REG_FP(this)[4]));
11511101         break;
11521102
11531103      case M68K_FP5:
1154         string.printf("%f", fx80_to_double(REG_FP(m68k)[5]));
1104         string.printf("%f", fx80_to_double(REG_FP(this)[5]));
11551105         break;
11561106
11571107      case M68K_FP6:
1158         string.printf("%f", fx80_to_double(REG_FP(m68k)[6]));
1108         string.printf("%f", fx80_to_double(REG_FP(this)[6]));
11591109         break;
11601110
11611111      case M68K_FP7:
1162         string.printf("%f", fx80_to_double(REG_FP(m68k)[7]));
1112         string.printf("%f", fx80_to_double(REG_FP(this)[7]));
11631113         break;
11641114
11651115      case STATE_GENFLAGS:
1166         sr = m68ki_get_sr(m68k);
1116         sr = m68ki_get_sr(this);
11671117         string.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
11681118            sr & 0x8000 ? 'T':'.',
11691119            sr & 0x4000 ? 't':'.',
r23920r23921
11831133            sr & 0x0001 ? 'C':'.');
11841134         break;
11851135   }
1186}
11871136
1188static CPU_GET_INFO( m68k )
1189{
1190   m68ki_cpu_core *m68k = (device != NULL && device->token() != NULL) ? m68k_get_safe_token(device) : NULL;
1191
1192   switch (state)
1193   {
1194      /* --- the following bits of info are returned as 64-bit signed integers --- */
1195      case CPUINFO_INT_CONTEXT_SIZE:                  info->i = sizeof(m68ki_cpu_core);       break;
1196      case CPUINFO_INT_INPUT_LINES:                   info->i = 8;                            break;
1197      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:            info->i = -1;                           break;
1198      case CPUINFO_INT_ENDIANNESS:                    info->i = ENDIANNESS_BIG;               break;
1199      case CPUINFO_INT_CLOCK_MULTIPLIER:              info->i = 1;                            break;
1200      case CPUINFO_INT_CLOCK_DIVIDER:                 info->i = 1;                            break;
1201      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 2;                            break;
1202      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 10;                           break;
1203      case CPUINFO_INT_MIN_CYCLES:                    info->i = 4;                            break;
1204      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
1205
1206      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 16;                           break;
1207      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 24;                           break;
1208      case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM:        info->i = 0;                            break;
1209
1210      case CPUINFO_INT_INPUT_STATE + 0:               info->i = 0;  /* there is no level 0 */ break;
1211      case CPUINFO_INT_INPUT_STATE + 1:               info->i = (m68k->virq_state >> 1) & 1;  break;
1212      case CPUINFO_INT_INPUT_STATE + 2:               info->i = (m68k->virq_state >> 2) & 1;  break;
1213      case CPUINFO_INT_INPUT_STATE + 3:               info->i = (m68k->virq_state >> 3) & 1;  break;
1214      case CPUINFO_INT_INPUT_STATE + 4:               info->i = (m68k->virq_state >> 4) & 1;  break;
1215      case CPUINFO_INT_INPUT_STATE + 5:               info->i = (m68k->virq_state >> 5) & 1;  break;
1216      case CPUINFO_INT_INPUT_STATE + 6:               info->i = (m68k->virq_state >> 6) & 1;  break;
1217      case CPUINFO_INT_INPUT_STATE + 7:               info->i = (m68k->virq_state >> 7) & 1;  break;
1218
1219      /* --- the following bits of info are returned as pointers to functions --- */
1220      case CPUINFO_FCT_SET_INFO:      info->setinfo = CPU_SET_INFO_NAME(m68k);                break;
1221      case CPUINFO_FCT_INIT:          /* set per-core */                                      break;
1222      case CPUINFO_FCT_RESET:         info->reset = CPU_RESET_NAME(m68k);                     break;
1223      case CPUINFO_FCT_EXECUTE:       info->execute = CPU_EXECUTE_NAME(m68k);                 break;
1224      case CPUINFO_FCT_DISASSEMBLE:   info->disassemble = CPU_DISASSEMBLE_NAME(m68k);         break;
1225      case CPUINFO_FCT_IMPORT_STATE:  info->import_state = CPU_IMPORT_STATE_NAME(m68k);       break;
1226      case CPUINFO_FCT_EXPORT_STATE:  info->export_state = CPU_EXPORT_STATE_NAME(m68k);       break;
1227      case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(m68k);     break;
1228      case CPUINFO_FCT_TRANSLATE:         info->translate = CPU_TRANSLATE_NAME(m68k);     break;
1229
1230      /* --- the following bits of info are returned as pointers --- */
1231      case CPUINFO_PTR_INSTRUCTION_COUNTER:           info->icount = &m68k->remaining_cycles; break;
1232
1233      /* --- the following bits of info are returned as NULL-terminated strings --- */
1234      case CPUINFO_STR_NAME:                          /* set per-core */                      break;
1235      case CPUINFO_STR_FAMILY:                    strcpy(info->s, "Motorola 68K");        break;
1236      case CPUINFO_STR_VERSION:                   strcpy(info->s, "4.95");                break;
1237      case CPUINFO_STR_SOURCE_FILE:                       strcpy(info->s, __FILE__);              break;
1238      case CPUINFO_STR_CREDITS:                   strcpy(info->s, "Copyright Karl Stenerud. All rights reserved. (2.1 fixes HJB, FPU+MMU by RB+HO+OG)"); break;
1239   }
12401137}
12411138
12421139
12431140/* global access */
12441141
1245void m68k_set_encrypted_opcode_range(device_t *device, offs_t start, offs_t end)
1142void m68k_set_encrypted_opcode_range(m68000_base_device *device, offs_t start, offs_t end)
12461143{
1247   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1248   m68k->encrypted_start = start;
1249   m68k->encrypted_end = end;
1144   device->encrypted_start = start;
1145   device->encrypted_end = end;
12501146}
12511147
1252void m68k_set_hmmu_enable(device_t *device, int enable)
1148void m68k_set_hmmu_enable(m68000_base_device *device, int enable)
12531149{
1254   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1255
1256   m68k->hmmu_enabled = enable;
1150   device->hmmu_enabled = enable;
12571151}
12581152
1259void m68k_set_instruction_hook(device_t *device, instruction_hook_t ihook)
1153void m68k_set_instruction_hook(m68000_base_device *device, instruction_hook_t ihook)
12601154{
1261   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1262
1263   m68k->instruction_hook = ihook;
1155   device->instruction_hook = ihook;
12641156}
12651157
12661158/****************************************************************************
12671159 * 8-bit data memory interface
12681160 ****************************************************************************/
12691161
1270UINT16 m68k_memory_interface::m68008_read_immediate_16(offs_t address)
1162UINT16 m68000_base_device::m68008_read_immediate_16(offs_t address)
12711163{
12721164   return (m_direct->read_decrypted_byte(address) << 8) | (m_direct->read_decrypted_byte(address + 1));
12731165}
12741166
1275void m68k_memory_interface::init8(address_space &space)
1167void m68000_base_device::init8(address_space &space)
12761168{
12771169   m_space = &space;
12781170   m_direct = &space.direct();
1279   m_cpustate = m68k_get_safe_token(&space.device());
1171//   m_cpustate = this;
12801172   opcode_xor = 0;
12811173
1282   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::m68008_read_immediate_16), this);
1174   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::m68008_read_immediate_16), this);
12831175   read8 = m68k_read8_delegate(FUNC(address_space::read_byte), &space);
12841176   read16 = m68k_read16_delegate(FUNC(address_space::read_word), &space);
12851177   read32 = m68k_read32_delegate(FUNC(address_space::read_dword), &space);
r23920r23921
12921184 * 16-bit data memory interface
12931185 ****************************************************************************/
12941186
1295UINT16 m68k_memory_interface::read_immediate_16(offs_t address)
1187UINT16 m68000_base_device::read_immediate_16(offs_t address)
12961188{
12971189   return m_direct->read_decrypted_word((address), opcode_xor);
12981190}
12991191
1300UINT16 m68k_memory_interface::simple_read_immediate_16(offs_t address)
1192UINT16 m68000_base_device::simple_read_immediate_16(offs_t address)
13011193{
13021194   return m_direct->read_decrypted_word(address);
13031195}
13041196
1305void m68k_memory_interface::init16(address_space &space)
1197void m68000_base_device::init16(address_space &space)
13061198{
13071199   m_space = &space;
13081200   m_direct = &space.direct();
1309   m_cpustate = m68k_get_safe_token(&space.device());
13101201   opcode_xor = 0;
13111202
1312   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::simple_read_immediate_16), this);
1203   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::simple_read_immediate_16), this);
13131204   read8 = m68k_read8_delegate(FUNC(address_space::read_byte), &space);
13141205   read16 = m68k_read16_delegate(FUNC(address_space::read_word), &space);
13151206   read32 = m68k_read32_delegate(FUNC(address_space::read_dword), &space);
r23920r23921
13221213   and install handlers?  Going through this logic for every memory access is
13231214   very slow */
13241215
1325int m68307_calc_cs(m68ki_cpu_core *m68k, offs_t address)
1216int m68307_calc_cs(m68000_base_device *m68k, offs_t address)
13261217{
13271218   m68307_sim* sim = m68k->m68307SIM;
13281219
r23920r23921
13391230
13401231/* see note above */
13411232
1342int m68340_calc_cs(m68ki_cpu_core *m68k, offs_t address)
1233int m68340_calc_cs(m68000_base_device *m68k, offs_t address)
13431234{
13441235   m68340_sim* sim = m68k->m68340SIM;
13451236
r23920r23921
13651256
13661257
13671258
1368UINT16 m68k_memory_interface::simple_read_immediate_16_m68307(offs_t address)
1259UINT16 m68000_base_device::simple_read_immediate_16_m68307(offs_t address)
13691260{
1370//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1261//  m68307_currentcs = m68307_calc_cs(this, address);
13711262   return m_direct->read_decrypted_word(address);
13721263}
13731264
1374UINT8 m68k_memory_interface::read_byte_m68307(offs_t address)
1265UINT8 m68000_base_device::read_byte_m68307(offs_t address)
13751266{
1376//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1267//  m68307_currentcs = m68307_calc_cs(this, address);
13771268   return m_space->read_byte(address);
13781269}
13791270
1380UINT16 m68k_memory_interface::read_word_m68307(offs_t address)
1271UINT16 m68000_base_device::read_word_m68307(offs_t address)
13811272{
1382//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1273//  m68307_currentcs = m68307_calc_cs(this, address);
13831274   return m_space->read_word(address);
13841275}
13851276
1386UINT32 m68k_memory_interface::read_dword_m68307(offs_t address)
1277UINT32 m68000_base_device::read_dword_m68307(offs_t address)
13871278{
1388//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1279//  m68307_currentcs = m68307_calc_cs(this, address);
13891280   return m_space->read_dword(address);
13901281}
13911282
1392void m68k_memory_interface::write_byte_m68307(offs_t address, UINT8 data)
1283void m68000_base_device::write_byte_m68307(offs_t address, UINT8 data)
13931284{
1394//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1285//  m68307_currentcs = m68307_calc_cs(this, address);
13951286   m_space->write_byte(address, data);
13961287}
13971288
1398void m68k_memory_interface::write_word_m68307(offs_t address, UINT16 data)
1289void m68000_base_device::write_word_m68307(offs_t address, UINT16 data)
13991290{
1400//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1291//  m68307_currentcs = m68307_calc_cs(this, address);
14011292   m_space->write_word(address, data);
14021293}
14031294
1404void m68k_memory_interface::write_dword_m68307(offs_t address, UINT32 data)
1295void m68000_base_device::write_dword_m68307(offs_t address, UINT32 data)
14051296{
1406//  m_cpustate->m68307_currentcs = m68307_calc_cs(m_cpustate, address);
1297//  m68307_currentcs = m68307_calc_cs(this, address);
14071298   m_space->write_dword(address, data);
14081299}
14091300
14101301
14111302
14121303
1413void m68k_memory_interface::init16_m68307(address_space &space)
1304void m68000_base_device::init16_m68307(address_space &space)
14141305{
14151306   m_space = &space;
14161307   m_direct = &space.direct();
1417   m_cpustate = m68k_get_safe_token(&space.device());
14181308   opcode_xor = 0;
14191309
1420   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::simple_read_immediate_16_m68307), this);
1421   read8 = m68k_read8_delegate(FUNC(m68k_memory_interface::read_byte_m68307), this);
1422   read16 = m68k_read16_delegate(FUNC(m68k_memory_interface::read_word_m68307), this);
1423   read32 = m68k_read32_delegate(FUNC(m68k_memory_interface::read_dword_m68307), this);
1424   write8 = m68k_write8_delegate(FUNC(m68k_memory_interface::write_byte_m68307), this);
1425   write16 = m68k_write16_delegate(FUNC(m68k_memory_interface::write_word_m68307), this);
1426   write32 = m68k_write32_delegate(FUNC(m68k_memory_interface::write_dword_m68307), this);
1310   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::simple_read_immediate_16_m68307), this);
1311   read8 = m68k_read8_delegate(FUNC(m68000_base_device::read_byte_m68307), this);
1312   read16 = m68k_read16_delegate(FUNC(m68000_base_device::read_word_m68307), this);
1313   read32 = m68k_read32_delegate(FUNC(m68000_base_device::read_dword_m68307), this);
1314   write8 = m68k_write8_delegate(FUNC(m68000_base_device::write_byte_m68307), this);
1315   write16 = m68k_write16_delegate(FUNC(m68000_base_device::write_word_m68307), this);
1316   write32 = m68k_write32_delegate(FUNC(m68000_base_device::write_dword_m68307), this);
14271317}
14281318
14291319/****************************************************************************
r23920r23921
14311321 ****************************************************************************/
14321322
14331323/* interface for 32-bit data bus (68EC020, 68020) */
1434void m68k_memory_interface::init32(address_space &space)
1324void m68000_base_device::init32(address_space &space)
14351325{
14361326   m_space = &space;
14371327   m_direct = &space.direct();
1438   m_cpustate = m68k_get_safe_token(&space.device());
14391328   opcode_xor = WORD_XOR_BE(0);
14401329
1441   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::read_immediate_16), this);
1330   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::read_immediate_16), this);
14421331   read8 = m68k_read8_delegate(FUNC(address_space::read_byte), &space);
14431332   read16 = m68k_read16_delegate(FUNC(address_space::read_word_unaligned), &space);
14441333   read32 = m68k_read32_delegate(FUNC(address_space::read_dword_unaligned), &space);
r23920r23921
14481337}
14491338
14501339/* interface for 32-bit data bus with PMMU (68EC020, 68020) */
1451UINT8 m68k_memory_interface::read_byte_32_mmu(offs_t address)
1340UINT8 m68000_base_device::read_byte_32_mmu(offs_t address)
14521341{
1453   if (m_cpustate->pmmu_enabled)
1342   if (pmmu_enabled)
14541343   {
1455      address = pmmu_translate_addr(m_cpustate, address);
1456      if (m_cpustate->mmu_tmp_buserror_occurred) {
1344      address = pmmu_translate_addr(this, address);
1345      if (mmu_tmp_buserror_occurred) {
14571346         return ~0;
14581347      }
14591348   }
r23920r23921
14611350   return m_space->read_byte(address);
14621351}
14631352
1464void m68k_memory_interface::write_byte_32_mmu(offs_t address, UINT8 data)
1353void m68000_base_device::write_byte_32_mmu(offs_t address, UINT8 data)
14651354{
1466   if (m_cpustate->pmmu_enabled)
1355   if (pmmu_enabled)
14671356   {
1468      address = pmmu_translate_addr(m_cpustate, address);
1469      if (m_cpustate->mmu_tmp_buserror_occurred) {
1357      address = pmmu_translate_addr(this, address);
1358      if (mmu_tmp_buserror_occurred) {
14701359         return;
14711360      }
14721361   }
r23920r23921
14741363   m_space->write_byte(address, data);
14751364}
14761365
1477UINT16 m68k_memory_interface::read_immediate_16_mmu(offs_t address)
1366UINT16 m68000_base_device::read_immediate_16_mmu(offs_t address)
14781367{
1479   if (m_cpustate->pmmu_enabled)
1368   if (pmmu_enabled)
14801369   {
1481      address = pmmu_translate_addr(m_cpustate, address);
1482      if (m_cpustate->mmu_tmp_buserror_occurred) {
1370      address = pmmu_translate_addr(this, address);
1371      if (mmu_tmp_buserror_occurred) {
14831372         return ~0;
14841373      }
14851374   }
14861375
1487   return m_direct->read_decrypted_word((address), m_cpustate->memory.opcode_xor);
1376   return m_direct->read_decrypted_word((address), opcode_xor);
14881377}
14891378
14901379/* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */
1491UINT16 m68k_memory_interface::readword_d32_mmu(offs_t address)
1380UINT16 m68000_base_device::readword_d32_mmu(offs_t address)
14921381{
14931382   UINT16 result;
14941383
1495   if (m_cpustate->pmmu_enabled)
1384   if (pmmu_enabled)
14961385   {
1497      UINT32 address0 = pmmu_translate_addr(m_cpustate, address);
1498      if (m_cpustate->mmu_tmp_buserror_occurred) {
1386      UINT32 address0 = pmmu_translate_addr(this, address);
1387      if (mmu_tmp_buserror_occurred) {
14991388         return ~0;
15001389      } else if (!(address & 1)) {
15011390         return m_space->read_word(address0);
15021391      } else {
1503         UINT32 address1 = pmmu_translate_addr(m_cpustate, address + 1);
1504         if (m_cpustate->mmu_tmp_buserror_occurred) {
1392         UINT32 address1 = pmmu_translate_addr(this, address + 1);
1393         if (mmu_tmp_buserror_occurred) {
15051394            return ~0;
15061395         } else {
15071396            result = m_space->read_byte(address0) << 8;
r23920r23921
15171406}
15181407
15191408/* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */
1520void m68k_memory_interface::writeword_d32_mmu(offs_t address, UINT16 data)
1409void m68000_base_device::writeword_d32_mmu(offs_t address, UINT16 data)
15211410{
1522   if (m_cpustate->pmmu_enabled)
1411   if (pmmu_enabled)
15231412   {
1524      UINT32 address0 = pmmu_translate_addr(m_cpustate, address);
1525      if (m_cpustate->mmu_tmp_buserror_occurred) {
1413      UINT32 address0 = pmmu_translate_addr(this, address);
1414      if (mmu_tmp_buserror_occurred) {
15261415         return;
15271416      } else if (!(address & 1)) {
15281417         m_space->write_word(address0, data);
15291418         return;
15301419      } else {
1531         UINT32 address1 = pmmu_translate_addr(m_cpustate, address + 1);
1532         if (m_cpustate->mmu_tmp_buserror_occurred) {
1420         UINT32 address1 = pmmu_translate_addr(this, address + 1);
1421         if (mmu_tmp_buserror_occurred) {
15331422            return;
15341423         } else {
15351424            m_space->write_byte(address0, data >> 8);
r23920r23921
15491438}
15501439
15511440/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */
1552UINT32 m68k_memory_interface::readlong_d32_mmu(offs_t address)
1441UINT32 m68000_base_device::readlong_d32_mmu(offs_t address)
15531442{
15541443   UINT32 result;
15551444
1556   if (m_cpustate->pmmu_enabled)
1445   if (pmmu_enabled)
15571446   {
1558      UINT32 address0 = pmmu_translate_addr(m_cpustate, address);
1559      if (m_cpustate->mmu_tmp_buserror_occurred) {
1447      UINT32 address0 = pmmu_translate_addr(this, address);
1448      if (mmu_tmp_buserror_occurred) {
15601449         return ~0;
15611450      } else if ((address +3) & 0xfc) {
15621451         // not at page boundary; use default code
r23920r23921
15641453      } else if (!(address & 3)) { // 0
15651454         return m_space->read_dword(address0);
15661455      } else {
1567         UINT32 address2 = pmmu_translate_addr(m_cpustate, address+2);
1568         if (m_cpustate->mmu_tmp_buserror_occurred) {
1456         UINT32 address2 = pmmu_translate_addr(this, address+2);
1457         if (mmu_tmp_buserror_occurred) {
15691458            return ~0;
15701459         } else if (!(address & 1)) { // 2
15711460            result = m_space->read_word(address0) << 16;
15721461            return result | m_space->read_word(address2);
15731462         } else {
1574            UINT32 address1 = pmmu_translate_addr(m_cpustate, address+1);
1575            UINT32 address3 = pmmu_translate_addr(m_cpustate, address+3);
1576            if (m_cpustate->mmu_tmp_buserror_occurred) {
1463            UINT32 address1 = pmmu_translate_addr(this, address+1);
1464            UINT32 address3 = pmmu_translate_addr(this, address+3);
1465            if (mmu_tmp_buserror_occurred) {
15771466               return ~0;
15781467            } else {
15791468               result = m_space->read_byte(address0) << 24;
r23920r23921
15971486}
15981487
15991488/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */
1600void m68k_memory_interface::writelong_d32_mmu(offs_t address, UINT32 data)
1489void m68000_base_device::writelong_d32_mmu(offs_t address, UINT32 data)
16011490{
1602   if (m_cpustate->pmmu_enabled)
1491   if (pmmu_enabled)
16031492   {
1604      UINT32 address0 = pmmu_translate_addr(m_cpustate, address);
1605      if (m_cpustate->mmu_tmp_buserror_occurred) {
1493      UINT32 address0 = pmmu_translate_addr(this, address);
1494      if (mmu_tmp_buserror_occurred) {
16061495         return;
16071496      } else if ((address +3) & 0xfc) {
16081497         // not at page boundary; use default code
r23920r23921
16111500         m_space->write_dword(address0, data);
16121501         return;
16131502      } else {
1614         UINT32 address2 = pmmu_translate_addr(m_cpustate, address+2);
1615         if (m_cpustate->mmu_tmp_buserror_occurred) {
1503         UINT32 address2 = pmmu_translate_addr(this, address+2);
1504         if (mmu_tmp_buserror_occurred) {
16161505            return;
16171506         } else if (!(address & 1)) { // 2
16181507            m_space->write_word(address0, data >> 16);
16191508            m_space->write_word(address2, data);
16201509            return;
16211510         } else {
1622            UINT32 address1 = pmmu_translate_addr(m_cpustate, address+1);
1623            UINT32 address3 = pmmu_translate_addr(m_cpustate, address+3);
1624            if (m_cpustate->mmu_tmp_buserror_occurred) {
1511            UINT32 address1 = pmmu_translate_addr(this, address+1);
1512            UINT32 address3 = pmmu_translate_addr(this, address+3);
1513            if (mmu_tmp_buserror_occurred) {
16251514               return;
16261515            } else {
16271516               m_space->write_byte(address0, data >> 24);
r23920r23921
16491538   m_space->write_byte(address + 3, data);
16501539}
16511540
1652void m68k_memory_interface::init32mmu(address_space &space)
1541void m68000_base_device::init32mmu(address_space &space)
16531542{
16541543   m_space = &space;
16551544   m_direct = &space.direct();
1656   m_cpustate = m68k_get_safe_token(&space.device());
16571545   opcode_xor = WORD_XOR_BE(0);
16581546
1659   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::read_immediate_16_mmu), this);
1660   read8 = m68k_read8_delegate(FUNC(m68k_memory_interface::read_byte_32_mmu), this);
1661   read16 = m68k_read16_delegate(FUNC(m68k_memory_interface::readword_d32_mmu), this);
1662   read32 = m68k_read32_delegate(FUNC(m68k_memory_interface::readlong_d32_mmu), this);
1663   write8 = m68k_write8_delegate(FUNC(m68k_memory_interface::write_byte_32_mmu), this);
1664   write16 = m68k_write16_delegate(FUNC(m68k_memory_interface::writeword_d32_mmu), this);
1665   write32 = m68k_write32_delegate(FUNC(m68k_memory_interface::writelong_d32_mmu), this);
1547   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::read_immediate_16_mmu), this);
1548   read8 = m68k_read8_delegate(FUNC(m68000_base_device::read_byte_32_mmu), this);
1549   read16 = m68k_read16_delegate(FUNC(m68000_base_device::readword_d32_mmu), this);
1550   read32 = m68k_read32_delegate(FUNC(m68000_base_device::readlong_d32_mmu), this);
1551   write8 = m68k_write8_delegate(FUNC(m68000_base_device::write_byte_32_mmu), this);
1552   write16 = m68k_write16_delegate(FUNC(m68000_base_device::writeword_d32_mmu), this);
1553   write32 = m68k_write32_delegate(FUNC(m68000_base_device::writelong_d32_mmu), this);
16661554}
16671555
16681556
16691557/* interface for 32-bit data bus with PMMU (68EC020, 68020) */
1670UINT8 m68k_memory_interface::read_byte_32_hmmu(offs_t address)
1558UINT8 m68000_base_device::read_byte_32_hmmu(offs_t address)
16711559{
1672   if (m_cpustate->hmmu_enabled)
1560   if (hmmu_enabled)
16731561   {
1674      address = hmmu_translate_addr(m_cpustate, address);
1562      address = hmmu_translate_addr(this, address);
16751563   }
16761564
16771565   return m_space->read_byte(address);
16781566}
16791567
1680void m68k_memory_interface::write_byte_32_hmmu(offs_t address, UINT8 data)
1568void m68000_base_device::write_byte_32_hmmu(offs_t address, UINT8 data)
16811569{
1682   if (m_cpustate->hmmu_enabled)
1570   if (hmmu_enabled)
16831571   {
1684      address = hmmu_translate_addr(m_cpustate, address);
1572      address = hmmu_translate_addr(this, address);
16851573   }
16861574
16871575   m_space->write_byte(address, data);
16881576}
16891577
1690UINT16 m68k_memory_interface::read_immediate_16_hmmu(offs_t address)
1578UINT16 m68000_base_device::read_immediate_16_hmmu(offs_t address)
16911579{
1692   if (m_cpustate->hmmu_enabled)
1580   if (hmmu_enabled)
16931581   {
1694      address = hmmu_translate_addr(m_cpustate, address);
1582      address = hmmu_translate_addr(this, address);
16951583   }
16961584
1697   return m_direct->read_decrypted_word((address), m_cpustate->memory.opcode_xor);
1585   return m_direct->read_decrypted_word((address), opcode_xor);
16981586}
16991587
17001588/* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */
1701UINT16 m68k_memory_interface::readword_d32_hmmu(offs_t address)
1589UINT16 m68000_base_device::readword_d32_hmmu(offs_t address)
17021590{
17031591   UINT16 result;
17041592
1705   if (m_cpustate->hmmu_enabled)
1593   if (hmmu_enabled)
17061594   {
1707      address = hmmu_translate_addr(m_cpustate, address);
1595      address = hmmu_translate_addr(this, address);
17081596   }
17091597
17101598   if (!(address & 1))
r23920r23921
17141602}
17151603
17161604/* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */
1717void m68k_memory_interface::writeword_d32_hmmu(offs_t address, UINT16 data)
1605void m68000_base_device::writeword_d32_hmmu(offs_t address, UINT16 data)
17181606{
1719   if (m_cpustate->hmmu_enabled)
1607   if (hmmu_enabled)
17201608   {
1721      address = hmmu_translate_addr(m_cpustate, address);
1609      address = hmmu_translate_addr(this, address);
17221610   }
17231611
17241612   if (!(address & 1))
r23920r23921
17311619}
17321620
17331621/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */
1734UINT32 m68k_memory_interface::readlong_d32_hmmu(offs_t address)
1622UINT32 m68000_base_device::readlong_d32_hmmu(offs_t address)
17351623{
17361624   UINT32 result;
17371625
1738   if (m_cpustate->hmmu_enabled)
1626   if (hmmu_enabled)
17391627   {
1740      address = hmmu_translate_addr(m_cpustate, address);
1628      address = hmmu_translate_addr(this, address);
17411629   }
17421630
17431631   if (!(address & 3))
r23920r23921
17531641}
17541642
17551643/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */
1756void m68k_memory_interface::writelong_d32_hmmu(offs_t address, UINT32 data)
1644void m68000_base_device::writelong_d32_hmmu(offs_t address, UINT32 data)
17571645{
1758   if (m_cpustate->hmmu_enabled)
1646   if (hmmu_enabled)
17591647   {
1760      address = hmmu_translate_addr(m_cpustate, address);
1648      address = hmmu_translate_addr(this, address);
17611649   }
17621650
17631651   if (!(address & 3))
r23920r23921
17761664   m_space->write_byte(address + 3, data);
17771665}
17781666
1779void m68k_memory_interface::init32hmmu(address_space &space)
1667void m68000_base_device::init32hmmu(address_space &space)
17801668{
17811669   m_space = &space;
17821670   m_direct = &space.direct();
1783   m_cpustate = m68k_get_safe_token(&space.device());
17841671   opcode_xor = WORD_XOR_BE(0);
17851672
1786   readimm16 = m68k_readimm16_delegate(FUNC(m68k_memory_interface::read_immediate_16_hmmu), this);
1787   read8 = m68k_read8_delegate(FUNC(m68k_memory_interface::read_byte_32_hmmu), this);
1788   read16 = m68k_read16_delegate(FUNC(m68k_memory_interface::readword_d32_hmmu), this);
1789   read32 = m68k_read32_delegate(FUNC(m68k_memory_interface::readlong_d32_hmmu), this);
1790   write8 = m68k_write8_delegate(FUNC(m68k_memory_interface::write_byte_32_hmmu), this);
1791   write16 = m68k_write16_delegate(FUNC(m68k_memory_interface::writeword_d32_hmmu), this);
1792   write32 = m68k_write32_delegate(FUNC(m68k_memory_interface::writelong_d32_hmmu), this);
1673   readimm16 = m68k_readimm16_delegate(FUNC(m68000_base_device::read_immediate_16_hmmu), this);
1674   read8 = m68k_read8_delegate(FUNC(m68000_base_device::read_byte_32_hmmu), this);
1675   read16 = m68k_read16_delegate(FUNC(m68000_base_device::readword_d32_hmmu), this);
1676   read32 = m68k_read32_delegate(FUNC(m68000_base_device::readlong_d32_hmmu), this);
1677   write8 = m68k_write8_delegate(FUNC(m68000_base_device::write_byte_32_hmmu), this);
1678   write16 = m68k_write16_delegate(FUNC(m68000_base_device::writeword_d32_hmmu), this);
1679   write32 = m68k_write32_delegate(FUNC(m68000_base_device::writelong_d32_hmmu), this);
17931680}
17941681
1795void m68k_set_reset_callback(device_t *device, m68k_reset_func callback)
1682void m68k_set_reset_callback(m68000_base_device *device, m68k_reset_func callback)
17961683{
1797   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1798   m68k->reset_instr_callback = callback;
1684   device->reset_instr_callback = callback;
17991685}
18001686
1801void m68k_set_cmpild_callback(device_t *device, m68k_cmpild_func callback)
1687void m68k_set_cmpild_callback(m68000_base_device *device, m68k_cmpild_func callback)
18021688{
1803   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1804   m68k->cmpild_instr_callback = callback;
1689   device->cmpild_instr_callback = callback;
18051690}
18061691
1807void m68k_set_rte_callback(device_t *device, m68k_rte_func callback)
1692void m68k_set_rte_callback(m68000_base_device *device, m68k_rte_func callback)
18081693{
1809   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1810   m68k->rte_instr_callback = callback;
1694   device->rte_instr_callback = callback;
18111695}
18121696
1813void m68k_set_tas_callback(device_t *device, m68k_tas_func callback)
1697void m68k_set_tas_callback(m68000_base_device *device, m68k_tas_func callback)
18141698{
1815   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1816   m68k->tas_instr_callback = callback;
1699   device->tas_instr_callback = callback;
18171700}
18181701
1819UINT16 m68k_get_fc(device_t *device)
1702UINT16 m68k_get_fc(m68000_base_device *device)
18201703{
1821   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1822   return m68k->mmu_tmp_fc;
1704   return device->mmu_tmp_fc;
18231705}
18241706
1825void m68307_set_port_callbacks(device_t *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback portb_w)
1707void m68307_set_port_callbacks(m68000_base_device *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback portb_w)
18261708{
1827   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1828   m68k->m_m68307_porta_r = porta_r;
1829   m68k->m_m68307_porta_w = porta_w;
1830   m68k->m_m68307_portb_r = portb_r;
1831   m68k->m_m68307_portb_w = portb_w;
1709   device->m_m68307_porta_r = porta_r;
1710   device->m_m68307_porta_w = porta_w;
1711   device->m_m68307_portb_r = portb_r;
1712   device->m_m68307_portb_w = portb_w;
18321713}
18331714
1834void m68307_set_duart68681(device_t* cpudev, device_t* duart68681)
1715void m68307_set_duart68681(m68000_base_device* cpudev, device_t* duart68681)
18351716{
1836   m68ki_cpu_core *m68k = m68k_get_safe_token(cpudev);
1837   if (m68k->m68307SERIAL)
1838      m68k->m68307SERIAL->m68307ser_set_duart68681(duart68681);
1717   if (cpudev->m68307SERIAL)
1718      cpudev->m68307SERIAL->m68307ser_set_duart68681(duart68681);
18391719}
18401720
18411721
18421722
18431723
1844UINT16 m68307_get_cs(device_t *device, offs_t address)
1724UINT16 m68307_get_cs(m68000_base_device *device, offs_t address)
18451725{
1846   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1726   device->m68307_currentcs = m68307_calc_cs(device, address);
18471727
1848   m68k->m68307_currentcs = m68307_calc_cs(m68k, address);
1849
1850   return m68k->m68307_currentcs;
1728   return device->m68307_currentcs;
18511729}
18521730
1853UINT16 m68340_get_cs(device_t *device, offs_t address)
1731UINT16 m68340_get_cs(m68000_base_device *device, offs_t address)
18541732{
1855   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1733   device->m68307_currentcs = m68340_calc_cs(device, address);
18561734
1857   m68k->m68307_currentcs = m68340_calc_cs(m68k, address);
1858
1859   return m68k->m68307_currentcs;
1735   return device->m68307_currentcs;
18601736}
18611737
18621738/****************************************************************************
18631739 * State definition
18641740 ****************************************************************************/
18651741
1866static void define_state(device_t *device)
1742void m68000_base_device::define_state(void)
18671743{
1868   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1869   UINT32 addrmask = (m68k->cpu_type & MASK_24BIT_SPACE) ? 0xffffff : 0xffffffff;
1744   UINT32 addrmask = (cpu_type & MASK_24BIT_SPACE) ? 0xffffff : 0xffffffff;
18701745
1871   device_state_interface *state;
1872   device->interface(state);
1873   state->state_add(M68K_PC,         "PC",        m68k->pc).mask(addrmask);
1874   state->state_add(STATE_GENPC,     "GENPC",     m68k->pc).mask(addrmask).noshow();
1875   state->state_add(STATE_GENPCBASE, "GENPCBASE", m68k->ppc).mask(addrmask).noshow();
1876   state->state_add(M68K_SP,         "SP",        m68k->dar[15]);
1877   state->state_add(STATE_GENSP,     "GENSP",     m68k->dar[15]).noshow();
1878   state->state_add(STATE_GENFLAGS,  "GENFLAGS",  m68k->iotemp).noshow().callimport().callexport().formatstr("%16s");
1879   state->state_add(M68K_ISP,        "ISP",       m68k->iotemp).callimport().callexport();
1880   state->state_add(M68K_USP,        "USP",       m68k->iotemp).callimport().callexport();
1881   if (m68k->cpu_type & MASK_020_OR_LATER)
1882      state->state_add(M68K_MSP,    "MSP",       m68k->iotemp).callimport().callexport();
1883   state->state_add(M68K_ISP,        "ISP",       m68k->iotemp).callimport().callexport();
1746   state_add(M68K_PC,         "PC",        pc).mask(addrmask);
1747   state_add(STATE_GENPC,     "GENPC",     pc).mask(addrmask).noshow();
1748   state_add(STATE_GENPCBASE, "GENPCBASE", ppc).mask(addrmask).noshow();
1749   state_add(M68K_SP,         "SP",        dar[15]);
1750   state_add(STATE_GENSP,     "GENSP",     dar[15]).noshow();
1751   state_add(STATE_GENFLAGS,  "GENFLAGS",  iotemp).noshow().callimport().callexport().formatstr("%16s");
1752   state_add(M68K_ISP,        "ISP",       iotemp).callimport().callexport();
1753   state_add(M68K_USP,        "USP",       iotemp).callimport().callexport();
1754   if (cpu_type & MASK_020_OR_LATER)
1755      state_add(M68K_MSP,    "MSP",       iotemp).callimport().callexport();
1756   state_add(M68K_ISP,        "ISP",       iotemp).callimport().callexport();
18841757
18851758   astring tempstr;
18861759   for (int regnum = 0; regnum < 8; regnum++)
1887      state->state_add(M68K_D0 + regnum, tempstr.format("D%d", regnum), m68k->dar[regnum]);
1760      state_add(M68K_D0 + regnum, tempstr.format("D%d", regnum), dar[regnum]);
18881761   for (int regnum = 0; regnum < 8; regnum++)
1889      state->state_add(M68K_A0 + regnum, tempstr.format("A%d", regnum), m68k->dar[8 + regnum]);
1762      state_add(M68K_A0 + regnum, tempstr.format("A%d", regnum), dar[8 + regnum]);
18901763
1891   state->state_add(M68K_PREF_ADDR,  "PREF_ADDR", m68k->pref_addr).mask(addrmask);
1892   state->state_add(M68K_PREF_DATA,  "PREF_DATA", m68k->pref_data);
1764   state_add(M68K_PREF_ADDR,  "PREF_ADDR", pref_addr).mask(addrmask);
1765   state_add(M68K_PREF_DATA,  "PREF_DATA", pref_data);
18931766
1894   if (m68k->cpu_type & MASK_010_OR_LATER)
1767   if (cpu_type & MASK_010_OR_LATER)
18951768   {
1896      state->state_add(M68K_SFC,    "SFC",       m68k->sfc).mask(0x7);
1897      state->state_add(M68K_DFC,    "DFC",       m68k->dfc).mask(0x7);
1898      state->state_add(M68K_VBR,    "VBR",       m68k->vbr);
1769      state_add(M68K_SFC,    "SFC",       sfc).mask(0x7);
1770      state_add(M68K_DFC,    "DFC",       dfc).mask(0x7);
1771      state_add(M68K_VBR,    "VBR",       vbr);
18991772   }
19001773
1901   if (m68k->cpu_type & MASK_020_OR_LATER)
1774   if (cpu_type & MASK_020_OR_LATER)
19021775   {
1903      state->state_add(M68K_CACR,   "CACR",      m68k->cacr);
1904      state->state_add(M68K_CAAR,   "CAAR",      m68k->caar);
1776      state_add(M68K_CACR,   "CACR",      cacr);
1777      state_add(M68K_CAAR,   "CAAR",      caar);
19051778   }
19061779
1907   if (m68k->cpu_type & MASK_030_OR_LATER)
1780   if (cpu_type & MASK_030_OR_LATER)
19081781   {
19091782      for (int regnum = 0; regnum < 8; regnum++)
1910         state->state_add(M68K_FP0 + regnum, tempstr.format("FP%d", regnum), m68k->iotemp).callimport().callexport().formatstr("%10s");
1911      state->state_add(M68K_FPSR, "FPSR", m68k->fpsr);
1912      state->state_add(M68K_FPCR, "FPCR", m68k->fpcr);
1783         state_add(M68K_FP0 + regnum, tempstr.format("FP%d", regnum), iotemp).callimport().callexport().formatstr("%10s");
1784      state_add(M68K_FPSR, "FPSR", fpsr);
1785      state_add(M68K_FPCR, "FPCR", fpcr);
19131786   }
19141787}
19151788
19161789
1917/****************************************************************************
1918 * 68000 section
1919 ****************************************************************************/
1790/* 68307 specifics - MOVE */
19201791
1921static CPU_INIT( m68000 )
1922{
1923   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1924
1925   CPU_INIT_CALL(m68k);
1926
1927   m68k->cpu_type         = CPU_TYPE_000;
1928   m68k->dasm_type        = M68K_CPU_TYPE_68000;
1929// hack alert: we use placement new to ensure we are properly initialized
1930// because we live in the device state which is allocated as bytes
1931// remove me when we have a real C++ device
1932   new(&m68k->memory) m68k_memory_interface;
1933   m68k->memory.init16(*m68k->program);
1934   m68k->sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
1935   m68k->jump_table       = m68ki_instruction_jump_table[0];
1936   m68k->cyc_instruction  = m68ki_cycles[0];
1937   m68k->cyc_exception    = m68ki_exception_cycle_table[0];
1938   m68k->cyc_bcc_notake_b = -2;
1939   m68k->cyc_bcc_notake_w = 2;
1940   m68k->cyc_dbcc_f_noexp = -2;
1941   m68k->cyc_dbcc_f_exp   = 2;
1942   m68k->cyc_scc_r_true   = 2;
1943   m68k->cyc_movem_w      = 2;
1944   m68k->cyc_movem_l      = 3;
1945   m68k->cyc_shift        = 1;
1946   m68k->cyc_reset        = 132;
1947   m68k->has_pmmu         = 0;
1948   m68k->has_hmmu         = 0;
1949   m68k->has_fpu          = 0;
1950
1951   define_state(device);
1952}
1953
1954CPU_GET_INFO( m68000 )
1955{
1956   switch (state)
1957   {
1958      /* --- the following bits of info are returned as pointers to data or functions --- */
1959      case CPUINFO_FCT_INIT:                      info->init = CPU_INIT_NAME(m68000);             break;
1960
1961      /* --- the following bits of info are returned as NULL-terminated strings --- */
1962      case CPUINFO_STR_NAME:                      strcpy(info->s, "68000");                       break;
1963
1964      default:                                    CPU_GET_INFO_CALL(m68k);                        break;
1965   }
1966}
1967
1968static CPU_INIT( m68301 )
1969{
1970//  m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1971
1972   CPU_INIT_CALL(m68000);
1973
1974   /* there is a basic implementation of this in emu/machine/tmp68301.c but it should be moved here */
1975
1976}
1977
1978CPU_GET_INFO( m68301 )
1979{
1980   switch (state)
1981   {
1982      /* --- the following bits of info are returned as pointers to data or functions --- */
1983      case CPUINFO_FCT_INIT:                      info->init = CPU_INIT_NAME(m68301);             break;
1984
1985      /* --- the following bits of info are returned as NULL-terminated strings --- */
1986      case CPUINFO_STR_NAME:                      strcpy(info->s, "68301");                       break;
1987
1988      default:                                    CPU_GET_INFO_CALL(m68k);                        break;
1989   }
1990}
1991
1992
1993
1994
19951792void m68307_set_interrupt(device_t *device, int level, int vector)
19961793{
19971794   device->execute().set_input_line_and_vector(level, HOLD_LINE, vector);
19981795}
19991796
2000void m68307_timer0_interrupt(legacy_cpu_device *cpudev)
1797void m68307_timer0_interrupt(m68000_base_device *cpudev)
20011798{
2002   m68ki_cpu_core* m68k = m68k_get_safe_token(cpudev);
2003   int prioritylevel = (m68k->m68307SIM->m_picr & 0x7000)>>12;
2004   int vector        = (m68k->m68307SIM->m_pivr & 0x00f0) | 0xa;
1799   int prioritylevel = (cpudev->m68307SIM->m_picr & 0x7000)>>12;
1800   int vector        = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xa;
20051801   m68307_set_interrupt(cpudev, prioritylevel, vector);
20061802}
20071803
2008void m68307_timer1_interrupt(legacy_cpu_device *cpudev)
1804void m68307_timer1_interrupt(m68000_base_device *cpudev)
20091805{
2010   m68ki_cpu_core* m68k = m68k_get_safe_token(cpudev);
2011   int prioritylevel = (m68k->m68307SIM->m_picr & 0x0700)>>8;
2012   int vector        = (m68k->m68307SIM->m_pivr & 0x00f0) | 0xb;
1806   int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0700)>>8;
1807   int vector        = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xb;
20131808   m68307_set_interrupt(cpudev, prioritylevel, vector);
20141809}
20151810
2016void m68307_serial_interrupt(legacy_cpu_device *cpudev, int vector)
1811void m68307_serial_interrupt(m68000_base_device *cpudev, int vector)
20171812{
2018   m68ki_cpu_core* m68k = m68k_get_safe_token(cpudev);
2019   int prioritylevel = (m68k->m68307SIM->m_picr & 0x0070)>>4;
1813   int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0070)>>4;
20201814   m68307_set_interrupt(cpudev, prioritylevel, vector);
20211815}
20221816
2023void m68307_mbus_interrupt(legacy_cpu_device *cpudev)
1817void m68307_mbus_interrupt(m68000_base_device *cpudev)
20241818{
2025   m68ki_cpu_core* m68k = m68k_get_safe_token(cpudev);
2026   int prioritylevel = (m68k->m68307SIM->m_picr & 0x0007)>>0;
2027   int vector        = (m68k->m68307SIM->m_pivr & 0x00f0) | 0xd;
1819   int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0007)>>0;
1820   int vector        = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xd;
20281821   m68307_set_interrupt(cpudev, prioritylevel, vector);
20291822}
20301823
2031void m68307_licr2_interrupt(legacy_cpu_device *cpudev)
1824void m68307_licr2_interrupt(m68000_base_device *cpudev)
20321825{
2033   m68ki_cpu_core* m68k = m68k_get_safe_token(cpudev);
2034   int prioritylevel = (m68k->m68307SIM->m_licr2 & 0x0007)>>0;
2035   int vector        = (m68k->m68307SIM->m_pivr & 0x00f0) | 0x9;
2036   m68k->m68307SIM->m_licr2 |= 0x8;
1826   int prioritylevel = (cpudev->m68307SIM->m_licr2 & 0x0007)>>0;
1827   int vector        = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0x9;
1828   cpudev->m68307SIM->m_licr2 |= 0x8;
20371829
20381830
20391831   m68307_set_interrupt(cpudev, prioritylevel, vector);
20401832}
20411833
2042
2043
2044static CPU_INIT( m68307 )
1834void m68000_base_device::init_cpu_m68307(void)
20451835{
2046   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
1836   init_cpu_m68000();
20471837
2048   CPU_INIT_CALL(m68000);
2049
20501838   /* basic CS logic, timers, mbus, serial logic
20511839      set via remappable register
20521840   */
2053   new(&m68k->memory) m68k_memory_interface;
2054   m68k->memory.init16_m68307(*m68k->program);
1841   
1842   init16_m68307(*program);
20551843
2056   m68k->m68307SIM    = new m68307_sim();
2057   m68k->m68307MBUS   = new m68307_mbus();
2058   m68k->m68307SERIAL = new m68307_serial();
2059   m68k->m68307TIMER  = new m68307_timer();
1844   m68307SIM    = new m68307_sim();
1845   m68307MBUS   = new m68307_mbus();
1846   m68307SERIAL = new m68307_serial();
1847   m68307TIMER  = new m68307_timer();
20601848
2061   m68k->m68307TIMER->init(device);
1849   m68307TIMER->init(this);
20621850
2063   m68k->m68307SIM->reset();
2064   m68k->m68307MBUS->reset();
2065   m68k->m68307SERIAL->reset();
2066   m68k->m68307TIMER->reset();
1851   m68307SIM->reset();
1852   m68307MBUS->reset();
1853   m68307SERIAL->reset();
1854   m68307TIMER->reset();
20671855
2068   m68k->internal = &device->space(AS_PROGRAM);
2069   m68k->m68307_base = 0xbfff;
2070   m68k->m68307_scrhigh = 0x0007;
2071   m68k->m68307_scrlow = 0xf010;
1856   internal = &this->space(AS_PROGRAM);
1857   m68307_base = 0xbfff;
1858   m68307_scrhigh = 0x0007;
1859   m68307_scrlow = 0xf010;
20721860
2073   m68307_set_port_callbacks(device, 0,0,0,0);
1861   m68307_set_port_callbacks(this, 0,0,0,0);
20741862}
20751863
2076static READ16_HANDLER( m68307_internal_base_r )
1864
1865
1866READ16_MEMBER( m68000_base_device::m68307_internal_base_r )
20771867{
2078   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
1868   m68000_base_device *m68k = this;
20791869
20801870   int pc = space.device().safe_pc();
20811871   logerror("%08x m68307_internal_base_r %08x, (%04x)\n", pc, offset*2,mem_mask);
r23920r23921
20921882   return 0x0000;
20931883}
20941884
2095static WRITE16_HANDLER( m68307_internal_base_w )
1885WRITE16_MEMBER( m68000_base_device::m68307_internal_base_w )
20961886{
2097   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
1887   m68000_base_device *m68k = this;
20981888
20991889   int pc = space.device().safe_pc();
21001890   logerror("%08x m68307_internal_base_w %08x, %04x (%04x)\n", pc, offset*2,data,mem_mask);
r23920r23921
21201910         base = (m68k->m68307_base & 0x0fff) << 12;
21211911         //mask = (m68k->m68307_base & 0xe000) >> 13;
21221912         //if ( m68k->m68307_base & 0x1000 ) mask |= 7;
2123         m68k->internal->install_legacy_readwrite_handler(base + 0x000, base + 0x04f, FUNC(m68307_internal_sim_r),    FUNC(m68307_internal_sim_w));
2124         m68k->internal->install_legacy_readwrite_handler(base + 0x100, base + 0x11f, FUNC(m68307_internal_serial_r), FUNC(m68307_internal_serial_w), 0xffff);
2125         m68k->internal->install_legacy_readwrite_handler(base + 0x120, base + 0x13f, FUNC(m68307_internal_timer_r),  FUNC(m68307_internal_timer_w));
2126         m68k->internal->install_legacy_readwrite_handler(base + 0x140, base + 0x149, FUNC(m68307_internal_mbus_r),   FUNC(m68307_internal_mbus_w), 0xffff);
1913         m68k->internal->install_readwrite_handler(base + 0x000, base + 0x04f, read16_delegate(FUNC(m68000_base_device::m68307_internal_sim_r),this),    write16_delegate(FUNC(m68000_base_device::m68307_internal_sim_w),this));
1914         m68k->internal->install_readwrite_handler(base + 0x100, base + 0x11f, read8_delegate(FUNC(m68000_base_device::m68307_internal_serial_r),this), write8_delegate(FUNC(m68000_base_device::m68307_internal_serial_w),this), 0xffff);
1915         m68k->internal->install_readwrite_handler(base + 0x120, base + 0x13f, read16_delegate(FUNC(m68000_base_device::m68307_internal_timer_r),this),  write16_delegate(FUNC(m68000_base_device::m68307_internal_timer_w),this));
1916         m68k->internal->install_readwrite_handler(base + 0x140, base + 0x149, read8_delegate(FUNC(m68000_base_device::m68307_internal_mbus_r),this),   write8_delegate(FUNC(m68000_base_device::m68307_internal_mbus_w),this), 0xffff);
21271917
1918
21281919         break;
21291920
21301921      case 0x4:
r23920r23921
21411932   }
21421933}
21431934
2144static ADDRESS_MAP_START( m68307_internal_map, AS_PROGRAM, 16, legacy_cpu_device )
2145   AM_RANGE(0x000000f0, 0x000000ff) AM_READWRITE_LEGACY(m68307_internal_base_r, m68307_internal_base_w)
1935static ADDRESS_MAP_START( m68307_internal_map, AS_PROGRAM, 16, m68000_base_device )
1936   AM_RANGE(0x000000f0, 0x000000ff) AM_READWRITE(m68307_internal_base_r, m68307_internal_base_w)
21461937ADDRESS_MAP_END
21471938
2148CPU_GET_INFO( m68307 )
1939/* 68340 specifics - MOVE */
1940
1941READ32_MEMBER( m68000_base_device::m68340_internal_base_r )
21491942{
2150   switch (state)
1943   m68000_base_device *m68k = this;
1944   int pc = space.device().safe_pc();
1945   logerror("%08x m68340_internal_base_r %08x, (%08x)\n", pc, offset*4,mem_mask);
1946   return m68k->m68340_base;
1947}
1948
1949WRITE32_MEMBER( m68000_base_device::m68340_internal_base_w )
1950{
1951   m68000_base_device *m68k = this;
1952
1953   int pc = space.device().safe_pc();
1954   logerror("%08x m68340_internal_base_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
1955
1956   // other conditions?
1957   if (m68k->dfc==0x7)
21511958   {
2152      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:    info->i = 24;                           break;
1959      // unmap old modules
1960      if (m68k->m68340_base&1)
1961      {
1962         int base = m68k->m68340_base & 0xfffff000;
21531963
2154      /* --- the following bits of info are returned as pointers to data or functions --- */
2155      case CPUINFO_FCT_INIT:                      info->init = CPU_INIT_NAME(m68307);             break;
1964         m68k->internal->unmap_readwrite(base + 0x000, base + 0x05f);
1965         m68k->internal->unmap_readwrite(base + 0x600, base + 0x67f);
1966         m68k->internal->unmap_readwrite(base + 0x700, base + 0x723);
1967         m68k->internal->unmap_readwrite(base + 0x780, base + 0x7bf);
21561968
2157      /* --- the following bits of info are returned as NULL-terminated strings --- */
2158      case CPUINFO_STR_NAME:                      strcpy(info->s, "68307");                       break;
1969      }
21591970
2160      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + AS_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(m68307_internal_map); break;
1971      COMBINE_DATA(&m68k->m68340_base);
1972      logerror("%08x m68340_internal_base_w %08x, %08x (%08x) (m68340_base write)\n", pc, offset*4,data,mem_mask);
21611973
1974      // map new modules
1975      if (m68k->m68340_base&1)
1976      {
1977         int base = m68k->m68340_base & 0xfffff000;
21621978
2163      default:                                    CPU_GET_INFO_CALL(m68k);                        break;
1979         m68k->internal->install_readwrite_handler(base + 0x000, base + 0x03f, read16_delegate(FUNC(m68000_base_device::m68340_internal_sim_r),this),     write16_delegate(FUNC(m68000_base_device::m68340_internal_sim_w),this),0xffffffff);
1980         m68k->internal->install_readwrite_handler(base + 0x010, base + 0x01f, read8_delegate(FUNC(m68000_base_device::m68340_internal_sim_ports_r),this),write8_delegate(FUNC(m68000_base_device::m68340_internal_sim_ports_w),this),0xffffffff);
1981         m68k->internal->install_readwrite_handler(base + 0x040, base + 0x05f, read32_delegate(FUNC(m68000_base_device::m68340_internal_sim_cs_r),this),  write32_delegate(FUNC(m68000_base_device::m68340_internal_sim_cs_w),this));
1982         m68k->internal->install_readwrite_handler(base + 0x600, base + 0x67f, read32_delegate(FUNC(m68000_base_device::m68340_internal_timer_r),this),   write32_delegate(FUNC(m68000_base_device::m68340_internal_timer_w),this));
1983         m68k->internal->install_readwrite_handler(base + 0x700, base + 0x723, read32_delegate(FUNC(m68000_base_device::m68340_internal_serial_r),this),  write32_delegate(FUNC(m68000_base_device::m68340_internal_serial_w),this));
1984         m68k->internal->install_readwrite_handler(base + 0x780, base + 0x7bf, read32_delegate(FUNC(m68000_base_device::m68340_internal_dma_r),this),     write32_delegate(FUNC(m68000_base_device::m68340_internal_dma_w),this));
1985
1986      }
1987
21641988   }
1989   else
1990   {
1991      logerror("%08x m68340_internal_base_w %08x, %04x (%04x) (should fall through?)\n", pc, offset*4,data,mem_mask);
1992   }
1993
1994
1995
21651996}
21661997
21671998
2168/****************************************************************************
2169 * M68008 section
2170 ****************************************************************************/
1999static ADDRESS_MAP_START( m68340_internal_map, AS_PROGRAM, 32, m68000_base_device )
2000   AM_RANGE(0x0003ff00, 0x0003ff03) AM_READWRITE( m68340_internal_base_r, m68340_internal_base_w)
2001ADDRESS_MAP_END
21712002
2172static CPU_INIT( m68008 )
2003
2004/****************
2005 CPU Inits
2006****************/
2007
2008
2009void m68000_base_device::init_cpu_m68000(void)
21732010{
2174   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2011   init_cpu_common();
21752012
2176   CPU_INIT_CALL(m68k);
2013   cpu_type         = CPU_TYPE_000;
2014//   dasm_type        = M68K_CPU_TYPE_68000;
2015   
2016   init16(*program);
2017   sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2018   jump_table       = m68ki_instruction_jump_table[0];
2019   cyc_instruction  = m68ki_cycles[0];
2020   cyc_exception    = m68ki_exception_cycle_table[0];
2021   cyc_bcc_notake_b = -2;
2022   cyc_bcc_notake_w = 2;
2023   cyc_dbcc_f_noexp = -2;
2024   cyc_dbcc_f_exp   = 2;
2025   cyc_scc_r_true   = 2;
2026   cyc_movem_w      = 2;
2027   cyc_movem_l      = 3;
2028   cyc_shift        = 1;
2029   cyc_reset        = 132;
2030   has_pmmu         = 0;
2031   has_hmmu         = 0;
2032   has_fpu          = 0;
21772033
2178   m68k->cpu_type         = CPU_TYPE_008;
2179   m68k->dasm_type        = M68K_CPU_TYPE_68008;
2180// hack alert: we use placement new to ensure we are properly initialized
2181// because we live in the device state which is allocated as bytes
2182// remove me when we have a real C++ device
2183   new(&m68k->memory) m68k_memory_interface;
2184   m68k->memory.init8(*m68k->program);
2185   m68k->sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2186   m68k->jump_table       = m68ki_instruction_jump_table[0];
2187   m68k->cyc_instruction  = m68ki_cycles[0];
2188   m68k->cyc_exception    = m68ki_exception_cycle_table[0];
2189   m68k->cyc_bcc_notake_b = -2;
2190   m68k->cyc_bcc_notake_w = 2;
2191   m68k->cyc_dbcc_f_noexp = -2;
2192   m68k->cyc_dbcc_f_exp   = 2;
2193   m68k->cyc_scc_r_true   = 2;
2194   m68k->cyc_movem_w      = 2;
2195   m68k->cyc_movem_l      = 3;
2196   m68k->cyc_shift        = 1;
2197   m68k->cyc_reset        = 132;
2198   m68k->has_pmmu         = 0;
2199   m68k->has_fpu          = 0;
2034   define_state();
22002035
2201   define_state(device);
22022036}
22032037
2204CPU_GET_INFO( m68008 )
2038
2039void m68000_base_device::init_cpu_m68008(void)
22052040{
2206   switch (state)
2207   {
2208      /* --- the following bits of info are returned as 64-bit signed integers --- */
2209      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:    info->i = 8;                            break;
2210      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:    info->i = 20;                           break;
22112041
2212      /* --- the following bits of info are returned as pointers to data or functions --- */
2213      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68008);                     break;
2042   init_cpu_common();
22142043
2215      /* --- the following bits of info are returned as NULL-terminated strings --- */
2216      case CPUINFO_STR_NAME:                          strcpy(info->s, "68008");               break;
2044   cpu_type         = CPU_TYPE_008;
2045//   dasm_type        = M68K_CPU_TYPE_68008;
2046   
2047   init8(*program);
2048   sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2049   jump_table       = m68ki_instruction_jump_table[0];
2050   cyc_instruction  = m68ki_cycles[0];
2051   cyc_exception    = m68ki_exception_cycle_table[0];
2052   cyc_bcc_notake_b = -2;
2053   cyc_bcc_notake_w = 2;
2054   cyc_dbcc_f_noexp = -2;
2055   cyc_dbcc_f_exp   = 2;
2056   cyc_scc_r_true   = 2;
2057   cyc_movem_w      = 2;
2058   cyc_movem_l      = 3;
2059   cyc_shift        = 1;
2060   cyc_reset        = 132;
2061   has_pmmu         = 0;
2062   has_fpu          = 0;
22172063
2218      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2219   }
2064   define_state();
2065
22202066}
22212067
2222CPU_GET_INFO( m68008plcc )
2068
2069void m68000_base_device::init_cpu_m68010(void)
22232070{
2224   switch (state)
2225   {
2226      /* --- the following bits of info are returned as 64-bit signed integers --- */
2227      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:    info->i = 8;                            break;
2228      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:    info->i = 22;                           break;
22292071
2230      /* --- the following bits of info are returned as pointers to data or functions --- */
2231      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68008);                     break;
2072   init_cpu_common();
2073   cpu_type         = CPU_TYPE_010;
2074//   dasm_type        = M68K_CPU_TYPE_68010;
2075   
2076   init16(*program);
2077   sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2078   jump_table       = m68ki_instruction_jump_table[1];
2079   cyc_instruction  = m68ki_cycles[1];
2080   cyc_exception    = m68ki_exception_cycle_table[1];
2081   cyc_bcc_notake_b = -4;
2082   cyc_bcc_notake_w = 0;
2083   cyc_dbcc_f_noexp = 0;
2084   cyc_dbcc_f_exp   = 6;
2085   cyc_scc_r_true   = 0;
2086   cyc_movem_w      = 2;
2087   cyc_movem_l      = 3;
2088   cyc_shift        = 1;
2089   cyc_reset        = 130;
2090   has_pmmu         = 0;
2091   has_fpu          = 0;
22322092
2233      /* --- the following bits of info are returned as NULL-terminated strings --- */
2234      case CPUINFO_STR_NAME:                          strcpy(info->s, "68008");               break;
2093   define_state();
2094}
22352095
2236      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2237   }
2096
2097void m68000_base_device::init_cpu_m68020(void)
2098{
2099   init_cpu_common();
2100   cpu_type         = CPU_TYPE_020;
2101//   dasm_type        = M68K_CPU_TYPE_68020;
2102   
2103   init32(*program);
2104   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2105   jump_table       = m68ki_instruction_jump_table[2];
2106   cyc_instruction  = m68ki_cycles[2];
2107   cyc_exception    = m68ki_exception_cycle_table[2];
2108   cyc_bcc_notake_b = -2;
2109   cyc_bcc_notake_w = 0;
2110   cyc_dbcc_f_noexp = 0;
2111   cyc_dbcc_f_exp   = 4;
2112   cyc_scc_r_true   = 0;
2113   cyc_movem_w      = 2;
2114   cyc_movem_l      = 2;
2115   cyc_shift        = 0;
2116   cyc_reset        = 518;
2117
2118   define_state();
22382119}
22392120
22402121
2241/****************************************************************************
2242 * M68010 section
2243 ****************************************************************************/
2122void m68000_base_device::init_cpu_m68020pmmu(void)
2123{
2124   init_cpu_m68020();
22442125
2245static CPU_INIT( m68010 )
2126   has_pmmu         = 1;
2127   has_fpu          = 1;
2128
2129   
2130   init32mmu(*program);
2131}
2132
2133
2134
2135void m68000_base_device::init_cpu_m68020hmmu(void)
22462136{
2247   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2137   init_cpu_m68020();
22482138
2249   CPU_INIT_CALL(m68k);
2139   has_hmmu = 1;
2140   has_fpu  = 1;
22502141
2251   m68k->cpu_type         = CPU_TYPE_010;
2252   m68k->dasm_type        = M68K_CPU_TYPE_68010;
2253// hack alert: we use placement new to ensure we are properly initialized
2254// because we live in the device state which is allocated as bytes
2255// remove me when we have a real C++ device
2256   new(&m68k->memory) m68k_memory_interface;
2257   m68k->memory.init16(*m68k->program);
2258   m68k->sr_mask          = 0xa71f; /* T1 -- S  -- -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2259   m68k->jump_table       = m68ki_instruction_jump_table[1];
2260   m68k->cyc_instruction  = m68ki_cycles[1];
2261   m68k->cyc_exception    = m68ki_exception_cycle_table[1];
2262   m68k->cyc_bcc_notake_b = -4;
2263   m68k->cyc_bcc_notake_w = 0;
2264   m68k->cyc_dbcc_f_noexp = 0;
2265   m68k->cyc_dbcc_f_exp   = 6;
2266   m68k->cyc_scc_r_true   = 0;
2267   m68k->cyc_movem_w      = 2;
2268   m68k->cyc_movem_l      = 3;
2269   m68k->cyc_shift        = 1;
2270   m68k->cyc_reset        = 130;
2271   m68k->has_pmmu         = 0;
2272   m68k->has_fpu          = 0;
2273
2274   define_state(device);
2142   
2143   init32hmmu(*program);
22752144}
22762145
2277CPU_GET_INFO( m68010 )
2146void m68000_base_device::init_cpu_m68ec020(void)
22782147{
2279   switch (state)
2280   {
2281      /* --- the following bits of info are returned as pointers to data or functions --- */
2282      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68010);                     break;
2148   init_cpu_common();
22832149
2284      /* --- the following bits of info are returned as NULL-terminated strings --- */
2285      case CPUINFO_STR_NAME:                          strcpy(info->s, "68010");               break;
2150   cpu_type         = CPU_TYPE_EC020;
2151//   dasm_type        = M68K_CPU_TYPE_68EC020;
22862152
2287      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2288   }
2153   
2154   init32(*program);
2155   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2156   jump_table       = m68ki_instruction_jump_table[2];
2157   cyc_instruction  = m68ki_cycles[2];
2158   cyc_exception    = m68ki_exception_cycle_table[2];
2159   cyc_bcc_notake_b = -2;
2160   cyc_bcc_notake_w = 0;
2161   cyc_dbcc_f_noexp = 0;
2162   cyc_dbcc_f_exp   = 4;
2163   cyc_scc_r_true   = 0;
2164   cyc_movem_w      = 2;
2165   cyc_movem_l      = 2;
2166   cyc_shift        = 0;
2167   cyc_reset        = 518;
2168   has_pmmu         = 0;
2169   has_fpu          = 0;
2170
2171   define_state();
22892172}
22902173
22912174
2292/****************************************************************************
2293 * M68020 section
2294 ****************************************************************************/
2295
2296static CPU_INIT( m68020 )
2175void m68000_base_device::init_cpu_m68030(void)
22972176{
2298   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2177   init_cpu_common();
22992178
2300   CPU_INIT_CALL(m68k);
2179   cpu_type         = CPU_TYPE_030;
2180//   dasm_type        = M68K_CPU_TYPE_68030;
23012181
2302   m68k->cpu_type         = CPU_TYPE_020;
2303   m68k->dasm_type        = M68K_CPU_TYPE_68020;
2304// hack alert: we use placement new to ensure we are properly initialized
2305// because we live in the device state which is allocated as bytes
2306// remove me when we have a real C++ device
2307   new(&m68k->memory) m68k_memory_interface;
2308   m68k->memory.init32(*m68k->program);
2309   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2310   m68k->jump_table       = m68ki_instruction_jump_table[2];
2311   m68k->cyc_instruction  = m68ki_cycles[2];
2312   m68k->cyc_exception    = m68ki_exception_cycle_table[2];
2313   m68k->cyc_bcc_notake_b = -2;
2314   m68k->cyc_bcc_notake_w = 0;
2315   m68k->cyc_dbcc_f_noexp = 0;
2316   m68k->cyc_dbcc_f_exp   = 4;
2317   m68k->cyc_scc_r_true   = 0;
2318   m68k->cyc_movem_w      = 2;
2319   m68k->cyc_movem_l      = 2;
2320   m68k->cyc_shift        = 0;
2321   m68k->cyc_reset        = 518;
2182   
2183   init32mmu(*program);
2184   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2185   jump_table       = m68ki_instruction_jump_table[3];
2186   cyc_instruction  = m68ki_cycles[3];
2187   cyc_exception    = m68ki_exception_cycle_table[3];
2188   cyc_bcc_notake_b = -2;
2189   cyc_bcc_notake_w = 0;
2190   cyc_dbcc_f_noexp = 0;
2191   cyc_dbcc_f_exp   = 4;
2192   cyc_scc_r_true   = 0;
2193   cyc_movem_w      = 2;
2194   cyc_movem_l      = 2;
2195   cyc_shift        = 0;
2196   cyc_reset        = 518;
2197   has_pmmu         = 1;
2198   has_fpu          = 1;
23222199
2323   define_state(device);
2200   define_state();
23242201}
23252202
2326CPU_GET_INFO( m68020 )
2327{
2328   switch (state)
2329   {
2330      /* --- the following bits of info are returned as 64-bit signed integers --- */
2331      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 20;                           break;
2332      case CPUINFO_INT_MIN_CYCLES:                    info->i = 2;                            break;
2333      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
23342203
2335      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 32;                           break;
2336      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
23372204
2338      /* --- the following bits of info are returned as pointers to data or functions --- */
2339      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68020);                     break;
2205void m68000_base_device::init_cpu_m68ec030(void)
2206{
2207   init_cpu_common();
2208   
2209   cpu_type         = CPU_TYPE_EC030;
2210//   dasm_type        = M68K_CPU_TYPE_68EC030;
23402211
2341      /* --- the following bits of info are returned as NULL-terminated strings --- */
2342      case CPUINFO_STR_NAME:                          strcpy(info->s, "68020");               break;
2212   
2213   init32(*program);
2214   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2215   jump_table       = m68ki_instruction_jump_table[3];
2216   cyc_instruction  = m68ki_cycles[3];
2217   cyc_exception    = m68ki_exception_cycle_table[3];
2218   cyc_bcc_notake_b = -2;
2219   cyc_bcc_notake_w = 0;
2220   cyc_dbcc_f_noexp = 0;
2221   cyc_dbcc_f_exp   = 4;
2222   cyc_scc_r_true   = 0;
2223   cyc_movem_w      = 2;
2224   cyc_movem_l      = 2;
2225   cyc_shift        = 0;
2226   cyc_reset        = 518;
2227   has_pmmu         = 0;     /* EC030 lacks the PMMU and is effectively a die-shrink 68020 */
2228   has_fpu          = 1;
23432229
2344      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2345   }
2230   define_state();
23462231}
23472232
2348// 68020 with 68851 PMMU
2349static CPU_INIT( m68020pmmu )
2233
2234
2235void m68000_base_device::init_cpu_m68040(void)
23502236{
2351   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2237   init_cpu_common();
23522238
2353   CPU_INIT_CALL(m68020);
2239   cpu_type         = CPU_TYPE_040;
2240//   dasm_type        = M68K_CPU_TYPE_68040;
23542241
2355   m68k->has_pmmu         = 1;
2356   m68k->has_fpu          = 1;
2242   
2243   init32mmu(*program);
2244   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2245   jump_table       = m68ki_instruction_jump_table[4];
2246   cyc_instruction  = m68ki_cycles[4];
2247   cyc_exception    = m68ki_exception_cycle_table[4];
2248   cyc_bcc_notake_b = -2;
2249   cyc_bcc_notake_w = 0;
2250   cyc_dbcc_f_noexp = 0;
2251   cyc_dbcc_f_exp   = 4;
2252   cyc_scc_r_true   = 0;
2253   cyc_movem_w      = 2;
2254   cyc_movem_l      = 2;
2255   cyc_shift        = 0;
2256   cyc_reset        = 518;
2257   has_pmmu         = 1;
2258   has_fpu          = 1;
23572259
2358// hack alert: we use placement new to ensure we are properly initialized
2359// because we live in the device state which is allocated as bytes
2360// remove me when we have a real C++ device
2361   new(&m68k->memory) m68k_memory_interface;
2362   m68k->memory.init32mmu(*m68k->program);
2260   define_state();
23632261}
23642262
2365CPU_GET_INFO( m68020pmmu )
2263
2264void m68000_base_device::init_cpu_m68ec040(void)
23662265{
2367   switch (state)
2368   {
2369      /* --- the following bits of info are returned as pointers to data or functions --- */
2370      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68020pmmu);                     break;
2266   init_cpu_common();
23712267
2372      /* --- the following bits of info are returned as NULL-terminated strings --- */
2373      case CPUINFO_STR_NAME:                          strcpy(info->s, "68020, 68851");                break;
2268   cpu_type         = CPU_TYPE_EC040;
2269//   dasm_type        = M68K_CPU_TYPE_68EC040;
23742270
2375      default:                                        CPU_GET_INFO_CALL(m68020);              break;
2376   }
2271   
2272   init32(*program);
2273   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2274   jump_table       = m68ki_instruction_jump_table[4];
2275   cyc_instruction  = m68ki_cycles[4];
2276   cyc_exception    = m68ki_exception_cycle_table[4];
2277   cyc_bcc_notake_b = -2;
2278   cyc_bcc_notake_w = 0;
2279   cyc_dbcc_f_noexp = 0;
2280   cyc_dbcc_f_exp   = 4;
2281   cyc_scc_r_true   = 0;
2282   cyc_movem_w      = 2;
2283   cyc_movem_l      = 2;
2284   cyc_shift        = 0;
2285   cyc_reset        = 518;
2286   has_pmmu         = 0;
2287   has_fpu          = 0;
2288
2289   define_state();
23772290}
23782291
2379// 68020 with Apple HMMU & 68881 FPU
2380static CPU_INIT( m68020hmmu )
2292
2293void m68000_base_device::init_cpu_m68lc040(void)
23812294{
2382   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2295   init_cpu_common();
23832296
2384   CPU_INIT_CALL(m68020);
2297   cpu_type         = CPU_TYPE_LC040;
2298//   dasm_type        = M68K_CPU_TYPE_68LC040;
23852299
2386   m68k->has_hmmu = 1;
2387   m68k->has_fpu  = 1;
2388// hack alert: we use placement new to ensure we are properly initialized
2389// because we live in the device state which is allocated as bytes
2390// remove me when we have a real C++ device
2391   new(&m68k->memory) m68k_memory_interface;
2392   m68k->memory.init32hmmu(*m68k->program);
2300   
2301   init32mmu(*program);
2302   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2303   jump_table       = m68ki_instruction_jump_table[4];
2304   cyc_instruction  = m68ki_cycles[4];
2305   cyc_exception    = m68ki_exception_cycle_table[4];
2306   cyc_bcc_notake_b = -2;
2307   cyc_bcc_notake_w = 0;
2308   cyc_dbcc_f_noexp = 0;
2309   cyc_dbcc_f_exp   = 4;
2310   cyc_scc_r_true   = 0;
2311   cyc_movem_w      = 2;
2312   cyc_movem_l      = 2;
2313   cyc_shift        = 0;
2314   cyc_reset        = 518;
2315   has_pmmu         = 1;
2316   has_fpu          = 0;
2317
2318   define_state();
23932319}
23942320
2395CPU_GET_INFO( m68020hmmu )
2321
2322void m68000_base_device::init_cpu_scc68070(void)
23962323{
2397   switch (state)
2398   {
2399      /* --- the following bits of info are returned as pointers to data or functions --- */
2400      case CPUINFO_FCT_INIT:      info->init = CPU_INIT_NAME(m68020hmmu);         break;
2401      case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(m68khmmu);     break;
2324   init_cpu_m68010();
2325   cpu_type         = CPU_TYPE_SCC070;
2326}
24022327
2403      /* --- the following bits of info are returned as NULL-terminated strings --- */
2404      case CPUINFO_STR_NAME:      strcpy(info->s, "68020, Apple HMMU");           break;
24052328
2406      default:            CPU_GET_INFO_CALL(m68020);              break;
2407   }
2329void m68000_base_device::init_cpu_m68340(void)
2330{
2331   init_cpu_common();
2332
2333   cpu_type         = CPU_TYPE_68340;
2334//   dasm_type        = M68K_CPU_TYPE_68340;
2335
2336   
2337   init32(*program);
2338   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2339   jump_table       = m68ki_instruction_jump_table[5];
2340   cyc_instruction  = m68ki_cycles[5];
2341   cyc_exception    = m68ki_exception_cycle_table[5];
2342   cyc_bcc_notake_b = -2;
2343   cyc_bcc_notake_w = 0;
2344   cyc_dbcc_f_noexp = 0;
2345   cyc_dbcc_f_exp   = 4;
2346   cyc_scc_r_true   = 0;
2347   cyc_movem_w      = 2;
2348   cyc_movem_l      = 2;
2349   cyc_shift        = 0;
2350   cyc_reset        = 518;
2351
2352   m68340SIM    = new m68340_sim();
2353   m68340DMA    = new m68340_dma();
2354   m68340SERIAL = new m68340_serial();
2355   m68340TIMER  = new m68340_timer();
2356
2357   m68340SIM->reset();
2358   m68340DMA->reset();
2359   m68340SERIAL->reset();
2360   m68340TIMER->reset();
2361
2362   m68340_base = 0x00000000;
2363
2364   internal = &this->space(AS_PROGRAM);
2365
2366   define_state();
24082367}
24092368
2410/****************************************************************************
2411 * M680EC20 section
2412 ****************************************************************************/
24132369
2414static CPU_INIT( m68ec020 )
2370
2371void m68000_base_device::init_cpu_coldfire(void)
24152372{
2416   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2373   init_cpu_common();
2374   
2375   cpu_type         = CPU_TYPE_COLDFIRE;
2376//   dasm_type        = M68K_CPU_TYPE_COLDFIRE;
24172377
2418   CPU_INIT_CALL(m68k);
2378   
2379   init32(*program);
2380   sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2381   jump_table       = m68ki_instruction_jump_table[6];
2382   cyc_instruction  = m68ki_cycles[6];
2383   cyc_exception    = m68ki_exception_cycle_table[6];
2384   cyc_bcc_notake_b = -2;
2385   cyc_bcc_notake_w = 0;
2386   cyc_dbcc_f_noexp = 0;
2387   cyc_dbcc_f_exp   = 4;
2388   cyc_scc_r_true   = 0;
2389   cyc_movem_w      = 2;
2390   cyc_movem_l      = 2;
2391   cyc_shift        = 0;
2392   cyc_reset        = 518;
24192393
2420   m68k->cpu_type         = CPU_TYPE_EC020;
2421   m68k->dasm_type        = M68K_CPU_TYPE_68EC020;
2422// hack alert: we use placement new to ensure we are properly initialized
2423// because we live in the device state which is allocated as bytes
2424// remove me when we have a real C++ device
2425   new(&m68k->memory) m68k_memory_interface;
2426   m68k->memory.init32(*m68k->program);
2427   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2428   m68k->jump_table       = m68ki_instruction_jump_table[2];
2429   m68k->cyc_instruction  = m68ki_cycles[2];
2430   m68k->cyc_exception    = m68ki_exception_cycle_table[2];
2431   m68k->cyc_bcc_notake_b = -2;
2432   m68k->cyc_bcc_notake_w = 0;
2433   m68k->cyc_dbcc_f_noexp = 0;
2434   m68k->cyc_dbcc_f_exp   = 4;
2435   m68k->cyc_scc_r_true   = 0;
2436   m68k->cyc_movem_w      = 2;
2437   m68k->cyc_movem_l      = 2;
2438   m68k->cyc_shift        = 0;
2439   m68k->cyc_reset        = 518;
2440   m68k->has_pmmu         = 0;
2441   m68k->has_fpu          = 0;
2394   define_state();
2395}
24422396
2443   define_state(device);
2397
2398
2399
2400
2401
2402/*
2403      case CPUINFO_INT_CLOCK_MULTIPLIER:              info->i = 1;                            break;
2404      case CPUINFO_INT_CLOCK_DIVIDER:                 info->i = 1;                            break;
2405
2406      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 24;                           break;
2407      case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM:        info->i = 0;                            break;
2408
2409      case CPUINFO_INT_INPUT_STATE + 0:               info->i = 0;  // there is no level 0
2410      case CPUINFO_INT_INPUT_STATE + 1:               info->i = (m68k->virq_state >> 1) & 1;  break;
2411      case CPUINFO_INT_INPUT_STATE + 2:               info->i = (m68k->virq_state >> 2) & 1;  break;
2412      case CPUINFO_INT_INPUT_STATE + 3:               info->i = (m68k->virq_state >> 3) & 1;  break;
2413      case CPUINFO_INT_INPUT_STATE + 4:               info->i = (m68k->virq_state >> 4) & 1;  break;
2414      case CPUINFO_INT_INPUT_STATE + 5:               info->i = (m68k->virq_state >> 5) & 1;  break;
2415      case CPUINFO_INT_INPUT_STATE + 6:               info->i = (m68k->virq_state >> 6) & 1;  break;
2416      case CPUINFO_INT_INPUT_STATE + 7:               info->i = (m68k->virq_state >> 7) & 1;  break;
2417
2418      case CPUINFO_STR_FAMILY:                    strcpy(info->s, "Motorola 68K");        break;
2419      case CPUINFO_STR_VERSION:                   strcpy(info->s, "4.95");                break;
2420      case CPUINFO_STR_SOURCE_FILE:                       strcpy(info->s, __FILE__);              break;
2421      case CPUINFO_STR_CREDITS:                   strcpy(info->s, "Copyright Karl Stenerud. All rights reserved. (2.1 fixes HJB, FPU+MMU by RB+HO+OG)"); break;
2422
2423
2424*/
2425
2426
2427
2428
2429
2430CPU_DISASSEMBLE( dasm_m68000 )
2431{
2432   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68000);
24442433}
24452434
2446CPU_GET_INFO( m68ec020 )
2435CPU_DISASSEMBLE( dasm_m68008 )
24472436{
2448   switch (state)
2449   {
2450      /* --- the following bits of info are returned as 64-bit signed integers --- */
2451      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 24;                           break;
2437   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68008);
2438}
24522439
2453      /* --- the following bits of info are returned as pointers to data or functions --- */
2454      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68ec020);                   break;
2440CPU_DISASSEMBLE( dasm_m68010 )
2441{
2442   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68010);
2443}
24552444
2456      /* --- the following bits of info are returned as NULL-terminated strings --- */
2457      case CPUINFO_STR_NAME:                          strcpy(info->s, "68EC020");             break;
2445CPU_DISASSEMBLE( dasm_m68020 )
2446{
2447   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68020);
2448}
24582449
2459      default:                                        CPU_GET_INFO_CALL(m68020);              break;
2460   }
2450CPU_DISASSEMBLE( dasm_m68030 )
2451{
2452   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68030);
24612453}
24622454
2463/****************************************************************************
2464 * M68030 section
2465 ****************************************************************************/
2455CPU_DISASSEMBLE( dasm_m68ec030 )
2456{
2457   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68EC030);
2458}
24662459
2467static CPU_INIT( m68030 )
2460CPU_DISASSEMBLE( dasm_m68040 )
24682461{
2469   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2462   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68040);
2463}
24702464
2471   CPU_INIT_CALL(m68k);
2465CPU_DISASSEMBLE( dasm_m68ec040 )
2466{
2467   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68EC040);
2468}
24722469
2473   m68k->cpu_type         = CPU_TYPE_030;
2474   m68k->dasm_type        = M68K_CPU_TYPE_68030;
2475// hack alert: we use placement new to ensure we are properly initialized
2476// because we live in the device state which is allocated as bytes
2477// remove me when we have a real C++ device
2478   new(&m68k->memory) m68k_memory_interface;
2479   m68k->memory.init32mmu(*m68k->program);
2480   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2481   m68k->jump_table       = m68ki_instruction_jump_table[3];
2482   m68k->cyc_instruction  = m68ki_cycles[3];
2483   m68k->cyc_exception    = m68ki_exception_cycle_table[3];
2484   m68k->cyc_bcc_notake_b = -2;
2485   m68k->cyc_bcc_notake_w = 0;
2486   m68k->cyc_dbcc_f_noexp = 0;
2487   m68k->cyc_dbcc_f_exp   = 4;
2488   m68k->cyc_scc_r_true   = 0;
2489   m68k->cyc_movem_w      = 2;
2490   m68k->cyc_movem_l      = 2;
2491   m68k->cyc_shift        = 0;
2492   m68k->cyc_reset        = 518;
2493   m68k->has_pmmu         = 1;
2494   m68k->has_fpu          = 1;
2470CPU_DISASSEMBLE( dasm_m68lc040 )
2471{
2472   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68LC040);
2473}
24952474
2496   define_state(device);
2475CPU_DISASSEMBLE( dasm_m68340 )
2476{
2477   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68340);
24972478}
24982479
2499CPU_GET_INFO( m68030 )
2480CPU_DISASSEMBLE( dasm_coldfire )
25002481{
2501   switch (state)
2482   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_COLDFIRE);
2483}
2484
2485offs_t m68000_base_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); };
2486offs_t m68000_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); };
2487offs_t m68301_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); };
2488offs_t m68307_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); };
2489offs_t m68008_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, buffer, pc, oprom, opram, options); };
2490offs_t m68008plcc_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, buffer, pc, oprom, opram, options); };
2491offs_t m68010_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68010)(this, buffer, pc, oprom, opram, options); };
2492offs_t m68ec020_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); };
2493offs_t m68020_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); };
2494offs_t m68020pmmu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); };
2495offs_t m68020hmmu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); };
2496offs_t m68ec030_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec030)(this, buffer, pc, oprom, opram, options); };
2497offs_t m68030_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68030)(this, buffer, pc, oprom, opram, options); };
2498offs_t m68ec040_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec040)(this, buffer, pc, oprom, opram, options); };
2499offs_t m68lc040_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68lc040)(this, buffer, pc, oprom, opram, options); };
2500offs_t m68040_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68040)(this, buffer, pc, oprom, opram, options); };
2501offs_t scc68070_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); };
2502offs_t m68340_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_m68340)(this, buffer, pc, oprom, opram, options); };
2503offs_t mcf5206e_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { return CPU_DISASSEMBLE_NAME(dasm_coldfire)(this, buffer, pc, oprom, opram, options); };
2504
2505
2506/* Service an interrupt request and start exception processing */
2507void m68000_base_device::m68ki_exception_interrupt(m68000_base_device *m68k, UINT32 int_level)
2508{
2509   UINT32 vector;
2510   UINT32 sr;
2511   UINT32 new_pc;
2512
2513   if(CPU_TYPE_IS_000(cpu_type))
25022514   {
2503      /* --- the following bits of info are returned as 64-bit signed integers --- */
2504      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 20;                           break;
2505      case CPUINFO_INT_MIN_CYCLES:                    info->i = 2;                            break;
2506      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
2515      instr_mode = INSTRUCTION_NO;
2516   }
25072517
2508      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 32;                           break;
2509      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
2518   /* Turn off the stopped state */
2519   stopped &= ~STOP_LEVEL_STOP;
25102520
2511      /* --- the following bits of info are returned as pointers to data or functions --- */
2512      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68030);                     break;
2521   /* If we are halted, don't do anything */
2522   if(stopped)
2523      return;
25132524
2514      /* --- the following bits of info are returned as NULL-terminated strings --- */
2515      case CPUINFO_STR_NAME:                          strcpy(info->s, "68030");               break;
2525   /* Acknowledge the interrupt */
2526   vector = (*int_ack_callback)(this, int_level);
2527   
2528   /* Get the interrupt vector */
2529   if(vector == M68K_INT_ACK_AUTOVECTOR)
2530      /* Use the autovectors.  This is the most commonly used implementation */
2531      vector = EXCEPTION_INTERRUPT_AUTOVECTOR+int_level;
2532   else if(vector == M68K_INT_ACK_SPURIOUS)
2533      /* Called if no devices respond to the interrupt acknowledge */
2534      vector = EXCEPTION_SPURIOUS_INTERRUPT;
2535   else if(vector > 255)
2536      return;
25162537
2517      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2538   /* Start exception processing */
2539   sr = m68ki_init_exception(m68k);
2540
2541   /* Set the interrupt mask to the level of the one being serviced */
2542   int_mask = int_level<<8;
2543
2544   /* Get the new PC */
2545   new_pc = m68ki_read_data_32(this, (vector<<2) + vbr);
2546
2547   /* If vector is uninitialized, call the uninitialized interrupt vector */
2548   if(new_pc == 0)
2549      new_pc = m68ki_read_data_32(this, (EXCEPTION_UNINITIALIZED_INTERRUPT<<2) + vbr);
2550
2551   /* Generate a stack frame */
2552   m68ki_stack_frame_0000(this, REG_PC(m68k), sr, vector);
2553   if(m_flag && CPU_TYPE_IS_EC020_PLUS(cpu_type))
2554   {
2555      /* Create throwaway frame */
2556      m68ki_set_sm_flag(this, s_flag);  /* clear M */
2557      sr |= 0x2000; /* Same as SR in master stack frame except S is forced high */
2558      m68ki_stack_frame_0001(this, REG_PC(m68k), sr, vector);
25182559   }
2560
2561   m68ki_jump(this, new_pc);
2562
2563   /* Defer cycle counting until later */
2564   remaining_cycles -= cyc_exception[vector];
25192565}
25202566
25212567
2522/****************************************************************************
2523 * M680EC30 section
2524 ****************************************************************************/
2568const device_type M68K = &device_creator<m68000_base_device>;
25252569
2526static CPU_INIT( m68ec030 )
2570//-------------------------------------------------
2571//  h6280_device - constructor
2572//-------------------------------------------------
2573
2574m68000_base_device::m68000_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2575   : cpu_device(mconfig, M68K, "M68K", tag, owner, clock, "m68k", __FILE__),
2576   m_program_config("program", ENDIANNESS_BIG, 16, 24)
25272577{
2528   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2578   clear_all();
2579}
25292580
2530   CPU_INIT_CALL(m68k);
25312581
2532   m68k->cpu_type         = CPU_TYPE_EC030;
2533   m68k->dasm_type        = M68K_CPU_TYPE_68EC030;
2534// hack alert: we use placement new to ensure we are properly initialized
2535// because we live in the device state which is allocated as bytes
2536// remove me when we have a real C++ device
2537   new(&m68k->memory) m68k_memory_interface;
2538   m68k->memory.init32(*m68k->program);
2539   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2540   m68k->jump_table       = m68ki_instruction_jump_table[3];
2541   m68k->cyc_instruction  = m68ki_cycles[3];
2542   m68k->cyc_exception    = m68ki_exception_cycle_table[3];
2543   m68k->cyc_bcc_notake_b = -2;
2544   m68k->cyc_bcc_notake_w = 0;
2545   m68k->cyc_dbcc_f_noexp = 0;
2546   m68k->cyc_dbcc_f_exp   = 4;
2547   m68k->cyc_scc_r_true   = 0;
2548   m68k->cyc_movem_w      = 2;
2549   m68k->cyc_movem_l      = 2;
2550   m68k->cyc_shift        = 0;
2551   m68k->cyc_reset        = 518;
2552   m68k->has_pmmu         = 0;     /* EC030 lacks the PMMU and is effectively a die-shrink 68020 */
2553   m68k->has_fpu          = 1;
25542582
2555   define_state(device);
2583
2584m68000_base_device::m68000_base_device(const machine_config &mconfig, const char *name, const char *tag, device_t *owner, UINT32 clock,
2585                              const device_type type, UINT32 prg_data_width, UINT32 prg_address_bits, address_map_constructor internal_map, const char *shortname, const char *source)
2586   : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source),
2587      m_program_config("program", ENDIANNESS_BIG, prg_data_width, prg_address_bits, 0, internal_map)
2588{
2589   clear_all();
25562590}
25572591
2558CPU_GET_INFO( m68ec030 )
2592
2593m68000_base_device::m68000_base_device(const machine_config &mconfig, const char *name, const char *tag, device_t *owner, UINT32 clock,
2594                              const device_type type, UINT32 prg_data_width, UINT32 prg_address_bits, const char *shortname, const char *source)
2595   : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source),
2596      m_program_config("program", ENDIANNESS_BIG, prg_data_width, prg_address_bits)
25592597{
2560   switch (state)
2561   {
2562      /* --- the following bits of info are returned as pointers to data or functions --- */
2563      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68ec030);                   break;
2598   clear_all();
2599}
25642600
2565      /* --- the following bits of info are returned as NULL-terminated strings --- */
2566      case CPUINFO_STR_NAME:                          strcpy(info->s, "68EC030");             break;
2601void m68000_base_device::clear_all()
2602{
25672603
2568      default:                                        CPU_GET_INFO_CALL(m68030);              break;
2569   }
2604   cpu_type= 0;
2605//   dasm_type= 0;
2606   for (int i=0;i<16;i++)
2607      dar[i]= 0;
2608   ppc= 0;
2609   pc= 0;
2610   for (int i=0;i<7;i++)
2611      sp[i]= 0;
2612   vbr= 0;
2613   sfc= 0;
2614   dfc= 0;
2615   cacr= 0;
2616   caar= 0;
2617   ir= 0;
2618//   for (int i=0;i<8;i++)
2619//      fpr[i]= 0;
2620   fpiar= 0;
2621   fpsr= 0;
2622   fpcr= 0;
2623   t1_flag= 0;
2624   t0_flag= 0;
2625   s_flag= 0;
2626   m_flag= 0;
2627   x_flag= 0;
2628   n_flag= 0;
2629   not_z_flag= 0;
2630   v_flag= 0;
2631   c_flag= 0;
2632   int_mask= 0;
2633   int_level= 0;
2634   stopped= 0;
2635   pref_addr= 0;
2636   pref_data= 0;
2637   sr_mask= 0;
2638   instr_mode= 0;
2639   run_mode= 0;
2640   has_pmmu= 0;
2641   has_hmmu= 0;
2642   pmmu_enabled= 0;
2643   hmmu_enabled= 0;
2644   has_fpu= 0;
2645   fpu_just_reset= 0;
2646
2647   cyc_bcc_notake_b = 0;
2648   cyc_bcc_notake_w = 0;
2649   cyc_dbcc_f_noexp = 0;
2650   cyc_dbcc_f_exp = 0;
2651   cyc_scc_r_true = 0;
2652   cyc_movem_w = 0;
2653   cyc_movem_l = 0;
2654   cyc_shift = 0;
2655   cyc_reset = 0;
2656
2657   initial_cycles = 0;
2658   remaining_cycles = 0;
2659   reset_cycles = 0;
2660   tracing = 0;
2661
2662//   aerr_trap = 0;
2663
2664   aerr_address = 0;
2665   aerr_write_mode = 0;
2666   aerr_fc = 0;
2667
2668   virq_state = 0;
2669   nmi_pending = 0;
2670
2671   cyc_instruction = 0;
2672   cyc_exception = 0;
2673
2674   int_ack_callback = 0;
2675   bkpt_ack_callback = 0;
2676   reset_instr_callback = 0;
2677   cmpild_instr_callback = 0;
2678   rte_instr_callback = 0;
2679   tas_instr_callback = 0;
2680
2681   program = 0;
2682
2683   opcode_xor = 0;
2684//   readimm16 = 0;
2685//   read8 = 0;
2686//   read16 = 0;
2687//   read32 = 0;
2688//   write8 = 0;
2689//   write16 = 0;
2690//   write32 = 0;
2691
2692   m_space = 0;
2693   m_direct = 0;
2694
2695
2696   encrypted_start = 0;
2697   encrypted_end = 0;
2698
2699   iotemp = 0;
2700
2701   save_sr = 0;
2702   save_stopped = 0;
2703   save_halted = 0;
2704
2705
2706   mmu_crp_aptr = mmu_crp_limit = 0;
2707   mmu_srp_aptr = mmu_srp_limit = 0;
2708   mmu_urp_aptr = 0;
2709   mmu_tc = 0;
2710   mmu_sr = 0;
2711   mmu_sr_040 = 0;
2712
2713   for (int i=0; i<MMU_ATC_ENTRIES;i++)
2714      mmu_atc_tag[i] = mmu_atc_data[i] = 0;
2715   
2716   mmu_atc_rr = 0;
2717   mmu_tt0 = mmu_tt1 = 0;
2718   mmu_itt0 = mmu_itt1 = mmu_dtt0 = mmu_dtt1 = 0;
2719   mmu_acr0= mmu_acr1 = mmu_acr2 = mmu_acr3 = 0;
2720   mmu_tmp_sr = 0;
2721   mmu_tmp_fc = 0;
2722   mmu_tmp_rw = 0;
2723   mmu_tmp_buserror_address = 0;
2724   mmu_tmp_buserror_occurred = 0;
2725   mmu_tmp_buserror_fc = 0;
2726   mmu_tmp_buserror_rw = 0;
2727
2728   for (int i=0;i<M68K_IC_SIZE;i++)
2729      ic_address[i] = 0;
2730   
2731   for (int i=0;i<M68K_IC_SIZE;i++)
2732      ic_data[i] = 0;
2733
2734   m68307SIM = 0;
2735   m68307MBUS = 0;
2736   m68307SERIAL = 0;
2737   m68307TIMER = 0;
2738   m68307_base = 0;
2739   m68307_scrhigh = 0;
2740   m68307_scrlow = 0;
2741   m68307_currentcs = 0;
2742   m68340SIM = 0;
2743   m68340DMA = 0;
2744   m68340SERIAL = 0;
2745   m68340TIMER = 0;
2746   m68340_base = 0;
2747   internal = 0;
2748   m_m68307_porta_r = 0;
2749   m_m68307_porta_w = 0;
2750   m_m68307_portb_r = 0;
2751   m_m68307_portb_w = 0;
2752   instruction_hook = 0;
25702753}
25712754
2572/****************************************************************************
2573 * M68040 section
2574 ****************************************************************************/
25752755
2576static CPU_INIT( m68040 )
2756void m68000_base_device::execute_run()
25772757{
2578   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2758   cpu_execute();
2759}
25792760
2580   CPU_INIT_CALL(m68k);
2761void m68000_base_device::device_start()
2762{
25812763
2582   m68k->cpu_type         = CPU_TYPE_040;
2583   m68k->dasm_type        = M68K_CPU_TYPE_68040;
2584// hack alert: we use placement new to ensure we are properly initialized
2585// because we live in the device state which is allocated as bytes
2586// remove me when we have a real C++ device
2587   new(&m68k->memory) m68k_memory_interface;
2588   m68k->memory.init32mmu(*m68k->program);
2589   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2590   m68k->jump_table       = m68ki_instruction_jump_table[4];
2591   m68k->cyc_instruction  = m68ki_cycles[4];
2592   m68k->cyc_exception    = m68ki_exception_cycle_table[4];
2593   m68k->cyc_bcc_notake_b = -2;
2594   m68k->cyc_bcc_notake_w = 0;
2595   m68k->cyc_dbcc_f_noexp = 0;
2596   m68k->cyc_dbcc_f_exp   = 4;
2597   m68k->cyc_scc_r_true   = 0;
2598   m68k->cyc_movem_w      = 2;
2599   m68k->cyc_movem_l      = 2;
2600   m68k->cyc_shift        = 0;
2601   m68k->cyc_reset        = 518;
2602   m68k->has_pmmu         = 1;
2603   m68k->has_fpu          = 1;
2764}
26042765
2605   define_state(device);
2766void m68000_base_device::device_reset()
2767{
2768   reset_cpu();
26062769}
26072770
2608CPU_GET_INFO( m68040 )
2771void m68000_base_device::device_stop()
26092772{
2610   switch (state)
2611   {
2612      /* --- the following bits of info are returned as 64-bit signed integers --- */
2613      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 20;                           break;
2614      case CPUINFO_INT_MIN_CYCLES:                    info->i = 2;                            break;
2615      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
26162773
2617      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 32;                           break;
2618      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
2774}
26192775
2620      /* --- the following bits of info are returned as pointers to data or functions --- */
2621      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68040);                     break;
26222776
2623      /* --- the following bits of info are returned as NULL-terminated strings --- */
2624      case CPUINFO_STR_NAME:                          strcpy(info->s, "68040");               break;
26252777
2626      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2778
2779void m68000_base_device::execute_set_input(int inputnum, int state)
2780{
2781   switch (inputnum)
2782   {
2783      /* --- the following bits of info are set as 64-bit signed integers --- */
2784      case M68K_IRQ_NONE:
2785      case M68K_IRQ_1:
2786      case M68K_IRQ_2:
2787      case M68K_IRQ_3:
2788      case M68K_IRQ_4:
2789      case M68K_IRQ_5:
2790      case M68K_IRQ_6:
2791      case M68K_IRQ_7:
2792      case INPUT_LINE_NMI:
2793         set_irq_line(this, inputnum, state);
2794         break;
2795
2796      case M68K_LINE_BUSERROR:
2797         if (state == ASSERT_LINE)
2798         {
2799            m68k_cause_bus_error(this);
2800         }
2801         break;
26272802   }
26282803}
26292804
2630/****************************************************************************
2631 * M68EC040 section
2632 ****************************************************************************/
26332805
2634static CPU_INIT( m68ec040 )
2806const address_space_config *m68000_base_device::memory_space_config(address_spacenum spacenum) const
26352807{
2636   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2808   if (spacenum == AS_PROGRAM)
2809   {
2810      return &m_program_config;
2811   }
26372812
2638   CPU_INIT_CALL(m68k);
2813   return NULL;
2814}
26392815
2640   m68k->cpu_type         = CPU_TYPE_EC040;
2641   m68k->dasm_type        = M68K_CPU_TYPE_68EC040;
2642// hack alert: we use placement new to ensure we are properly initialized
2643// because we live in the device state which is allocated as bytes
2644// remove me when we have a real C++ device
2645   new(&m68k->memory) m68k_memory_interface;
2646   m68k->memory.init32(*m68k->program);
2647   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2648   m68k->jump_table       = m68ki_instruction_jump_table[4];
2649   m68k->cyc_instruction  = m68ki_cycles[4];
2650   m68k->cyc_exception    = m68ki_exception_cycle_table[4];
2651   m68k->cyc_bcc_notake_b = -2;
2652   m68k->cyc_bcc_notake_w = 0;
2653   m68k->cyc_dbcc_f_noexp = 0;
2654   m68k->cyc_dbcc_f_exp   = 4;
2655   m68k->cyc_scc_r_true   = 0;
2656   m68k->cyc_movem_w      = 2;
2657   m68k->cyc_movem_l      = 2;
2658   m68k->cyc_shift        = 0;
2659   m68k->cyc_reset        = 518;
2660   m68k->has_pmmu         = 0;
2661   m68k->has_fpu          = 0;
26622816
2663   define_state(device);
2817
2818const device_type M68000 = &device_creator<m68000_device>;
2819const device_type M68301 = &device_creator<m68301_device>;
2820const device_type M68307 = &device_creator<m68307_device>;
2821const device_type M68008 = &device_creator<m68008_device>;
2822const device_type M68008PLCC = &device_creator<m68008plcc_device>;
2823const device_type M68010 = &device_creator<m68010_device>;
2824const device_type M68EC020 = &device_creator<m68ec020_device>;
2825const device_type M68020 = &device_creator<m68020_device>;
2826const device_type M68020PMMU = &device_creator<m68020pmmu_device>;
2827const device_type M68020HMMU = &device_creator<m68020hmmu_device>;
2828const device_type M68EC030 = &device_creator<m68ec030_device>;
2829const device_type M68030 = &device_creator<m68030_device>;
2830const device_type M68EC040 = &device_creator<m68ec040_device>;
2831const device_type M68LC040 = &device_creator<m68lc040_device>;
2832const device_type M68040 = &device_creator<m68040_device>;
2833const device_type SCC68070 = &device_creator<scc68070_device>;
2834const device_type M68340 = &device_creator<m68340_device>;
2835const device_type MCF5206E = &device_creator<mcf5206e_device>;
2836
2837m68000_device::m68000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2838   : m68000_base_device(mconfig, "M68000", tag, owner, clock, M68000, 16,24, "m68000", __FILE__)
2839{
2840
26642841}
26652842
2666CPU_GET_INFO( m68ec040 )
2843void m68000_device::device_start()
26672844{
2668   switch (state)
2669   {
2670      /* --- the following bits of info are returned as pointers to data or functions --- */
2671      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68ec040);                   break;
2845   init_cpu_m68000();
2846}
26722847
2673      /* --- the following bits of info are returned as NULL-terminated strings --- */
2674      case CPUINFO_STR_NAME:                          strcpy(info->s, "68EC040");             break;
26752848
2676      default:                                        CPU_GET_INFO_CALL(m68040);              break;
2677   }
2849
2850
2851m68301_device::m68301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2852   : m68000_base_device(mconfig, "M68301", tag, owner, clock, M68301, 16,24, "m68301", __FILE__)
2853{
2854
26782855}
26792856
2680/****************************************************************************
2681 * M68LC040 section
2682 ****************************************************************************/
26832857
2684static CPU_INIT( m68lc040 )
2858void m68301_device::device_start()
26852859{
2686   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2860   init_cpu_m68000();
2861}
26872862
2688   CPU_INIT_CALL(m68k);
26892863
2690   m68k->cpu_type         = CPU_TYPE_LC040;
2691   m68k->dasm_type        = M68K_CPU_TYPE_68LC040;
2692// hack alert: we use placement new to ensure we are properly initialized
2693// because we live in the device state which is allocated as bytes
2694// remove me when we have a real C++ device
2695   new(&m68k->memory) m68k_memory_interface;
2696   m68k->memory.init32mmu(*m68k->program);
2697   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2698   m68k->jump_table       = m68ki_instruction_jump_table[4];
2699   m68k->cyc_instruction  = m68ki_cycles[4];
2700   m68k->cyc_exception    = m68ki_exception_cycle_table[4];
2701   m68k->cyc_bcc_notake_b = -2;
2702   m68k->cyc_bcc_notake_w = 0;
2703   m68k->cyc_dbcc_f_noexp = 0;
2704   m68k->cyc_dbcc_f_exp   = 4;
2705   m68k->cyc_scc_r_true   = 0;
2706   m68k->cyc_movem_w      = 2;
2707   m68k->cyc_movem_l      = 2;
2708   m68k->cyc_shift        = 0;
2709   m68k->cyc_reset        = 518;
2710   m68k->has_pmmu         = 1;
2711   m68k->has_fpu          = 0;
27122864
2713   define_state(device);
2865
2866m68307_device::m68307_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2867   : m68000_base_device(mconfig, "M68307", tag, owner, clock, M68307, 16,24, ADDRESS_MAP_NAME(m68307_internal_map), "m68307", __FILE__)
2868{
2869
27142870}
27152871
2716CPU_GET_INFO( m68lc040 )
2872void m68307_device::device_start()
27172873{
2718   switch (state)
2719   {
2720      /* --- the following bits of info are returned as pointers to data or functions --- */
2721      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68lc040);                   break;
2874   init_cpu_m68307();
2875}
27222876
2723      /* --- the following bits of info are returned as NULL-terminated strings --- */
2724      case CPUINFO_STR_NAME:                          strcpy(info->s, "68LC040");             break;
2877/* m68008_device */
27252878
2726      default:                                        CPU_GET_INFO_CALL(m68040);              break;
2727   }
2879m68008_device::m68008_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2880   : m68000_base_device(mconfig, "M68008", tag, owner, clock, M68008, 8,20, "m68008", __FILE__)
2881{
2882
27282883}
27292884
2730/****************************************************************************
2731 * SCC-68070 section
2732 ****************************************************************************/
2885void m68008_device::device_start()
2886{
2887   init_cpu_m68008();
2888}
27332889
2734static CPU_INIT( scc68070 )
2890
2891m68008plcc_device::m68008plcc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2892   : m68000_base_device(mconfig, "M68008PLCC", tag, owner, clock, M68008, 8,22, "m68008plcc", __FILE__)
27352893{
2736   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
27372894
2738   CPU_INIT_CALL(m68010);
2895}
27392896
2740   m68k->cpu_type         = CPU_TYPE_SCC070;
2897void m68008plcc_device::device_start()
2898{
2899   init_cpu_m68008();
27412900}
27422901
2743CPU_GET_INFO( scc68070 )
2902
2903
2904m68010_device::m68010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2905   : m68000_base_device(mconfig, "M68010", tag, owner, clock, M68010, 16,24, "m68010", __FILE__)
27442906{
2745   switch (state)
2746   {
2747      /* --- the following bits of info are returned as 64-bit signed integers --- */
2748      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
27492907
2750      /* --- the following bits of info are returned as pointers to data or functions --- */
2751      case CPUINFO_FCT_INIT:                          info->init = CPU_INIT_NAME(scc68070);   break;
2908}
27522909
2753      /* --- the following bits of info are returned as NULL-terminated strings --- */
2754      case CPUINFO_STR_NAME:                          strcpy(info->s, "SCC68070");            break;
2910void m68010_device::device_start()
2911{
2912   init_cpu_m68010();
2913}
27552914
2756      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2757   }
2915
2916
2917m68020_device::m68020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2918   : m68000_base_device(mconfig, "M68020", tag, owner, clock, M68020, 32,32, "m68020", __FILE__)
2919{
2920
27582921}
27592922
2760/****************************************************************************
2761 * Freescale M68340 section
2762 ****************************************************************************/
2923void m68020_device::device_start()
2924{
2925   init_cpu_m68020();
2926}
27632927
2764static READ32_HANDLER( m68340_internal_base_r )
2928// 68020 with 68851 PMMU
2929m68020pmmu_device::m68020pmmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2930   : m68000_base_device(mconfig, "M68020PMMU", tag, owner, clock, M68020PMMU, 32,32, "m68020pmmu", __FILE__)
27652931{
2766   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
2767   int pc = space.device().safe_pc();
2768   logerror("%08x m68340_internal_base_r %08x, (%08x)\n", pc, offset*4,mem_mask);
2769   return m68k->m68340_base;
2932
27702933}
27712934
2772static WRITE32_HANDLER( m68340_internal_base_w )
2935void m68020pmmu_device::device_start()
27732936{
2774   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
2937   init_cpu_m68020pmmu();
2938}
27752939
2776   int pc = space.device().safe_pc();
2777   logerror("%08x m68340_internal_base_w %08x, %08x (%08x)\n", pc, offset*4,data,mem_mask);
2778
2779   // other conditions?
2780   if (m68k->dfc==0x7)
2940bool m68020hmmu_device::memory_translate(address_spacenum space, int intention, offs_t &address)
2941{
2942   /* only applies to the program address space and only does something if the MMU's enabled */
2943   if (this)
27812944   {
2782      // unmap old modules
2783      if (m68k->m68340_base&1)
2945      if ((space == AS_PROGRAM) && (hmmu_enabled))
27842946      {
2785         int base = m68k->m68340_base & 0xfffff000;
2947         address = hmmu_translate_addr(this, address);
2948      }
2949   }
2950   return TRUE;
2951}
27862952
2787         m68k->internal->unmap_readwrite(base + 0x000, base + 0x05f);
2788         m68k->internal->unmap_readwrite(base + 0x600, base + 0x67f);
2789         m68k->internal->unmap_readwrite(base + 0x700, base + 0x723);
2790         m68k->internal->unmap_readwrite(base + 0x780, base + 0x7bf);
27912953
2792      }
2954// 68020 with Apple HMMU & 68881 FPU
2955//       case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(m68khmmu);     break;
2956m68020hmmu_device::m68020hmmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2957   : m68000_base_device(mconfig, "M68020HMMU", tag, owner, clock, M68020HMMU, 32,32, "m68020hmmu", __FILE__)
2958{
27932959
2794      COMBINE_DATA(&m68k->m68340_base);
2795      logerror("%08x m68340_internal_base_w %08x, %08x (%08x) (m68340_base write)\n", pc, offset*4,data,mem_mask);
2960}
27962961
2797      // map new modules
2798      if (m68k->m68340_base&1)
2799      {
2800         int base = m68k->m68340_base & 0xfffff000;
2962void m68020hmmu_device::device_start()
2963{
2964   init_cpu_m68020hmmu();
2965}
28012966
2802         m68k->internal->install_legacy_readwrite_handler(base + 0x000, base + 0x03f, FUNC(m68340_internal_sim_r),    FUNC(m68340_internal_sim_w),0xffffffff);
2803         m68k->internal->install_legacy_readwrite_handler(base + 0x010, base + 0x01f, FUNC(m68340_internal_sim_ports_r), FUNC(m68340_internal_sim_ports_w),0xffffffff);
2804         m68k->internal->install_legacy_readwrite_handler(base + 0x040, base + 0x05f, FUNC(m68340_internal_sim_cs_r), FUNC(m68340_internal_sim_cs_w));
2805         m68k->internal->install_legacy_readwrite_handler(base + 0x600, base + 0x67f, FUNC(m68340_internal_timer_r),  FUNC(m68340_internal_timer_w));
2806         m68k->internal->install_legacy_readwrite_handler(base + 0x700, base + 0x723, FUNC(m68340_internal_serial_r), FUNC(m68340_internal_serial_w));
2807         m68k->internal->install_legacy_readwrite_handler(base + 0x780, base + 0x7bf, FUNC(m68340_internal_dma_r),    FUNC(m68340_internal_dma_w));
28082967
2809      }
2968m68ec020_device::m68ec020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2969   : m68000_base_device(mconfig, "M68EC020", tag, owner, clock, M68EC020, 32,24, "m68ec020", __FILE__)
2970{
28102971
2811   }
2812   else
2813   {
2814      logerror("%08x m68340_internal_base_w %08x, %04x (%04x) (should fall through?)\n", pc, offset*4,data,mem_mask);
2815   }
2972}
28162973
2974void m68ec020_device::device_start()
2975{
2976   init_cpu_m68ec020();
2977}
28172978
2979m68030_device::m68030_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2980   : m68000_base_device(mconfig, "M68030", tag, owner, clock, M68030, 32,32, "m68030", __FILE__)
2981{
28182982
28192983}
28202984
2985void m68030_device::device_start()
2986{
2987   init_cpu_m68030();
2988}
28212989
2822static ADDRESS_MAP_START( m68340_internal_map, AS_PROGRAM, 32, legacy_cpu_device )
2823   AM_RANGE(0x0003ff00, 0x0003ff03) AM_READWRITE_LEGACY( m68340_internal_base_r, m68340_internal_base_w)
2824ADDRESS_MAP_END
2990m68ec030_device::m68ec030_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2991   : m68000_base_device(mconfig, "M68EC030", tag, owner, clock, M68EC030, 32,32, "m68ec030", __FILE__)
2992{
28252993
2826static CPU_INIT( m68340 )
2994}
2995
2996void m68ec030_device::device_start()
28272997{
2828   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
2998   init_cpu_m68ec030();
2999}
28293000
2830   CPU_INIT_CALL(m68k);
3001m68040_device::m68040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3002   : m68000_base_device(mconfig, "M68040", tag, owner, clock, M68040, 32,32, "m68040", __FILE__)
3003{
28313004
2832   m68k->cpu_type         = CPU_TYPE_68340;
2833   m68k->dasm_type        = M68K_CPU_TYPE_68340;
2834// hack alert: we use placement new to ensure we are properly initialized
2835// because we live in the device state which is allocated as bytes
2836// remove me when we have a real C++ device
2837   new(&m68k->memory) m68k_memory_interface;
2838   m68k->memory.init32(*m68k->program);
2839   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2840   m68k->jump_table       = m68ki_instruction_jump_table[5];
2841   m68k->cyc_instruction  = m68ki_cycles[5];
2842   m68k->cyc_exception    = m68ki_exception_cycle_table[5];
2843   m68k->cyc_bcc_notake_b = -2;
2844   m68k->cyc_bcc_notake_w = 0;
2845   m68k->cyc_dbcc_f_noexp = 0;
2846   m68k->cyc_dbcc_f_exp   = 4;
2847   m68k->cyc_scc_r_true   = 0;
2848   m68k->cyc_movem_w      = 2;
2849   m68k->cyc_movem_l      = 2;
2850   m68k->cyc_shift        = 0;
2851   m68k->cyc_reset        = 518;
3005}
28523006
2853   m68k->m68340SIM    = new m68340_sim();
2854   m68k->m68340DMA    = new m68340_dma();
2855   m68k->m68340SERIAL = new m68340_serial();
2856   m68k->m68340TIMER  = new m68340_timer();
28573007
2858   m68k->m68340SIM->reset();
2859   m68k->m68340DMA->reset();
2860   m68k->m68340SERIAL->reset();
2861   m68k->m68340TIMER->reset();
3008void m68040_device::device_start()
3009{
3010   init_cpu_m68040();
3011}
28623012
2863   m68k->m68340_base = 0x00000000;
28643013
2865   m68k->internal = &device->space(AS_PROGRAM);
28663014
2867   define_state(device);
3015m68ec040_device::m68ec040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3016   : m68000_base_device(mconfig, "M68EC040", tag, owner, clock, M68EC040, 32,32, "m68ec040", __FILE__)
3017{
3018
28683019}
28693020
2870CPU_GET_INFO( m68340 )
3021void m68ec040_device::device_start()
28713022{
2872   switch (state)
2873   {
2874      /* --- the following bits of info are returned as 64-bit signed integers --- */
2875      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 20;                           break;
2876      case CPUINFO_INT_MIN_CYCLES:                    info->i = 2;                            break;
2877      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
3023   init_cpu_m68ec040();
3024}
28783025
2879      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 32;                           break;
2880      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
28813026
2882      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + AS_PROGRAM: info->internal_map32 = ADDRESS_MAP_NAME(m68340_internal_map); break;
28833027
2884      /* --- the following bits of info are returned as pointers to data or functions --- */
2885      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(m68340);                     break;
3028m68lc040_device::m68lc040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3029   : m68000_base_device(mconfig, "M68LC040", tag, owner, clock, M68LC040, 32,32, "m68lc040", __FILE__)
3030{
28863031
2887      /* --- the following bits of info are returned as NULL-terminated strings --- */
2888      case CPUINFO_STR_NAME:                          strcpy(info->s, "Freescale 68340");             break;
3032}
28893033
2890      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2891   }
3034void m68lc040_device::device_start()
3035{
3036   init_cpu_m68lc040();
28923037}
28933038
2894/*
2895  ColdFire
28963039
2897*/
3040scc68070_device::scc68070_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3041   : m68000_base_device(mconfig, "SCC68070", tag, owner, clock, SCC68070, 16,32, "scc68070", __FILE__)
3042{
28983043
2899static CPU_INIT( coldfire )
3044}
3045
3046void scc68070_device::device_start()
29003047{
2901   m68ki_cpu_core *m68k = m68k_get_safe_token(device);
3048   init_cpu_scc68070();
3049}
29023050
2903   CPU_INIT_CALL(m68k);
29043051
2905   m68k->cpu_type         = CPU_TYPE_COLDFIRE;
2906   m68k->dasm_type        = M68K_CPU_TYPE_COLDFIRE;
2907// hack alert: we use placement new to ensure we are properly initialized
2908// because we live in the device state which is allocated as bytes
2909// remove me when we have a real C++ device
2910   new(&m68k->memory) m68k_memory_interface;
2911   m68k->memory.init32(*m68k->program);
2912   m68k->sr_mask          = 0xf71f; /* T1 T0 S  M  -- I2 I1 I0 -- -- -- X  N  Z  V  C  */
2913   m68k->jump_table       = m68ki_instruction_jump_table[6];
2914   m68k->cyc_instruction  = m68ki_cycles[6];
2915   m68k->cyc_exception    = m68ki_exception_cycle_table[6];
2916   m68k->cyc_bcc_notake_b = -2;
2917   m68k->cyc_bcc_notake_w = 0;
2918   m68k->cyc_dbcc_f_noexp = 0;
2919   m68k->cyc_dbcc_f_exp   = 4;
2920   m68k->cyc_scc_r_true   = 0;
2921   m68k->cyc_movem_w      = 2;
2922   m68k->cyc_movem_l      = 2;
2923   m68k->cyc_shift        = 0;
2924   m68k->cyc_reset        = 518;
3052m68340_device::m68340_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3053   : m68000_base_device(mconfig, "M68340", tag, owner, clock, M68340, 32,32, ADDRESS_MAP_NAME(m68340_internal_map), "m68340", __FILE__)
3054{
29253055
2926   define_state(device);
29273056}
29283057
2929CPU_GET_INFO( mcf5206e )
3058void m68340_device::device_start()
29303059{
2931   switch (state)
2932   {
2933      /* --- the following bits of info are returned as 64-bit signed integers --- */
2934      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 20;                           break;
2935      case CPUINFO_INT_MIN_CYCLES:                    info->i = 2;                            break;
2936      case CPUINFO_INT_MAX_CYCLES:                    info->i = 158;                          break;
3060   init_cpu_m68340();
3061}
29373062
2938      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:            info->i = 32;                           break;
2939      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM:        info->i = 32;                           break;
29403063
2941      /* --- the following bits of info are returned as pointers to data or functions --- */
2942      case CPUINFO_FCT_INIT:          info->init = CPU_INIT_NAME(coldfire);                       break;
29433064
2944      /* --- the following bits of info are returned as NULL-terminated strings --- */
2945      case CPUINFO_STR_NAME:                          strcpy(info->s, "MCF5206E");            break;
3065mcf5206e_device::mcf5206e_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3066   : m68000_base_device(mconfig, "MCF5206E", tag, owner, clock, MCF5206E, 32,32, "mcf5206e", __FILE__)
3067{
29463068
2947      default:                                        CPU_GET_INFO_CALL(m68k);                break;
2948   }
29493069}
29503070
2951DEFINE_LEGACY_CPU_DEVICE(M68000, m68000);
2952DEFINE_LEGACY_CPU_DEVICE(M68301, m68301);
2953DEFINE_LEGACY_CPU_DEVICE(M68307, m68307);
2954DEFINE_LEGACY_CPU_DEVICE(M68008, m68008);
2955DEFINE_LEGACY_CPU_DEVICE(M68008PLCC, m68008plcc);
2956DEFINE_LEGACY_CPU_DEVICE(M68010, m68010);
2957DEFINE_LEGACY_CPU_DEVICE(M68EC020, m68ec020);
2958DEFINE_LEGACY_CPU_DEVICE(M68020, m68020);
2959DEFINE_LEGACY_CPU_DEVICE(M68020PMMU, m68020pmmu);
2960DEFINE_LEGACY_CPU_DEVICE(M68020HMMU, m68020hmmu);
2961DEFINE_LEGACY_CPU_DEVICE(M68EC030, m68ec030);
2962DEFINE_LEGACY_CPU_DEVICE(M68030, m68030);
2963DEFINE_LEGACY_CPU_DEVICE(M68EC040, m68ec040);
2964DEFINE_LEGACY_CPU_DEVICE(M68LC040, m68lc040);
2965DEFINE_LEGACY_CPU_DEVICE(M68040, m68040);
2966DEFINE_LEGACY_CPU_DEVICE(SCC68070, scc68070);
2967DEFINE_LEGACY_CPU_DEVICE(M68340, m68340);
2968DEFINE_LEGACY_CPU_DEVICE(MCF5206E, mcf5206e);
3071void mcf5206e_device::device_start()
3072{
3073   init_cpu_coldfire();
3074}
No newline at end of file
trunk/src/emu/cpu/m68000/68340ser.c
r23920r23921
44#include "m68kcpu.h"
55
66
7READ32_HANDLER( m68340_internal_serial_r )
7READ32_HANDLER( m68000_base_device::m68340_internal_serial_r )
88{
9   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
9   m68000_base_device *m68k = this;
1010   m68340_serial* serial = m68k->m68340SERIAL;
1111   assert(serial != NULL);
1212
r23920r23921
1919   return 0x00000000;
2020}
2121
22WRITE32_HANDLER( m68340_internal_serial_w )
22WRITE32_MEMBER( m68000_base_device::m68340_internal_serial_w )
2323{
24   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
24   m68000_base_device *m68k = this;
2525   m68340_serial* serial = m68k->m68340SERIAL;
2626   assert(serial != NULL);
2727
trunk/src/emu/cpu/m68000/m68000.h
r23920r23921
1414#include "68340ser.h"
1515#include "68340tmu.h"
1616
17#include "../../../lib/softfloat/milieu.h"
18#include "../../../lib/softfloat/softfloat.h"
19#include <setjmp.h>
20
21
22/* MMU constants */
23#define MMU_ATC_ENTRIES (22)    // 68851 has 64, 030 has 22
24
25/* instruction cache constants */
26#define M68K_IC_SIZE 128
27
28
29
30
31/* Address error */
32/* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */
33#ifdef _BSD_SETJMP_H
34#define m68ki_set_address_error_trap(m68k) \
35   if(sigsetjmp(m68k->aerr_trap, 0) != 0) \
36   { \
37      m68ki_exception_address_error(m68k); \
38      if(m68k->stopped) \
39      { \
40         if (m68k->remaining_cycles > 0) \
41            m68k->remaining_cycles = 0; \
42         return; \
43      } \
44   }
45
46#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
47   if((ADDR)&1) \
48   { \
49      m68k->aerr_address = ADDR; \
50      m68k->aerr_write_mode = WRITE_MODE; \
51      m68k->aerr_fc = FC; \
52      siglongjmp(m68k->aerr_trap, 1); \
53   }
54#else
55#define m68ki_set_address_error_trap(m68k) \
56   SETJMP_GNUC_PROTECT(); \
57   if(setjmp(m68k->aerr_trap) != 0) \
58   { \
59      m68ki_exception_address_error(m68k); \
60      if(m68k->stopped) \
61      { \
62         if (m68k->remaining_cycles > 0) \
63            m68k->remaining_cycles = 0; \
64         return; \
65      } \
66   }
67
68#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
69   if((ADDR)&1) \
70   { \
71      m68k->aerr_address = ADDR; \
72      m68k->aerr_write_mode = WRITE_MODE; \
73      m68k->aerr_fc = FC; \
74      longjmp(m68k->aerr_trap, 1); \
75   }
76#endif
77
78
79
1780/* There are 7 levels of interrupt to the 68K.
1881 * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI).
1982 */
r23920r23921
108171
109172
110173
111DECLARE_LEGACY_CPU_DEVICE(M68000, m68000);
112DECLARE_LEGACY_CPU_DEVICE(M68301, m68301);
113DECLARE_LEGACY_CPU_DEVICE(M68307, m68307);
114DECLARE_LEGACY_CPU_DEVICE(M68008, m68008);
115DECLARE_LEGACY_CPU_DEVICE(M68008PLCC, m68008plcc);
116DECLARE_LEGACY_CPU_DEVICE(M68010, m68010);
117DECLARE_LEGACY_CPU_DEVICE(M68EC020, m68ec020);
118DECLARE_LEGACY_CPU_DEVICE(M68020, m68020);
119DECLARE_LEGACY_CPU_DEVICE(M68020PMMU, m68020pmmu);
120DECLARE_LEGACY_CPU_DEVICE(M68020HMMU, m68020hmmu);
121DECLARE_LEGACY_CPU_DEVICE(M68EC030, m68ec030);
122DECLARE_LEGACY_CPU_DEVICE(M68030, m68030);
123DECLARE_LEGACY_CPU_DEVICE(M68EC040, m68ec040);
124DECLARE_LEGACY_CPU_DEVICE(M68LC040, m68lc040);
125DECLARE_LEGACY_CPU_DEVICE(M68040, m68040);
126DECLARE_LEGACY_CPU_DEVICE(SCC68070, scc68070);
127DECLARE_LEGACY_CPU_DEVICE(M68340, m68340);
128DECLARE_LEGACY_CPU_DEVICE(MCF5206E, mcf5206e);
129174
175unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
130176
131void m68k_set_encrypted_opcode_range(device_t *device, offs_t start, offs_t end);
132177
133void m68k_set_hmmu_enable(device_t *device, int enable);
134178
135unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
179typedef int (*instruction_hook_t)(m68000_base_device *device, offs_t curpc);
136180
137void m68k_set_reset_callback(device_t *device, m68k_reset_func callback);
138void m68k_set_cmpild_callback(device_t *device, m68k_cmpild_func callback);
139void m68k_set_rte_callback(device_t *device, m68k_rte_func callback);
140void m68k_set_tas_callback(device_t *device, m68k_tas_func callback);
141UINT16 m68k_get_fc(device_t *device);
142181
143void m68307_set_port_callbacks(device_t *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback m_m68307_porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback m_m68307_portb_w);
144UINT16 m68307_get_cs(device_t *device, offs_t address);
145UINT16 m68340_get_cs(device_t *device, offs_t address);
146void m68307_set_interrupt(device_t *device, int level, int vector);
147void m68307_timer0_interrupt(legacy_cpu_device *cpudev);
148void m68307_timer1_interrupt(legacy_cpu_device *cpudev);
149void m68307_serial_interrupt(legacy_cpu_device *cpudev, int vector);
150void m68307_mbus_interrupt(legacy_cpu_device *cpudev);
151void m68307_licr2_interrupt(legacy_cpu_device *cpudev);
152182
153void m68307_set_duart68681(device_t* cpudev, device_t* duart68681);
183extern const device_type M68K;
154184
155typedef int (*instruction_hook_t)(device_t *device, offs_t curpc);
156void m68k_set_instruction_hook(device_t *device, instruction_hook_t ihook);
185class m68000_base_device : public cpu_device
186{
187public:
157188
189   // construction/destruction
190   m68000_base_device(const machine_config &mconfig, const char *name, const char *tag, device_t *owner, UINT32 clock,
191                  const device_type type, UINT32 prg_data_width, UINT32 prg_address_bits, const char *shortname, const char *source);
158192
193   m68000_base_device(const machine_config &mconfig, const char *name, const char *tag, device_t *owner, UINT32 clock,
194                  const device_type type, UINT32 prg_data_width, UINT32 prg_address_bits, address_map_constructor internal_map, const char *shortname, const char *source);
195
196   m68000_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
197
198   void clear_all(void);
199
200   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
201   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
202   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
203
204
205
206
207   // device_execute_interface overrides
208   virtual UINT32 execute_min_cycles() const { return 4; };
209   virtual UINT32 execute_max_cycles() const { return 158; };
210   virtual UINT32 execute_input_lines() const { return 8; }; // number of input lines
211   virtual void execute_run();
212   virtual void execute_set_input(int inputnum, int state);
213
214   // device-level overrides
215   virtual void device_start();
216   virtual void device_reset();
217   virtual void device_stop();
218
219   // device_memory_interface overrides
220   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
221
222   // address spaces
223   const address_space_config m_program_config;
224
225   void define_state(void);
226
227
228
229
230public:
231
232
233   UINT32 cpu_type;     /* CPU Type: 68000, 68008, 68010, 68EC020, 68020, 68EC030, 68030, 68EC040, or 68040 */
234//   UINT32 dasm_type;    /* disassembly type */
235   UINT32 dar[16];      /* Data and Address Registers */
236   UINT32 ppc;        /* Previous program counter */
237   UINT32 pc;           /* Program Counter */
238   UINT32 sp[7];        /* User, Interrupt, and Master Stack Pointers */
239   UINT32 vbr;          /* Vector Base Register (m68010+) */
240   UINT32 sfc;          /* Source Function Code Register (m68010+) */
241   UINT32 dfc;          /* Destination Function Code Register (m68010+) */
242   UINT32 cacr;         /* Cache Control Register (m68020, unemulated) */
243   UINT32 caar;         /* Cache Address Register (m68020, unemulated) */
244   UINT32 ir;           /* Instruction Register */
245   floatx80 fpr[8];     /* FPU Data Register (m68030/040) */
246   UINT32 fpiar;        /* FPU Instruction Address Register (m68040) */
247   UINT32 fpsr;         /* FPU Status Register (m68040) */
248   UINT32 fpcr;         /* FPU Control Register (m68040) */
249   UINT32 t1_flag;      /* Trace 1 */
250   UINT32 t0_flag;      /* Trace 0 */
251   UINT32 s_flag;       /* Supervisor */
252   UINT32 m_flag;       /* Master/Interrupt state */
253   UINT32 x_flag;       /* Extend */
254   UINT32 n_flag;       /* Negative */
255   UINT32 not_z_flag;   /* Zero, inverted for speedups */
256   UINT32 v_flag;       /* Overflow */
257   UINT32 c_flag;       /* Carry */
258   UINT32 int_mask;     /* I0-I2 */
259   UINT32 int_level;    /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */
260   UINT32 stopped;      /* Stopped state */
261   UINT32 pref_addr;    /* Last prefetch address */
262   UINT32 pref_data;    /* Data in the prefetch queue */
263   UINT32 sr_mask;      /* Implemented status register bits */
264   UINT32 instr_mode;   /* Stores whether we are in instruction mode or group 0/1 exception mode */
265   UINT32 run_mode;     /* Stores whether we are processing a reset, bus error, address error, or something else */
266   int    has_pmmu;     /* Indicates if a PMMU available (yes on 030, 040, no on EC030) */
267   int    has_hmmu;     /* Indicates if an Apple HMMU is available in place of the 68851 (020 only) */
268   int    pmmu_enabled; /* Indicates if the PMMU is enabled */
269   int    hmmu_enabled; /* Indicates if the HMMU is enabled */
270   int    has_fpu;      /* Indicates if a FPU is available (yes on 030, 040, may be on 020) */
271   int    fpu_just_reset; /* Indicates the FPU was just reset */
272
273   /* Clocks required for instructions / exceptions */
274   UINT32 cyc_bcc_notake_b;
275   UINT32 cyc_bcc_notake_w;
276   UINT32 cyc_dbcc_f_noexp;
277   UINT32 cyc_dbcc_f_exp;
278   UINT32 cyc_scc_r_true;
279   UINT32 cyc_movem_w;
280   UINT32 cyc_movem_l;
281   UINT32 cyc_shift;
282   UINT32 cyc_reset;
283
284   int  initial_cycles;
285   int  remaining_cycles;                     /* Number of clocks remaining */
286   int  reset_cycles;
287   UINT32 tracing;
288
289#ifdef _BSD_SETJMP_H
290   sigjmp_buf aerr_trap;
291#else
292   jmp_buf aerr_trap;
293#endif
294   UINT32    aerr_address;
295   UINT32    aerr_write_mode;
296   UINT32    aerr_fc;
297
298   /* Virtual IRQ lines state */
299   UINT32 virq_state;
300   UINT32 nmi_pending;
301
302   void (**jump_table)(m68000_base_device *m68k);
303   const UINT8* cyc_instruction;
304   const UINT8* cyc_exception;
305
306   /* Callbacks to host */
307   device_irq_acknowledge_callback int_ack_callback;             /* Interrupt Acknowledge */
308   m68k_bkpt_ack_func bkpt_ack_callback;         /* Breakpoint Acknowledge */
309   m68k_reset_func reset_instr_callback;         /* Called when a RESET instruction is encountered */
310   m68k_cmpild_func cmpild_instr_callback;       /* Called when a CMPI.L #v, Dn instruction is encountered */
311   m68k_rte_func rte_instr_callback;             /* Called when a RTE instruction is encountered */
312   m68k_tas_func tas_instr_callback;             /* Called when a TAS instruction is encountered, allows / disallows writeback */
313
314   address_space *program;
315
316
317
318   /* Redirect memory calls */
319
320   typedef delegate<UINT8 (offs_t)> m68k_read8_delegate;
321   typedef delegate<UINT16 (offs_t)> m68k_readimm16_delegate;
322   typedef delegate<UINT16 (offs_t)> m68k_read16_delegate;
323   typedef delegate<UINT32 (offs_t)> m68k_read32_delegate;
324   typedef delegate<void (offs_t, UINT8)> m68k_write8_delegate;
325   typedef delegate<void (offs_t, UINT16)> m68k_write16_delegate;
326   typedef delegate<void (offs_t, UINT32)> m68k_write32_delegate;
327
328//   class m68k_memory_interface
329//   {
330   public:
331      void init8(address_space &space);
332      void init16(address_space &space);
333      void init16_m68307(address_space &space);
334      void init32(address_space &space);
335      void init32mmu(address_space &space);
336      void init32hmmu(address_space &space);
337
338      offs_t  opcode_xor;                     // Address Calculation
339      m68k_readimm16_delegate readimm16;      // Immediate read 16 bit
340      m68k_read8_delegate read8;
341      m68k_read16_delegate read16;
342      m68k_read32_delegate read32;
343      m68k_write8_delegate write8;
344      m68k_write16_delegate write16;
345      m68k_write32_delegate write32;
346
347   private:
348      UINT16 m68008_read_immediate_16(offs_t address);
349      UINT16 read_immediate_16(offs_t address);
350      UINT16 simple_read_immediate_16(offs_t address);
351
352      UINT16 simple_read_immediate_16_m68307(offs_t address);
353      UINT8 read_byte_m68307(offs_t address);
354      UINT16 read_word_m68307(offs_t address);
355      UINT32 read_dword_m68307(offs_t address);
356      void write_byte_m68307(offs_t address, UINT8 data);
357      void write_word_m68307(offs_t address, UINT16 data);
358      void write_dword_m68307(offs_t address, UINT32 data);
359
360      UINT8 read_byte_32_mmu(offs_t address);
361      void write_byte_32_mmu(offs_t address, UINT8 data);
362      UINT16 read_immediate_16_mmu(offs_t address);
363      UINT16 readword_d32_mmu(offs_t address);
364      void writeword_d32_mmu(offs_t address, UINT16 data);
365      UINT32 readlong_d32_mmu(offs_t address);
366      void writelong_d32_mmu(offs_t address, UINT32 data);
367
368      UINT8 read_byte_32_hmmu(offs_t address);
369      void write_byte_32_hmmu(offs_t address, UINT8 data);
370      UINT16 read_immediate_16_hmmu(offs_t address);
371      UINT16 readword_d32_hmmu(offs_t address);
372      void writeword_d32_hmmu(offs_t address, UINT16 data);
373      UINT32 readlong_d32_hmmu(offs_t address);
374      void writelong_d32_hmmu(offs_t address, UINT32 data);
375
376      address_space *m_space;
377      direct_read_data *m_direct;
378//      m68000_base_device *m_cpustate;
379//   };
380
381   public:
382//   m68k_memory_interface memory;
383   offs_t encrypted_start;
384   offs_t encrypted_end;
385
386   UINT32      iotemp;
387
388   /* save state data */
389   UINT16 save_sr;
390   UINT8 save_stopped;
391   UINT8 save_halted;
392
393   /* PMMU registers */
394   UINT32 mmu_crp_aptr, mmu_crp_limit;
395   UINT32 mmu_srp_aptr, mmu_srp_limit;
396   UINT32 mmu_urp_aptr;    /* 040 only */
397   UINT32 mmu_tc;
398   UINT16 mmu_sr;
399   UINT32 mmu_sr_040;
400   UINT32 mmu_atc_tag[MMU_ATC_ENTRIES], mmu_atc_data[MMU_ATC_ENTRIES];
401   UINT32 mmu_atc_rr;
402   UINT32 mmu_tt0, mmu_tt1;
403   UINT32 mmu_itt0, mmu_itt1, mmu_dtt0, mmu_dtt1;
404   UINT32 mmu_acr0, mmu_acr1, mmu_acr2, mmu_acr3;
405
406   UINT16 mmu_tmp_sr;      /* temporary hack: status code for ptest and to handle write protection */
407   UINT16 mmu_tmp_fc;      /* temporary hack: function code for the mmu (moves) */
408   UINT16 mmu_tmp_rw;      /* temporary hack: read/write (1/0) for the mmu */
409   UINT32 mmu_tmp_buserror_address;   /* temporary hack: (first) bus error address */
410   UINT16 mmu_tmp_buserror_occurred;  /* temporary hack: flag that bus error has occurred from mmu */
411   UINT16 mmu_tmp_buserror_fc;   /* temporary hack: (first) bus error fc */
412   UINT16 mmu_tmp_buserror_rw;   /* temporary hack: (first) bus error rw */
413
414   UINT32 ic_address[M68K_IC_SIZE];   /* instruction cache address data */
415   UINT16 ic_data[M68K_IC_SIZE];      /* instruction cache content data */
416
417   /* 68307 peripheral modules */
418   m68307_sim*    m68307SIM;
419   m68307_mbus*   m68307MBUS;
420   m68307_serial* m68307SERIAL;
421   m68307_timer*  m68307TIMER;
422
423   UINT16 m68307_base;
424   UINT16 m68307_scrhigh;
425   UINT16 m68307_scrlow;
426
427   int m68307_currentcs;
428
429   /* 68340 peripheral modules */
430   m68340_sim*    m68340SIM;
431   m68340_dma*    m68340DMA;
432   m68340_serial* m68340SERIAL;
433   m68340_timer*  m68340TIMER;
434
435   UINT32 m68340_base;
436
437
438   DECLARE_READ16_MEMBER( m68307_internal_base_r );
439   DECLARE_WRITE16_MEMBER( m68307_internal_base_w );
440   DECLARE_READ16_MEMBER( m68307_internal_timer_r );
441   DECLARE_WRITE16_MEMBER( m68307_internal_timer_w );
442   DECLARE_READ16_MEMBER( m68307_internal_sim_r );
443   DECLARE_WRITE16_MEMBER( m68307_internal_sim_w );
444   DECLARE_READ8_MEMBER( m68307_internal_serial_r );
445   DECLARE_WRITE8_MEMBER( m68307_internal_serial_w );
446   DECLARE_READ8_MEMBER( m68307_internal_mbus_r );
447   DECLARE_WRITE8_MEMBER( m68307_internal_mbus_w );
448
449   READ32_MEMBER( m68340_internal_base_r );
450   WRITE32_MEMBER( m68340_internal_base_w );
451   READ32_MEMBER( m68340_internal_dma_r );
452   WRITE32_MEMBER( m68340_internal_dma_w );
453   READ32_HANDLER( m68340_internal_serial_r );
454   WRITE32_MEMBER( m68340_internal_serial_w );
455   READ16_MEMBER( m68340_internal_sim_r );
456   READ8_MEMBER( m68340_internal_sim_ports_r );
457   READ32_MEMBER( m68340_internal_sim_cs_r );
458   WRITE16_MEMBER( m68340_internal_sim_w );
459   WRITE8_MEMBER( m68340_internal_sim_ports_w );
460   WRITE32_MEMBER( m68340_internal_sim_cs_w );
461   READ32_MEMBER( m68340_internal_timer_r );
462   WRITE32_MEMBER( m68340_internal_timer_w );
463
464
465   /* 68308 / 68340 internal address map */
466   address_space *internal;
467
468   /* callbacks for internal ports */
469   m68307_porta_read_callback m_m68307_porta_r;
470   m68307_porta_write_callback m_m68307_porta_w;
471   m68307_portb_read_callback m_m68307_portb_r;
472   m68307_portb_write_callback m_m68307_portb_w;
473
474
475
476   /* external instruction hook (does not depend on debug mode) */
477   instruction_hook_t instruction_hook;
478
479
480
481   void init_cpu_common(void);
482   void init_cpu_m68000(void);
483   void init_cpu_m68307(void);
484   void init_cpu_m68008(void);
485   void init_cpu_m68010(void);
486   void init_cpu_m68020(void);
487   void init_cpu_m68020pmmu(void);
488   void init_cpu_m68020hmmu(void);
489   void init_cpu_m68ec020(void);
490   void init_cpu_m68030(void);
491   void init_cpu_m68ec030(void);
492   void init_cpu_m68040(void);
493   void init_cpu_m68ec040(void);
494   void init_cpu_m68lc040(void);
495   void init_cpu_m68340(void);
496   void init_cpu_scc68070(void);
497   void init_cpu_coldfire(void);
498
499
500   void m68ki_exception_interrupt(m68000_base_device *m68k, UINT32 int_level);
501
502   void reset_cpu(void);
503   inline void cpu_execute(void);
504   
505   // device_state_interface overrides
506   virtual void state_import(const device_state_entry &entry);
507   virtual void state_export(const device_state_entry &entry);
508   virtual void state_string_export(const device_state_entry &entry, astring &string);
509
510   // device_memory_interface overrides
511   virtual bool memory_translate(address_spacenum space, int intention, offs_t &address);
512};
513
514
515
516class m68000_device : public m68000_base_device
517{
518public:
519   // construction/destruction
520   m68000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
521
522   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
523   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
524   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
525
526   virtual UINT32 execute_min_cycles() const { return 4; };
527   virtual UINT32 execute_max_cycles() const { return 158; };
528
529   virtual UINT32 execute_default_irq_vector() const { return -1; };
530
531   // device-level overrides
532   virtual void device_start();
533protected:
534};
535
536class m68301_device : public m68000_base_device
537{
538public:
539   // construction/destruction
540   m68301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
541
542   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
543   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
544   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
545
546   virtual UINT32 execute_min_cycles() const { return 4; };
547   virtual UINT32 execute_max_cycles() const { return 158; };
548
549   virtual UINT32 execute_default_irq_vector() const { return -1; };
550
551   // device-level overrides
552   virtual void device_start();
553protected:
554};
555
556
557class m68307_device : public m68000_base_device
558{
559public:
560   // construction/destruction
561   m68307_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
562
563   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
564   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
565   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
566
567   virtual UINT32 execute_min_cycles() const { return 4; };
568   virtual UINT32 execute_max_cycles() const { return 158; };
569
570   virtual UINT32 execute_default_irq_vector() const { return -1; };
571
572   // device-level overrides
573   virtual void device_start();
574protected:
575};
576
577class m68008_device : public m68000_base_device
578{
579public:
580   // construction/destruction
581   m68008_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
582
583   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
584   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
585   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
586
587   virtual UINT32 execute_min_cycles() const { return 4; };
588   virtual UINT32 execute_max_cycles() const { return 158; };
589
590   virtual UINT32 execute_default_irq_vector() const { return -1; };
591
592   // device-level overrides
593   virtual void device_start();
594protected:
595};
596
597class m68008plcc_device : public m68000_base_device
598{
599public:
600   // construction/destruction
601   m68008plcc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
602
603   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
604   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
605   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
606
607   virtual UINT32 execute_min_cycles() const { return 4; };
608   virtual UINT32 execute_max_cycles() const { return 158; };
609
610   virtual UINT32 execute_default_irq_vector() const { return -1; };
611
612   // device-level overrides
613   virtual void device_start();
614protected:
615};
616
617class m68010_device : public m68000_base_device
618{
619public:
620   // construction/destruction
621   m68010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
622
623   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
624   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
625   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
626
627   virtual UINT32 execute_min_cycles() const { return 4; };
628   virtual UINT32 execute_max_cycles() const { return 158; };
629
630   virtual UINT32 execute_default_irq_vector() const { return -1; };
631
632   // device-level overrides
633   virtual void device_start();
634protected:
635};
636
637class m68ec020_device : public m68000_base_device
638{
639public:
640   // construction/destruction
641   m68ec020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
642
643   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
644   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
645   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
646
647   virtual UINT32 execute_min_cycles() const { return 2; };
648   virtual UINT32 execute_max_cycles() const { return 158; };
649
650   virtual UINT32 execute_default_irq_vector() const { return -1; };
651
652   // device-level overrides
653   virtual void device_start();
654protected:
655};
656
657class m68020_device : public m68000_base_device
658{
659public:
660   // construction/destruction
661   m68020_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
662
663   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
664   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
665   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
666
667   virtual UINT32 execute_min_cycles() const { return 2; };
668   virtual UINT32 execute_max_cycles() const { return 158; };
669
670   virtual UINT32 execute_default_irq_vector() const { return -1; };
671
672   // device-level overrides
673   virtual void device_start();
674protected:
675};
676
677class m68020pmmu_device : public m68000_base_device
678{
679public:
680   // construction/destruction
681   m68020pmmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
682
683   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
684   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
685   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
686
687   virtual UINT32 execute_min_cycles() const { return 2; };
688   virtual UINT32 execute_max_cycles() const { return 158; };
689
690   virtual UINT32 execute_default_irq_vector() const { return -1; };
691
692   // device-level overrides
693   virtual void device_start();
694protected:
695};
696
697class m68020hmmu_device : public m68000_base_device
698{
699public:
700   // construction/destruction
701   m68020hmmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
702
703   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
704   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
705   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
706
707   virtual UINT32 execute_min_cycles() const { return 2; };
708   virtual UINT32 execute_max_cycles() const { return 158; };
709
710   virtual UINT32 execute_default_irq_vector() const { return -1; };
711
712   virtual bool memory_translate(address_spacenum space, int intention, offs_t &address);
713
714   // device-level overrides
715   virtual void device_start();
716protected:
717};
718
719class m68ec030_device : public m68000_base_device
720{
721public:
722   // construction/destruction
723   m68ec030_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
724
725   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
726   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
727   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
728
729   virtual UINT32 execute_min_cycles() const { return 2; };
730   virtual UINT32 execute_max_cycles() const { return 158; };
731
732   virtual UINT32 execute_default_irq_vector() const { return -1; };
733
734   // device-level overrides
735   virtual void device_start();
736protected:
737};
738
739class m68030_device : public m68000_base_device
740{
741public:
742   // construction/destruction
743   m68030_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
744
745   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
746   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
747   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
748
749   virtual UINT32 execute_min_cycles() const { return 2; };
750   virtual UINT32 execute_max_cycles() const { return 158; };
751
752   virtual UINT32 execute_default_irq_vector() const { return -1; };
753
754   // device-level overrides
755   virtual void device_start();
756protected:
757};
758
759class m68ec040_device : public m68000_base_device
760{
761public:
762   // construction/destruction
763   m68ec040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
764
765   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
766   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
767   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
768
769   virtual UINT32 execute_min_cycles() const { return 2; };
770   virtual UINT32 execute_max_cycles() const { return 158; };
771
772   virtual UINT32 execute_default_irq_vector() const { return -1; };
773
774   // device-level overrides
775   virtual void device_start();
776protected:
777};
778
779class m68lc040_device : public m68000_base_device
780{
781public:
782   // construction/destruction
783   m68lc040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
784
785   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
786   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
787   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
788
789   virtual UINT32 execute_min_cycles() const { return 2; };
790   virtual UINT32 execute_max_cycles() const { return 158; };
791
792   virtual UINT32 execute_default_irq_vector() const { return -1; };
793
794   // device-level overrides
795   virtual void device_start();
796protected:
797};
798
799class m68040_device : public m68000_base_device
800{
801public:
802   // construction/destruction
803   m68040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
804
805   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
806   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
807   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
808
809   virtual UINT32 execute_min_cycles() const { return 2; };
810   virtual UINT32 execute_max_cycles() const { return 158; };
811
812   virtual UINT32 execute_default_irq_vector() const { return -1; };
813
814   // device-level overrides
815   virtual void device_start();
816protected:
817};
818
819class scc68070_device : public m68000_base_device
820{
821public:
822   // construction/destruction
823   scc68070_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
824
825   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
826   virtual UINT32 disasm_max_opcode_bytes() const { return 10; };
827   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
828
829   virtual UINT32 execute_min_cycles() const { return 4; };
830   virtual UINT32 execute_max_cycles() const { return 158; };
831
832   virtual UINT32 execute_default_irq_vector() const { return -1; };
833
834   // device-level overrides
835   virtual void device_start();
836protected:
837};
838
839
840
841
842class m68340_device : public m68000_base_device
843{
844public:
845   // construction/destruction
846   m68340_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
847   
848   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
849   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
850   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
851
852   virtual UINT32 execute_min_cycles() const { return 2; };
853   virtual UINT32 execute_max_cycles() const { return 158; };
854
855   virtual UINT32 execute_default_irq_vector() const { return -1; };
856
857   // device-level overrides
858   virtual void device_start();
859protected:
860};
861
862
863
864class mcf5206e_device : public m68000_base_device
865{
866public:
867   // construction/destruction
868   mcf5206e_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
869
870   virtual UINT32 disasm_min_opcode_bytes() const { return 2; };
871   virtual UINT32 disasm_max_opcode_bytes() const { return 20; };
872   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
873
874   virtual UINT32 execute_min_cycles() const { return 2; };
875   virtual UINT32 execute_max_cycles() const { return 158; };
876
877   virtual UINT32 execute_default_irq_vector() const { return -1; };
878
879
880   // device-level overrides
881   virtual void device_start();
882protected:
883};
884
885
886extern const device_type M68000;
887extern const device_type M68301;
888extern const device_type M68307;
889extern const device_type M68008;
890extern const device_type M68008PLCC;
891extern const device_type M68010;
892extern const device_type M68EC020;
893extern const device_type M68020;
894extern const device_type M68020PMMU;
895extern const device_type M68020HMMU;
896extern const device_type M68EC030;
897extern const device_type M68030;
898extern const device_type M68EC040;
899extern const device_type M68LC040;
900extern const device_type M68040;
901extern const device_type SCC68070;
902extern const device_type M68340;
903extern const device_type MCF5206E;
904
905extern void m68k_set_reset_callback(m68000_base_device *device, m68k_reset_func callback);
906extern void m68k_set_cmpild_callback(m68000_base_device *device, m68k_cmpild_func callback);
907extern void m68k_set_rte_callback(m68000_base_device *device, m68k_rte_func callback);
908extern void m68k_set_tas_callback(m68000_base_device *device, m68k_tas_func callback);
909extern UINT16 m68k_get_fc(m68000_base_device *device);
910extern void m68307_set_port_callbacks(m68000_base_device *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback portb_w);
911extern void m68307_set_duart68681(m68000_base_device* cpudev, device_t* duart68681);
912extern UINT16 m68307_get_cs(m68000_base_device *device, offs_t address);
913extern UINT16 m68340_get_cs(m68000_base_device *device, offs_t address);
914extern void m68307_timer0_interrupt(m68000_base_device *cpudev);
915extern void m68307_timer1_interrupt(m68000_base_device *cpudev);
916extern void m68307_serial_interrupt(m68000_base_device *cpudev, int vector);
917extern void m68307_mbus_interrupt(m68000_base_device *cpudev);
918extern void m68307_licr2_interrupt(m68000_base_device *cpudev);
919extern void m68k_set_encrypted_opcode_range(m68000_base_device *device, offs_t start, offs_t end);
920extern void m68k_set_hmmu_enable(m68000_base_device *device, int enable);
921extern void m68k_set_instruction_hook(m68000_base_device *device, instruction_hook_t ihook);
922
159923#endif /* __M68000_H__ */
trunk/src/emu/cpu/m68000/68307sim.c
r23920r23921
44#include "m68kcpu.h"
55
66
7READ16_HANDLER( m68307_internal_sim_r )
7READ16_MEMBER( m68000_base_device::m68307_internal_sim_r )
88{
9   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
9   m68000_base_device *m68k = this;
1010   m68307_sim* sim = m68k->m68307SIM;
1111   assert(sim != NULL);
1212
r23920r23921
1616   {
1717      switch (offset<<1)
1818      {
19         case m68307SIM_PADAT: return sim->read_padat(space, mem_mask);
20         case m68307SIM_PBDAT: return sim->read_pbdat(space, mem_mask);
19         case m68307SIM_PADAT: return sim->read_padat(this, space, mem_mask);
20         case m68307SIM_PBDAT: return sim->read_pbdat(this, space, mem_mask);
2121
2222         case m68307SIM_LICR2: return  (sim->m_licr2);
2323
r23920r23921
4141}
4242
4343
44WRITE16_HANDLER( m68307_internal_sim_w )
44WRITE16_MEMBER( m68000_base_device::m68307_internal_sim_w )
4545{
46   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
46   m68000_base_device *m68k = this;
4747   m68307_sim* sim = m68k->m68307SIM;
4848   assert(sim != NULL);
4949
r23920r23921
6464            break;
6565
6666         case m68307SIM_PADAT:
67            sim->write_padat(space, data,mem_mask);
67            sim->write_padat(this, space, data,mem_mask);
6868            break;
6969
7070         case m68307SIM_PBCNT:
r23920r23921
7878            break;
7979
8080         case m68307SIM_PBDAT:
81            sim->write_pbdat(space, data, mem_mask);
81            sim->write_pbdat(this, space, data, mem_mask);
8282            break;
8383
8484
r23920r23921
149149}
150150
151151
152UINT16 m68307_sim::read_padat(address_space &space, UINT16 mem_mask)
152UINT16 m68307_sim::read_padat(m68000_base_device* m68k, address_space &space, UINT16 mem_mask)
153153{
154154   int pc = space.device().safe_pc();
155   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
156155
157156   if (m68k->m_m68307_porta_r)
158157   {
r23920r23921
176175}
177176
178177
179void m68307_sim::write_padat(address_space &space, UINT16 data, UINT16 mem_mask)
178void m68307_sim::write_padat(m68000_base_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask)
180179{
181180   int pc = space.device().safe_pc();
182   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
183181   COMBINE_DATA(&m_padat);
184182
185183   if (m68k->m_m68307_porta_w)
r23920r23921
202200   COMBINE_DATA(&m_pbddr);
203201}
204202
205UINT16 m68307_sim::read_pbdat(address_space &space, UINT16 mem_mask)
203UINT16 m68307_sim::read_pbdat(m68000_base_device* m68k, address_space &space, UINT16 mem_mask)
206204{
207205   int pc = space.device().safe_pc();
208   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
209206
210207   if (m68k->m_m68307_portb_r)
211208   {
r23920r23921
229226}
230227
231228
232void m68307_sim::write_pbdat(address_space &space, UINT16 data, UINT16 mem_mask)
229void m68307_sim::write_pbdat(m68000_base_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask)
233230{
234231   int pc = space.device().safe_pc();
235   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
236232   COMBINE_DATA(&m_pbdat);
237233
238234   if (m68k->m_m68307_portb_w)
trunk/src/emu/cpu/m68000/m68kfpu.c
r23920r23921
5151   return float64_to_floatx80(*d);
5252}
5353
54INLINE floatx80 load_extended_float80(m68ki_cpu_core *m68k, UINT32 ea)
54INLINE floatx80 load_extended_float80(m68000_base_device *m68k, UINT32 ea)
5555{
5656   UINT32 d1,d2;
5757   UINT16 d3;
r23920r23921
6767   return fp;
6868}
6969
70INLINE void store_extended_float80(m68ki_cpu_core *m68k, UINT32 ea, floatx80 fpr)
70INLINE void store_extended_float80(m68000_base_device *m68k, UINT32 ea, floatx80 fpr)
7171{
7272   m68ki_write_16(m68k, ea+0, fpr.high);
7373   m68ki_write_16(m68k, ea+2, 0);
r23920r23921
7575   m68ki_write_32(m68k, ea+8, fpr.low&0xffffffff);
7676}
7777
78INLINE floatx80 load_pack_float80(m68ki_cpu_core *m68k, UINT32 ea)
78INLINE floatx80 load_pack_float80(m68000_base_device *m68k, UINT32 ea)
7979{
8080   UINT32 dw1, dw2, dw3;
8181   floatx80 result;
r23920r23921
126126   return result;
127127}
128128
129INLINE void store_pack_float80(m68ki_cpu_core *m68k, UINT32 ea, int k, floatx80 fpr)
129INLINE void store_pack_float80(m68000_base_device *m68k, UINT32 ea, int k, floatx80 fpr)
130130{
131131   UINT32 dw1, dw2, dw3;
132132   char str[128], *ch;
r23920r23921
258258   m68ki_write_32(m68k, ea+8, dw3);
259259}
260260
261INLINE void SET_CONDITION_CODES(m68ki_cpu_core *m68k, floatx80 reg)
261INLINE void SET_CONDITION_CODES(m68000_base_device *m68k, floatx80 reg)
262262{
263263//  UINT64 *regi;
264264
r23920r23921
291291   }
292292}
293293
294INLINE int TEST_CONDITION(m68ki_cpu_core *m68k, int condition)
294INLINE int TEST_CONDITION(m68000_base_device *m68k, int condition)
295295{
296296   int n = (REG_FPSR(m68k) & FPCC_N) != 0;
297297   int z = (REG_FPSR(m68k) & FPCC_Z) != 0;
r23920r23921
353353   return r;
354354}
355355
356static UINT8 READ_EA_8(m68ki_cpu_core *m68k, int ea)
356static UINT8 READ_EA_8(m68000_base_device *m68k, int ea)
357357{
358358   int mode = (ea >> 3) & 0x7;
359359   int reg = (ea & 0x7);
r23920r23921
429429   return 0;
430430}
431431
432static UINT16 READ_EA_16(m68ki_cpu_core *m68k, int ea)
432static UINT16 READ_EA_16(m68000_base_device *m68k, int ea)
433433{
434434   int mode = (ea >> 3) & 0x7;
435435   int reg = (ea & 0x7);
r23920r23921
506506   return 0;
507507}
508508
509static UINT32 READ_EA_32(m68ki_cpu_core *m68k, int ea)
509static UINT32 READ_EA_32(m68000_base_device *m68k, int ea)
510510{
511511   int mode = (ea >> 3) & 0x7;
512512   int reg = (ea & 0x7);
r23920r23921
581581   return 0;
582582}
583583
584static UINT64 READ_EA_64(m68ki_cpu_core *m68k, int ea)
584static UINT64 READ_EA_64(m68000_base_device *m68k, int ea)
585585{
586586   int mode = (ea >> 3) & 0x7;
587587   int reg = (ea & 0x7);
r23920r23921
668668}
669669
670670
671static floatx80 READ_EA_FPE(m68ki_cpu_core *m68k, int ea)
671static floatx80 READ_EA_FPE(m68000_base_device *m68k, int ea)
672672{
673673   floatx80 fpr;
674674   int mode = (ea >> 3) & 0x7;
r23920r23921
743743   return fpr;
744744}
745745
746static floatx80 READ_EA_PACK(m68ki_cpu_core *m68k, int ea)
746static floatx80 READ_EA_PACK(m68000_base_device *m68k, int ea)
747747{
748748   floatx80 fpr;
749749   int mode = (ea >> 3) & 0x7;
r23920r23921
790790   return fpr;
791791}
792792
793static void WRITE_EA_8(m68ki_cpu_core *m68k, int ea, UINT8 data)
793static void WRITE_EA_8(m68000_base_device *m68k, int ea, UINT8 data)
794794{
795795   int mode = (ea >> 3) & 0x7;
796796   int reg = (ea & 0x7);
r23920r23921
858858   }
859859}
860860
861static void WRITE_EA_16(m68ki_cpu_core *m68k, int ea, UINT16 data)
861static void WRITE_EA_16(m68000_base_device *m68k, int ea, UINT16 data)
862862{
863863   int mode = (ea >> 3) & 0x7;
864864   int reg = (ea & 0x7);
r23920r23921
926926   }
927927}
928928
929static void WRITE_EA_32(m68ki_cpu_core *m68k, int ea, UINT32 data)
929static void WRITE_EA_32(m68000_base_device *m68k, int ea, UINT32 data)
930930{
931931   int mode = (ea >> 3) & 0x7;
932932   int reg = (ea & 0x7);
r23920r23921
999999   }
10001000}
10011001
1002static void WRITE_EA_64(m68ki_cpu_core *m68k, int ea, UINT64 data)
1002static void WRITE_EA_64(m68000_base_device *m68k, int ea, UINT64 data)
10031003{
10041004   int mode = (ea >> 3) & 0x7;
10051005   int reg = (ea & 0x7);
r23920r23921
10721072   }
10731073}
10741074
1075static void WRITE_EA_FPE(m68ki_cpu_core *m68k, int ea, floatx80 fpr)
1075static void WRITE_EA_FPE(m68000_base_device *m68k, int ea, floatx80 fpr)
10761076{
10771077   int mode = (ea >> 3) & 0x7;
10781078   int reg = (ea & 0x7);
r23920r23921
11161116   }
11171117}
11181118
1119static void WRITE_EA_PACK(m68ki_cpu_core *m68k, int ea, int k, floatx80 fpr)
1119static void WRITE_EA_PACK(m68000_base_device *m68k, int ea, int k, floatx80 fpr)
11201120{
11211121   int mode = (ea >> 3) & 0x7;
11221122   int reg = (ea & 0x7);
r23920r23921
11601160   }
11611161}
11621162
1163static void fpgen_rm_reg(m68ki_cpu_core *m68k, UINT16 w2)
1163static void fpgen_rm_reg(m68000_base_device *m68k, UINT16 w2)
11641164{
11651165   int ea = m68k->ir & 0x3f;
11661166   int rm = (w2 >> 14) & 0x1;
r23920r23921
15251525   }
15261526}
15271527
1528static void fmove_reg_mem(m68ki_cpu_core *m68k, UINT16 w2)
1528static void fmove_reg_mem(m68000_base_device *m68k, UINT16 w2)
15291529{
15301530   int ea = m68k->ir & 0x3f;
15311531   int src = (w2 >>  7) & 0x7;
r23920r23921
15971597   m68k->remaining_cycles -= 12;
15981598}
15991599
1600static void fmove_fpcr(m68ki_cpu_core *m68k, UINT16 w2)
1600static void fmove_fpcr(m68000_base_device *m68k, UINT16 w2)
16011601{
16021602   int ea = m68k->ir & 0x3f;
16031603   int dir = (w2 >> 13) & 0x1;
r23920r23921
16991699   m68k->remaining_cycles -= 10;
17001700}
17011701
1702static void fmovem(m68ki_cpu_core *m68k, UINT16 w2)
1702static void fmovem(m68000_base_device *m68k, UINT16 w2)
17031703{
17041704   int i;
17051705   int ea = m68k->ir & 0x3f;
r23920r23921
18131813   }
18141814}
18151815
1816static void fscc(m68ki_cpu_core *m68k)
1816static void fscc(m68000_base_device *m68k)
18171817{
18181818   int ea = m68k->ir & 0x3f;
18191819   int condition = (INT16)(OPER_I_16(m68k));
r23920r23921
18221822   m68k->remaining_cycles -= 7; // ???
18231823}
18241824
1825static void fbcc16(m68ki_cpu_core *m68k)
1825static void fbcc16(m68000_base_device *m68k)
18261826{
18271827   INT32 offset;
18281828   int condition = m68k->ir & 0x3f;
r23920r23921
18391839   m68k->remaining_cycles -= 7;
18401840}
18411841
1842static void fbcc32(m68ki_cpu_core *m68k)
1842static void fbcc32(m68000_base_device *m68k)
18431843{
18441844   INT32 offset;
18451845   int condition = m68k->ir & 0x3f;
r23920r23921
18571857}
18581858
18591859
1860void m68040_fpu_op0(m68ki_cpu_core *m68k)
1860void m68040_fpu_op0(m68000_base_device *m68k)
18611861{
18621862   m68k->fpu_just_reset = 0;
18631863
r23920r23921
19281928   }
19291929}
19301930
1931static int perform_fsave(m68ki_cpu_core *m68k, UINT32 addr, int inc)
1931static int perform_fsave(m68000_base_device *m68k, UINT32 addr, int inc)
19321932{
19331933   if(m68k->cpu_type & CPU_TYPE_040)
19341934   {
r23920r23921
19701970}
19711971
19721972// FRESTORE on a NULL frame reboots the FPU - all registers to NaN, the 3 status regs to 0
1973static void do_frestore_null(m68ki_cpu_core *m68k)
1973static void do_frestore_null(m68000_base_device *m68k)
19741974{
19751975   int i;
19761976
r23920r23921
19881988   m68k->fpu_just_reset = 1;
19891989}
19901990
1991static void m68040_do_fsave(m68ki_cpu_core *m68k, UINT32 addr, int reg, int inc)
1991static void m68040_do_fsave(m68000_base_device *m68k, UINT32 addr, int reg, int inc)
19921992{
19931993   if (m68k->fpu_just_reset)
19941994   {
r23920r23921
20032003   }
20042004}
20052005
2006static void m68040_do_frestore(m68ki_cpu_core *m68k, UINT32 addr, int reg)
2006static void m68040_do_frestore(m68000_base_device *m68k, UINT32 addr, int reg)
20072007{
20082008   bool m40 = m68k->cpu_type & CPU_TYPE_040;
20092009   UINT32 temp = m68ki_read_32(m68k, addr);
r23920r23921
20412041   }
20422042}
20432043
2044void m68040_fpu_op1(m68ki_cpu_core *m68k)
2044void m68040_fpu_op1(m68000_base_device *m68k)
20452045{
20462046   int ea = m68k->ir & 0x3f;
20472047   int mode = (ea >> 3) & 0x7;
trunk/src/emu/cpu/m68000/68307bus.c
r23920r23921
55#include "m68kcpu.h"
66
77
8READ8_HANDLER( m68307_internal_mbus_r )
8READ8_MEMBER( m68000_base_device::m68307_internal_mbus_r )
99{
10   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
10   m68000_base_device *m68k = this;
1111   m68307_mbus* mbus = m68k->m68307MBUS;
1212   assert(mbus != NULL);
1313   UINT8 retval;
r23920r23921
5353   return 0xff;
5454}
5555
56WRITE8_HANDLER( m68307_internal_mbus_w )
56WRITE8_MEMBER( m68000_base_device::m68307_internal_mbus_w )
5757{
58   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
58   m68000_base_device *m68k = this;
5959   m68307_mbus* mbus = m68k->m68307MBUS;
6060   assert(mbus != NULL);
6161
trunk/src/emu/cpu/m68000/68307ser.c
r23920r23921
1313#include "m68kcpu.h"
1414
1515
16READ8_HANDLER( m68307_internal_serial_r )
16READ8_MEMBER( m68000_base_device::m68307_internal_serial_r )
1717{
18   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
18   m68000_base_device *m68k = this;
1919   m68307_serial* serial = m68k->m68307SERIAL;
2020   assert(serial != NULL);
2121
r23920r23921
9090   return 0x0000;
9191}
9292
93WRITE8_HANDLER( m68307_internal_serial_w )
93WRITE8_MEMBER( m68000_base_device::m68307_internal_serial_w )
9494{
95   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
95   m68000_base_device *m68k = this;
9696   m68307_serial* serial = m68k->m68307SERIAL;
9797   assert(serial != NULL);
9898
trunk/src/emu/cpu/m68000/m68kcpu.h
r23920r23921
2525#ifndef __M68KCPU_H__
2626#define __M68KCPU_H__
2727
28typedef class _m68ki_cpu_core m68ki_cpu_core;
28class m68000_base_device;
2929
3030#include "m68000.h"
31#include "../../../lib/softfloat/milieu.h"
32#include "../../../lib/softfloat/softfloat.h"
3331
32
3433#include <limits.h>
3534#include <setjmp.h>
3635
r23920r23921
101100#define RUN_MODE_NORMAL          0
102101#define RUN_MODE_BERR_AERR_RESET 1
103102
104/* MMU constants */
105#define MMU_ATC_ENTRIES (22)    // 68851 has 64, 030 has 22
106103
107/* instruction cache constants */
108#define M68K_IC_SIZE 128
109104
110105#define M68K_CACR_IBE 0x10 // Instruction Burst Enable
111106#define M68K_CACR_CI  0x08 // Clear Instruction Cache
r23920r23921
266261/* Cause a trace exception if we are tracing */
267262#define m68ki_exception_if_trace(m68k) if(m68k->tracing) m68ki_exception_trace(m68k)
268263
269
270/* Address error */
271/* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */
272#ifdef _BSD_SETJMP_H
273#define m68ki_set_address_error_trap(m68k) \
274   if(sigsetjmp(m68k->aerr_trap, 0) != 0) \
275   { \
276      m68ki_exception_address_error(m68k); \
277      if(m68k->stopped) \
278      { \
279         if (m68k->remaining_cycles > 0) \
280            m68k->remaining_cycles = 0; \
281         return; \
282      } \
283   }
284
285#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
286   if((ADDR)&1) \
287   { \
288      m68k->aerr_address = ADDR; \
289      m68k->aerr_write_mode = WRITE_MODE; \
290      m68k->aerr_fc = FC; \
291      siglongjmp(m68k->aerr_trap, 1); \
292   }
293#else
294#define m68ki_set_address_error_trap(m68k) \
295   SETJMP_GNUC_PROTECT(); \
296   if(setjmp(m68k->aerr_trap) != 0) \
297   { \
298      m68ki_exception_address_error(m68k); \
299      if(m68k->stopped) \
300      { \
301         if (m68k->remaining_cycles > 0) \
302            m68k->remaining_cycles = 0; \
303         return; \
304      } \
305   }
306
307#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
308   if((ADDR)&1) \
309   { \
310      m68k->aerr_address = ADDR; \
311      m68k->aerr_write_mode = WRITE_MODE; \
312      m68k->aerr_fc = FC; \
313      longjmp(m68k->aerr_trap, 1); \
314   }
315#endif
316
317
318264/* -------------------------- EA / Operand Access ------------------------- */
319265
320266/*
r23920r23921
535481   double f;
536482};
537483
538/* Redirect memory calls */
539
540typedef delegate<UINT8 (offs_t)> m68k_read8_delegate;
541typedef delegate<UINT16 (offs_t)> m68k_readimm16_delegate;
542typedef delegate<UINT16 (offs_t)> m68k_read16_delegate;
543typedef delegate<UINT32 (offs_t)> m68k_read32_delegate;
544typedef delegate<void (offs_t, UINT8)> m68k_write8_delegate;
545typedef delegate<void (offs_t, UINT16)> m68k_write16_delegate;
546typedef delegate<void (offs_t, UINT32)> m68k_write32_delegate;
547
548class m68k_memory_interface
484class m68000_base_device_ops
549485{
550486public:
551   void init8(address_space &space);
552   void init16(address_space &space);
553   void init16_m68307(address_space &space);
554   void init32(address_space &space);
555   void init32mmu(address_space &space);
556   void init32hmmu(address_space &space);
557
558   offs_t  opcode_xor;                     // Address Calculation
559   m68k_readimm16_delegate readimm16;      // Immediate read 16 bit
560   m68k_read8_delegate read8;
561   m68k_read16_delegate read16;
562   m68k_read32_delegate read32;
563   m68k_write8_delegate write8;
564   m68k_write16_delegate write16;
565   m68k_write32_delegate write32;
566
567private:
568   UINT16 m68008_read_immediate_16(offs_t address);
569   UINT16 read_immediate_16(offs_t address);
570   UINT16 simple_read_immediate_16(offs_t address);
571
572   UINT16 simple_read_immediate_16_m68307(offs_t address);
573   UINT8 read_byte_m68307(offs_t address);
574   UINT16 read_word_m68307(offs_t address);
575   UINT32 read_dword_m68307(offs_t address);
576   void write_byte_m68307(offs_t address, UINT8 data);
577   void write_word_m68307(offs_t address, UINT16 data);
578   void write_dword_m68307(offs_t address, UINT32 data);
579
580   UINT8 read_byte_32_mmu(offs_t address);
581   void write_byte_32_mmu(offs_t address, UINT8 data);
582   UINT16 read_immediate_16_mmu(offs_t address);
583   UINT16 readword_d32_mmu(offs_t address);
584   void writeword_d32_mmu(offs_t address, UINT16 data);
585   UINT32 readlong_d32_mmu(offs_t address);
586   void writelong_d32_mmu(offs_t address, UINT32 data);
587
588   UINT8 read_byte_32_hmmu(offs_t address);
589   void write_byte_32_hmmu(offs_t address, UINT8 data);
590   UINT16 read_immediate_16_hmmu(offs_t address);
591   UINT16 readword_d32_hmmu(offs_t address);
592   void writeword_d32_hmmu(offs_t address, UINT16 data);
593   UINT32 readlong_d32_hmmu(offs_t address);
594   void writelong_d32_hmmu(offs_t address, UINT32 data);
595
596   address_space *m_space;
597   direct_read_data *m_direct;
598   m68ki_cpu_core *m_cpustate;
599};
600
601class _m68ki_cpu_core
602{
603public:
604
605   UINT32 cpu_type;     /* CPU Type: 68000, 68008, 68010, 68EC020, 68020, 68EC030, 68030, 68EC040, or 68040 */
606   UINT32 dasm_type;    /* disassembly type */
607   UINT32 dar[16];      /* Data and Address Registers */
608   UINT32 ppc;        /* Previous program counter */
609   UINT32 pc;           /* Program Counter */
610   UINT32 sp[7];        /* User, Interrupt, and Master Stack Pointers */
611   UINT32 vbr;          /* Vector Base Register (m68010+) */
612   UINT32 sfc;          /* Source Function Code Register (m68010+) */
613   UINT32 dfc;          /* Destination Function Code Register (m68010+) */
614   UINT32 cacr;         /* Cache Control Register (m68020, unemulated) */
615   UINT32 caar;         /* Cache Address Register (m68020, unemulated) */
616   UINT32 ir;           /* Instruction Register */
617   floatx80 fpr[8];     /* FPU Data Register (m68030/040) */
618   UINT32 fpiar;        /* FPU Instruction Address Register (m68040) */
619   UINT32 fpsr;         /* FPU Status Register (m68040) */
620   UINT32 fpcr;         /* FPU Control Register (m68040) */
621   UINT32 t1_flag;      /* Trace 1 */
622   UINT32 t0_flag;      /* Trace 0 */
623   UINT32 s_flag;       /* Supervisor */
624   UINT32 m_flag;       /* Master/Interrupt state */
625   UINT32 x_flag;       /* Extend */
626   UINT32 n_flag;       /* Negative */
627   UINT32 not_z_flag;   /* Zero, inverted for speedups */
628   UINT32 v_flag;       /* Overflow */
629   UINT32 c_flag;       /* Carry */
630   UINT32 int_mask;     /* I0-I2 */
631   UINT32 int_level;    /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */
632   UINT32 stopped;      /* Stopped state */
633   UINT32 pref_addr;    /* Last prefetch address */
634   UINT32 pref_data;    /* Data in the prefetch queue */
635   UINT32 sr_mask;      /* Implemented status register bits */
636   UINT32 instr_mode;   /* Stores whether we are in instruction mode or group 0/1 exception mode */
637   UINT32 run_mode;     /* Stores whether we are processing a reset, bus error, address error, or something else */
638   int    has_pmmu;     /* Indicates if a PMMU available (yes on 030, 040, no on EC030) */
639   int    has_hmmu;     /* Indicates if an Apple HMMU is available in place of the 68851 (020 only) */
640   int    pmmu_enabled; /* Indicates if the PMMU is enabled */
641   int    hmmu_enabled; /* Indicates if the HMMU is enabled */
642   int    has_fpu;      /* Indicates if a FPU is available (yes on 030, 040, may be on 020) */
643   int    fpu_just_reset; /* Indicates the FPU was just reset */
644
645   /* Clocks required for instructions / exceptions */
646   UINT32 cyc_bcc_notake_b;
647   UINT32 cyc_bcc_notake_w;
648   UINT32 cyc_dbcc_f_noexp;
649   UINT32 cyc_dbcc_f_exp;
650   UINT32 cyc_scc_r_true;
651   UINT32 cyc_movem_w;
652   UINT32 cyc_movem_l;
653   UINT32 cyc_shift;
654   UINT32 cyc_reset;
655
656   int  initial_cycles;
657   int  remaining_cycles;                     /* Number of clocks remaining */
658   int  reset_cycles;
659   UINT32 tracing;
660
661#ifdef _BSD_SETJMP_H
662   sigjmp_buf aerr_trap;
663#else
664   jmp_buf aerr_trap;
665#endif
666   UINT32    aerr_address;
667   UINT32    aerr_write_mode;
668   UINT32    aerr_fc;
669
670   /* Virtual IRQ lines state */
671   UINT32 virq_state;
672   UINT32 nmi_pending;
673
674   void (**jump_table)(m68ki_cpu_core *m68k);
675   const UINT8* cyc_instruction;
676   const UINT8* cyc_exception;
677
678   /* Callbacks to host */
679   device_irq_acknowledge_callback int_ack_callback;             /* Interrupt Acknowledge */
680   m68k_bkpt_ack_func bkpt_ack_callback;         /* Breakpoint Acknowledge */
681   m68k_reset_func reset_instr_callback;         /* Called when a RESET instruction is encountered */
682   m68k_cmpild_func cmpild_instr_callback;       /* Called when a CMPI.L #v, Dn instruction is encountered */
683   m68k_rte_func rte_instr_callback;             /* Called when a RTE instruction is encountered */
684   m68k_tas_func tas_instr_callback;             /* Called when a TAS instruction is encountered, allows / disallows writeback */
685
686   legacy_cpu_device *device;
687   address_space *program;
688   m68k_memory_interface memory;
689   offs_t encrypted_start;
690   offs_t encrypted_end;
691
692   UINT32      iotemp;
693
694   /* save state data */
695   UINT16 save_sr;
696   UINT8 save_stopped;
697   UINT8 save_halted;
698
699   /* PMMU registers */
700   UINT32 mmu_crp_aptr, mmu_crp_limit;
701   UINT32 mmu_srp_aptr, mmu_srp_limit;
702   UINT32 mmu_urp_aptr;    /* 040 only */
703   UINT32 mmu_tc;
704   UINT16 mmu_sr;
705   UINT32 mmu_sr_040;
706   UINT32 mmu_atc_tag[MMU_ATC_ENTRIES], mmu_atc_data[MMU_ATC_ENTRIES];
707   UINT32 mmu_atc_rr;
708   UINT32 mmu_tt0, mmu_tt1;
709   UINT32 mmu_itt0, mmu_itt1, mmu_dtt0, mmu_dtt1;
710   UINT32 mmu_acr0, mmu_acr1, mmu_acr2, mmu_acr3;
711
712   UINT16 mmu_tmp_sr;      /* temporary hack: status code for ptest and to handle write protection */
713   UINT16 mmu_tmp_fc;      /* temporary hack: function code for the mmu (moves) */
714   UINT16 mmu_tmp_rw;      /* temporary hack: read/write (1/0) for the mmu */
715   UINT32 mmu_tmp_buserror_address;   /* temporary hack: (first) bus error address */
716   UINT16 mmu_tmp_buserror_occurred;  /* temporary hack: flag that bus error has occurred from mmu */
717   UINT16 mmu_tmp_buserror_fc;   /* temporary hack: (first) bus error fc */
718   UINT16 mmu_tmp_buserror_rw;   /* temporary hack: (first) bus error rw */
719
720   UINT32 ic_address[M68K_IC_SIZE];   /* instruction cache address data */
721   UINT16 ic_data[M68K_IC_SIZE];      /* instruction cache content data */
722
723   /* 68307 peripheral modules */
724   m68307_sim*    m68307SIM;
725   m68307_mbus*   m68307MBUS;
726   m68307_serial* m68307SERIAL;
727   m68307_timer*  m68307TIMER;
728
729   UINT16 m68307_base;
730   UINT16 m68307_scrhigh;
731   UINT16 m68307_scrlow;
732
733   int m68307_currentcs;
734
735   /* 68340 peripheral modules */
736   m68340_sim*    m68340SIM;
737   m68340_dma*    m68340DMA;
738   m68340_serial* m68340SERIAL;
739   m68340_timer*  m68340TIMER;
740
741   UINT32 m68340_base;
742
743
744   /* 68308 / 68340 internal address map */
745   address_space *internal;
746
747   /* callbacks for internal ports */
748   m68307_porta_read_callback m_m68307_porta_r;
749   m68307_porta_write_callback m_m68307_porta_w;
750   m68307_portb_read_callback m_m68307_portb_r;
751   m68307_portb_write_callback m_m68307_portb_w;
752
753
754
755   /* external instruction hook (does not depend on debug mode) */
756   typedef int (*instruction_hook_t)(device_t *device, offs_t curpc);
757   instruction_hook_t instruction_hook;
758
759487   #define OPCODE_PROTOTYPES
760488   #include "m68kops.h"
761489   #undef OPCODE_PROTOTYPES
762490};
763491
764492
765INLINE m68ki_cpu_core *m68k_get_safe_token(device_t *device)
766{
767   assert(device != NULL);
768   assert(device->type() == M68000 ||
769         device->type() == M68301 ||
770         device->type() == M68307 ||
771         device->type() == M68008 ||
772         device->type() == M68008PLCC ||
773         device->type() == M68010 ||
774         device->type() == M68EC020 ||
775         device->type() == M68020 ||
776         device->type() == M68020HMMU ||
777         device->type() == M68020PMMU ||
778         device->type() == M68EC030 ||
779         device->type() == M68030 ||
780         device->type() == M68EC040 ||
781         device->type() == M68040 ||
782         device->type() == SCC68070 ||
783         device->type() == MCF5206E ||
784         device->type() == M68340);
785   return (m68ki_cpu_core *)downcast<legacy_cpu_device *>(device)->token();
786}
787493
788494extern const UINT8    m68ki_shift_8_table[];
789495extern const UINT16   m68ki_shift_16_table[];
r23920r23921
792498extern const UINT8    m68ki_ea_idx_cycle_table[];
793499
794500/* Read data immediately after the program counter */
795INLINE UINT32 m68ki_read_imm_16(m68ki_cpu_core *m68k);
796INLINE UINT32 m68ki_read_imm_32(m68ki_cpu_core *m68k);
501INLINE UINT32 m68ki_read_imm_16(m68000_base_device *m68k);
502INLINE UINT32 m68ki_read_imm_32(m68000_base_device *m68k);
797503
798504/* Read data with specific function code */
799INLINE UINT32 m68ki_read_8_fc  (m68ki_cpu_core *m68k, UINT32 address, UINT32 fc);
800INLINE UINT32 m68ki_read_16_fc (m68ki_cpu_core *m68k, UINT32 address, UINT32 fc);
801INLINE UINT32 m68ki_read_32_fc (m68ki_cpu_core *m68k, UINT32 address, UINT32 fc);
505INLINE UINT32 m68ki_read_8_fc  (m68000_base_device *m68k, UINT32 address, UINT32 fc);
506INLINE UINT32 m68ki_read_16_fc (m68000_base_device *m68k, UINT32 address, UINT32 fc);
507INLINE UINT32 m68ki_read_32_fc (m68000_base_device *m68k, UINT32 address, UINT32 fc);
802508
803509/* Write data with specific function code */
804INLINE void m68ki_write_8_fc (m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value);
805INLINE void m68ki_write_16_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value);
806INLINE void m68ki_write_32_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value);
807INLINE void m68ki_write_32_pd_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value);
510INLINE void m68ki_write_8_fc (m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value);
511INLINE void m68ki_write_16_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value);
512INLINE void m68ki_write_32_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value);
513INLINE void m68ki_write_32_pd_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value);
808514
809515/* Indexed and PC-relative ea fetching */
810INLINE UINT32 m68ki_get_ea_pcdi(m68ki_cpu_core *m68k);
811INLINE UINT32 m68ki_get_ea_pcix(m68ki_cpu_core *m68k);
812INLINE UINT32 m68ki_get_ea_ix(m68ki_cpu_core *m68k, UINT32 An);
516INLINE UINT32 m68ki_get_ea_pcdi(m68000_base_device *m68k);
517INLINE UINT32 m68ki_get_ea_pcix(m68000_base_device *m68k);
518INLINE UINT32 m68ki_get_ea_ix(m68000_base_device *m68k, UINT32 An);
813519
814520/* Operand fetching */
815INLINE UINT32 OPER_AY_AI_8(m68ki_cpu_core *m68k);
816INLINE UINT32 OPER_AY_AI_16(m68ki_cpu_core *m68k);
817INLINE UINT32 OPER_AY_AI_32(m68ki_cpu_core *m68k);
818INLINE UINT32 OPER_AY_PI_8(m68ki_cpu_core *m68k);
819INLINE UINT32 OPER_AY_PI_16(m68ki_cpu_core *m68k);
820INLINE UINT32 OPER_AY_PI_32(m68ki_cpu_core *m68k);
821INLINE UINT32 OPER_AY_PD_8(m68ki_cpu_core *m68k);
822INLINE UINT32 OPER_AY_PD_16(m68ki_cpu_core *m68k);
823INLINE UINT32 OPER_AY_PD_32(m68ki_cpu_core *m68k);
824INLINE UINT32 OPER_AY_DI_8(m68ki_cpu_core *m68k);
825INLINE UINT32 OPER_AY_DI_16(m68ki_cpu_core *m68k);
826INLINE UINT32 OPER_AY_DI_32(m68ki_cpu_core *m68k);
827INLINE UINT32 OPER_AY_IX_8(m68ki_cpu_core *m68k);
828INLINE UINT32 OPER_AY_IX_16(m68ki_cpu_core *m68k);
829INLINE UINT32 OPER_AY_IX_32(m68ki_cpu_core *m68k);
521INLINE UINT32 OPER_AY_AI_8(m68000_base_device *m68k);
522INLINE UINT32 OPER_AY_AI_16(m68000_base_device *m68k);
523INLINE UINT32 OPER_AY_AI_32(m68000_base_device *m68k);
524INLINE UINT32 OPER_AY_PI_8(m68000_base_device *m68k);
525INLINE UINT32 OPER_AY_PI_16(m68000_base_device *m68k);
526INLINE UINT32 OPER_AY_PI_32(m68000_base_device *m68k);
527INLINE UINT32 OPER_AY_PD_8(m68000_base_device *m68k);
528INLINE UINT32 OPER_AY_PD_16(m68000_base_device *m68k);
529INLINE UINT32 OPER_AY_PD_32(m68000_base_device *m68k);
530INLINE UINT32 OPER_AY_DI_8(m68000_base_device *m68k);
531INLINE UINT32 OPER_AY_DI_16(m68000_base_device *m68k);
532INLINE UINT32 OPER_AY_DI_32(m68000_base_device *m68k);
533INLINE UINT32 OPER_AY_IX_8(m68000_base_device *m68k);
534INLINE UINT32 OPER_AY_IX_16(m68000_base_device *m68k);
535INLINE UINT32 OPER_AY_IX_32(m68000_base_device *m68k);
830536
831INLINE UINT32 OPER_AX_AI_8(m68ki_cpu_core *m68k);
832INLINE UINT32 OPER_AX_AI_16(m68ki_cpu_core *m68k);
833INLINE UINT32 OPER_AX_AI_32(m68ki_cpu_core *m68k);
834INLINE UINT32 OPER_AX_PI_8(m68ki_cpu_core *m68k);
835INLINE UINT32 OPER_AX_PI_16(m68ki_cpu_core *m68k);
836INLINE UINT32 OPER_AX_PI_32(m68ki_cpu_core *m68k);
837INLINE UINT32 OPER_AX_PD_8(m68ki_cpu_core *m68k);
838INLINE UINT32 OPER_AX_PD_16(m68ki_cpu_core *m68k);
839INLINE UINT32 OPER_AX_PD_32(m68ki_cpu_core *m68k);
840INLINE UINT32 OPER_AX_DI_8(m68ki_cpu_core *m68k);
841INLINE UINT32 OPER_AX_DI_16(m68ki_cpu_core *m68k);
842INLINE UINT32 OPER_AX_DI_32(m68ki_cpu_core *m68k);
843INLINE UINT32 OPER_AX_IX_8(m68ki_cpu_core *m68k);
844INLINE UINT32 OPER_AX_IX_16(m68ki_cpu_core *m68k);
845INLINE UINT32 OPER_AX_IX_32(m68ki_cpu_core *m68k);
537INLINE UINT32 OPER_AX_AI_8(m68000_base_device *m68k);
538INLINE UINT32 OPER_AX_AI_16(m68000_base_device *m68k);
539INLINE UINT32 OPER_AX_AI_32(m68000_base_device *m68k);
540INLINE UINT32 OPER_AX_PI_8(m68000_base_device *m68k);
541INLINE UINT32 OPER_AX_PI_16(m68000_base_device *m68k);
542INLINE UINT32 OPER_AX_PI_32(m68000_base_device *m68k);
543INLINE UINT32 OPER_AX_PD_8(m68000_base_device *m68k);
544INLINE UINT32 OPER_AX_PD_16(m68000_base_device *m68k);
545INLINE UINT32 OPER_AX_PD_32(m68000_base_device *m68k);
546INLINE UINT32 OPER_AX_DI_8(m68000_base_device *m68k);
547INLINE UINT32 OPER_AX_DI_16(m68000_base_device *m68k);
548INLINE UINT32 OPER_AX_DI_32(m68000_base_device *m68k);
549INLINE UINT32 OPER_AX_IX_8(m68000_base_device *m68k);
550INLINE UINT32 OPER_AX_IX_16(m68000_base_device *m68k);
551INLINE UINT32 OPER_AX_IX_32(m68000_base_device *m68k);
846552
847INLINE UINT32 OPER_A7_PI_8(m68ki_cpu_core *m68k);
848INLINE UINT32 OPER_A7_PD_8(m68ki_cpu_core *m68k);
553INLINE UINT32 OPER_A7_PI_8(m68000_base_device *m68k);
554INLINE UINT32 OPER_A7_PD_8(m68000_base_device *m68k);
849555
850INLINE UINT32 OPER_AW_8(m68ki_cpu_core *m68k);
851INLINE UINT32 OPER_AW_16(m68ki_cpu_core *m68k);
852INLINE UINT32 OPER_AW_32(m68ki_cpu_core *m68k);
853INLINE UINT32 OPER_AL_8(m68ki_cpu_core *m68k);
854INLINE UINT32 OPER_AL_16(m68ki_cpu_core *m68k);
855INLINE UINT32 OPER_AL_32(m68ki_cpu_core *m68k);
856INLINE UINT32 OPER_PCDI_8(m68ki_cpu_core *m68k);
857INLINE UINT32 OPER_PCDI_16(m68ki_cpu_core *m68k);
858INLINE UINT32 OPER_PCDI_32(m68ki_cpu_core *m68k);
859INLINE UINT32 OPER_PCIX_8(m68ki_cpu_core *m68k);
860INLINE UINT32 OPER_PCIX_16(m68ki_cpu_core *m68k);
861INLINE UINT32 OPER_PCIX_32(m68ki_cpu_core *m68k);
556INLINE UINT32 OPER_AW_8(m68000_base_device *m68k);
557INLINE UINT32 OPER_AW_16(m68000_base_device *m68k);
558INLINE UINT32 OPER_AW_32(m68000_base_device *m68k);
559INLINE UINT32 OPER_AL_8(m68000_base_device *m68k);
560INLINE UINT32 OPER_AL_16(m68000_base_device *m68k);
561INLINE UINT32 OPER_AL_32(m68000_base_device *m68k);
562INLINE UINT32 OPER_PCDI_8(m68000_base_device *m68k);
563INLINE UINT32 OPER_PCDI_16(m68000_base_device *m68k);
564INLINE UINT32 OPER_PCDI_32(m68000_base_device *m68k);
565INLINE UINT32 OPER_PCIX_8(m68000_base_device *m68k);
566INLINE UINT32 OPER_PCIX_16(m68000_base_device *m68k);
567INLINE UINT32 OPER_PCIX_32(m68000_base_device *m68k);
862568
863569/* Stack operations */
864INLINE void m68ki_push_16(m68ki_cpu_core *m68k, UINT32 value);
865INLINE void m68ki_push_32(m68ki_cpu_core *m68k, UINT32 value);
866INLINE UINT32 m68ki_pull_16(m68ki_cpu_core *m68k);
867INLINE UINT32 m68ki_pull_32(m68ki_cpu_core *m68k);
570INLINE void m68ki_push_16(m68000_base_device *m68k, UINT32 value);
571INLINE void m68ki_push_32(m68000_base_device *m68k, UINT32 value);
572INLINE UINT32 m68ki_pull_16(m68000_base_device *m68k);
573INLINE UINT32 m68ki_pull_32(m68000_base_device *m68k);
868574
869575/* Program flow operations */
870INLINE void m68ki_jump(m68ki_cpu_core *m68k, UINT32 new_pc);
871INLINE void m68ki_jump_vector(m68ki_cpu_core *m68k, UINT32 vector);
872INLINE void m68ki_branch_8(m68ki_cpu_core *m68k, UINT32 offset);
873INLINE void m68ki_branch_16(m68ki_cpu_core *m68k, UINT32 offset);
874INLINE void m68ki_branch_32(m68ki_cpu_core *m68k, UINT32 offset);
576INLINE void m68ki_jump(m68000_base_device *m68k, UINT32 new_pc);
577INLINE void m68ki_jump_vector(m68000_base_device *m68k, UINT32 vector);
578INLINE void m68ki_branch_8(m68000_base_device *m68k, UINT32 offset);
579INLINE void m68ki_branch_16(m68000_base_device *m68k, UINT32 offset);
580INLINE void m68ki_branch_32(m68000_base_device *m68k, UINT32 offset);
875581
876582/* Status register operations. */
877INLINE void m68ki_set_s_flag(m68ki_cpu_core *m68k, UINT32 value);            /* Only bit 2 of value should be set (i.e. 4 or 0) */
878INLINE void m68ki_set_sm_flag(m68ki_cpu_core *m68k, UINT32 value);           /* only bits 1 and 2 of value should be set */
879INLINE void m68ki_set_ccr(m68ki_cpu_core *m68k, UINT32 value);               /* set the condition code register */
880INLINE void m68ki_set_sr(m68ki_cpu_core *m68k, UINT32 value);                /* set the status register */
881INLINE void m68ki_set_sr_noint(m68ki_cpu_core *m68k, UINT32 value);          /* set the status register */
583INLINE void m68ki_set_s_flag(m68000_base_device *m68k, UINT32 value);            /* Only bit 2 of value should be set (i.e. 4 or 0) */
584INLINE void m68ki_set_sm_flag(m68000_base_device *m68k, UINT32 value);           /* only bits 1 and 2 of value should be set */
585INLINE void m68ki_set_ccr(m68000_base_device *m68k, UINT32 value);               /* set the condition code register */
586INLINE void m68ki_set_sr(m68000_base_device *m68k, UINT32 value);                /* set the status register */
587INLINE void m68ki_set_sr_noint(m68000_base_device *m68k, UINT32 value);          /* set the status register */
882588
883589/* Exception processing */
884INLINE UINT32 m68ki_init_exception(m68ki_cpu_core *m68k);              /* Initial exception processing */
590INLINE UINT32 m68ki_init_exception(m68000_base_device *m68k);              /* Initial exception processing */
885591
886INLINE void m68ki_stack_frame_3word(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr); /* Stack various frame types */
887INLINE void m68ki_stack_frame_buserr(m68ki_cpu_core *m68k, UINT32 sr);
592INLINE void m68ki_stack_frame_3word(m68000_base_device *m68k, UINT32 pc, UINT32 sr); /* Stack various frame types */
593INLINE void m68ki_stack_frame_buserr(m68000_base_device *m68k, UINT32 sr);
888594
889INLINE void m68ki_stack_frame_0000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
890INLINE void m68ki_stack_frame_0001(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
891INLINE void m68ki_stack_frame_0010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector);
892INLINE void m68ki_stack_frame_1000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
893INLINE void m68ki_stack_frame_1010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address);
894INLINE void m68ki_stack_frame_1011(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address);
895INLINE void m68ki_stack_frame_0111(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu);
595INLINE void m68ki_stack_frame_0000(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
596INLINE void m68ki_stack_frame_0001(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
597INLINE void m68ki_stack_frame_0010(m68000_base_device *m68k, UINT32 sr, UINT32 vector);
598INLINE void m68ki_stack_frame_1000(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector);
599INLINE void m68ki_stack_frame_1010(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address);
600INLINE void m68ki_stack_frame_1011(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address);
601INLINE void m68ki_stack_frame_0111(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu);
896602
897INLINE void m68ki_exception_trap(m68ki_cpu_core *m68k, UINT32 vector);
898INLINE void m68ki_exception_trapN(m68ki_cpu_core *m68k, UINT32 vector);
899INLINE void m68ki_exception_trace(m68ki_cpu_core *m68k);
900INLINE void m68ki_exception_privilege_violation(m68ki_cpu_core *m68k);
901INLINE void m68ki_exception_1010(m68ki_cpu_core *m68k);
902INLINE void m68ki_exception_1111(m68ki_cpu_core *m68k);
903INLINE void m68ki_exception_illegal(m68ki_cpu_core *m68k);
904INLINE void m68ki_exception_format_error(m68ki_cpu_core *m68k);
905INLINE void m68ki_exception_address_error(m68ki_cpu_core *m68k);
906INLINE void m68ki_exception_interrupt(m68ki_cpu_core *m68k, UINT32 int_level);
907INLINE void m68ki_check_interrupts(m68ki_cpu_core *m68k);            /* ASG: check for interrupts */
603INLINE void m68ki_exception_trap(m68000_base_device *m68k, UINT32 vector);
604INLINE void m68ki_exception_trapN(m68000_base_device *m68k, UINT32 vector);
605INLINE void m68ki_exception_trace(m68000_base_device *m68k);
606INLINE void m68ki_exception_privilege_violation(m68000_base_device *m68k);
607INLINE void m68ki_exception_1010(m68000_base_device *m68k);
608INLINE void m68ki_exception_1111(m68000_base_device *m68k);
609INLINE void m68ki_exception_illegal(m68000_base_device *m68k);
610INLINE void m68ki_exception_format_error(m68000_base_device *m68k);
611INLINE void m68ki_exception_address_error(m68000_base_device *m68k);
908612
613INLINE void m68ki_check_interrupts(m68000_base_device *m68k);            /* ASG: check for interrupts */
614
909615/* quick disassembly (used for logging) */
910616char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type);
911617
r23920r23921
915621/* ======================================================================== */
916622
917623
918INLINE unsigned int m68k_read_immediate_32(m68ki_cpu_core *m68k, unsigned int address)
624INLINE unsigned int m68k_read_immediate_32(m68000_base_device *m68k, unsigned int address)
919625{
920   return (m68k->memory.readimm16(address) << 16) | m68k->memory.readimm16(address + 2);
626   return (m68k->/*memory.*/readimm16(address) << 16) | m68k->/*memory.*/readimm16(address + 2);
921627}
922628
923INLINE unsigned int m68k_read_pcrelative_8(m68ki_cpu_core *m68k, unsigned int address)
629INLINE unsigned int m68k_read_pcrelative_8(m68000_base_device *m68k, unsigned int address)
924630{
925631   if (address >= m68k->encrypted_start && address < m68k->encrypted_end)
926      return ((m68k->memory.readimm16(address&~1)>>(8*(1-(address & 1))))&0xff);
632      return ((m68k->/*memory.*/readimm16(address&~1)>>(8*(1-(address & 1))))&0xff);
927633
928   return m68k->memory.read8(address);
634   return m68k->/*memory.*/read8(address);
929635}
930636
931INLINE unsigned int m68k_read_pcrelative_16(m68ki_cpu_core *m68k, unsigned int address)
637INLINE unsigned int m68k_read_pcrelative_16(m68000_base_device *m68k, unsigned int address)
932638{
933639   if (address >= m68k->encrypted_start && address < m68k->encrypted_end)
934      return m68k->memory.readimm16(address);
640      return m68k->/*memory.*/readimm16(address);
935641
936   return m68k->memory.read16(address);
642   return m68k->/*memory.*/read16(address);
937643}
938644
939INLINE unsigned int m68k_read_pcrelative_32(m68ki_cpu_core *m68k, unsigned int address)
645INLINE unsigned int m68k_read_pcrelative_32(m68000_base_device *m68k, unsigned int address)
940646{
941647   if (address >= m68k->encrypted_start && address < m68k->encrypted_end)
942648      return m68k_read_immediate_32(m68k, address);
943649
944   return m68k->memory.read32(address);
650   return m68k->/*memory.*/read32(address);
945651}
946652
947653
r23920r23921
950656 * A real 68k first writes the high word to [address+2], and then writes the
951657 * low word to [address].
952658 */
953INLINE void m68kx_write_memory_32_pd(m68ki_cpu_core *m68k, unsigned int address, unsigned int value)
659INLINE void m68kx_write_memory_32_pd(m68000_base_device *m68k, unsigned int address, unsigned int value)
954660{
955   m68k->memory.write16(address+2, value>>16);
956   m68k->memory.write16(address, value&0xffff);
661   m68k->/*memory.*/write16(address+2, value>>16);
662   m68k->/*memory.*/write16(address, value&0xffff);
957663}
958664
959665
960666/* ---------------------------- Read Immediate ---------------------------- */
961667
962668// clear the instruction cache
963INLINE void m68ki_ic_clear(m68ki_cpu_core *m68k)
669INLINE void m68ki_ic_clear(m68000_base_device *m68k)
964670{
965671   int i;
966672   for (i=0; i< M68K_IC_SIZE; i++) {
r23920r23921
970676
971677// read immediate word using the instruction cache
972678
973INLINE UINT32 m68ki_ic_readimm16(m68ki_cpu_core *m68k, UINT32 address)
679INLINE UINT32 m68ki_ic_readimm16(m68000_base_device *m68k, UINT32 address)
974680{
975681/*  if(CPU_TYPE_IS_EC020_PLUS(m68k->cpu_type) && (m68k->cacr & M68K_CACR_EI))
976682    {
r23920r23921
992698    }
993699    else*/
994700   {
995      return m68k->memory.readimm16(address);
701      return m68k->/*memory.*/readimm16(address);
996702   }
997703
998704   // this can't happen, but Apple GCC insists
r23920r23921
1002708/* Handles all immediate reads, does address error check, function code setting,
1003709 * and prefetching if they are enabled in m68kconf.h
1004710 */
1005INLINE UINT32 m68ki_read_imm_16(m68ki_cpu_core *m68k)
711INLINE UINT32 m68ki_read_imm_16(m68000_base_device *m68k)
1006712{
1007713   UINT32 result;
1008714
r23920r23921
1029735   return result;
1030736}
1031737
1032INLINE UINT32 m68ki_read_imm_32(m68ki_cpu_core *m68k)
738INLINE UINT32 m68ki_read_imm_32(m68000_base_device *m68k)
1033739{
1034740   UINT32 temp_val;
1035741
r23920r23921
1066772 * These functions will also check for address error and set the function
1067773 * code if they are enabled in m68kconf.h.
1068774 */
1069INLINE UINT32 m68ki_read_8_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc)
775INLINE UINT32 m68ki_read_8_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc)
1070776{
1071777   m68k->mmu_tmp_fc = fc;
1072778   m68k->mmu_tmp_rw = 1;
1073   return m68k->memory.read8(address);
779   return m68k->/*memory.*/read8(address);
1074780}
1075INLINE UINT32 m68ki_read_16_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc)
781INLINE UINT32 m68ki_read_16_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc)
1076782{
1077783   if (CPU_TYPE_IS_010_LESS(m68k->cpu_type))
1078784   {
r23920r23921
1080786   }
1081787   m68k->mmu_tmp_fc = fc;
1082788   m68k->mmu_tmp_rw = 1;
1083   return m68k->memory.read16(address);
789   return m68k->/*memory.*/read16(address);
1084790}
1085INLINE UINT32 m68ki_read_32_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc)
791INLINE UINT32 m68ki_read_32_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc)
1086792{
1087793   if (CPU_TYPE_IS_010_LESS(m68k->cpu_type))
1088794   {
r23920r23921
1090796   }
1091797   m68k->mmu_tmp_fc = fc;
1092798   m68k->mmu_tmp_rw = 1;
1093   return m68k->memory.read32(address);
799   return m68k->/*memory.*/read32(address);
1094800}
1095801
1096INLINE void m68ki_write_8_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value)
802INLINE void m68ki_write_8_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value)
1097803{
1098804   m68k->mmu_tmp_fc = fc;
1099805   m68k->mmu_tmp_rw = 0;
1100   m68k->memory.write8(address, value);
806   m68k->/*memory.*/write8(address, value);
1101807}
1102INLINE void m68ki_write_16_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value)
808INLINE void m68ki_write_16_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value)
1103809{
1104810   if (CPU_TYPE_IS_010_LESS(m68k->cpu_type))
1105811   {
r23920r23921
1107813   }
1108814   m68k->mmu_tmp_fc = fc;
1109815   m68k->mmu_tmp_rw = 0;
1110   m68k->memory.write16(address, value);
816   m68k->/*memory.*/write16(address, value);
1111817}
1112INLINE void m68ki_write_32_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value)
818INLINE void m68ki_write_32_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value)
1113819{
1114820   if (CPU_TYPE_IS_010_LESS(m68k->cpu_type))
1115821   {
r23920r23921
1117823   }
1118824   m68k->mmu_tmp_fc = fc;
1119825   m68k->mmu_tmp_rw = 0;
1120   m68k->memory.write32(address, value);
826   m68k->/*memory.*/write32(address, value);
1121827}
1122828
1123829/* Special call to simulate undocumented 68k behavior when move.l with a
r23920r23921
1125831 * A real 68k first writes the high word to [address+2], and then writes the
1126832 * low word to [address].
1127833 */
1128INLINE void m68ki_write_32_pd_fc(m68ki_cpu_core *m68k, UINT32 address, UINT32 fc, UINT32 value)
834INLINE void m68ki_write_32_pd_fc(m68000_base_device *m68k, UINT32 address, UINT32 fc, UINT32 value)
1129835{
1130836   if (CPU_TYPE_IS_010_LESS(m68k->cpu_type))
1131837   {
r23920r23921
1133839   }
1134840   m68k->mmu_tmp_fc = fc;
1135841   m68k->mmu_tmp_rw = 0;
1136   m68k->memory.write16(address+2, value>>16);
1137   m68k->memory.write16(address, value&0xffff);
842   m68k->/*memory.*/write16(address+2, value>>16);
843   m68k->/*memory.*/write16(address, value&0xffff);
1138844}
1139845
1140846
r23920r23921
1143849/* The program counter relative addressing modes cause operands to be
1144850 * retrieved from program space, not data space.
1145851 */
1146INLINE UINT32 m68ki_get_ea_pcdi(m68ki_cpu_core *m68k)
852INLINE UINT32 m68ki_get_ea_pcdi(m68000_base_device *m68k)
1147853{
1148854   UINT32 old_pc = REG_PC(m68k);
1149855   return old_pc + MAKE_INT_16(m68ki_read_imm_16(m68k));
1150856}
1151857
1152858
1153INLINE UINT32 m68ki_get_ea_pcix(m68ki_cpu_core *m68k)
859INLINE UINT32 m68ki_get_ea_pcix(m68000_base_device *m68k)
1154860{
1155861   return m68ki_get_ea_ix(m68k, REG_PC(m68k));
1156862}
r23920r23921
1197903 * 1  011  mem indir with long outer
1198904 * 1  100-111  reserved
1199905 */
1200INLINE UINT32 m68ki_get_ea_ix(m68ki_cpu_core *m68k, UINT32 An)
906INLINE UINT32 m68ki_get_ea_ix(m68000_base_device *m68k, UINT32 An)
1201907{
1202908   /* An = base register */
1203909   UINT32 extension = m68ki_read_imm_16(m68k);
r23920r23921
1270976
1271977
1272978/* Fetch operands */
1273INLINE UINT32 OPER_AY_AI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AY_AI_8(m68k);  return m68ki_read_8(m68k, ea); }
1274INLINE UINT32 OPER_AY_AI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_AI_16(m68k); return m68ki_read_16(m68k, ea);}
1275INLINE UINT32 OPER_AY_AI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_AI_32(m68k); return m68ki_read_32(m68k, ea);}
1276INLINE UINT32 OPER_AY_PI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AY_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
1277INLINE UINT32 OPER_AY_PI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_PI_16(m68k); return m68ki_read_16(m68k, ea);}
1278INLINE UINT32 OPER_AY_PI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_PI_32(m68k); return m68ki_read_32(m68k, ea);}
1279INLINE UINT32 OPER_AY_PD_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AY_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
1280INLINE UINT32 OPER_AY_PD_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_PD_16(m68k); return m68ki_read_16(m68k, ea);}
1281INLINE UINT32 OPER_AY_PD_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_PD_32(m68k); return m68ki_read_32(m68k, ea);}
1282INLINE UINT32 OPER_AY_DI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AY_DI_8(m68k);  return m68ki_read_8(m68k, ea); }
1283INLINE UINT32 OPER_AY_DI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_DI_16(m68k); return m68ki_read_16(m68k, ea);}
1284INLINE UINT32 OPER_AY_DI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_DI_32(m68k); return m68ki_read_32(m68k, ea);}
1285INLINE UINT32 OPER_AY_IX_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AY_IX_8(m68k);  return m68ki_read_8(m68k, ea); }
1286INLINE UINT32 OPER_AY_IX_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_IX_16(m68k); return m68ki_read_16(m68k, ea);}
1287INLINE UINT32 OPER_AY_IX_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AY_IX_32(m68k); return m68ki_read_32(m68k, ea);}
979INLINE UINT32 OPER_AY_AI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AY_AI_8(m68k);  return m68ki_read_8(m68k, ea); }
980INLINE UINT32 OPER_AY_AI_16(m68000_base_device *m68k) {UINT32 ea = EA_AY_AI_16(m68k); return m68ki_read_16(m68k, ea);}
981INLINE UINT32 OPER_AY_AI_32(m68000_base_device *m68k) {UINT32 ea = EA_AY_AI_32(m68k); return m68ki_read_32(m68k, ea);}
982INLINE UINT32 OPER_AY_PI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AY_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
983INLINE UINT32 OPER_AY_PI_16(m68000_base_device *m68k) {UINT32 ea = EA_AY_PI_16(m68k); return m68ki_read_16(m68k, ea);}
984INLINE UINT32 OPER_AY_PI_32(m68000_base_device *m68k) {UINT32 ea = EA_AY_PI_32(m68k); return m68ki_read_32(m68k, ea);}
985INLINE UINT32 OPER_AY_PD_8(m68000_base_device *m68k)  {UINT32 ea = EA_AY_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
986INLINE UINT32 OPER_AY_PD_16(m68000_base_device *m68k) {UINT32 ea = EA_AY_PD_16(m68k); return m68ki_read_16(m68k, ea);}
987INLINE UINT32 OPER_AY_PD_32(m68000_base_device *m68k) {UINT32 ea = EA_AY_PD_32(m68k); return m68ki_read_32(m68k, ea);}
988INLINE UINT32 OPER_AY_DI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AY_DI_8(m68k);  return m68ki_read_8(m68k, ea); }
989INLINE UINT32 OPER_AY_DI_16(m68000_base_device *m68k) {UINT32 ea = EA_AY_DI_16(m68k); return m68ki_read_16(m68k, ea);}
990INLINE UINT32 OPER_AY_DI_32(m68000_base_device *m68k) {UINT32 ea = EA_AY_DI_32(m68k); return m68ki_read_32(m68k, ea);}
991INLINE UINT32 OPER_AY_IX_8(m68000_base_device *m68k)  {UINT32 ea = EA_AY_IX_8(m68k);  return m68ki_read_8(m68k, ea); }
992INLINE UINT32 OPER_AY_IX_16(m68000_base_device *m68k) {UINT32 ea = EA_AY_IX_16(m68k); return m68ki_read_16(m68k, ea);}
993INLINE UINT32 OPER_AY_IX_32(m68000_base_device *m68k) {UINT32 ea = EA_AY_IX_32(m68k); return m68ki_read_32(m68k, ea);}
1288994
1289INLINE UINT32 OPER_AX_AI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AX_AI_8(m68k);  return m68ki_read_8(m68k, ea); }
1290INLINE UINT32 OPER_AX_AI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_AI_16(m68k); return m68ki_read_16(m68k, ea);}
1291INLINE UINT32 OPER_AX_AI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_AI_32(m68k); return m68ki_read_32(m68k, ea);}
1292INLINE UINT32 OPER_AX_PI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AX_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
1293INLINE UINT32 OPER_AX_PI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_PI_16(m68k); return m68ki_read_16(m68k, ea);}
1294INLINE UINT32 OPER_AX_PI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_PI_32(m68k); return m68ki_read_32(m68k, ea);}
1295INLINE UINT32 OPER_AX_PD_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AX_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
1296INLINE UINT32 OPER_AX_PD_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_PD_16(m68k); return m68ki_read_16(m68k, ea);}
1297INLINE UINT32 OPER_AX_PD_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_PD_32(m68k); return m68ki_read_32(m68k, ea);}
1298INLINE UINT32 OPER_AX_DI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AX_DI_8(m68k);  return m68ki_read_8(m68k, ea); }
1299INLINE UINT32 OPER_AX_DI_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_DI_16(m68k); return m68ki_read_16(m68k, ea);}
1300INLINE UINT32 OPER_AX_DI_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_DI_32(m68k); return m68ki_read_32(m68k, ea);}
1301INLINE UINT32 OPER_AX_IX_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_AX_IX_8(m68k);  return m68ki_read_8(m68k, ea); }
1302INLINE UINT32 OPER_AX_IX_16(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_IX_16(m68k); return m68ki_read_16(m68k, ea);}
1303INLINE UINT32 OPER_AX_IX_32(m68ki_cpu_core *m68k) {UINT32 ea = EA_AX_IX_32(m68k); return m68ki_read_32(m68k, ea);}
995INLINE UINT32 OPER_AX_AI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AX_AI_8(m68k);  return m68ki_read_8(m68k, ea); }
996INLINE UINT32 OPER_AX_AI_16(m68000_base_device *m68k) {UINT32 ea = EA_AX_AI_16(m68k); return m68ki_read_16(m68k, ea);}
997INLINE UINT32 OPER_AX_AI_32(m68000_base_device *m68k) {UINT32 ea = EA_AX_AI_32(m68k); return m68ki_read_32(m68k, ea);}
998INLINE UINT32 OPER_AX_PI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AX_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
999INLINE UINT32 OPER_AX_PI_16(m68000_base_device *m68k) {UINT32 ea = EA_AX_PI_16(m68k); return m68ki_read_16(m68k, ea);}
1000INLINE UINT32 OPER_AX_PI_32(m68000_base_device *m68k) {UINT32 ea = EA_AX_PI_32(m68k); return m68ki_read_32(m68k, ea);}
1001INLINE UINT32 OPER_AX_PD_8(m68000_base_device *m68k)  {UINT32 ea = EA_AX_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
1002INLINE UINT32 OPER_AX_PD_16(m68000_base_device *m68k) {UINT32 ea = EA_AX_PD_16(m68k); return m68ki_read_16(m68k, ea);}
1003INLINE UINT32 OPER_AX_PD_32(m68000_base_device *m68k) {UINT32 ea = EA_AX_PD_32(m68k); return m68ki_read_32(m68k, ea);}
1004INLINE UINT32 OPER_AX_DI_8(m68000_base_device *m68k)  {UINT32 ea = EA_AX_DI_8(m68k);  return m68ki_read_8(m68k, ea); }
1005INLINE UINT32 OPER_AX_DI_16(m68000_base_device *m68k) {UINT32 ea = EA_AX_DI_16(m68k); return m68ki_read_16(m68k, ea);}
1006INLINE UINT32 OPER_AX_DI_32(m68000_base_device *m68k) {UINT32 ea = EA_AX_DI_32(m68k); return m68ki_read_32(m68k, ea);}
1007INLINE UINT32 OPER_AX_IX_8(m68000_base_device *m68k)  {UINT32 ea = EA_AX_IX_8(m68k);  return m68ki_read_8(m68k, ea); }
1008INLINE UINT32 OPER_AX_IX_16(m68000_base_device *m68k) {UINT32 ea = EA_AX_IX_16(m68k); return m68ki_read_16(m68k, ea);}
1009INLINE UINT32 OPER_AX_IX_32(m68000_base_device *m68k) {UINT32 ea = EA_AX_IX_32(m68k); return m68ki_read_32(m68k, ea);}
13041010
1305INLINE UINT32 OPER_A7_PI_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_A7_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
1306INLINE UINT32 OPER_A7_PD_8(m68ki_cpu_core *m68k)  {UINT32 ea = EA_A7_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
1011INLINE UINT32 OPER_A7_PI_8(m68000_base_device *m68k)  {UINT32 ea = EA_A7_PI_8(m68k);  return m68ki_read_8(m68k, ea); }
1012INLINE UINT32 OPER_A7_PD_8(m68000_base_device *m68k)  {UINT32 ea = EA_A7_PD_8(m68k);  return m68ki_read_8(m68k, ea); }
13071013
1308INLINE UINT32 OPER_AW_8(m68ki_cpu_core *m68k)     {UINT32 ea = EA_AW_8(m68k);     return m68ki_read_8(m68k, ea); }
1309INLINE UINT32 OPER_AW_16(m68ki_cpu_core *m68k)    {UINT32 ea = EA_AW_16(m68k);    return m68ki_read_16(m68k, ea);}
1310INLINE UINT32 OPER_AW_32(m68ki_cpu_core *m68k)    {UINT32 ea = EA_AW_32(m68k);    return m68ki_read_32(m68k, ea);}
1311INLINE UINT32 OPER_AL_8(m68ki_cpu_core *m68k)     {UINT32 ea = EA_AL_8(m68k);     return m68ki_read_8(m68k, ea); }
1312INLINE UINT32 OPER_AL_16(m68ki_cpu_core *m68k)    {UINT32 ea = EA_AL_16(m68k);    return m68ki_read_16(m68k, ea);}
1313INLINE UINT32 OPER_AL_32(m68ki_cpu_core *m68k)    {UINT32 ea = EA_AL_32(m68k);    return m68ki_read_32(m68k, ea);}
1314INLINE UINT32 OPER_PCDI_8(m68ki_cpu_core *m68k)   {UINT32 ea = EA_PCDI_8(m68k);   return m68ki_read_pcrel_8(m68k, ea); }
1315INLINE UINT32 OPER_PCDI_16(m68ki_cpu_core *m68k)  {UINT32 ea = EA_PCDI_16(m68k);  return m68ki_read_pcrel_16(m68k, ea);}
1316INLINE UINT32 OPER_PCDI_32(m68ki_cpu_core *m68k)  {UINT32 ea = EA_PCDI_32(m68k);  return m68ki_read_pcrel_32(m68k, ea);}
1317INLINE UINT32 OPER_PCIX_8(m68ki_cpu_core *m68k)   {UINT32 ea = EA_PCIX_8(m68k);   return m68ki_read_pcrel_8(m68k, ea); }
1318INLINE UINT32 OPER_PCIX_16(m68ki_cpu_core *m68k)  {UINT32 ea = EA_PCIX_16(m68k);  return m68ki_read_pcrel_16(m68k, ea);}
1319INLINE UINT32 OPER_PCIX_32(m68ki_cpu_core *m68k)  {UINT32 ea = EA_PCIX_32(m68k);  return m68ki_read_pcrel_32(m68k, ea);}
1014INLINE UINT32 OPER_AW_8(m68000_base_device *m68k)     {UINT32 ea = EA_AW_8(m68k);     return m68ki_read_8(m68k, ea); }
1015INLINE UINT32 OPER_AW_16(m68000_base_device *m68k)    {UINT32 ea = EA_AW_16(m68k);    return m68ki_read_16(m68k, ea);}
1016INLINE UINT32 OPER_AW_32(m68000_base_device *m68k)    {UINT32 ea = EA_AW_32(m68k);    return m68ki_read_32(m68k, ea);}
1017INLINE UINT32 OPER_AL_8(m68000_base_device *m68k)     {UINT32 ea = EA_AL_8(m68k);     return m68ki_read_8(m68k, ea); }
1018INLINE UINT32 OPER_AL_16(m68000_base_device *m68k)    {UINT32 ea = EA_AL_16(m68k);    return m68ki_read_16(m68k, ea);}
1019INLINE UINT32 OPER_AL_32(m68000_base_device *m68k)    {UINT32 ea = EA_AL_32(m68k);    return m68ki_read_32(m68k, ea);}
1020INLINE UINT32 OPER_PCDI_8(m68000_base_device *m68k)   {UINT32 ea = EA_PCDI_8(m68k);   return m68ki_read_pcrel_8(m68k, ea); }
1021INLINE UINT32 OPER_PCDI_16(m68000_base_device *m68k)  {UINT32 ea = EA_PCDI_16(m68k);  return m68ki_read_pcrel_16(m68k, ea);}
1022INLINE UINT32 OPER_PCDI_32(m68000_base_device *m68k)  {UINT32 ea = EA_PCDI_32(m68k);  return m68ki_read_pcrel_32(m68k, ea);}
1023INLINE UINT32 OPER_PCIX_8(m68000_base_device *m68k)   {UINT32 ea = EA_PCIX_8(m68k);   return m68ki_read_pcrel_8(m68k, ea); }
1024INLINE UINT32 OPER_PCIX_16(m68000_base_device *m68k)  {UINT32 ea = EA_PCIX_16(m68k);  return m68ki_read_pcrel_16(m68k, ea);}
1025INLINE UINT32 OPER_PCIX_32(m68000_base_device *m68k)  {UINT32 ea = EA_PCIX_32(m68k);  return m68ki_read_pcrel_32(m68k, ea);}
13201026
13211027
13221028
13231029/* ---------------------------- Stack Functions --------------------------- */
13241030
13251031/* Push/pull data from the stack */
1326INLINE void m68ki_push_16(m68ki_cpu_core *m68k, UINT32 value)
1032INLINE void m68ki_push_16(m68000_base_device *m68k, UINT32 value)
13271033{
13281034   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 2);
13291035   m68ki_write_16(m68k, REG_SP(m68k), value);
13301036}
13311037
1332INLINE void m68ki_push_32(m68ki_cpu_core *m68k, UINT32 value)
1038INLINE void m68ki_push_32(m68000_base_device *m68k, UINT32 value)
13331039{
13341040   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 4);
13351041   m68ki_write_32(m68k, REG_SP(m68k), value);
13361042}
13371043
1338INLINE UINT32 m68ki_pull_16(m68ki_cpu_core *m68k)
1044INLINE UINT32 m68ki_pull_16(m68000_base_device *m68k)
13391045{
13401046   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 2);
13411047   return m68ki_read_16(m68k, REG_SP(m68k)-2);
13421048}
13431049
1344INLINE UINT32 m68ki_pull_32(m68ki_cpu_core *m68k)
1050INLINE UINT32 m68ki_pull_32(m68000_base_device *m68k)
13451051{
13461052   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 4);
13471053   return m68ki_read_32(m68k, REG_SP(m68k)-4);
r23920r23921
13511057/* Increment/decrement the stack as if doing a push/pull but
13521058 * don't do any memory access.
13531059 */
1354INLINE void m68ki_fake_push_16(m68ki_cpu_core *m68k)
1060INLINE void m68ki_fake_push_16(m68000_base_device *m68k)
13551061{
13561062   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 2);
13571063}
13581064
1359INLINE void m68ki_fake_push_32(m68ki_cpu_core *m68k)
1065INLINE void m68ki_fake_push_32(m68000_base_device *m68k)
13601066{
13611067   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) - 4);
13621068}
13631069
1364INLINE void m68ki_fake_pull_16(m68ki_cpu_core *m68k)
1070INLINE void m68ki_fake_pull_16(m68000_base_device *m68k)
13651071{
13661072   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 2);
13671073}
13681074
1369INLINE void m68ki_fake_pull_32(m68ki_cpu_core *m68k)
1075INLINE void m68ki_fake_pull_32(m68000_base_device *m68k)
13701076{
13711077   REG_SP(m68k) = MASK_OUT_ABOVE_32(REG_SP(m68k) + 4);
13721078}
r23920r23921
13781084 * These functions will also call the pc_changed callback if it was enabled
13791085 * in m68kconf.h.
13801086 */
1381INLINE void m68ki_jump(m68ki_cpu_core *m68k, UINT32 new_pc)
1087INLINE void m68ki_jump(m68000_base_device *m68k, UINT32 new_pc)
13821088{
13831089   REG_PC(m68k) = new_pc;
13841090}
13851091
1386INLINE void m68ki_jump_vector(m68ki_cpu_core *m68k, UINT32 vector)
1092INLINE void m68ki_jump_vector(m68000_base_device *m68k, UINT32 vector)
13871093{
13881094   REG_PC(m68k) = (vector<<2) + m68k->vbr;
13891095   REG_PC(m68k) = m68ki_read_data_32(m68k, REG_PC(m68k));
r23920r23921
13951101 * So far I've found no problems with not calling pc_changed for 8 or 16
13961102 * bit branches.
13971103 */
1398INLINE void m68ki_branch_8(m68ki_cpu_core *m68k, UINT32 offset)
1104INLINE void m68ki_branch_8(m68000_base_device *m68k, UINT32 offset)
13991105{
14001106   REG_PC(m68k) += MAKE_INT_8(offset);
14011107}
14021108
1403INLINE void m68ki_branch_16(m68ki_cpu_core *m68k, UINT32 offset)
1109INLINE void m68ki_branch_16(m68000_base_device *m68k, UINT32 offset)
14041110{
14051111   REG_PC(m68k) += MAKE_INT_16(offset);
14061112}
14071113
1408INLINE void m68ki_branch_32(m68ki_cpu_core *m68k, UINT32 offset)
1114INLINE void m68ki_branch_32(m68000_base_device *m68k, UINT32 offset)
14091115{
14101116   REG_PC(m68k) += offset;
14111117}
r23920r23921
14171123/* Set the S flag and change the active stack pointer.
14181124 * Note that value MUST be 4 or 0.
14191125 */
1420INLINE void m68ki_set_s_flag(m68ki_cpu_core *m68k, UINT32 value)
1126INLINE void m68ki_set_s_flag(m68000_base_device *m68k, UINT32 value)
14211127{
14221128   /* Backup the old stack pointer */
14231129   REG_SP_BASE(m68k)[m68k->s_flag | ((m68k->s_flag>>1) & m68k->m_flag)] = REG_SP(m68k);
r23920r23921
14301136/* Set the S and M flags and change the active stack pointer.
14311137 * Note that value MUST be 0, 2, 4, or 6 (bit2 = S, bit1 = M).
14321138 */
1433INLINE void m68ki_set_sm_flag(m68ki_cpu_core *m68k, UINT32 value)
1139INLINE void m68ki_set_sm_flag(m68000_base_device *m68k, UINT32 value)
14341140{
14351141   /* Backup the old stack pointer */
14361142   REG_SP_BASE(m68k)[m68k->s_flag | ((m68k->s_flag>>1) & m68k->m_flag)] = REG_SP(m68k);
r23920r23921
14421148}
14431149
14441150/* Set the S and M flags.  Don't touch the stack pointer. */
1445INLINE void m68ki_set_sm_flag_nosp(m68ki_cpu_core *m68k, UINT32 value)
1151INLINE void m68ki_set_sm_flag_nosp(m68000_base_device *m68k, UINT32 value)
14461152{
14471153   /* Set the S and M flags */
14481154   m68k->s_flag = value & SFLAG_SET;
r23920r23921
14511157
14521158
14531159/* Set the condition code register */
1454INLINE void m68ki_set_ccr(m68ki_cpu_core *m68k, UINT32 value)
1160INLINE void m68ki_set_ccr(m68000_base_device *m68k, UINT32 value)
14551161{
14561162   m68k->x_flag = BIT_4(value)  << 4;
14571163   m68k->n_flag = BIT_3(value)  << 4;
r23920r23921
14611167}
14621168
14631169/* Set the status register but don't check for interrupts */
1464INLINE void m68ki_set_sr_noint(m68ki_cpu_core *m68k, UINT32 value)
1170INLINE void m68ki_set_sr_noint(m68000_base_device *m68k, UINT32 value)
14651171{
14661172   /* Mask out the "unimplemented" bits */
14671173   value &= m68k->sr_mask;
r23920r23921
14771183/* Set the status register but don't check for interrupts nor
14781184 * change the stack pointer
14791185 */
1480INLINE void m68ki_set_sr_noint_nosp(m68ki_cpu_core *m68k, UINT32 value)
1186INLINE void m68ki_set_sr_noint_nosp(m68000_base_device *m68k, UINT32 value)
14811187{
14821188   /* Mask out the "unimplemented" bits */
14831189   value &= m68k->sr_mask;
r23920r23921
14911197}
14921198
14931199/* Set the status register and check for interrupts */
1494INLINE void m68ki_set_sr(m68ki_cpu_core *m68k, UINT32 value)
1200INLINE void m68ki_set_sr(m68000_base_device *m68k, UINT32 value)
14951201{
14961202   m68ki_set_sr_noint(m68k, value);
14971203   m68ki_check_interrupts(m68k);
r23920r23921
15011207/* ------------------------- Exception Processing ------------------------- */
15021208
15031209/* Initiate exception processing */
1504INLINE UINT32 m68ki_init_exception(m68ki_cpu_core *m68k)
1210INLINE UINT32 m68ki_init_exception(m68000_base_device *m68k)
15051211{
15061212   /* Save the old status register */
15071213   UINT32 sr = m68ki_get_sr(m68k);
r23920r23921
15161222}
15171223
15181224/* 3 word stack frame (68000 only) */
1519INLINE void m68ki_stack_frame_3word(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr)
1225INLINE void m68ki_stack_frame_3word(m68000_base_device *m68k, UINT32 pc, UINT32 sr)
15201226{
15211227   m68ki_push_32(m68k, pc);
15221228   m68ki_push_16(m68k, sr);
r23920r23921
15251231/* Format 0 stack frame.
15261232 * This is the standard stack frame for 68010+.
15271233 */
1528INLINE void m68ki_stack_frame_0000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
1234INLINE void m68ki_stack_frame_0000(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
15291235{
15301236   /* Stack a 3-word frame if we are 68000 */
15311237   if(m68k->cpu_type == CPU_TYPE_000 || m68k->cpu_type == CPU_TYPE_008)
r23920r23921
15411247/* Format 1 stack frame (68020).
15421248 * For 68020, this is the 4 word throwaway frame.
15431249 */
1544INLINE void m68ki_stack_frame_0001(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
1250INLINE void m68ki_stack_frame_0001(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
15451251{
15461252   m68ki_push_16(m68k, 0x1000 | (vector<<2));
15471253   m68ki_push_32(m68k, pc);
r23920r23921
15511257/* Format 2 stack frame.
15521258 * This is used only by 68020 for trap exceptions.
15531259 */
1554INLINE void m68ki_stack_frame_0010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector)
1260INLINE void m68ki_stack_frame_0010(m68000_base_device *m68k, UINT32 sr, UINT32 vector)
15551261{
15561262   m68ki_push_32(m68k, REG_PPC(m68k));
15571263   m68ki_push_16(m68k, 0x2000 | (vector<<2));
r23920r23921
15621268
15631269/* Bus error stack frame (68000 only).
15641270 */
1565INLINE void m68ki_stack_frame_buserr(m68ki_cpu_core *m68k, UINT32 sr)
1271INLINE void m68ki_stack_frame_buserr(m68000_base_device *m68k, UINT32 sr)
15661272{
15671273   m68ki_push_32(m68k, REG_PC(m68k));
15681274   m68ki_push_16(m68k, sr);
r23920r23921
15791285/* Format 8 stack frame (68010).
15801286 * 68010 only.  This is the 29 word bus/address error frame.
15811287 */
1582INLINE void m68ki_stack_frame_1000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
1288INLINE void m68ki_stack_frame_1000(m68000_base_device *m68k, UINT32 pc, UINT32 sr, UINT32 vector)
15831289{
15841290   /* VERSION
15851291    * NUMBER
r23920r23921
16331339 * if the error happens at an instruction boundary.
16341340 * PC stacked is address of next instruction.
16351341 */
1636INLINE void m68ki_stack_frame_1010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address)
1342INLINE void m68ki_stack_frame_1010(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address)
16371343{
16381344   int orig_rw = m68k->mmu_tmp_buserror_rw;    // this gets splatted by the following pushes, so save it now
16391345   int orig_fc = m68k->mmu_tmp_buserror_fc;
r23920r23921
16851391 * if the error happens during instruction execution.
16861392 * PC stacked is address of instruction in progress.
16871393 */
1688INLINE void m68ki_stack_frame_1011(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address)
1394INLINE void m68ki_stack_frame_1011(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address)
16891395{
16901396   int orig_rw = m68k->mmu_tmp_buserror_rw;    // this gets splatted by the following pushes, so save it now
16911397   int orig_fc = m68k->mmu_tmp_buserror_fc;
r23920r23921
17591465 * This is used by the 68040 for bus fault and mmu trap
17601466 * 30 words
17611467 */
1762INLINE void m68ki_stack_frame_0111(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu)
1468INLINE void m68ki_stack_frame_0111(m68000_base_device *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu)
17631469{
17641470   int orig_rw = m68k->mmu_tmp_buserror_rw;    // this gets splatted by the following pushes, so save it now
17651471   int orig_fc = m68k->mmu_tmp_buserror_fc;
r23920r23921
18021508/* Used for Group 2 exceptions.
18031509 * These stack a type 2 frame on the 020.
18041510 */
1805INLINE void m68ki_exception_trap(m68ki_cpu_core *m68k, UINT32 vector)
1511INLINE void m68ki_exception_trap(m68000_base_device *m68k, UINT32 vector)
18061512{
18071513   UINT32 sr = m68ki_init_exception(m68k);
18081514
r23920r23921
18181524}
18191525
18201526/* Trap#n stacks a 0 frame but behaves like group2 otherwise */
1821INLINE void m68ki_exception_trapN(m68ki_cpu_core *m68k, UINT32 vector)
1527INLINE void m68ki_exception_trapN(m68000_base_device *m68k, UINT32 vector)
18221528{
18231529   UINT32 sr = m68ki_init_exception(m68k);
18241530   m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, vector);
r23920r23921
18291535}
18301536
18311537/* Exception for trace mode */
1832INLINE void m68ki_exception_trace(m68ki_cpu_core *m68k)
1538INLINE void m68ki_exception_trace(m68000_base_device *m68k)
18331539{
18341540   UINT32 sr = m68ki_init_exception(m68k);
18351541
r23920r23921
18541560}
18551561
18561562/* Exception for privilege violation */
1857INLINE void m68ki_exception_privilege_violation(m68ki_cpu_core *m68k)
1563INLINE void m68ki_exception_privilege_violation(m68000_base_device *m68k)
18581564{
18591565   UINT32 sr = m68ki_init_exception(m68k);
18601566
r23920r23921
18711577}
18721578
18731579/* Exception for A-Line instructions */
1874INLINE void m68ki_exception_1010(m68ki_cpu_core *m68k)
1580INLINE void m68ki_exception_1010(m68000_base_device *m68k)
18751581{
18761582   UINT32 sr;
18771583
r23920r23921
18841590}
18851591
18861592/* Exception for F-Line instructions */
1887INLINE void m68ki_exception_1111(m68ki_cpu_core *m68k)
1593INLINE void m68ki_exception_1111(m68000_base_device *m68k)
18881594{
18891595   UINT32 sr;
18901596
r23920r23921
18971603}
18981604
18991605/* Exception for illegal instructions */
1900INLINE void m68ki_exception_illegal(m68ki_cpu_core *m68k)
1606INLINE void m68ki_exception_illegal(m68000_base_device *m68k)
19011607{
19021608   UINT32 sr;
19031609
r23920r23921
19161622}
19171623
19181624/* Exception for format errror in RTE */
1919INLINE void m68ki_exception_format_error(m68ki_cpu_core *m68k)
1625INLINE void m68ki_exception_format_error(m68000_base_device *m68k)
19201626{
19211627   UINT32 sr = m68ki_init_exception(m68k);
19221628   m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, EXCEPTION_FORMAT_ERROR);
r23920r23921
19271633}
19281634
19291635/* Exception for address error */
1930INLINE void m68ki_exception_address_error(m68ki_cpu_core *m68k)
1636INLINE void m68ki_exception_address_error(m68000_base_device *m68k)
19311637{
19321638   UINT32 sr = m68ki_init_exception(m68k);
19331639
r23920r23921
19371643    */
19381644   if(m68k->run_mode == RUN_MODE_BERR_AERR_RESET)
19391645   {
1940      m68k->memory.read8(0x00ffff01);
1646      m68k->/*memory.*/read8(0x00ffff01);
19411647      m68k->stopped = STOP_LEVEL_HALT;
19421648      return;
19431649   }
r23920r23921
19531659}
19541660
19551661
1956/* Service an interrupt request and start exception processing */
1957INLINE void m68ki_exception_interrupt(m68ki_cpu_core *m68k, UINT32 int_level)
1958{
1959   UINT32 vector;
1960   UINT32 sr;
1961   UINT32 new_pc;
19621662
1963   if(CPU_TYPE_IS_000(m68k->cpu_type))
1964   {
1965      m68k->instr_mode = INSTRUCTION_NO;
1966   }
1967
1968   /* Turn off the stopped state */
1969   m68k->stopped &= ~STOP_LEVEL_STOP;
1970
1971   /* If we are halted, don't do anything */
1972   if(m68k->stopped)
1973      return;
1974
1975   /* Acknowledge the interrupt */
1976   vector = (*m68k->int_ack_callback)(m68k->device, int_level);
1977
1978   /* Get the interrupt vector */
1979   if(vector == M68K_INT_ACK_AUTOVECTOR)
1980      /* Use the autovectors.  This is the most commonly used implementation */
1981      vector = EXCEPTION_INTERRUPT_AUTOVECTOR+int_level;
1982   else if(vector == M68K_INT_ACK_SPURIOUS)
1983      /* Called if no devices respond to the interrupt acknowledge */
1984      vector = EXCEPTION_SPURIOUS_INTERRUPT;
1985   else if(vector > 255)
1986      return;
1987
1988   /* Start exception processing */
1989   sr = m68ki_init_exception(m68k);
1990
1991   /* Set the interrupt mask to the level of the one being serviced */
1992   m68k->int_mask = int_level<<8;
1993
1994   /* Get the new PC */
1995   new_pc = m68ki_read_data_32(m68k, (vector<<2) + m68k->vbr);
1996
1997   /* If vector is uninitialized, call the uninitialized interrupt vector */
1998   if(new_pc == 0)
1999      new_pc = m68ki_read_data_32(m68k, (EXCEPTION_UNINITIALIZED_INTERRUPT<<2) + m68k->vbr);
2000
2001   /* Generate a stack frame */
2002   m68ki_stack_frame_0000(m68k, REG_PC(m68k), sr, vector);
2003   if(m68k->m_flag && CPU_TYPE_IS_EC020_PLUS(m68k->cpu_type))
2004   {
2005      /* Create throwaway frame */
2006      m68ki_set_sm_flag(m68k, m68k->s_flag);  /* clear M */
2007      sr |= 0x2000; /* Same as SR in master stack frame except S is forced high */
2008      m68ki_stack_frame_0001(m68k, REG_PC(m68k), sr, vector);
2009   }
2010
2011   m68ki_jump(m68k, new_pc);
2012
2013   /* Defer cycle counting until later */
2014   m68k->remaining_cycles -= m68k->cyc_exception[vector];
2015}
2016
2017
20181663/* ASG: Check for interrupts */
2019INLINE void m68ki_check_interrupts(m68ki_cpu_core *m68k)
1664INLINE void m68ki_check_interrupts(m68000_base_device *m68k)
20201665{
20211666   if(m68k->nmi_pending)
20221667   {
20231668      m68k->nmi_pending = FALSE;
2024      m68ki_exception_interrupt(m68k, 7);
1669      m68k->m68ki_exception_interrupt(m68k, 7);
20251670   }
20261671   else if(m68k->int_level > m68k->int_mask)
2027      m68ki_exception_interrupt(m68k, m68k->int_level>>8);
1672      m68k->m68ki_exception_interrupt(m68k, m68k->int_level>>8);
20281673}
20291674
20301675
trunk/src/emu/cpu/m68000/68340sim.h
r23920r23921
4141
4242
4343
44DECLARE_READ16_HANDLER( m68340_internal_sim_r );
45DECLARE_WRITE16_HANDLER( m68340_internal_sim_w );
46DECLARE_READ32_HANDLER( m68340_internal_sim_cs_r );
47DECLARE_WRITE32_HANDLER( m68340_internal_sim_cs_w );
48DECLARE_READ8_HANDLER( m68340_internal_sim_ports_r );
49DECLARE_WRITE8_HANDLER( m68340_internal_sim_ports_w );
5044
5145
5246
53
5447class m68340_sim
5548{
5649   public:
trunk/src/emu/cpu/m68000/68340ser.h
r23920r23921
11
2DECLARE_READ32_HANDLER( m68340_internal_serial_r );
3DECLARE_WRITE32_HANDLER( m68340_internal_serial_w );
4
52class m68340_serial
63{
74   public:
trunk/src/emu/cpu/m68000/68307sim.h
r23920r23921
11/* 68307 SIM module */
22
3DECLARE_READ16_HANDLER( m68307_internal_sim_r );
4DECLARE_WRITE16_HANDLER( m68307_internal_sim_w );
3#include "m68000.h"
54
5class m68000_base_device;
6
7
68/* ports */
79#define m68307SIM_PACNT (0x10)
810#define m68307SIM_PADDR (0x12)
r23920r23921
5153
5254   void write_pacnt(UINT16 data, UINT16 mem_mask);
5355   void write_paddr(UINT16 data, UINT16 mem_mask);
54   UINT16 read_padat(address_space &space, UINT16 mem_mask);
55   void write_padat(address_space &space, UINT16 data, UINT16 mem_mask);
56   UINT16 read_padat(m68000_base_device* m68k, address_space &space, UINT16 mem_mask);
57   void write_padat(m68000_base_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask);
5658
5759   void write_pbcnt(UINT16 data, UINT16 mem_mask);
5860   void write_pbddr(UINT16 data, UINT16 mem_mask);
59   UINT16 read_pbdat(address_space &space, UINT16 mem_mask);
60   void write_pbdat(address_space &space, UINT16 data, UINT16 mem_mask);
61   UINT16 read_pbdat(m68000_base_device* m68k, address_space &space, UINT16 mem_mask);
62   void write_pbdat(m68000_base_device* m68k, address_space &space, UINT16 data, UINT16 mem_mask);
6163
6264
6365
trunk/src/emu/cpu/m68000/68307ser.h
r23920r23921
1#include "m68000.h"
12#include "machine/68681.h"
23
34#define m68307SER_UMR1_UMR2  (0x01)
r23920r23921
1718#define m68307SER_UOP1       (0x1d)
1819#define m68307SER_UOP0       (0x1f)
1920
20
21DECLARE_READ8_HANDLER( m68307_internal_serial_r );
22DECLARE_WRITE8_HANDLER( m68307_internal_serial_w );
23
2421class m68307_serial
2522{
2623   public:
trunk/src/emu/cpu/m68000/68307bus.h
r23920r23921
1#include "m68000.h"
2
13#define m68307BUS_MADR (0x01)
24#define m68307BUS_MFDR (0x03)
35#define m68307BUS_MBCR (0x05)
r23920r23921
46#define m68307BUS_MBSR (0x07)
57#define m68307BUS_MBDR (0x09)
68
7DECLARE_READ8_HANDLER( m68307_internal_mbus_r );
8DECLARE_WRITE8_HANDLER( m68307_internal_mbus_w );
99
1010class m68307_mbus
1111{
trunk/src/emu/cpu/m68000/68340dma.c
r23920r23921
44#include "m68kcpu.h"
55
66
7READ32_HANDLER( m68340_internal_dma_r )
7READ32_MEMBER( m68000_base_device::m68340_internal_dma_r )
88{
9   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
9   m68000_base_device *m68k = this;
1010   m68340_dma* dma = m68k->m68340DMA;
1111   assert(dma != NULL);
1212
r23920r23921
1919   return 0x00000000;
2020}
2121
22WRITE32_HANDLER( m68340_internal_dma_w )
22WRITE32_MEMBER( m68000_base_device::m68340_internal_dma_w )
2323{
24   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
24   m68000_base_device *m68k = this;
2525   m68340_dma* dma = m68k->m68340DMA;
2626   assert(dma != NULL);
2727
trunk/src/emu/cpu/m68000/m68kmmu.h
r23920r23921
4747#define M68K_MMU_TC_SRE        0x02000000
4848
4949/* decodes the effective address */
50static UINT32 DECODE_EA_32(m68ki_cpu_core *m68k, int ea)
50static UINT32 DECODE_EA_32(m68000_base_device *m68k, int ea)
5151{
5252   int mode = (ea >> 3) & 0x7;
5353   int reg = (ea & 0x7);
r23920r23921
106106/*
107107    pmmu_atc_add: adds this address to the ATC
108108*/
109void pmmu_atc_add(m68ki_cpu_core *m68k, UINT32 logical, UINT32 physical, int fc)
109void pmmu_atc_add(m68000_base_device *m68k, UINT32 logical, UINT32 physical, int fc)
110110{
111111   int i, found;
112112
r23920r23921
163163
164164    7fff0003 001ffd10 80f05750 is what should load
165165*/
166void pmmu_atc_flush(m68ki_cpu_core *m68k)
166void pmmu_atc_flush(m68000_base_device *m68k)
167167{
168168   int i;
169169   // printf("ATC flush: pc=%08x\n", REG_PPC(m68k));
r23920r23921
177177}
178178
179179
180INLINE UINT32 get_dt2_table_entry(m68ki_cpu_core *m68k, UINT32 tptr, UINT8 ptest)
180INLINE UINT32 get_dt2_table_entry(m68000_base_device *m68k, UINT32 tptr, UINT8 ptest)
181181{
182182   UINT32 tbl_entry = m68k->program->read_dword(tptr);
183183   UINT32 dt = tbl_entry & M68K_MMU_DF_DT;
r23920r23921
199199   return tbl_entry;
200200}
201201
202INLINE UINT32 get_dt3_table_entry(m68ki_cpu_core *m68k, UINT32 tptr, UINT8 fc, UINT8 ptest)
202INLINE UINT32 get_dt3_table_entry(m68000_base_device *m68k, UINT32 tptr, UINT8 fc, UINT8 ptest)
203203{
204204   UINT32 tbl_entry2 = m68k->program->read_dword(tptr);
205205   UINT32 tbl_entry = m68k->program->read_dword(tptr + 4);
r23920r23921
227227/*
228228    pmmu_translate_addr_with_fc: perform 68851/68030-style PMMU address translation
229229*/
230/*INLINE*/ static UINT32 pmmu_translate_addr_with_fc(m68ki_cpu_core *m68k, UINT32 addr_in, UINT8 fc, UINT8 ptest)
230/*INLINE*/ static UINT32 pmmu_translate_addr_with_fc(m68000_base_device *m68k, UINT32 addr_in, UINT8 fc, UINT8 ptest)
231231{
232232   UINT32 addr_out, tbl_entry = 0, tamode = 0, tbmode = 0, tcmode = 0;
233233   UINT32 root_aptr, root_limit, tofs, ps, is, abits, bbits, cbits;
r23920r23921
526526
527527// FC bits: 2 = supervisor, 1 = program, 0 = data
528528// the 68040 is a subset of the 68851 and 68030 PMMUs - the page table sizes are fixed, there is no early termination, etc, etc.
529/*INLINE*/ static UINT32 pmmu_translate_addr_with_fc_040(m68ki_cpu_core *m68k, UINT32 addr_in, UINT8 fc, UINT8 ptest)
529/*INLINE*/ static UINT32 pmmu_translate_addr_with_fc_040(m68000_base_device *m68k, UINT32 addr_in, UINT8 fc, UINT8 ptest)
530530{
531531   UINT32 addr_out, tt0, tt1;
532532
r23920r23921
761761/*
762762    pmmu_translate_addr: perform 68851/68030-style PMMU address translation
763763*/
764/*INLINE*/ static UINT32 pmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in)
764/*INLINE*/ static UINT32 pmmu_translate_addr(m68000_base_device *m68k, UINT32 addr_in)
765765{
766766   UINT32 addr_out;
767767
r23920r23921
787787    m68851_mmu_ops: COP 0 MMU opcode handling
788788*/
789789
790void m68881_mmu_ops(m68ki_cpu_core *m68k)
790void m68881_mmu_ops(m68000_base_device *m68k)
791791{
792792   UINT16 modes;
793793   UINT32 ea = m68k->ir & 0x3f;
r23920r23921
10631063
10641064
10651065/* Apple HMMU translation is much simpler */
1066INLINE UINT32 hmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in)
1066INLINE UINT32 hmmu_translate_addr(m68000_base_device *m68k, UINT32 addr_in)
10671067{
10681068   UINT32 addr_out;
10691069
trunk/src/emu/cpu/m68000/68340tmu.c
r23920r23921
55
66
77
8READ32_HANDLER( m68340_internal_timer_r )
8READ32_MEMBER( m68000_base_device::m68340_internal_timer_r )
99{
10   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
10   m68000_base_device *m68k = this;
1111   m68340_timer* timer = m68k->m68340TIMER;
1212   assert(timer != NULL);
1313
r23920r23921
2020   return 0x00000000;
2121}
2222
23WRITE32_HANDLER( m68340_internal_timer_w )
23WRITE32_MEMBER( m68000_base_device::m68340_internal_timer_w )
2424{
25   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
25   m68000_base_device *m68k = this;
2626   m68340_timer* timer = m68k->m68340TIMER;
2727   assert(timer != NULL);
2828
trunk/src/emu/cpu/m68000/68340dma.h
r23920r23921
11
2DECLARE_READ32_HANDLER( m68340_internal_dma_r );
3DECLARE_WRITE32_HANDLER( m68340_internal_dma_w );
4
52class m68340_dma
63{
74   public:
trunk/src/emu/cpu/m68000/m68k_in.c
r23920r23921
102102/* Build the opcode handler table */
103103void m68ki_build_opcode_table(void);
104104
105extern void (*m68ki_instruction_jump_table[][0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */
105extern void (*m68ki_instruction_jump_table[][0x10000])(m68000_base_device *m68k); /* opcode handler jump table */
106106extern unsigned char m68ki_cycles[][0x10000];
107107
108108
r23920r23921
124124
125125#define NUM_CPU_TYPES 7
126126
127void (*m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000])(m68ki_cpu_core *m68k); /* opcode handler jump table */
127void (*m68ki_instruction_jump_table[NUM_CPU_TYPES][0x10000])(m68000_base_device *m68k); /* opcode handler jump table */
128128unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */
129129
130130/* This is used to generate the opcode handler jump table */
131131struct opcode_handler_struct
132132{
133   void (*opcode_handler)(m68ki_cpu_core *m68k);        /* handler function */
133   void (*opcode_handler)(m68000_base_device *m68k);        /* handler function */
134134   unsigned int  mask;                  /* mask on opcode */
135135   unsigned int  match;                 /* what to match after masking */
136136   unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */
r23920r23921
174174      /* default to illegal */
175175      for(k=0;k<NUM_CPU_TYPES;k++)
176176      {
177         m68ki_instruction_jump_table[k][i] = _m68ki_cpu_core::m68k_op_illegal;
177         m68ki_instruction_jump_table[k][i] = m68000_base_device_ops::m68k_op_illegal;
178178         m68ki_cycles[k][i] = 0;
179179      }
180180   }
r23920r23921
269269
270270#include "emu.h"
271271#include "m68kcpu.h"
272extern void m68040_fpu_op0(m68ki_cpu_core *m68k);
273extern void m68040_fpu_op1(m68ki_cpu_core *m68k);
274extern void m68881_mmu_ops(m68ki_cpu_core *m68k);
272extern void m68040_fpu_op0(m68000_base_device *m68k);
273extern void m68040_fpu_op1(m68000_base_device *m68k);
274extern void m68881_mmu_ops(m68000_base_device *m68k);
275275
276276/* ======================================================================== */
277277/* ========================= INSTRUCTION HANDLERS ========================= */
r23920r23921
31593159   if(CPU_TYPE_IS_010_PLUS((mc68kcpu)->cpu_type))
31603160   {
31613161      if ((mc68kcpu)->bkpt_ack_callback != NULL)
3162         (*(mc68kcpu)->bkpt_ack_callback)((mc68kcpu)->device, CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type) ? (mc68kcpu)->ir & 7 : 0);
3162         (*(mc68kcpu)->bkpt_ack_callback)((mc68kcpu), CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type) ? (mc68kcpu)->ir & 7 : 0);
31633163   }
31643164   m68ki_exception_illegal(mc68kcpu);
31653165}
r23920r23921
33243324      REG_PC(mc68kcpu) += 2;
33253325(void)ea;   /* just to avoid an 'unused variable' warning */
33263326      logerror("%s at %08x: called unimplemented instruction %04x (callm)\n",
3327                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
3327                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
33283328      return;
33293329   }
33303330   m68ki_exception_illegal(mc68kcpu);
r23920r23921
42614261   UINT32 res = dst - src;
42624262
42634263   if ((mc68kcpu)->cmpild_instr_callback != NULL)
4264      (*(mc68kcpu)->cmpild_instr_callback)((mc68kcpu)->device, src, (mc68kcpu)->ir & 7);
4264      (*(mc68kcpu)->cmpild_instr_callback)((mc68kcpu), src, (mc68kcpu)->ir & 7);
42654265
42664266   (mc68kcpu)->n_flag = NFLAG_32(res);
42674267   (mc68kcpu)->not_z_flag = MASK_OUT_ABOVE_32(res);
r23920r23921
44024402   if(CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type))
44034403   {
44044404      logerror("%s at %08x: called unimplemented instruction %04x (cpbcc)\n",
4405                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
4405                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
44064406      return;
44074407   }
44084408   m68ki_exception_1111(mc68kcpu);
r23920r23921
44144414   if(CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type))
44154415   {
44164416      logerror("%s at %08x: called unimplemented instruction %04x (cpdbcc)\n",
4417                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
4417                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
44184418      return;
44194419   }
44204420   m68ki_exception_1111(mc68kcpu);
r23920r23921
44264426   if(CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type) && (mc68kcpu->has_fpu || mc68kcpu->has_pmmu))
44274427   {
44284428      logerror("%s at %08x: called unimplemented instruction %04x (cpgen)\n",
4429                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
4429                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
44304430      return;
44314431   }
44324432   m68ki_exception_1111(mc68kcpu);
r23920r23921
44384438   if(CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type))
44394439   {
44404440      logerror("%s at %08x: called unimplemented instruction %04x (cpscc)\n",
4441                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
4441                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
44424442      return;
44434443   }
44444444   m68ki_exception_1111(mc68kcpu);
r23920r23921
44504450   if(CPU_TYPE_IS_EC020_PLUS((mc68kcpu)->cpu_type))
44514451   {
44524452      logerror("%s at %08x: called unimplemented instruction %04x (cptrapcc)\n",
4453                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
4453                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
44544454      return;
44554455   }
44564456   m68ki_exception_1111(mc68kcpu);
r23920r23921
82628262   if((mc68kcpu)->s_flag)
82638263   {
82648264      if ((mc68kcpu)->reset_instr_callback != NULL)
8265         (*(mc68kcpu)->reset_instr_callback)((mc68kcpu)->device);
8265         (*(mc68kcpu)->reset_instr_callback)((mc68kcpu));
82668266      (mc68kcpu)->remaining_cycles -= (mc68kcpu)->cyc_reset;
82678267      return;
82688268   }
r23920r23921
89688968      UINT32 format_word;
89698969
89708970      if ((mc68kcpu)->rte_instr_callback != NULL)
8971         (*(mc68kcpu)->rte_instr_callback)((mc68kcpu)->device);
8971         (*(mc68kcpu)->rte_instr_callback)((mc68kcpu));
89728972      m68ki_trace_t0(mc68kcpu);              /* auto-disable (see m68kcpu.h) */
89738973
89748974      if(CPU_TYPE_IS_000((mc68kcpu)->cpu_type))
r23920r23921
91299129   {
91309130      m68ki_trace_t0(mc68kcpu);              /* auto-disable (see m68kcpu.h) */
91319131      logerror("%s at %08x: called unimplemented instruction %04x (rtm)\n",
9132                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
9132                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
91339133      return;
91349134   }
91359135   m68ki_exception_illegal(mc68kcpu);
r23920r23921
1000310003
1000410004   /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback
1000510005      disabled in order to function properly.  Some Amiga software may also rely
10006      on (mc68kcpu), but only when accessing specific addresses so additional functionality
10006      on this, but only when accessing specific addresses so additional functionality
1000710007      will be needed. */
1000810008   if ((mc68kcpu)->tas_instr_callback != NULL)
10009      allow_writeback = (*(mc68kcpu)->tas_instr_callback)((mc68kcpu)->device);
10009      allow_writeback = (*(mc68kcpu)->tas_instr_callback)((mc68kcpu));
1001010010
1001110011   if (allow_writeback)
1001210012      m68ki_write_8((mc68kcpu), ea, dst | 0x80);
r23920r23921
1051110511   if(CPU_TYPE_IS_040_PLUS((mc68kcpu)->cpu_type))
1051210512   {
1051310513      logerror("%s at %08x: called unimplemented instruction %04x (cpush)\n",
10514                  (mc68kcpu)->device->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
10514                  (mc68kcpu)->tag(), REG_PC(mc68kcpu) - 2, (mc68kcpu)->ir);
1051510515      return;
1051610516   }
1051710517   m68ki_exception_1111(mc68kcpu);
trunk/src/emu/cpu/m68000/68307tmu.c
r23920r23921
44#include "emu.h"
55#include "m68kcpu.h"
66
7READ16_HANDLER( m68307_internal_timer_r )
7READ16_MEMBER( m68000_base_device::m68307_internal_timer_r )
88{
9   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
9   m68000_base_device *m68k = this;
1010   m68307_timer* timer = m68k->m68307TIMER;
1111   assert(timer != NULL);
1212
r23920r23921
3232   return 0x0000;
3333}
3434
35WRITE16_HANDLER( m68307_internal_timer_w )
35WRITE16_MEMBER( m68000_base_device::m68307_internal_timer_w )
3636{
37   m68ki_cpu_core *m68k = m68k_get_safe_token(&space.device());
37   m68000_base_device *m68k = this;
3838   m68307_timer* timer = m68k->m68307TIMER;
3939   assert(timer != NULL);
4040
r23920r23921
101101
102102static TIMER_CALLBACK( m68307_timer0_callback )
103103{
104   legacy_cpu_device *dev = (legacy_cpu_device *)ptr;
105   m68ki_cpu_core* m68k = m68k_get_safe_token(dev);
104   m68000_base_device* m68k = (m68000_base_device *)ptr;
106105   m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[0];
107106   tptr->regs[m68307TIMER_TMR] |= 0x2;
108107
109   m68307_timer0_interrupt(dev);
108   m68307_timer0_interrupt(m68k);
110109
111   tptr->mametimer->adjust(m68k->device->cycles_to_attotime(20000));
110   tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));
112111}
113112
114113static TIMER_CALLBACK( m68307_timer1_callback )
115114{
116   legacy_cpu_device *dev = (legacy_cpu_device *)ptr;
117   m68ki_cpu_core* m68k = m68k_get_safe_token(dev);
115   m68000_base_device* m68k = (m68000_base_device *)ptr;
118116   m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[1];
119117   tptr->regs[m68307TIMER_TMR] |= 0x2;
120118
121   m68307_timer1_interrupt(dev);
119   m68307_timer1_interrupt(m68k);
122120
123   tptr->mametimer->adjust(m68k->device->cycles_to_attotime(20000));
121   tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));
124122
125123}
126124
r23920r23921
129127   printf("wd timer\n");
130128}
131129
132void m68307_timer::init(legacy_cpu_device *device)
130void m68307_timer::init(m68000_base_device *device)
133131{
132   parent = device;
133
134134   m68307_single_timer* tptr;
135135
136136   tptr = &singletimer[0];
137   tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer0_callback), device);
137   tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer0_callback), parent);
138138
139139   tptr = &singletimer[1];
140   tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer1_callback), device);
140   tptr->mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_timer1_callback), parent);
141141
142   parent = device;
143142
144   wd_mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_wd_timer_callback), device);
143   wd_mametimer = device->machine().scheduler().timer_alloc(FUNC(m68307_wd_timer_callback), parent);
145144
146145
147146}
r23920r23921
162161
163162void m68307_timer::write_tmr(UINT16 data, UINT16 mem_mask, int which)
164163{
165   m68ki_cpu_core* m68k = m68k_get_safe_token(parent);
164   m68000_base_device* m68k = parent;
166165   m68307_single_timer* tptr = &singletimer[which];
167166
168167   COMBINE_DATA(&tptr->regs[m68307TIMER_TMR]);
r23920r23921
204203   if (rst==0x0) logerror("(timer is reset)\n");
205204   if (rst==0x1) logerror("(timer is running)\n");
206205
207   tptr->mametimer->adjust(m68k->device->cycles_to_attotime(100000));
206   tptr->mametimer->adjust(m68k->cycles_to_attotime(100000));
208207
209208   logerror("\n");
210209
trunk/src/emu/cpu/m68000/68340tmu.h
r23920r23921
11
2DECLARE_READ32_HANDLER( m68340_internal_timer_r );
3DECLARE_WRITE32_HANDLER( m68340_internal_timer_w );
42
53class m68340_timer
64{
trunk/src/emu/cpu/m68000/68307tmu.h
r23920r23921
11
2DECLARE_READ16_HANDLER( m68307_internal_timer_r );
3DECLARE_WRITE16_HANDLER( m68307_internal_timer_w );
2#include "m68000.h"
43
4class m68000_base_device;
5
6
57#define m68307TIMER_TMR (0x0)
68#define m68307TIMER_TRR (0x1)
79#define m68307TIMER_TCR (0x2)
r23920r23921
2527   m68307_single_timer singletimer[2];
2628
2729   emu_timer *wd_mametimer;
28   legacy_cpu_device *parent;
30   m68000_base_device *parent;
2931
3032   void write_tmr(UINT16 data, UINT16 mem_mask, int which);
3133   void write_trr(UINT16 data, UINT16 mem_mask, int which);
3234   void write_ter(UINT16 data, UINT16 mem_mask, int which);
3335   UINT16 read_tcn(UINT16 mem_mask, int which);
3436
35   void init(legacy_cpu_device *device);
37   void init(m68000_base_device *device);
3638   void reset(void);
3739};
trunk/src/emu/cpu/m68000/m68kmake.c
r23920r23921
790790/* Write the name of an opcode handler function */
791791static void write_function_name(FILE* filep, char* base_name)
792792{
793   fprintf(filep, "void _m68ki_cpu_core::%s(_m68ki_cpu_core* mc68kcpu)\n", base_name);
794   fprintf(g_prototype_file, "static void %s(_m68ki_cpu_core* mc68kcpu);\n", base_name);
793   fprintf(filep, "void m68000_base_device_ops::%s(m68000_base_device* mc68kcpu)\n", base_name);
794   fprintf(g_prototype_file, "static void %s(m68000_base_device* mc68kcpu);\n", base_name);
795795}
796796
797797static void add_opcode_output_table_entry(opcode_struct* op, char* name)
r23920r23921
804804
805805   *ptr = *op;
806806
807   sprintf( ptr->name, "_m68ki_cpu_core::%s", name);
807   sprintf( ptr->name, "m68000_base_device_ops::%s", name);
808808   ptr->bits = num_bits(ptr->op_mask);
809809}
810810
trunk/src/mess/drivers/apollo.c
r23920r23921
141141 apollo_set_cpu_has_fpu - enable/disable the FPU
142142 -------------------------------------------------*/
143143
144void apollo_set_cpu_has_fpu(device_t *device, int onoff)
144void apollo_set_cpu_has_fpu(m68000_base_device *device, int onoff)
145145{
146146   if (device == NULL || (device->type() != M68020PMMU && device->type() != M68030))
147147   {
r23920r23921
149149   }
150150   else
151151   {
152      m68ki_cpu_core *cpu = (m68ki_cpu_core *) downcast<legacy_cpu_device *> (device)->token();
153      cpu->has_fpu = onoff;
152     
153      device->has_fpu = onoff;
154154      DLOG1(("apollo_set_cpu_has_fpu: FPU has been %s", onoff ? "enabled" : "disabled"));
155155   }
156156}
r23920r23921
216216  apollo_instruction_hook
217217  must be called by the CPU core before executing each instruction
218218***************************************************************************/
219int apollo_instruction_hook(device_t *device, offs_t curpc)
219int apollo_instruction_hook(m68000_base_device *device, offs_t curpc)
220220{
221   m68ki_cpu_core *m68k = (m68ki_cpu_core *) downcast<legacy_cpu_device *> (device)->token();
221   m68000_base_device *m68k = device;
222   //m68000_base_device *m68k = (m68000_base_device *) downcast<legacy_cpu_device *> (device)->token();
222223
223224   static UINT16 idle_counter = 0;
224225
r23920r23921
512513{
513514   offs_t address = offset * 4;
514515
515   m68ki_cpu_core *m68k = (m68ki_cpu_core *) downcast<legacy_cpu_device *>(&space.device())->token();
516   m68000_base_device *m68k = (m68000_base_device *) downcast<legacy_cpu_device *>(&space.device())->token();
516517
517518   if ((address & 0xfff00000) == 0xfa800000 && VERBOSE < 2) {
518519      // ?
trunk/src/mess/drivers/dectalk.c
r23920r23921
291291   void dectalk_x2212_recall(  );
292292   void dectalk_semaphore_w ( UINT16 data );
293293   UINT16 dectalk_outfifo_r (  );
294   required_device<cpu_device> m_maincpu;
294   required_device<m68000_base_device> m_maincpu;
295295   required_device<cpu_device> m_dsp;
296296   required_device<dac_device> m_dac;
297297
trunk/src/mess/machine/mac.c
r23920r23921
11311131   result = fdc->read(offset >> 8);
11321132
11331133   if (LOG_MAC_IWM)
1134      printf("mac_iwm_r: offset=0x%08x mem_mask %04x = %02x (PC %x)\n", offset, mem_mask, result, m_maincpu->pc());
1134      printf("mac_iwm_r: offset=0x%08x mem_mask %04x = %02x (PC %x)\n", offset, mem_mask, result, space.device().safe_pc());
11351135
11361136   return (result << 8) | result;
11371137}
r23920r23921
11411141   applefdc_base_device *fdc = space.machine().device<applefdc_base_device>("fdc");
11421142
11431143   if (LOG_MAC_IWM)
1144      printf("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, m_maincpu->pc());
1144      printf("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, space.device().safe_pc());
11451145
11461146   if (ACCESSING_BITS_0_7)
11471147      fdc->write((offset >> 8), data & 0xff);
r23920r23921
15001500   else if (ADB_IS_EGRET)
15011501   {
15021502      #if LOG_ADB
1503      printf("68K: New Egret state: SS %d VF %d (PC %x)\n", (data>>5)&1, (data>>4)&1, m_maincpu->pc());
1503      printf("68K: New Egret state: SS %d VF %d (PC %x)\n", (data>>5)&1, (data>>4)&1, space.device().safe_pc());
15041504      #endif
15051505      m_egret->set_via_full((data&0x10) ? 1 : 0);
15061506      m_egret->set_sys_session((data&0x20) ? 1 : 0);
r23920r23921
15081508   else if (ADB_IS_CUDA)
15091509   {
15101510      #if LOG_ADB
1511      printf("68K: New Cuda state: TIP %d BYTEACK %d (PC %x)\n", (data>>5)&1, (data>>4)&1, m_maincpu->pc());
1511      printf("68K: New Cuda state: TIP %d BYTEACK %d (PC %x)\n", (data>>5)&1, (data>>4)&1, space.device().safe_pc());
15121512      #endif
15131513      m_cuda->set_byteack((data&0x10) ? 1 : 0);
15141514      m_cuda->set_tip((data&0x20) ? 1 : 0);
r23920r23921
15781578   data = m_via2->read(space, offset);
15791579
15801580   if (LOG_VIA)
1581      logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, m_maincpu->pc());
1581      logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, space.device().safe_pc());
15821582
15831583   return (data & 0xff) | (data << 8);
15841584}
r23920r23921
15891589   offset &= 0x0f;
15901590
15911591   if (LOG_VIA)
1592      logerror("mac_via2_w: offset=%x data=0x%08x mask=%x (PC=%x)\n", offset, data, mem_mask, m_maincpu->pc());
1592      logerror("mac_via2_w: offset=%x data=0x%08x mask=%x (PC=%x)\n", offset, data, mem_mask, space.device().safe_pc());
15931593
15941594   if (ACCESSING_BITS_0_7)
15951595      m_via2->write(space, offset, data & 0xff);
trunk/src/mess/machine/apollo_dbg.c
r23920r23921
864864
865865// get parameter string for parameter type and value at addr
866866
867static const char *get_param(m68ki_cpu_core *m68k, UINT32 addr, char type)
867static const char *get_param(m68000_base_device *m68k, UINT32 addr, char type)
868868{
869869   UINT32 value = ~0;
870870
r23920r23921
880880
881881   if (!m68k->mmu_tmp_buserror_occurred)
882882   {
883      value = m68k->memory.read32(addr);
883      value = m68k->read32(addr);
884884      if (!m68k->mmu_tmp_buserror_occurred && (value != ~0))
885885      {
886886         switch (type)
887887         {
888888         case 'S': // string w/o terminating 0
889            value1 = m68k->memory.read32(addr + 4);
889            value1 = m68k->read32(addr + 4);
890890            if (!m68k->mmu_tmp_buserror_occurred && (value1 != ~0))
891891            {
892               maxlen = m68k->memory.read16(value1);
892               maxlen = m68k->read16(value1);
893893               if (maxlen > sizeof(sb) - 2)
894894               {
895895                  maxlen = sizeof(sb) - 2;
r23920r23921
898898         case 's': // string
899899            i = 0;
900900            sb[i++] = '"';
901            while (i <= maxlen && (ch = m68k->memory.read8(value++)) != 0
901            while (i <= maxlen && (ch = m68k->read8(value++)) != 0
902902                  && !m68k->mmu_tmp_buserror_occurred)
903903            {
904904               sb[i++] = ch < 32 ? '.' : ch;
r23920r23921
907907            sb[i] = 0;
908908            break;
909909         case 'b': // byte (1 byte)
910            sprintf(sb, "0x%x", m68k->memory.read8(value));
910            sprintf(sb, "0x%x", m68k->read8(value));
911911            break;
912912         case 'p': // pointer
913913            sprintf(sb, "0x%x", value);
914914            break;
915915         case 'w': // word (2 byte)
916            sprintf(sb, "0x%x", m68k->memory.read16(value));
916            sprintf(sb, "0x%x", m68k->read16(value));
917917            break;
918918         case 'x': // default  (hex 32 bit)
919            sprintf(sb, "0x%x", m68k->memory.read32(value));
919            sprintf(sb, "0x%x", m68k->read32(value));
920920            break;
921921         case 'u': // uid
922            sprintf(sb, "%08x.%08x", m68k->memory.read32(value),
923                  m68k->memory.read32(value + 4));
922            sprintf(sb, "%08x.%08x", m68k->read32(value),
923                  m68k->read32(value + 4));
924924            break;
925925         default:
926926            sprintf(sb, "%c", type);
r23920r23921
934934
935935// get the svc call string
936936
937static const char* get_svc_call(m68ki_cpu_core *m68k, int trap_no,
937static const char* get_svc_call(m68000_base_device *m68k, int trap_no,
938938      int trap_code,  char *sb)
939939{
940940   UINT32 sp = REG_A(m68k)[7];
r23920r23921
10341034   return sb;
10351035}
10361036
1037static const char * disassemble(m68ki_cpu_core *m68k, offs_t pc, char* sb)
1037static const char * disassemble(m68000_base_device *m68k, offs_t pc, char* sb)
10381038{
10391039   UINT8 oprom[10];
10401040   UINT8 opram[10];
r23920r23921
10501050   int i;
10511051   for (i = 0; i < sizeof(oprom); i++)
10521052   {
1053      oprom[i] = opram[i] = m68k->memory.read8(pc + i);
1053      oprom[i] = opram[i] = m68k->read8(pc + i);
10541054      if (m68k->mmu_tmp_buserror_occurred)
10551055      {
10561056         sprintf(sb, "- (apollo_disassemble failed at %08x)", pc + i);
r23920r23921
10621062         return sb;
10631063      }
10641064   }
1065   m68k->device->disassemble(sb, pc, oprom, opram, options);
1065   m68k->disassemble(sb, pc, oprom, opram, options);
10661066
10671067   // restore previous bus error state
10681068   m68k->mmu_tmp_buserror_occurred = tmp_buserror_occurred;
r23920r23921
10711071   return sb;
10721072}
10731073
1074static const UINT16 *get_data(m68ki_cpu_core *m68k, offs_t addr)
1074static const UINT16 *get_data(m68000_base_device *m68k, offs_t addr)
10751075{
10761076   static UINT16 data[4];
10771077
r23920r23921
10851085   int i;
10861086   for (i = 0; i < sizeof(data); i += 2)
10871087   {
1088      data[i/2] = m68k->memory.read16(addr + i);
1088      data[i/2] = m68k->read16(addr + i);
10891089   }
10901090
10911091   // restore previous bus error state
r23920r23921
11141114   {
11151115      UINT32 ppc_save;
11161116      UINT16 ir;
1117      m68ki_cpu_core *m68k = (m68ki_cpu_core *) downcast<legacy_cpu_device *> (device)->token();
1117      m68000_base_device *m68k = (m68000_base_device *) downcast<legacy_cpu_device *> (device)->token();
11181118      m68k->mmu_tmp_buserror_occurred = 0;
11191119
11201120      /* Read next instruction */
1121      ir = (m68k->pref_addr == REG_PC(m68k)) ? m68k->pref_data : m68k->memory.readimm16(REG_PC(m68k));
1121      ir = (m68k->pref_addr == REG_PC(m68k)) ? m68k->pref_data : m68k->readimm16(REG_PC(m68k));
11221122
11231123      // apollo_cpu_context expects the PC of current opcode in REG_PPC (not the previous PC)
11241124      ppc_save = REG_PPC(m68k);
trunk/src/mess/machine/apollo.c
r23920r23921
270270   else if ((data & APOLLO_CSR_CR_FPU_TRAP_ENABLE) == 0)
271271   {
272272      // enable FPU (i.e. FPU opcodes in CPU)
273      apollo_set_cpu_has_fpu(&space.device(), 1);
273      apollo_set_cpu_has_fpu(m_maincpu, 1);
274274   }
275275   else
276276   {
277277      // disable FPU (i.e. FPU opcodes in CPU)
278      apollo_set_cpu_has_fpu(&space.device(), 0);
278      apollo_set_cpu_has_fpu(m_maincpu, 0);
279279
280280      if (!apollo_is_dn3000())
281281      {
trunk/src/mess/includes/apollo.h
r23920r23921
6868const char *apollo_cpu_context(device_t *cpu);
6969
7070// enable/disable the FPU
71void apollo_set_cpu_has_fpu(device_t *device, int onoff);
71void apollo_set_cpu_has_fpu(m68000_base_device *device, int onoff);
7272
7373// check for excessive logging
7474void apollo_check_log();
r23920r23921
8686UINT32 apollo_get_node_id(void);
8787
8888   // should be called by the CPU core before executing each instruction
89int apollo_instruction_hook(device_t *device, offs_t curpc);
89int apollo_instruction_hook(m68000_base_device *device, offs_t curpc);
9090
9191void apollo_set_cache_status_register(UINT8 mask, UINT8 data);
9292
r23920r23921
123123         m_pic8259_slave(*this, "pic8259_slave")
124124         { }
125125
126   required_device<cpu_device> m_maincpu;
126   required_device<m68000_base_device> m_maincpu;
127127   required_device<sc499_device> m_ctape;
128128   required_shared_ptr<UINT32> m_messram_ptr;
129129
trunk/src/mess/includes/abc1600.h
r23920r23921
8585         m_video_ram(*this, "video_ram")
8686   { }
8787
88   required_device<cpu_device> m_maincpu;
88   required_device<m68000_base_device> m_maincpu;
8989   required_device<z80dma_device> m_dma0;
9090   required_device<z80dma_device> m_dma1;
9191   required_device<z80dma_device> m_dma2;
trunk/src/mess/includes/mac.h
r23920r23921
2121#include "machine/macrtc.h"
2222#include "sound/asc.h"
2323#include "sound/awacs.h"
24#include "cpu/m68000/m68000.h"
2425
2526#define MAC_SCREEN_NAME "screen"
2627#define MAC_539X_1_TAG "scsi:539x_1"
r23920r23921
220221      m_vram16(*this,"vram16")
221222      { }
222223
223   required_device<cpu_device> m_maincpu;
224   required_device<m68000_base_device> m_maincpu;
224225   required_device<via6522_device> m_via1;
225226   optional_device<via6522_device> m_via2;
226227   optional_device<asc_device> m_asc;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team