summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/vt83c461.cpp
blob: afe6071f9d3c3b9b5561c659aaddf1e55f92cc7b (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// license:BSD-3-Clause
// copyright-holders:smf
#include "emu.h"
#include "vt83c461.h"

//#define VERBOSE 1
#include "logmacro.h"


#define VT83C461_CONFIG_UNK                1
#define VT83C461_CONFIG_REGISTER           2
#define VT83C461_CONFIG_DATA               3


DEFINE_DEVICE_TYPE(VT83C461, vt83c461_device, "vt83c461", "VIA VT83C461 IDE Controller")

vt83c461_device::vt83c461_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	ide_controller_32_device(mconfig, VT83C461, tag, owner, clock),
	m_config_unknown(0),
	m_config_register_num(0)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void vt83c461_device::device_start()
{
	ide_controller_32_device::device_start();

	/* register ide states */
	save_item(NAME(m_config_unknown));
	save_item(NAME(m_config_register));
	save_item(NAME(m_config_register_num));
}

READ32_MEMBER( vt83c461_device::read_config )
{
	return read_config(offset);
}

uint32_t vt83c461_device::read_config(offs_t offset)
{
	uint32_t result = 0;

	/* logit */
	LOG("%s:IDE via config read at %X\n", machine().describe_context(), offset);

	switch(offset)
	{
	/* unknown config register */
	case VT83C461_CONFIG_UNK:
		result = m_config_unknown;
		break;

	/* active config register */
	case VT83C461_CONFIG_REGISTER:
		result = m_config_register_num;
		break;

	/* data from active config register */
	case VT83C461_CONFIG_DATA:
		if (m_config_register_num < IDE_CONFIG_REGISTERS)
			result = m_config_register[m_config_register_num];
		break;

	default:
		logerror("%s:unknown IDE via config read at %03X\n", machine().describe_context(), offset);
		break;
	}

	return result;
}

WRITE32_MEMBER( vt83c461_device::write_config )
{
	write_config(offset, data);
}

void vt83c461_device::write_config(offs_t offset, uint32_t data)
{
	/* logit */
	LOG("%s:IDE via config write to %X = %08X\n", machine().describe_context(), offset, data);

	switch (offset)
	{
	/* unknown config register */
	case VT83C461_CONFIG_UNK:
		m_config_unknown = data;
		break;

	/* active config register */
	case VT83C461_CONFIG_REGISTER:
		m_config_register_num = data;
		break;

	/* data from active config register */
	case VT83C461_CONFIG_DATA:
		if (m_config_register_num < IDE_CONFIG_REGISTERS)
			m_config_register[m_config_register_num] = data;
		break;

	default:
		logerror("%s:unknown IDE via config write at %03X = %08x\n", machine().describe_context(), offset, data);
		break;
	}
}