Amiga: Create a GAYLE device, used by the A600 and A1200, and implement

the internal IDE controller for both
This commit is contained in:
Dirk Best 2014-05-14 09:20:32 +00:00
parent 48e9b7663b
commit bf35b4dbb4
6 changed files with 392 additions and 151 deletions

2
.gitattributes vendored
View File

@ -2448,6 +2448,8 @@ src/emu/machine/f3853.c svneol=native#text/plain
src/emu/machine/f3853.h svneol=native#text/plain
src/emu/machine/fdc_pll.c svneol=native#text/plain
src/emu/machine/fdc_pll.h svneol=native#text/plain
src/emu/machine/gayle.c svneol=native#text/plain
src/emu/machine/gayle.h svneol=native#text/plain
src/emu/machine/generic.c svneol=native#text/plain
src/emu/machine/generic.h svneol=native#text/plain
src/emu/machine/hd63450.c svneol=native#text/plain

211
src/emu/machine/gayle.c Normal file
View File

@ -0,0 +1,211 @@
/***************************************************************************
GAYLE
license: MAME, GPL-2.0+
copyright-holders: Dirk Best
Gate array used in the Amiga 600 and Amiga 1200 computers.
***************************************************************************/
#include "gayle.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
#define VERBOSE 1
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type GAYLE = &device_creator<gayle_device>;
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// gayle_device - constructor
//-------------------------------------------------
gayle_device::gayle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, GAYLE, "GAYLE", tag, owner, clock, "gayle", __FILE__),
m_int2_w(*this),
m_cs0_read(*this),
m_cs0_write(*this),
m_cs1_read(*this),
m_cs1_write(*this),
m_gayle_id(0xff),
m_gayle_id_count(0)
{
}
//-------------------------------------------------
// set_id - set gayle id
//-------------------------------------------------
void gayle_device::set_id(device_t &device, UINT8 id)
{
gayle_device &gayle = downcast<gayle_device &>(device);
gayle.m_gayle_id = id;
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void gayle_device::device_start()
{
// resolve callbacks
m_int2_w.resolve_safe();
m_cs0_read.resolve_safe(0xffff);
m_cs0_write.resolve_safe();
m_cs1_read.resolve_safe(0xffff);
m_cs1_write.resolve_safe();
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void gayle_device::device_reset()
{
m_gayle_reg[0] = 0;
m_gayle_reg[1] = 0;
m_gayle_reg[2] = 0;
m_gayle_reg[3] = 0;
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
READ16_MEMBER( gayle_device::gayle_r )
{
UINT16 data = 0xffff;
offset <<= 1;
// swap
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
if (BIT(offset, 15))
{
switch (offset & 0x7fff)
{
case 0x0000: data = m_gayle_reg[0]; break;
case 0x1000: data = m_gayle_reg[1]; break;
case 0x2000: data = m_gayle_reg[2]; break;
case 0x3000: data = m_gayle_reg[3]; break;
}
}
else
{
if (!BIT(offset, 14))
{
if (BIT(offset, 13))
data = m_cs0_read(space, (offset >> 2) & 0x07, mem_mask);
else
data = m_cs1_read(space, (offset >> 2) & 0x07, mem_mask);
}
}
if (VERBOSE)
logerror("gayle_r(%06x): %04x & %04x\n", offset, data, mem_mask);
// swap data
data = (data << 8) | (data >> 8);
return data;
}
WRITE16_MEMBER( gayle_device::gayle_w )
{
offset <<= 1;
// swap
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = (data << 8) | (data >> 8);
if (VERBOSE)
logerror("gayle_w(%06x): %04x & %04x\n", offset, data, mem_mask);
if (BIT(offset, 15))
{
switch (offset & 0x7fff)
{
case 0x0000:
m_gayle_reg[0] = data;
break;
case 0x1000:
m_gayle_reg[1] &= data;
m_gayle_reg[1] |= data & 0x03;
break;
case 0x2000:
m_gayle_reg[2] = data;
break;
case 0x3000:
m_gayle_reg[3] = data;
break;
}
}
else
{
if (!BIT(offset, 14))
{
if (BIT(offset, 13))
m_cs0_write(space, (offset >> 2) & 0x07, data, mem_mask);
else
m_cs1_write(space, (offset >> 2) & 0x07, data, mem_mask);
}
}
}
WRITE_LINE_MEMBER( gayle_device::ide_interrupt_w )
{
if (VERBOSE)
logerror("ide_interrupt_w: %d\n", state);
// did we change state?
if (BIT(m_gayle_reg[GAYLE_CS], 7) != state)
m_gayle_reg[GAYLE_IRQ] |= 1 << 7;
// set line state
if (state)
m_gayle_reg[GAYLE_CS] |= 1 << 7;
else
m_gayle_reg[GAYLE_CS] &= ~(1 << 7);
// update interrupts
if (BIT(m_gayle_reg[GAYLE_INTEN], 7))
m_int2_w(BIT(m_gayle_reg[GAYLE_CS], 7));
}
READ16_MEMBER( gayle_device::gayle_id_r )
{
UINT16 data = 0xffff;
if (ACCESSING_BITS_8_15)
data = ((m_gayle_id << m_gayle_id_count++) & 0x80) << 8;
else
data = 0xffff;
if (VERBOSE)
logerror("gayle_id_r(%06x): %04x & %04x (id=%02x)\n", offset, data, mem_mask, m_gayle_id);
return data;
}
WRITE16_MEMBER( gayle_device::gayle_id_w )
{
if (VERBOSE)
logerror("gayle_id_w(%06x): %04x & %04x (id=%02x)\n", offset, data, mem_mask, m_gayle_id);
m_gayle_id_count = 0;
}

111
src/emu/machine/gayle.h Normal file
View File

@ -0,0 +1,111 @@
/***************************************************************************
GAYLE
license: MAME, GPL-2.0+
copyright-holders: Dirk Best
Gate array used in the Amiga 600 and Amiga 1200 computers.
***************************************************************************/
#pragma once
#ifndef __GAYLE_H__
#define __GAYLE_H__
#include "emu.h"
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_GAYLE_ADD(_tag, _clock, _id) \
MCFG_DEVICE_ADD(_tag, GAYLE, _clock) \
gayle_device::set_id(*device, _id);
#define MCFG_GAYLE_INT2_HANDLER(_devcb) \
devcb = &gayle_device::set_int2_handler(*device, DEVCB_##_devcb);
#define MCFG_GAYLE_CS0_READ_HANDLER(_devcb) \
devcb = &gayle_device::set_cs0_read_handler(*device, DEVCB_##_devcb);
#define MCFG_GAYLE_CS0_WRITE_HANDLER(_devcb) \
devcb = &gayle_device::set_cs0_write_handler(*device, DEVCB_##_devcb);
#define MCFG_GAYLE_CS1_READ_HANDLER(_devcb) \
devcb = &gayle_device::set_cs1_read_handler(*device, DEVCB_##_devcb);
#define MCFG_GAYLE_CS1_WRITE_HANDLER(_devcb) \
devcb = &gayle_device::set_cs1_write_handler(*device, DEVCB_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> gayle_device
class gayle_device : public device_t
{
public:
// construction/destruction
gayle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// callbacks
template<class _Object> static devcb_base &set_int2_handler(device_t &device, _Object object)
{ return downcast<gayle_device &>(device).m_int2_w.set_callback(object); }
template<class _Object> static devcb_base &set_cs0_read_handler(device_t &device, _Object object)
{ return downcast<gayle_device &>(device).m_cs0_read.set_callback(object); }
template<class _Object> static devcb_base &set_cs0_write_handler(device_t &device, _Object object)
{ return downcast<gayle_device &>(device).m_cs0_write.set_callback(object); }
template<class _Object> static devcb_base &set_cs1_read_handler(device_t &device, _Object object)
{ return downcast<gayle_device &>(device).m_cs1_read.set_callback(object); }
template<class _Object> static devcb_base &set_cs1_write_handler(device_t &device, _Object object)
{ return downcast<gayle_device &>(device).m_cs1_write.set_callback(object); }
// interface
DECLARE_WRITE_LINE_MEMBER( ide_interrupt_w );
DECLARE_READ16_MEMBER( gayle_r );
DECLARE_WRITE16_MEMBER( gayle_w );
DECLARE_READ16_MEMBER( gayle_id_r );
DECLARE_WRITE16_MEMBER( gayle_id_w );
// inline configuration
static void set_id(device_t &device, UINT8 id);
protected:
virtual void device_start();
virtual void device_reset();
private:
enum
{
GAYLE_CS = 0, // interrupt status
GAYLE_IRQ, // interrupt change
GAYLE_INTEN, // interrupt enable register
GAYLE_CFG // config register
};
devcb_write_line m_int2_w;
devcb_read16 m_cs0_read;
devcb_write16 m_cs0_write;
devcb_read16 m_cs1_read;
devcb_write16 m_cs1_write;
UINT8 m_gayle_id;
int m_gayle_id_count;
UINT8 m_gayle_reg[4];
};
// device type definition
extern const device_type GAYLE;
#endif

View File

@ -54,6 +54,16 @@ MACHINEOBJS += $(MACHINEOBJ)/dmac.o
endif
#-------------------------------------------------
#
#@src/emu/machine/gayle.h,MACHINES += GAYLE
#-------------------------------------------------
ifneq ($(filter GAYLE,$(MACHINES)),)
MACHINEOBJS += $(MACHINEOBJ)/gayle.o
endif
#-------------------------------------------------
#
#@src/emu/machine/40105.h,MACHINES += CMOS40105

View File

@ -15,6 +15,8 @@
#include "machine/bankdev.h"
#include "machine/6525tpi.h"
#include "machine/6526cia.h"
#include "machine/gayle.h"
#include "machine/ataintf.h"
#include "machine/dmac.h"
#include "machine/nvram.h"
#include "machine/i2cmem.h"
@ -209,53 +211,43 @@ class a600_state : public amiga_state
public:
a600_state(const machine_config &mconfig, device_type type, const char *tag) :
amiga_state(mconfig, type, tag),
m_gayle_id_count(0)
m_gayle_int2(0)
{ }
DECLARE_READ16_MEMBER( ide_r );
DECLARE_WRITE16_MEMBER( ide_w );
DECLARE_READ16_MEMBER( gayle_r );
DECLARE_WRITE16_MEMBER( gayle_w );
DECLARE_READ16_MEMBER( gayle_id_r );
DECLARE_WRITE16_MEMBER( gayle_id_w );
DECLARE_WRITE_LINE_MEMBER( gayle_int2_w );
DECLARE_DRIVER_INIT( pal );
DECLARE_DRIVER_INIT( ntsc );
static const UINT8 GAYLE_ID = 0xd0;
protected:
virtual void machine_reset();
virtual void update_irq2();
private:
static const int GAYLE_ID = 0xd0;
int m_gayle_id_count;
UINT8 m_gayle_reg[4];
int m_gayle_int2;
};
class a1200_state : public amiga_state
{
public:
a1200_state(const machine_config &mconfig, device_type type, const char *tag) :
amiga_state(mconfig, type, tag)
//m_gayle_id_count(0)
amiga_state(mconfig, type, tag),
m_gayle_int2(0)
{ }
DECLARE_READ32_MEMBER( ide_r );
DECLARE_WRITE32_MEMBER( ide_w );
DECLARE_READ32_MEMBER( gayle_r );
DECLARE_WRITE32_MEMBER( gayle_w );
DECLARE_WRITE_LINE_MEMBER( gayle_int2_w );
DECLARE_DRIVER_INIT( pal );
DECLARE_DRIVER_INIT( ntsc );
static const UINT8 GAYLE_ID = 0xd1;
protected:
virtual void machine_reset();
virtual void update_irq2();
private:
static const int GAYLE_ID = 0xd1;
//int m_gayle_id_count;
UINT8 m_gayle_reg[4];
int m_gayle_int2;
};
class a4000_state : public amiga_state
@ -659,130 +651,28 @@ WRITE32_MEMBER( a3000_state::motherboard_w )
logerror("motherboard_w(%06x): %08x & %08x\n", offset, data, mem_mask);
}
void a600_state::machine_reset()
void a600_state::update_irq2()
{
// base reset
amiga_state::machine_reset();
m_gayle_reg[0] = 0;
m_gayle_reg[1] = 0;
m_gayle_reg[2] = 0;
m_gayle_reg[3] = 0;
int state = (m_cia_0_irq || m_gayle_int2);
set_interrupt((state ? INTENA_SETCLR : 0x0000) | INTENA_PORTS);
}
// note: for ide a12 = cs0/cs1, offset >> 2 for reg
READ16_MEMBER( a600_state::ide_r )
WRITE_LINE_MEMBER( a600_state::gayle_int2_w )
{
UINT16 data = 0xffff;
logerror("ide_r(%06x): %08x & %08x\n", offset, data, mem_mask);
return data;
m_gayle_int2 = state;
update_irq2();
}
WRITE16_MEMBER( a600_state::ide_w )
void a1200_state::update_irq2()
{
logerror("ide_w(%06x): %08x & %08x\n", offset, data, mem_mask);
int state = (m_cia_0_irq || m_gayle_int2);
set_interrupt((state ? INTENA_SETCLR : 0x0000) | INTENA_PORTS);
}
READ16_MEMBER( a600_state::gayle_r )
WRITE_LINE_MEMBER( a1200_state::gayle_int2_w )
{
UINT16 data = 0xffff;
switch (offset)
{
case 0x0000: data = m_gayle_reg[0]; break;
case 0x1000: data = m_gayle_reg[1]; break;
case 0x2000: data = m_gayle_reg[2]; break;
case 0x3000: data = m_gayle_reg[3]; break;
}
logerror("gayle_r(%06x): %08x & %08x\n", offset, data, mem_mask);
return data;
}
WRITE16_MEMBER( a600_state::gayle_w )
{
logerror("gayle_w(%06x): %08x & %08x\n", offset, data, mem_mask);
switch (offset)
{
case 0x0000:
break;
case 0x1000:
break;
case 0x2000:
break;
case 0x3000:
break;
}
}
READ16_MEMBER( a600_state::gayle_id_r )
{
if (ACCESSING_BITS_8_15)
return ((GAYLE_ID << m_gayle_id_count++) & 0x80) << 8;
else
return 0xffff;
}
WRITE16_MEMBER( a600_state::gayle_id_w )
{
m_gayle_id_count = 0;
}
void a1200_state::machine_reset()
{
// base reset
amiga_state::machine_reset();
m_gayle_reg[0] = 0;
m_gayle_reg[1] = 0;
m_gayle_reg[2] = 0;
m_gayle_reg[3] = 0;
}
READ32_MEMBER( a1200_state::ide_r )
{
UINT16 data = 0xffff;
logerror("ide_r(%06x): %08x & %08x\n", offset, data, mem_mask);
return data;
}
WRITE32_MEMBER( a1200_state::ide_w )
{
logerror("ide_w(%06x): %08x & %08x\n", offset, data, mem_mask);
}
READ32_MEMBER( a1200_state::gayle_r )
{
UINT16 data = 0xffff;
switch (offset)
{
case 0x0000: data = m_gayle_reg[0]; break;
case 0x1000: data = m_gayle_reg[1]; break;
case 0x2000: data = m_gayle_reg[2]; break;
case 0x3000: data = m_gayle_reg[3]; break;
}
logerror("gayle_r(%06x): %08x & %08x\n", offset, data, mem_mask);
return data;
}
WRITE32_MEMBER( a1200_state::gayle_w )
{
logerror("gayle_w(%06x): %08x & %08x\n", offset, data, mem_mask);
switch (offset)
{
case 0x0000:
break;
case 0x1000:
break;
case 0x2000:
break;
case 0x3000:
break;
}
m_gayle_int2 = state;
update_irq2();
}
READ32_MEMBER( a4000_state::scsi_r )
@ -1123,15 +1013,13 @@ static ADDRESS_MAP_START( a600_mem, AS_PROGRAM, 16, a600_state )
AM_RANGE(0xb80000, 0xbeffff) AM_NOP // reserved (cdtv)
AM_RANGE(0xbf0000, 0xbfffff) AM_READWRITE(cia_r, gayle_cia_w)
AM_RANGE(0xc00000, 0xd7ffff) AM_NOP // slow mem
// AM_RANGE(0xd80000, 0xd8ffff) AM_NOP // spare chip select
// AM_RANGE(0xd90000, 0xd9ffff) AM_NOP // arcnet chip select
AM_RANGE(0xda0000, 0xda3fff) AM_READWRITE(ide_r, ide_w)
// AM_RANGE(0xda4000, 0xda7fff) AM_NOP // ide reserved
AM_RANGE(0xda8000, 0xdaffff) AM_READWRITE(gayle_r, gayle_w)
// AM_RANGE(0xdb0000, 0xdbffff) AM_NOP // reserved (external ide)
AM_RANGE(0xd80000, 0xd8ffff) AM_NOP // spare chip select
AM_RANGE(0xd90000, 0xd9ffff) AM_NOP // arcnet chip select
AM_RANGE(0xda0000, 0xdaffff) AM_DEVREADWRITE("gayle", gayle_device, gayle_r, gayle_w)
AM_RANGE(0xdb0000, 0xdbffff) AM_NOP // reserved (external ide)
AM_RANGE(0xdc0000, 0xdcffff) AM_NOP // rtc
// AM_RANGE(0xdd0000, 0xddffff) AM_NOP // reserved (dma controller)
AM_RANGE(0xde0000, 0xdeffff) AM_READWRITE(gayle_id_r, gayle_id_w)
AM_RANGE(0xdd0000, 0xddffff) AM_NOP // reserved (dma controller)
AM_RANGE(0xde0000, 0xdeffff) AM_DEVREADWRITE("gayle", gayle_device, gayle_id_r, gayle_id_w)
AM_RANGE(0xdf0000, 0xdfffff) AM_READWRITE(custom_chip_r, custom_chip_w) AM_SHARE("custom_regs")
AM_RANGE(0xe00000, 0xe7ffff) AM_WRITENOP AM_READ(rom_mirror_r)
AM_RANGE(0xe80000, 0xefffff) AM_NOP // autoconfig space (installed by devices)
@ -1151,13 +1039,11 @@ static ADDRESS_MAP_START( a1200_mem, AS_PROGRAM, 32, a1200_state )
AM_RANGE(0xc00000, 0xd7ffff) AM_NOP // slow mem
AM_RANGE(0xd80000, 0xd8ffff) AM_NOP // spare chip select
AM_RANGE(0xd90000, 0xd9ffff) AM_NOP // arcnet chip select
AM_RANGE(0xda0000, 0xda3fff) AM_READWRITE(ide_r, ide_w)
AM_RANGE(0xda4000, 0xda7fff) AM_NOP // ide reserved
AM_RANGE(0xda8000, 0xdaffff) AM_READWRITE(gayle_r, gayle_w)
AM_RANGE(0xda0000, 0xdaffff) AM_DEVREADWRITE16("gayle", gayle_device, gayle_r, gayle_w, 0xffffffff)
AM_RANGE(0xdb0000, 0xdbffff) AM_NOP // reserved (external ide)
AM_RANGE(0xdc0000, 0xdcffff) AM_NOP // rtc
AM_RANGE(0xdd0000, 0xddffff) AM_NOP // reserved (dma controller)
AM_RANGE(0xde0000, 0xdeffff) AM_NOP // reserved (mb resources)
AM_RANGE(0xde0000, 0xdeffff) AM_DEVREADWRITE16("gayle", gayle_device, gayle_id_r, gayle_id_w, 0xffffffff)
AM_RANGE(0xdf0000, 0xdfffff) AM_READWRITE16(custom_chip_r, custom_chip_w, 0xffffffff) AM_SHARE("custom_regs")
AM_RANGE(0xe00000, 0xe7ffff) AM_WRITENOP AM_READ(rom_mirror32_r)
AM_RANGE(0xe80000, 0xefffff) AM_NOP // autoconfig space (installed by devices)
@ -1646,7 +1532,17 @@ static MACHINE_CONFIG_DERIVED_CLASS( a600, amiga_base, a600_state )
MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(22)
MCFG_ADDRESS_MAP_BANK_STRIDE(0x200000)
// todo: ide, pcmcia
MCFG_GAYLE_ADD("gayle", amiga_state::CLK_28M_PAL / 2, a600_state::GAYLE_ID)
MCFG_GAYLE_INT2_HANDLER(WRITELINE(a600_state, gayle_int2_w))
MCFG_GAYLE_CS0_READ_HANDLER(DEVREAD16("ata", ata_interface_device, read_cs0))
MCFG_GAYLE_CS0_WRITE_HANDLER(DEVWRITE16("ata", ata_interface_device, write_cs0))
MCFG_GAYLE_CS1_READ_HANDLER(DEVREAD16("ata", ata_interface_device, read_cs1))
MCFG_GAYLE_CS1_WRITE_HANDLER(DEVWRITE16("ata", ata_interface_device, write_cs1))
MCFG_ATA_INTERFACE_ADD("ata", ata_devices, "hdd", NULL, false)
MCFG_ATA_INTERFACE_IRQ_HANDLER(DEVWRITELINE("gayle", gayle_device, ide_interrupt_w))
// todo: pcmcia
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED_CLASS( a600n, a600, a600_state )
@ -1683,7 +1579,17 @@ static MACHINE_CONFIG_DERIVED_CLASS( a1200, amiga_base, a1200_state )
MCFG_VIDEO_START_OVERRIDE(amiga_state, amiga_aga)
// todo: ide, pcmcia
MCFG_GAYLE_ADD("gayle", amiga_state::CLK_28M_PAL / 2, a1200_state::GAYLE_ID)
MCFG_GAYLE_INT2_HANDLER(WRITELINE(a1200_state, gayle_int2_w))
MCFG_GAYLE_CS0_READ_HANDLER(DEVREAD16("ata", ata_interface_device, read_cs0))
MCFG_GAYLE_CS0_WRITE_HANDLER(DEVWRITE16("ata", ata_interface_device, write_cs0))
MCFG_GAYLE_CS1_READ_HANDLER(DEVREAD16("ata", ata_interface_device, read_cs1))
MCFG_GAYLE_CS1_WRITE_HANDLER(DEVWRITE16("ata", ata_interface_device, write_cs1))
MCFG_ATA_INTERFACE_ADD("ata", ata_devices, "hdd", NULL, false)
MCFG_ATA_INTERFACE_IRQ_HANDLER(DEVWRITELINE("gayle", gayle_device, ide_interrupt_w))
// todo: pcmcia
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED_CLASS( a1200n, a1200, a1200_state )

View File

@ -329,6 +329,7 @@ MACHINES += AKIKO
MACHINES += AUTOCONFIG
MACHINES += CR511B
MACHINES += DMAC
MACHINES += GAYLE
#MACHINES += NCR53C7XX
#MACHINES += LSI53C810
MACHINES += 6522VIA