summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/rc2014/cf.cpp
blob: a40380f45f0967a8f5fe50e8a4a72b1d1a41c81f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic
/***************************************************************************

    RC2014 Compact Flash Module

****************************************************************************/

#include "emu.h"
#include "cf.h"
#include "bus/ata/ataintf.h"

namespace {

//**************************************************************************
//  RC2014 Compact Flash module
//  Module author: Spencer Owen
//**************************************************************************

class compact_flash_device : public device_t, public device_rc2014_card_interface
{
public:
	// construction/destruction
	compact_flash_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_add_mconfig(machine_config &config) override;

	DECLARE_WRITE_LINE_MEMBER( tx_w ) { m_bus->tx_w(state); }

	uint8_t ide_cs0_r(offs_t offset) { return m_ata->cs0_r(offset); }
	void ide_cs0_w(offs_t offset, uint8_t data) { m_ata->cs0_w(offset, data); }
private:
	required_device<ata_interface_device> m_ata;
};

compact_flash_device::compact_flash_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
	: device_t(mconfig, RC2014_COMPACT_FLASH, tag, owner, clock)
	, device_rc2014_card_interface(mconfig, *this)
	, m_ata(*this, "ata")
{
}

void compact_flash_device::device_start()
{
}

void compact_flash_device::device_reset()
{
	// A15-A8 and A7 not connected
	m_bus->installer(AS_IO)->install_readwrite_handler(0x10, 0x17, 0, 0xff80, 0, read8sm_delegate(*this, FUNC(compact_flash_device::ide_cs0_r)), write8sm_delegate(*this, FUNC(compact_flash_device::ide_cs0_w)));
}

void compact_flash_device::device_add_mconfig(machine_config &config)
{
	ATA_INTERFACE(config, m_ata).options(ata_devices, "cf", nullptr, true);
}

}
//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE_PRIVATE(RC2014_COMPACT_FLASH, device_rc2014_card_interface, compact_flash_device, "rc2014_cf", "RC2014 Compact Flash module")